Coverage Report

Created: 2025-07-04 06:49

/src/cpython/Python/Python-ast.c
Line
Count
Source (jump to first uncovered line)
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
30.8k
{
23
30.8k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
30.8k
    struct ast_state *state = &interp->ast;
25
30.8k
    assert(!state->finalized);
26
30.8k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
30.8k
    return state;
30
30.8k
}
31
32
void _PyAST_Fini(PyInterpreterState *interp)
33
0
{
34
0
    struct ast_state *state = &interp->ast;
35
36
0
    Py_CLEAR(state->AST_type);
37
0
    Py_CLEAR(state->Add_singleton);
38
0
    Py_CLEAR(state->Add_type);
39
0
    Py_CLEAR(state->And_singleton);
40
0
    Py_CLEAR(state->And_type);
41
0
    Py_CLEAR(state->AnnAssign_type);
42
0
    Py_CLEAR(state->Assert_type);
43
0
    Py_CLEAR(state->Assign_type);
44
0
    Py_CLEAR(state->AsyncFor_type);
45
0
    Py_CLEAR(state->AsyncFunctionDef_type);
46
0
    Py_CLEAR(state->AsyncWith_type);
47
0
    Py_CLEAR(state->Attribute_type);
48
0
    Py_CLEAR(state->AugAssign_type);
49
0
    Py_CLEAR(state->Await_type);
50
0
    Py_CLEAR(state->BinOp_type);
51
0
    Py_CLEAR(state->BitAnd_singleton);
52
0
    Py_CLEAR(state->BitAnd_type);
53
0
    Py_CLEAR(state->BitOr_singleton);
54
0
    Py_CLEAR(state->BitOr_type);
55
0
    Py_CLEAR(state->BitXor_singleton);
56
0
    Py_CLEAR(state->BitXor_type);
57
0
    Py_CLEAR(state->BoolOp_type);
58
0
    Py_CLEAR(state->Break_type);
59
0
    Py_CLEAR(state->Call_type);
60
0
    Py_CLEAR(state->ClassDef_type);
61
0
    Py_CLEAR(state->Compare_type);
62
0
    Py_CLEAR(state->Constant_type);
63
0
    Py_CLEAR(state->Continue_type);
64
0
    Py_CLEAR(state->Del_singleton);
65
0
    Py_CLEAR(state->Del_type);
66
0
    Py_CLEAR(state->Delete_type);
67
0
    Py_CLEAR(state->DictComp_type);
68
0
    Py_CLEAR(state->Dict_type);
69
0
    Py_CLEAR(state->Div_singleton);
70
0
    Py_CLEAR(state->Div_type);
71
0
    Py_CLEAR(state->Eq_singleton);
72
0
    Py_CLEAR(state->Eq_type);
73
0
    Py_CLEAR(state->ExceptHandler_type);
74
0
    Py_CLEAR(state->Expr_type);
75
0
    Py_CLEAR(state->Expression_type);
76
0
    Py_CLEAR(state->FloorDiv_singleton);
77
0
    Py_CLEAR(state->FloorDiv_type);
78
0
    Py_CLEAR(state->For_type);
79
0
    Py_CLEAR(state->FormattedValue_type);
80
0
    Py_CLEAR(state->FunctionDef_type);
81
0
    Py_CLEAR(state->FunctionType_type);
82
0
    Py_CLEAR(state->GeneratorExp_type);
83
0
    Py_CLEAR(state->Global_type);
84
0
    Py_CLEAR(state->GtE_singleton);
85
0
    Py_CLEAR(state->GtE_type);
86
0
    Py_CLEAR(state->Gt_singleton);
87
0
    Py_CLEAR(state->Gt_type);
88
0
    Py_CLEAR(state->IfExp_type);
89
0
    Py_CLEAR(state->If_type);
90
0
    Py_CLEAR(state->ImportFrom_type);
91
0
    Py_CLEAR(state->Import_type);
92
0
    Py_CLEAR(state->In_singleton);
93
0
    Py_CLEAR(state->In_type);
94
0
    Py_CLEAR(state->Interactive_type);
95
0
    Py_CLEAR(state->Interpolation_type);
96
0
    Py_CLEAR(state->Invert_singleton);
97
0
    Py_CLEAR(state->Invert_type);
98
0
    Py_CLEAR(state->IsNot_singleton);
99
0
    Py_CLEAR(state->IsNot_type);
100
0
    Py_CLEAR(state->Is_singleton);
101
0
    Py_CLEAR(state->Is_type);
102
0
    Py_CLEAR(state->JoinedStr_type);
103
0
    Py_CLEAR(state->LShift_singleton);
104
0
    Py_CLEAR(state->LShift_type);
105
0
    Py_CLEAR(state->Lambda_type);
106
0
    Py_CLEAR(state->ListComp_type);
107
0
    Py_CLEAR(state->List_type);
108
0
    Py_CLEAR(state->Load_singleton);
109
0
    Py_CLEAR(state->Load_type);
110
0
    Py_CLEAR(state->LtE_singleton);
111
0
    Py_CLEAR(state->LtE_type);
112
0
    Py_CLEAR(state->Lt_singleton);
113
0
    Py_CLEAR(state->Lt_type);
114
0
    Py_CLEAR(state->MatMult_singleton);
115
0
    Py_CLEAR(state->MatMult_type);
116
0
    Py_CLEAR(state->MatchAs_type);
117
0
    Py_CLEAR(state->MatchClass_type);
118
0
    Py_CLEAR(state->MatchMapping_type);
119
0
    Py_CLEAR(state->MatchOr_type);
120
0
    Py_CLEAR(state->MatchSequence_type);
121
0
    Py_CLEAR(state->MatchSingleton_type);
122
0
    Py_CLEAR(state->MatchStar_type);
123
0
    Py_CLEAR(state->MatchValue_type);
124
0
    Py_CLEAR(state->Match_type);
125
0
    Py_CLEAR(state->Mod_singleton);
126
0
    Py_CLEAR(state->Mod_type);
127
0
    Py_CLEAR(state->Module_type);
128
0
    Py_CLEAR(state->Mult_singleton);
129
0
    Py_CLEAR(state->Mult_type);
130
0
    Py_CLEAR(state->Name_type);
131
0
    Py_CLEAR(state->NamedExpr_type);
132
0
    Py_CLEAR(state->Nonlocal_type);
133
0
    Py_CLEAR(state->NotEq_singleton);
134
0
    Py_CLEAR(state->NotEq_type);
135
0
    Py_CLEAR(state->NotIn_singleton);
136
0
    Py_CLEAR(state->NotIn_type);
137
0
    Py_CLEAR(state->Not_singleton);
138
0
    Py_CLEAR(state->Not_type);
139
0
    Py_CLEAR(state->Or_singleton);
140
0
    Py_CLEAR(state->Or_type);
141
0
    Py_CLEAR(state->ParamSpec_type);
142
0
    Py_CLEAR(state->Pass_type);
143
0
    Py_CLEAR(state->Pow_singleton);
144
0
    Py_CLEAR(state->Pow_type);
145
0
    Py_CLEAR(state->RShift_singleton);
146
0
    Py_CLEAR(state->RShift_type);
147
0
    Py_CLEAR(state->Raise_type);
148
0
    Py_CLEAR(state->Return_type);
149
0
    Py_CLEAR(state->SetComp_type);
150
0
    Py_CLEAR(state->Set_type);
151
0
    Py_CLEAR(state->Slice_type);
152
0
    Py_CLEAR(state->Starred_type);
153
0
    Py_CLEAR(state->Store_singleton);
154
0
    Py_CLEAR(state->Store_type);
155
0
    Py_CLEAR(state->Sub_singleton);
156
0
    Py_CLEAR(state->Sub_type);
157
0
    Py_CLEAR(state->Subscript_type);
158
0
    Py_CLEAR(state->TemplateStr_type);
159
0
    Py_CLEAR(state->TryStar_type);
160
0
    Py_CLEAR(state->Try_type);
161
0
    Py_CLEAR(state->Tuple_type);
162
0
    Py_CLEAR(state->TypeAlias_type);
163
0
    Py_CLEAR(state->TypeIgnore_type);
164
0
    Py_CLEAR(state->TypeVarTuple_type);
165
0
    Py_CLEAR(state->TypeVar_type);
166
0
    Py_CLEAR(state->UAdd_singleton);
167
0
    Py_CLEAR(state->UAdd_type);
168
0
    Py_CLEAR(state->USub_singleton);
169
0
    Py_CLEAR(state->USub_type);
170
0
    Py_CLEAR(state->UnaryOp_type);
171
0
    Py_CLEAR(state->While_type);
172
0
    Py_CLEAR(state->With_type);
173
0
    Py_CLEAR(state->YieldFrom_type);
174
0
    Py_CLEAR(state->Yield_type);
175
0
    Py_CLEAR(state->__dict__);
176
0
    Py_CLEAR(state->__doc__);
177
0
    Py_CLEAR(state->__match_args__);
178
0
    Py_CLEAR(state->__module__);
179
0
    Py_CLEAR(state->_attributes);
180
0
    Py_CLEAR(state->_fields);
181
0
    Py_CLEAR(state->alias_type);
182
0
    Py_CLEAR(state->annotation);
183
0
    Py_CLEAR(state->arg);
184
0
    Py_CLEAR(state->arg_type);
185
0
    Py_CLEAR(state->args);
186
0
    Py_CLEAR(state->argtypes);
187
0
    Py_CLEAR(state->arguments_type);
188
0
    Py_CLEAR(state->asname);
189
0
    Py_CLEAR(state->ast);
190
0
    Py_CLEAR(state->attr);
191
0
    Py_CLEAR(state->bases);
192
0
    Py_CLEAR(state->body);
193
0
    Py_CLEAR(state->boolop_type);
194
0
    Py_CLEAR(state->bound);
195
0
    Py_CLEAR(state->cases);
196
0
    Py_CLEAR(state->cause);
197
0
    Py_CLEAR(state->cls);
198
0
    Py_CLEAR(state->cmpop_type);
199
0
    Py_CLEAR(state->col_offset);
200
0
    Py_CLEAR(state->comparators);
201
0
    Py_CLEAR(state->comprehension_type);
202
0
    Py_CLEAR(state->context_expr);
203
0
    Py_CLEAR(state->conversion);
204
0
    Py_CLEAR(state->ctx);
205
0
    Py_CLEAR(state->decorator_list);
206
0
    Py_CLEAR(state->default_value);
207
0
    Py_CLEAR(state->defaults);
208
0
    Py_CLEAR(state->elt);
209
0
    Py_CLEAR(state->elts);
210
0
    Py_CLEAR(state->end_col_offset);
211
0
    Py_CLEAR(state->end_lineno);
212
0
    Py_CLEAR(state->exc);
213
0
    Py_CLEAR(state->excepthandler_type);
214
0
    Py_CLEAR(state->expr_context_type);
215
0
    Py_CLEAR(state->expr_type);
216
0
    Py_CLEAR(state->finalbody);
217
0
    Py_CLEAR(state->format_spec);
218
0
    Py_CLEAR(state->func);
219
0
    Py_CLEAR(state->generators);
220
0
    Py_CLEAR(state->guard);
221
0
    Py_CLEAR(state->handlers);
222
0
    Py_CLEAR(state->id);
223
0
    Py_CLEAR(state->ifs);
224
0
    Py_CLEAR(state->is_async);
225
0
    Py_CLEAR(state->items);
226
0
    Py_CLEAR(state->iter);
227
0
    Py_CLEAR(state->key);
228
0
    Py_CLEAR(state->keys);
229
0
    Py_CLEAR(state->keyword_type);
230
0
    Py_CLEAR(state->keywords);
231
0
    Py_CLEAR(state->kind);
232
0
    Py_CLEAR(state->kw_defaults);
233
0
    Py_CLEAR(state->kwarg);
234
0
    Py_CLEAR(state->kwd_attrs);
235
0
    Py_CLEAR(state->kwd_patterns);
236
0
    Py_CLEAR(state->kwonlyargs);
237
0
    Py_CLEAR(state->left);
238
0
    Py_CLEAR(state->level);
239
0
    Py_CLEAR(state->lineno);
240
0
    Py_CLEAR(state->lower);
241
0
    Py_CLEAR(state->match_case_type);
242
0
    Py_CLEAR(state->mod_type);
243
0
    Py_CLEAR(state->module);
244
0
    Py_CLEAR(state->msg);
245
0
    Py_CLEAR(state->name);
246
0
    Py_CLEAR(state->names);
247
0
    Py_CLEAR(state->op);
248
0
    Py_CLEAR(state->operand);
249
0
    Py_CLEAR(state->operator_type);
250
0
    Py_CLEAR(state->ops);
251
0
    Py_CLEAR(state->optional_vars);
252
0
    Py_CLEAR(state->orelse);
253
0
    Py_CLEAR(state->pattern);
254
0
    Py_CLEAR(state->pattern_type);
255
0
    Py_CLEAR(state->patterns);
256
0
    Py_CLEAR(state->posonlyargs);
257
0
    Py_CLEAR(state->rest);
258
0
    Py_CLEAR(state->returns);
259
0
    Py_CLEAR(state->right);
260
0
    Py_CLEAR(state->simple);
261
0
    Py_CLEAR(state->slice);
262
0
    Py_CLEAR(state->step);
263
0
    Py_CLEAR(state->stmt_type);
264
0
    Py_CLEAR(state->str);
265
0
    Py_CLEAR(state->subject);
266
0
    Py_CLEAR(state->tag);
267
0
    Py_CLEAR(state->target);
268
0
    Py_CLEAR(state->targets);
269
0
    Py_CLEAR(state->test);
270
0
    Py_CLEAR(state->type);
271
0
    Py_CLEAR(state->type_comment);
272
0
    Py_CLEAR(state->type_ignore_type);
273
0
    Py_CLEAR(state->type_ignores);
274
0
    Py_CLEAR(state->type_param_type);
275
0
    Py_CLEAR(state->type_params);
276
0
    Py_CLEAR(state->unaryop_type);
277
0
    Py_CLEAR(state->upper);
278
0
    Py_CLEAR(state->value);
279
0
    Py_CLEAR(state->values);
280
0
    Py_CLEAR(state->vararg);
281
0
    Py_CLEAR(state->withitem_type);
282
283
0
    state->finalized = 1;
284
0
    state->once = (_PyOnceFlag){0};
285
0
}
286
287
static int init_identifiers(struct ast_state *state)
288
10
{
289
10
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
290
10
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
291
10
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
292
10
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
293
10
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
294
10
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
295
10
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
296
10
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
297
10
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
298
10
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
299
10
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
300
10
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
301
10
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
302
10
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
303
10
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
304
10
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
305
10
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
306
10
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
307
10
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
308
10
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
309
10
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
310
10
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
311
10
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
312
10
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
313
10
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
314
10
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
315
10
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
316
10
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
317
10
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
318
10
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
319
10
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
320
10
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
321
10
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
322
10
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
323
10
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
324
10
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
325
10
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
326
10
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
327
10
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
328
10
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
329
10
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
330
10
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
331
10
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
332
10
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
333
10
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
334
10
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
335
10
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
336
10
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
337
10
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
338
10
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
339
10
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
340
10
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
341
10
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
342
10
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
343
10
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
344
10
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
345
10
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
346
10
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
347
10
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
348
10
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
349
10
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
350
10
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
351
10
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
352
10
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
353
10
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
354
10
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
355
10
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
356
10
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
357
10
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
358
10
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
359
10
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
360
10
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
361
10
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
362
10
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
363
10
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
364
10
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
365
10
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
366
10
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
367
10
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
368
10
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
369
10
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
370
10
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
371
10
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
372
10
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
373
10
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
374
10
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
375
10
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
376
10
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
377
10
    return 0;
378
10
};
379
380
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
381
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
382
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
383
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
384
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
385
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
386
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
387
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
388
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
389
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
390
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
391
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
392
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
393
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
394
395
static PyObject* ast2obj_mod(struct ast_state *state, void*);
396
static const char * const Module_fields[]={
397
    "body",
398
    "type_ignores",
399
};
400
static const char * const Interactive_fields[]={
401
    "body",
402
};
403
static const char * const Expression_fields[]={
404
    "body",
405
};
406
static const char * const FunctionType_fields[]={
407
    "argtypes",
408
    "returns",
409
};
410
static const char * const stmt_attributes[] = {
411
    "lineno",
412
    "col_offset",
413
    "end_lineno",
414
    "end_col_offset",
415
};
416
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
417
static const char * const FunctionDef_fields[]={
418
    "name",
419
    "args",
420
    "body",
421
    "decorator_list",
422
    "returns",
423
    "type_comment",
424
    "type_params",
425
};
426
static const char * const AsyncFunctionDef_fields[]={
427
    "name",
428
    "args",
429
    "body",
430
    "decorator_list",
431
    "returns",
432
    "type_comment",
433
    "type_params",
434
};
435
static const char * const ClassDef_fields[]={
436
    "name",
437
    "bases",
438
    "keywords",
439
    "body",
440
    "decorator_list",
441
    "type_params",
442
};
443
static const char * const Return_fields[]={
444
    "value",
445
};
446
static const char * const Delete_fields[]={
447
    "targets",
448
};
449
static const char * const Assign_fields[]={
450
    "targets",
451
    "value",
452
    "type_comment",
453
};
454
static const char * const TypeAlias_fields[]={
455
    "name",
456
    "type_params",
457
    "value",
458
};
459
static const char * const AugAssign_fields[]={
460
    "target",
461
    "op",
462
    "value",
463
};
464
static const char * const AnnAssign_fields[]={
465
    "target",
466
    "annotation",
467
    "value",
468
    "simple",
469
};
470
static const char * const For_fields[]={
471
    "target",
472
    "iter",
473
    "body",
474
    "orelse",
475
    "type_comment",
476
};
477
static const char * const AsyncFor_fields[]={
478
    "target",
479
    "iter",
480
    "body",
481
    "orelse",
482
    "type_comment",
483
};
484
static const char * const While_fields[]={
485
    "test",
486
    "body",
487
    "orelse",
488
};
489
static const char * const If_fields[]={
490
    "test",
491
    "body",
492
    "orelse",
493
};
494
static const char * const With_fields[]={
495
    "items",
496
    "body",
497
    "type_comment",
498
};
499
static const char * const AsyncWith_fields[]={
500
    "items",
501
    "body",
502
    "type_comment",
503
};
504
static const char * const Match_fields[]={
505
    "subject",
506
    "cases",
507
};
508
static const char * const Raise_fields[]={
509
    "exc",
510
    "cause",
511
};
512
static const char * const Try_fields[]={
513
    "body",
514
    "handlers",
515
    "orelse",
516
    "finalbody",
517
};
518
static const char * const TryStar_fields[]={
519
    "body",
520
    "handlers",
521
    "orelse",
522
    "finalbody",
523
};
524
static const char * const Assert_fields[]={
525
    "test",
526
    "msg",
527
};
528
static const char * const Import_fields[]={
529
    "names",
530
};
531
static const char * const ImportFrom_fields[]={
532
    "module",
533
    "names",
534
    "level",
535
};
536
static const char * const Global_fields[]={
537
    "names",
538
};
539
static const char * const Nonlocal_fields[]={
540
    "names",
541
};
542
static const char * const Expr_fields[]={
543
    "value",
544
};
545
static const char * const expr_attributes[] = {
546
    "lineno",
547
    "col_offset",
548
    "end_lineno",
549
    "end_col_offset",
550
};
551
static PyObject* ast2obj_expr(struct ast_state *state, void*);
552
static const char * const BoolOp_fields[]={
553
    "op",
554
    "values",
555
};
556
static const char * const NamedExpr_fields[]={
557
    "target",
558
    "value",
559
};
560
static const char * const BinOp_fields[]={
561
    "left",
562
    "op",
563
    "right",
564
};
565
static const char * const UnaryOp_fields[]={
566
    "op",
567
    "operand",
568
};
569
static const char * const Lambda_fields[]={
570
    "args",
571
    "body",
572
};
573
static const char * const IfExp_fields[]={
574
    "test",
575
    "body",
576
    "orelse",
577
};
578
static const char * const Dict_fields[]={
579
    "keys",
580
    "values",
581
};
582
static const char * const Set_fields[]={
583
    "elts",
584
};
585
static const char * const ListComp_fields[]={
586
    "elt",
587
    "generators",
588
};
589
static const char * const SetComp_fields[]={
590
    "elt",
591
    "generators",
592
};
593
static const char * const DictComp_fields[]={
594
    "key",
595
    "value",
596
    "generators",
597
};
598
static const char * const GeneratorExp_fields[]={
599
    "elt",
600
    "generators",
601
};
602
static const char * const Await_fields[]={
603
    "value",
604
};
605
static const char * const Yield_fields[]={
606
    "value",
607
};
608
static const char * const YieldFrom_fields[]={
609
    "value",
610
};
611
static const char * const Compare_fields[]={
612
    "left",
613
    "ops",
614
    "comparators",
615
};
616
static const char * const Call_fields[]={
617
    "func",
618
    "args",
619
    "keywords",
620
};
621
static const char * const FormattedValue_fields[]={
622
    "value",
623
    "conversion",
624
    "format_spec",
625
};
626
static const char * const Interpolation_fields[]={
627
    "value",
628
    "str",
629
    "conversion",
630
    "format_spec",
631
};
632
static const char * const JoinedStr_fields[]={
633
    "values",
634
};
635
static const char * const TemplateStr_fields[]={
636
    "values",
637
};
638
static const char * const Constant_fields[]={
639
    "value",
640
    "kind",
641
};
642
static const char * const Attribute_fields[]={
643
    "value",
644
    "attr",
645
    "ctx",
646
};
647
static const char * const Subscript_fields[]={
648
    "value",
649
    "slice",
650
    "ctx",
651
};
652
static const char * const Starred_fields[]={
653
    "value",
654
    "ctx",
655
};
656
static const char * const Name_fields[]={
657
    "id",
658
    "ctx",
659
};
660
static const char * const List_fields[]={
661
    "elts",
662
    "ctx",
663
};
664
static const char * const Tuple_fields[]={
665
    "elts",
666
    "ctx",
667
};
668
static const char * const Slice_fields[]={
669
    "lower",
670
    "upper",
671
    "step",
672
};
673
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
674
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
675
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
676
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
677
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
678
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
679
static const char * const comprehension_fields[]={
680
    "target",
681
    "iter",
682
    "ifs",
683
    "is_async",
684
};
685
static const char * const excepthandler_attributes[] = {
686
    "lineno",
687
    "col_offset",
688
    "end_lineno",
689
    "end_col_offset",
690
};
691
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
692
static const char * const ExceptHandler_fields[]={
693
    "type",
694
    "name",
695
    "body",
696
};
697
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
698
static const char * const arguments_fields[]={
699
    "posonlyargs",
700
    "args",
701
    "vararg",
702
    "kwonlyargs",
703
    "kw_defaults",
704
    "kwarg",
705
    "defaults",
706
};
707
static PyObject* ast2obj_arg(struct ast_state *state, void*);
708
static const char * const arg_attributes[] = {
709
    "lineno",
710
    "col_offset",
711
    "end_lineno",
712
    "end_col_offset",
713
};
714
static const char * const arg_fields[]={
715
    "arg",
716
    "annotation",
717
    "type_comment",
718
};
719
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
720
static const char * const keyword_attributes[] = {
721
    "lineno",
722
    "col_offset",
723
    "end_lineno",
724
    "end_col_offset",
725
};
726
static const char * const keyword_fields[]={
727
    "arg",
728
    "value",
729
};
730
static PyObject* ast2obj_alias(struct ast_state *state, void*);
731
static const char * const alias_attributes[] = {
732
    "lineno",
733
    "col_offset",
734
    "end_lineno",
735
    "end_col_offset",
736
};
737
static const char * const alias_fields[]={
738
    "name",
739
    "asname",
740
};
741
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
742
static const char * const withitem_fields[]={
743
    "context_expr",
744
    "optional_vars",
745
};
746
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
747
static const char * const match_case_fields[]={
748
    "pattern",
749
    "guard",
750
    "body",
751
};
752
static const char * const pattern_attributes[] = {
753
    "lineno",
754
    "col_offset",
755
    "end_lineno",
756
    "end_col_offset",
757
};
758
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
759
static const char * const MatchValue_fields[]={
760
    "value",
761
};
762
static const char * const MatchSingleton_fields[]={
763
    "value",
764
};
765
static const char * const MatchSequence_fields[]={
766
    "patterns",
767
};
768
static const char * const MatchMapping_fields[]={
769
    "keys",
770
    "patterns",
771
    "rest",
772
};
773
static const char * const MatchClass_fields[]={
774
    "cls",
775
    "patterns",
776
    "kwd_attrs",
777
    "kwd_patterns",
778
};
779
static const char * const MatchStar_fields[]={
780
    "name",
781
};
782
static const char * const MatchAs_fields[]={
783
    "pattern",
784
    "name",
785
};
786
static const char * const MatchOr_fields[]={
787
    "patterns",
788
};
789
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
790
static const char * const TypeIgnore_fields[]={
791
    "lineno",
792
    "tag",
793
};
794
static const char * const type_param_attributes[] = {
795
    "lineno",
796
    "col_offset",
797
    "end_lineno",
798
    "end_col_offset",
799
};
800
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
801
static const char * const TypeVar_fields[]={
802
    "name",
803
    "bound",
804
    "default_value",
805
};
806
static const char * const ParamSpec_fields[]={
807
    "name",
808
    "default_value",
809
};
810
static const char * const TypeVarTuple_fields[]={
811
    "name",
812
    "default_value",
813
};
814
815
816
static int
817
add_ast_annotations(struct ast_state *state)
818
10
{
819
10
    bool cond;
820
10
    PyObject *Module_annotations = PyDict_New();
821
10
    if (!Module_annotations) return 0;
822
10
    {
823
10
        PyObject *type = state->stmt_type;
824
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
825
10
        cond = type != NULL;
826
10
        if (!cond) {
827
0
            Py_DECREF(Module_annotations);
828
0
            return 0;
829
0
        }
830
10
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
831
10
        Py_DECREF(type);
832
10
        if (!cond) {
833
0
            Py_DECREF(Module_annotations);
834
0
            return 0;
835
0
        }
836
10
    }
837
10
    {
838
10
        PyObject *type = state->type_ignore_type;
839
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
840
10
        cond = type != NULL;
841
10
        if (!cond) {
842
0
            Py_DECREF(Module_annotations);
843
0
            return 0;
844
0
        }
845
10
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
846
10
                                    == 0;
847
10
        Py_DECREF(type);
848
10
        if (!cond) {
849
0
            Py_DECREF(Module_annotations);
850
0
            return 0;
851
0
        }
852
10
    }
853
10
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
854
10
                                  Module_annotations) == 0;
855
10
    if (!cond) {
856
0
        Py_DECREF(Module_annotations);
857
0
        return 0;
858
0
    }
859
10
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
860
10
                                  Module_annotations) == 0;
861
10
    if (!cond) {
862
0
        Py_DECREF(Module_annotations);
863
0
        return 0;
864
0
    }
865
10
    Py_DECREF(Module_annotations);
866
10
    PyObject *Interactive_annotations = PyDict_New();
867
10
    if (!Interactive_annotations) return 0;
868
10
    {
869
10
        PyObject *type = state->stmt_type;
870
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
871
10
        cond = type != NULL;
872
10
        if (!cond) {
873
0
            Py_DECREF(Interactive_annotations);
874
0
            return 0;
875
0
        }
876
10
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
877
10
        Py_DECREF(type);
878
10
        if (!cond) {
879
0
            Py_DECREF(Interactive_annotations);
880
0
            return 0;
881
0
        }
882
10
    }
883
10
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
884
10
                                  Interactive_annotations) == 0;
885
10
    if (!cond) {
886
0
        Py_DECREF(Interactive_annotations);
887
0
        return 0;
888
0
    }
889
10
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
890
10
                                  Interactive_annotations) == 0;
891
10
    if (!cond) {
892
0
        Py_DECREF(Interactive_annotations);
893
0
        return 0;
894
0
    }
895
10
    Py_DECREF(Interactive_annotations);
896
10
    PyObject *Expression_annotations = PyDict_New();
897
10
    if (!Expression_annotations) return 0;
898
10
    {
899
10
        PyObject *type = state->expr_type;
900
10
        Py_INCREF(type);
901
10
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
902
10
        Py_DECREF(type);
903
10
        if (!cond) {
904
0
            Py_DECREF(Expression_annotations);
905
0
            return 0;
906
0
        }
907
10
    }
908
10
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
909
10
                                  Expression_annotations) == 0;
910
10
    if (!cond) {
911
0
        Py_DECREF(Expression_annotations);
912
0
        return 0;
913
0
    }
914
10
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
915
10
                                  Expression_annotations) == 0;
916
10
    if (!cond) {
917
0
        Py_DECREF(Expression_annotations);
918
0
        return 0;
919
0
    }
920
10
    Py_DECREF(Expression_annotations);
921
10
    PyObject *FunctionType_annotations = PyDict_New();
922
10
    if (!FunctionType_annotations) return 0;
923
10
    {
924
10
        PyObject *type = state->expr_type;
925
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
926
10
        cond = type != NULL;
927
10
        if (!cond) {
928
0
            Py_DECREF(FunctionType_annotations);
929
0
            return 0;
930
0
        }
931
10
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
932
10
                                    == 0;
933
10
        Py_DECREF(type);
934
10
        if (!cond) {
935
0
            Py_DECREF(FunctionType_annotations);
936
0
            return 0;
937
0
        }
938
10
    }
939
10
    {
940
10
        PyObject *type = state->expr_type;
941
10
        Py_INCREF(type);
942
10
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
943
10
                                    == 0;
944
10
        Py_DECREF(type);
945
10
        if (!cond) {
946
0
            Py_DECREF(FunctionType_annotations);
947
0
            return 0;
948
0
        }
949
10
    }
950
10
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
951
10
                                  FunctionType_annotations) == 0;
952
10
    if (!cond) {
953
0
        Py_DECREF(FunctionType_annotations);
954
0
        return 0;
955
0
    }
956
10
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
957
10
                                  FunctionType_annotations) == 0;
958
10
    if (!cond) {
959
0
        Py_DECREF(FunctionType_annotations);
960
0
        return 0;
961
0
    }
962
10
    Py_DECREF(FunctionType_annotations);
963
10
    PyObject *FunctionDef_annotations = PyDict_New();
964
10
    if (!FunctionDef_annotations) return 0;
965
10
    {
966
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
967
10
        Py_INCREF(type);
968
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
969
10
        Py_DECREF(type);
970
10
        if (!cond) {
971
0
            Py_DECREF(FunctionDef_annotations);
972
0
            return 0;
973
0
        }
974
10
    }
975
10
    {
976
10
        PyObject *type = state->arguments_type;
977
10
        Py_INCREF(type);
978
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
979
10
        Py_DECREF(type);
980
10
        if (!cond) {
981
0
            Py_DECREF(FunctionDef_annotations);
982
0
            return 0;
983
0
        }
984
10
    }
985
10
    {
986
10
        PyObject *type = state->stmt_type;
987
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
988
10
        cond = type != NULL;
989
10
        if (!cond) {
990
0
            Py_DECREF(FunctionDef_annotations);
991
0
            return 0;
992
0
        }
993
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
994
10
        Py_DECREF(type);
995
10
        if (!cond) {
996
0
            Py_DECREF(FunctionDef_annotations);
997
0
            return 0;
998
0
        }
999
10
    }
1000
10
    {
1001
10
        PyObject *type = state->expr_type;
1002
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1003
10
        cond = type != NULL;
1004
10
        if (!cond) {
1005
0
            Py_DECREF(FunctionDef_annotations);
1006
0
            return 0;
1007
0
        }
1008
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1009
10
                                    type) == 0;
1010
10
        Py_DECREF(type);
1011
10
        if (!cond) {
1012
0
            Py_DECREF(FunctionDef_annotations);
1013
0
            return 0;
1014
0
        }
1015
10
    }
1016
10
    {
1017
10
        PyObject *type = state->expr_type;
1018
10
        type = _Py_union_type_or(type, Py_None);
1019
10
        cond = type != NULL;
1020
10
        if (!cond) {
1021
0
            Py_DECREF(FunctionDef_annotations);
1022
0
            return 0;
1023
0
        }
1024
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1025
10
                                    == 0;
1026
10
        Py_DECREF(type);
1027
10
        if (!cond) {
1028
0
            Py_DECREF(FunctionDef_annotations);
1029
0
            return 0;
1030
0
        }
1031
10
    }
1032
10
    {
1033
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1034
10
        type = _Py_union_type_or(type, Py_None);
1035
10
        cond = type != NULL;
1036
10
        if (!cond) {
1037
0
            Py_DECREF(FunctionDef_annotations);
1038
0
            return 0;
1039
0
        }
1040
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1041
10
                                    type) == 0;
1042
10
        Py_DECREF(type);
1043
10
        if (!cond) {
1044
0
            Py_DECREF(FunctionDef_annotations);
1045
0
            return 0;
1046
0
        }
1047
10
    }
1048
10
    {
1049
10
        PyObject *type = state->type_param_type;
1050
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1051
10
        cond = type != NULL;
1052
10
        if (!cond) {
1053
0
            Py_DECREF(FunctionDef_annotations);
1054
0
            return 0;
1055
0
        }
1056
10
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1057
10
                                    type) == 0;
1058
10
        Py_DECREF(type);
1059
10
        if (!cond) {
1060
0
            Py_DECREF(FunctionDef_annotations);
1061
0
            return 0;
1062
0
        }
1063
10
    }
1064
10
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1065
10
                                  FunctionDef_annotations) == 0;
1066
10
    if (!cond) {
1067
0
        Py_DECREF(FunctionDef_annotations);
1068
0
        return 0;
1069
0
    }
1070
10
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1071
10
                                  FunctionDef_annotations) == 0;
1072
10
    if (!cond) {
1073
0
        Py_DECREF(FunctionDef_annotations);
1074
0
        return 0;
1075
0
    }
1076
10
    Py_DECREF(FunctionDef_annotations);
1077
10
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1078
10
    if (!AsyncFunctionDef_annotations) return 0;
1079
10
    {
1080
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1081
10
        Py_INCREF(type);
1082
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1083
10
                                    == 0;
1084
10
        Py_DECREF(type);
1085
10
        if (!cond) {
1086
0
            Py_DECREF(AsyncFunctionDef_annotations);
1087
0
            return 0;
1088
0
        }
1089
10
    }
1090
10
    {
1091
10
        PyObject *type = state->arguments_type;
1092
10
        Py_INCREF(type);
1093
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1094
10
                                    == 0;
1095
10
        Py_DECREF(type);
1096
10
        if (!cond) {
1097
0
            Py_DECREF(AsyncFunctionDef_annotations);
1098
0
            return 0;
1099
0
        }
1100
10
    }
1101
10
    {
1102
10
        PyObject *type = state->stmt_type;
1103
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1104
10
        cond = type != NULL;
1105
10
        if (!cond) {
1106
0
            Py_DECREF(AsyncFunctionDef_annotations);
1107
0
            return 0;
1108
0
        }
1109
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1110
10
                                    == 0;
1111
10
        Py_DECREF(type);
1112
10
        if (!cond) {
1113
0
            Py_DECREF(AsyncFunctionDef_annotations);
1114
0
            return 0;
1115
0
        }
1116
10
    }
1117
10
    {
1118
10
        PyObject *type = state->expr_type;
1119
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1120
10
        cond = type != NULL;
1121
10
        if (!cond) {
1122
0
            Py_DECREF(AsyncFunctionDef_annotations);
1123
0
            return 0;
1124
0
        }
1125
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1126
10
                                    "decorator_list", type) == 0;
1127
10
        Py_DECREF(type);
1128
10
        if (!cond) {
1129
0
            Py_DECREF(AsyncFunctionDef_annotations);
1130
0
            return 0;
1131
0
        }
1132
10
    }
1133
10
    {
1134
10
        PyObject *type = state->expr_type;
1135
10
        type = _Py_union_type_or(type, Py_None);
1136
10
        cond = type != NULL;
1137
10
        if (!cond) {
1138
0
            Py_DECREF(AsyncFunctionDef_annotations);
1139
0
            return 0;
1140
0
        }
1141
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1142
10
                                    type) == 0;
1143
10
        Py_DECREF(type);
1144
10
        if (!cond) {
1145
0
            Py_DECREF(AsyncFunctionDef_annotations);
1146
0
            return 0;
1147
0
        }
1148
10
    }
1149
10
    {
1150
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1151
10
        type = _Py_union_type_or(type, Py_None);
1152
10
        cond = type != NULL;
1153
10
        if (!cond) {
1154
0
            Py_DECREF(AsyncFunctionDef_annotations);
1155
0
            return 0;
1156
0
        }
1157
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1158
10
                                    "type_comment", type) == 0;
1159
10
        Py_DECREF(type);
1160
10
        if (!cond) {
1161
0
            Py_DECREF(AsyncFunctionDef_annotations);
1162
0
            return 0;
1163
0
        }
1164
10
    }
1165
10
    {
1166
10
        PyObject *type = state->type_param_type;
1167
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1168
10
        cond = type != NULL;
1169
10
        if (!cond) {
1170
0
            Py_DECREF(AsyncFunctionDef_annotations);
1171
0
            return 0;
1172
0
        }
1173
10
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1174
10
                                    "type_params", type) == 0;
1175
10
        Py_DECREF(type);
1176
10
        if (!cond) {
1177
0
            Py_DECREF(AsyncFunctionDef_annotations);
1178
0
            return 0;
1179
0
        }
1180
10
    }
1181
10
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1182
10
                                  AsyncFunctionDef_annotations) == 0;
1183
10
    if (!cond) {
1184
0
        Py_DECREF(AsyncFunctionDef_annotations);
1185
0
        return 0;
1186
0
    }
1187
10
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1188
10
                                  "__annotations__",
1189
10
                                  AsyncFunctionDef_annotations) == 0;
1190
10
    if (!cond) {
1191
0
        Py_DECREF(AsyncFunctionDef_annotations);
1192
0
        return 0;
1193
0
    }
1194
10
    Py_DECREF(AsyncFunctionDef_annotations);
1195
10
    PyObject *ClassDef_annotations = PyDict_New();
1196
10
    if (!ClassDef_annotations) return 0;
1197
10
    {
1198
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1199
10
        Py_INCREF(type);
1200
10
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1201
10
        Py_DECREF(type);
1202
10
        if (!cond) {
1203
0
            Py_DECREF(ClassDef_annotations);
1204
0
            return 0;
1205
0
        }
1206
10
    }
1207
10
    {
1208
10
        PyObject *type = state->expr_type;
1209
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1210
10
        cond = type != NULL;
1211
10
        if (!cond) {
1212
0
            Py_DECREF(ClassDef_annotations);
1213
0
            return 0;
1214
0
        }
1215
10
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1216
10
        Py_DECREF(type);
1217
10
        if (!cond) {
1218
0
            Py_DECREF(ClassDef_annotations);
1219
0
            return 0;
1220
0
        }
1221
10
    }
1222
10
    {
1223
10
        PyObject *type = state->keyword_type;
1224
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1225
10
        cond = type != NULL;
1226
10
        if (!cond) {
1227
0
            Py_DECREF(ClassDef_annotations);
1228
0
            return 0;
1229
0
        }
1230
10
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1231
10
                                    0;
1232
10
        Py_DECREF(type);
1233
10
        if (!cond) {
1234
0
            Py_DECREF(ClassDef_annotations);
1235
0
            return 0;
1236
0
        }
1237
10
    }
1238
10
    {
1239
10
        PyObject *type = state->stmt_type;
1240
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1241
10
        cond = type != NULL;
1242
10
        if (!cond) {
1243
0
            Py_DECREF(ClassDef_annotations);
1244
0
            return 0;
1245
0
        }
1246
10
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1247
10
        Py_DECREF(type);
1248
10
        if (!cond) {
1249
0
            Py_DECREF(ClassDef_annotations);
1250
0
            return 0;
1251
0
        }
1252
10
    }
1253
10
    {
1254
10
        PyObject *type = state->expr_type;
1255
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1256
10
        cond = type != NULL;
1257
10
        if (!cond) {
1258
0
            Py_DECREF(ClassDef_annotations);
1259
0
            return 0;
1260
0
        }
1261
10
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1262
10
                                    type) == 0;
1263
10
        Py_DECREF(type);
1264
10
        if (!cond) {
1265
0
            Py_DECREF(ClassDef_annotations);
1266
0
            return 0;
1267
0
        }
1268
10
    }
1269
10
    {
1270
10
        PyObject *type = state->type_param_type;
1271
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1272
10
        cond = type != NULL;
1273
10
        if (!cond) {
1274
0
            Py_DECREF(ClassDef_annotations);
1275
0
            return 0;
1276
0
        }
1277
10
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1278
10
                                    == 0;
1279
10
        Py_DECREF(type);
1280
10
        if (!cond) {
1281
0
            Py_DECREF(ClassDef_annotations);
1282
0
            return 0;
1283
0
        }
1284
10
    }
1285
10
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1286
10
                                  ClassDef_annotations) == 0;
1287
10
    if (!cond) {
1288
0
        Py_DECREF(ClassDef_annotations);
1289
0
        return 0;
1290
0
    }
1291
10
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1292
10
                                  ClassDef_annotations) == 0;
1293
10
    if (!cond) {
1294
0
        Py_DECREF(ClassDef_annotations);
1295
0
        return 0;
1296
0
    }
1297
10
    Py_DECREF(ClassDef_annotations);
1298
10
    PyObject *Return_annotations = PyDict_New();
1299
10
    if (!Return_annotations) return 0;
1300
10
    {
1301
10
        PyObject *type = state->expr_type;
1302
10
        type = _Py_union_type_or(type, Py_None);
1303
10
        cond = type != NULL;
1304
10
        if (!cond) {
1305
0
            Py_DECREF(Return_annotations);
1306
0
            return 0;
1307
0
        }
1308
10
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1309
10
        Py_DECREF(type);
1310
10
        if (!cond) {
1311
0
            Py_DECREF(Return_annotations);
1312
0
            return 0;
1313
0
        }
1314
10
    }
1315
10
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1316
10
                                  Return_annotations) == 0;
1317
10
    if (!cond) {
1318
0
        Py_DECREF(Return_annotations);
1319
0
        return 0;
1320
0
    }
1321
10
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1322
10
                                  Return_annotations) == 0;
1323
10
    if (!cond) {
1324
0
        Py_DECREF(Return_annotations);
1325
0
        return 0;
1326
0
    }
1327
10
    Py_DECREF(Return_annotations);
1328
10
    PyObject *Delete_annotations = PyDict_New();
1329
10
    if (!Delete_annotations) return 0;
1330
10
    {
1331
10
        PyObject *type = state->expr_type;
1332
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1333
10
        cond = type != NULL;
1334
10
        if (!cond) {
1335
0
            Py_DECREF(Delete_annotations);
1336
0
            return 0;
1337
0
        }
1338
10
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1339
10
        Py_DECREF(type);
1340
10
        if (!cond) {
1341
0
            Py_DECREF(Delete_annotations);
1342
0
            return 0;
1343
0
        }
1344
10
    }
1345
10
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1346
10
                                  Delete_annotations) == 0;
1347
10
    if (!cond) {
1348
0
        Py_DECREF(Delete_annotations);
1349
0
        return 0;
1350
0
    }
1351
10
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1352
10
                                  Delete_annotations) == 0;
1353
10
    if (!cond) {
1354
0
        Py_DECREF(Delete_annotations);
1355
0
        return 0;
1356
0
    }
1357
10
    Py_DECREF(Delete_annotations);
1358
10
    PyObject *Assign_annotations = PyDict_New();
1359
10
    if (!Assign_annotations) return 0;
1360
10
    {
1361
10
        PyObject *type = state->expr_type;
1362
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1363
10
        cond = type != NULL;
1364
10
        if (!cond) {
1365
0
            Py_DECREF(Assign_annotations);
1366
0
            return 0;
1367
0
        }
1368
10
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1369
10
        Py_DECREF(type);
1370
10
        if (!cond) {
1371
0
            Py_DECREF(Assign_annotations);
1372
0
            return 0;
1373
0
        }
1374
10
    }
1375
10
    {
1376
10
        PyObject *type = state->expr_type;
1377
10
        Py_INCREF(type);
1378
10
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1379
10
        Py_DECREF(type);
1380
10
        if (!cond) {
1381
0
            Py_DECREF(Assign_annotations);
1382
0
            return 0;
1383
0
        }
1384
10
    }
1385
10
    {
1386
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1387
10
        type = _Py_union_type_or(type, Py_None);
1388
10
        cond = type != NULL;
1389
10
        if (!cond) {
1390
0
            Py_DECREF(Assign_annotations);
1391
0
            return 0;
1392
0
        }
1393
10
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1394
10
                                    == 0;
1395
10
        Py_DECREF(type);
1396
10
        if (!cond) {
1397
0
            Py_DECREF(Assign_annotations);
1398
0
            return 0;
1399
0
        }
1400
10
    }
1401
10
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1402
10
                                  Assign_annotations) == 0;
1403
10
    if (!cond) {
1404
0
        Py_DECREF(Assign_annotations);
1405
0
        return 0;
1406
0
    }
1407
10
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1408
10
                                  Assign_annotations) == 0;
1409
10
    if (!cond) {
1410
0
        Py_DECREF(Assign_annotations);
1411
0
        return 0;
1412
0
    }
1413
10
    Py_DECREF(Assign_annotations);
1414
10
    PyObject *TypeAlias_annotations = PyDict_New();
1415
10
    if (!TypeAlias_annotations) return 0;
1416
10
    {
1417
10
        PyObject *type = state->expr_type;
1418
10
        Py_INCREF(type);
1419
10
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1420
10
        Py_DECREF(type);
1421
10
        if (!cond) {
1422
0
            Py_DECREF(TypeAlias_annotations);
1423
0
            return 0;
1424
0
        }
1425
10
    }
1426
10
    {
1427
10
        PyObject *type = state->type_param_type;
1428
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1429
10
        cond = type != NULL;
1430
10
        if (!cond) {
1431
0
            Py_DECREF(TypeAlias_annotations);
1432
0
            return 0;
1433
0
        }
1434
10
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1435
10
                                    == 0;
1436
10
        Py_DECREF(type);
1437
10
        if (!cond) {
1438
0
            Py_DECREF(TypeAlias_annotations);
1439
0
            return 0;
1440
0
        }
1441
10
    }
1442
10
    {
1443
10
        PyObject *type = state->expr_type;
1444
10
        Py_INCREF(type);
1445
10
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1446
10
        Py_DECREF(type);
1447
10
        if (!cond) {
1448
0
            Py_DECREF(TypeAlias_annotations);
1449
0
            return 0;
1450
0
        }
1451
10
    }
1452
10
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1453
10
                                  TypeAlias_annotations) == 0;
1454
10
    if (!cond) {
1455
0
        Py_DECREF(TypeAlias_annotations);
1456
0
        return 0;
1457
0
    }
1458
10
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1459
10
                                  TypeAlias_annotations) == 0;
1460
10
    if (!cond) {
1461
0
        Py_DECREF(TypeAlias_annotations);
1462
0
        return 0;
1463
0
    }
1464
10
    Py_DECREF(TypeAlias_annotations);
1465
10
    PyObject *AugAssign_annotations = PyDict_New();
1466
10
    if (!AugAssign_annotations) return 0;
1467
10
    {
1468
10
        PyObject *type = state->expr_type;
1469
10
        Py_INCREF(type);
1470
10
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1471
10
        Py_DECREF(type);
1472
10
        if (!cond) {
1473
0
            Py_DECREF(AugAssign_annotations);
1474
0
            return 0;
1475
0
        }
1476
10
    }
1477
10
    {
1478
10
        PyObject *type = state->operator_type;
1479
10
        Py_INCREF(type);
1480
10
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1481
10
        Py_DECREF(type);
1482
10
        if (!cond) {
1483
0
            Py_DECREF(AugAssign_annotations);
1484
0
            return 0;
1485
0
        }
1486
10
    }
1487
10
    {
1488
10
        PyObject *type = state->expr_type;
1489
10
        Py_INCREF(type);
1490
10
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1491
10
        Py_DECREF(type);
1492
10
        if (!cond) {
1493
0
            Py_DECREF(AugAssign_annotations);
1494
0
            return 0;
1495
0
        }
1496
10
    }
1497
10
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1498
10
                                  AugAssign_annotations) == 0;
1499
10
    if (!cond) {
1500
0
        Py_DECREF(AugAssign_annotations);
1501
0
        return 0;
1502
0
    }
1503
10
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1504
10
                                  AugAssign_annotations) == 0;
1505
10
    if (!cond) {
1506
0
        Py_DECREF(AugAssign_annotations);
1507
0
        return 0;
1508
0
    }
1509
10
    Py_DECREF(AugAssign_annotations);
1510
10
    PyObject *AnnAssign_annotations = PyDict_New();
1511
10
    if (!AnnAssign_annotations) return 0;
1512
10
    {
1513
10
        PyObject *type = state->expr_type;
1514
10
        Py_INCREF(type);
1515
10
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1516
10
        Py_DECREF(type);
1517
10
        if (!cond) {
1518
0
            Py_DECREF(AnnAssign_annotations);
1519
0
            return 0;
1520
0
        }
1521
10
    }
1522
10
    {
1523
10
        PyObject *type = state->expr_type;
1524
10
        Py_INCREF(type);
1525
10
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1526
10
                                    == 0;
1527
10
        Py_DECREF(type);
1528
10
        if (!cond) {
1529
0
            Py_DECREF(AnnAssign_annotations);
1530
0
            return 0;
1531
0
        }
1532
10
    }
1533
10
    {
1534
10
        PyObject *type = state->expr_type;
1535
10
        type = _Py_union_type_or(type, Py_None);
1536
10
        cond = type != NULL;
1537
10
        if (!cond) {
1538
0
            Py_DECREF(AnnAssign_annotations);
1539
0
            return 0;
1540
0
        }
1541
10
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1542
10
        Py_DECREF(type);
1543
10
        if (!cond) {
1544
0
            Py_DECREF(AnnAssign_annotations);
1545
0
            return 0;
1546
0
        }
1547
10
    }
1548
10
    {
1549
10
        PyObject *type = (PyObject *)&PyLong_Type;
1550
10
        Py_INCREF(type);
1551
10
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1552
10
        Py_DECREF(type);
1553
10
        if (!cond) {
1554
0
            Py_DECREF(AnnAssign_annotations);
1555
0
            return 0;
1556
0
        }
1557
10
    }
1558
10
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1559
10
                                  AnnAssign_annotations) == 0;
1560
10
    if (!cond) {
1561
0
        Py_DECREF(AnnAssign_annotations);
1562
0
        return 0;
1563
0
    }
1564
10
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1565
10
                                  AnnAssign_annotations) == 0;
1566
10
    if (!cond) {
1567
0
        Py_DECREF(AnnAssign_annotations);
1568
0
        return 0;
1569
0
    }
1570
10
    Py_DECREF(AnnAssign_annotations);
1571
10
    PyObject *For_annotations = PyDict_New();
1572
10
    if (!For_annotations) return 0;
1573
10
    {
1574
10
        PyObject *type = state->expr_type;
1575
10
        Py_INCREF(type);
1576
10
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1577
10
        Py_DECREF(type);
1578
10
        if (!cond) {
1579
0
            Py_DECREF(For_annotations);
1580
0
            return 0;
1581
0
        }
1582
10
    }
1583
10
    {
1584
10
        PyObject *type = state->expr_type;
1585
10
        Py_INCREF(type);
1586
10
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1587
10
        Py_DECREF(type);
1588
10
        if (!cond) {
1589
0
            Py_DECREF(For_annotations);
1590
0
            return 0;
1591
0
        }
1592
10
    }
1593
10
    {
1594
10
        PyObject *type = state->stmt_type;
1595
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1596
10
        cond = type != NULL;
1597
10
        if (!cond) {
1598
0
            Py_DECREF(For_annotations);
1599
0
            return 0;
1600
0
        }
1601
10
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1602
10
        Py_DECREF(type);
1603
10
        if (!cond) {
1604
0
            Py_DECREF(For_annotations);
1605
0
            return 0;
1606
0
        }
1607
10
    }
1608
10
    {
1609
10
        PyObject *type = state->stmt_type;
1610
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1611
10
        cond = type != NULL;
1612
10
        if (!cond) {
1613
0
            Py_DECREF(For_annotations);
1614
0
            return 0;
1615
0
        }
1616
10
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1617
10
        Py_DECREF(type);
1618
10
        if (!cond) {
1619
0
            Py_DECREF(For_annotations);
1620
0
            return 0;
1621
0
        }
1622
10
    }
1623
10
    {
1624
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1625
10
        type = _Py_union_type_or(type, Py_None);
1626
10
        cond = type != NULL;
1627
10
        if (!cond) {
1628
0
            Py_DECREF(For_annotations);
1629
0
            return 0;
1630
0
        }
1631
10
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1632
10
        Py_DECREF(type);
1633
10
        if (!cond) {
1634
0
            Py_DECREF(For_annotations);
1635
0
            return 0;
1636
0
        }
1637
10
    }
1638
10
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1639
10
                                  For_annotations) == 0;
1640
10
    if (!cond) {
1641
0
        Py_DECREF(For_annotations);
1642
0
        return 0;
1643
0
    }
1644
10
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1645
10
                                  For_annotations) == 0;
1646
10
    if (!cond) {
1647
0
        Py_DECREF(For_annotations);
1648
0
        return 0;
1649
0
    }
1650
10
    Py_DECREF(For_annotations);
1651
10
    PyObject *AsyncFor_annotations = PyDict_New();
1652
10
    if (!AsyncFor_annotations) return 0;
1653
10
    {
1654
10
        PyObject *type = state->expr_type;
1655
10
        Py_INCREF(type);
1656
10
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1657
10
        Py_DECREF(type);
1658
10
        if (!cond) {
1659
0
            Py_DECREF(AsyncFor_annotations);
1660
0
            return 0;
1661
0
        }
1662
10
    }
1663
10
    {
1664
10
        PyObject *type = state->expr_type;
1665
10
        Py_INCREF(type);
1666
10
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1667
10
        Py_DECREF(type);
1668
10
        if (!cond) {
1669
0
            Py_DECREF(AsyncFor_annotations);
1670
0
            return 0;
1671
0
        }
1672
10
    }
1673
10
    {
1674
10
        PyObject *type = state->stmt_type;
1675
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1676
10
        cond = type != NULL;
1677
10
        if (!cond) {
1678
0
            Py_DECREF(AsyncFor_annotations);
1679
0
            return 0;
1680
0
        }
1681
10
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1682
10
        Py_DECREF(type);
1683
10
        if (!cond) {
1684
0
            Py_DECREF(AsyncFor_annotations);
1685
0
            return 0;
1686
0
        }
1687
10
    }
1688
10
    {
1689
10
        PyObject *type = state->stmt_type;
1690
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1691
10
        cond = type != NULL;
1692
10
        if (!cond) {
1693
0
            Py_DECREF(AsyncFor_annotations);
1694
0
            return 0;
1695
0
        }
1696
10
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1697
10
        Py_DECREF(type);
1698
10
        if (!cond) {
1699
0
            Py_DECREF(AsyncFor_annotations);
1700
0
            return 0;
1701
0
        }
1702
10
    }
1703
10
    {
1704
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1705
10
        type = _Py_union_type_or(type, Py_None);
1706
10
        cond = type != NULL;
1707
10
        if (!cond) {
1708
0
            Py_DECREF(AsyncFor_annotations);
1709
0
            return 0;
1710
0
        }
1711
10
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1712
10
                                    == 0;
1713
10
        Py_DECREF(type);
1714
10
        if (!cond) {
1715
0
            Py_DECREF(AsyncFor_annotations);
1716
0
            return 0;
1717
0
        }
1718
10
    }
1719
10
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1720
10
                                  AsyncFor_annotations) == 0;
1721
10
    if (!cond) {
1722
0
        Py_DECREF(AsyncFor_annotations);
1723
0
        return 0;
1724
0
    }
1725
10
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1726
10
                                  AsyncFor_annotations) == 0;
1727
10
    if (!cond) {
1728
0
        Py_DECREF(AsyncFor_annotations);
1729
0
        return 0;
1730
0
    }
1731
10
    Py_DECREF(AsyncFor_annotations);
1732
10
    PyObject *While_annotations = PyDict_New();
1733
10
    if (!While_annotations) return 0;
1734
10
    {
1735
10
        PyObject *type = state->expr_type;
1736
10
        Py_INCREF(type);
1737
10
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1738
10
        Py_DECREF(type);
1739
10
        if (!cond) {
1740
0
            Py_DECREF(While_annotations);
1741
0
            return 0;
1742
0
        }
1743
10
    }
1744
10
    {
1745
10
        PyObject *type = state->stmt_type;
1746
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1747
10
        cond = type != NULL;
1748
10
        if (!cond) {
1749
0
            Py_DECREF(While_annotations);
1750
0
            return 0;
1751
0
        }
1752
10
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1753
10
        Py_DECREF(type);
1754
10
        if (!cond) {
1755
0
            Py_DECREF(While_annotations);
1756
0
            return 0;
1757
0
        }
1758
10
    }
1759
10
    {
1760
10
        PyObject *type = state->stmt_type;
1761
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1762
10
        cond = type != NULL;
1763
10
        if (!cond) {
1764
0
            Py_DECREF(While_annotations);
1765
0
            return 0;
1766
0
        }
1767
10
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1768
10
        Py_DECREF(type);
1769
10
        if (!cond) {
1770
0
            Py_DECREF(While_annotations);
1771
0
            return 0;
1772
0
        }
1773
10
    }
1774
10
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1775
10
                                  While_annotations) == 0;
1776
10
    if (!cond) {
1777
0
        Py_DECREF(While_annotations);
1778
0
        return 0;
1779
0
    }
1780
10
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1781
10
                                  While_annotations) == 0;
1782
10
    if (!cond) {
1783
0
        Py_DECREF(While_annotations);
1784
0
        return 0;
1785
0
    }
1786
10
    Py_DECREF(While_annotations);
1787
10
    PyObject *If_annotations = PyDict_New();
1788
10
    if (!If_annotations) return 0;
1789
10
    {
1790
10
        PyObject *type = state->expr_type;
1791
10
        Py_INCREF(type);
1792
10
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1793
10
        Py_DECREF(type);
1794
10
        if (!cond) {
1795
0
            Py_DECREF(If_annotations);
1796
0
            return 0;
1797
0
        }
1798
10
    }
1799
10
    {
1800
10
        PyObject *type = state->stmt_type;
1801
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1802
10
        cond = type != NULL;
1803
10
        if (!cond) {
1804
0
            Py_DECREF(If_annotations);
1805
0
            return 0;
1806
0
        }
1807
10
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1808
10
        Py_DECREF(type);
1809
10
        if (!cond) {
1810
0
            Py_DECREF(If_annotations);
1811
0
            return 0;
1812
0
        }
1813
10
    }
1814
10
    {
1815
10
        PyObject *type = state->stmt_type;
1816
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1817
10
        cond = type != NULL;
1818
10
        if (!cond) {
1819
0
            Py_DECREF(If_annotations);
1820
0
            return 0;
1821
0
        }
1822
10
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1823
10
        Py_DECREF(type);
1824
10
        if (!cond) {
1825
0
            Py_DECREF(If_annotations);
1826
0
            return 0;
1827
0
        }
1828
10
    }
1829
10
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1830
10
                                  If_annotations) == 0;
1831
10
    if (!cond) {
1832
0
        Py_DECREF(If_annotations);
1833
0
        return 0;
1834
0
    }
1835
10
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1836
10
                                  If_annotations) == 0;
1837
10
    if (!cond) {
1838
0
        Py_DECREF(If_annotations);
1839
0
        return 0;
1840
0
    }
1841
10
    Py_DECREF(If_annotations);
1842
10
    PyObject *With_annotations = PyDict_New();
1843
10
    if (!With_annotations) return 0;
1844
10
    {
1845
10
        PyObject *type = state->withitem_type;
1846
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1847
10
        cond = type != NULL;
1848
10
        if (!cond) {
1849
0
            Py_DECREF(With_annotations);
1850
0
            return 0;
1851
0
        }
1852
10
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1853
10
        Py_DECREF(type);
1854
10
        if (!cond) {
1855
0
            Py_DECREF(With_annotations);
1856
0
            return 0;
1857
0
        }
1858
10
    }
1859
10
    {
1860
10
        PyObject *type = state->stmt_type;
1861
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1862
10
        cond = type != NULL;
1863
10
        if (!cond) {
1864
0
            Py_DECREF(With_annotations);
1865
0
            return 0;
1866
0
        }
1867
10
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1868
10
        Py_DECREF(type);
1869
10
        if (!cond) {
1870
0
            Py_DECREF(With_annotations);
1871
0
            return 0;
1872
0
        }
1873
10
    }
1874
10
    {
1875
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1876
10
        type = _Py_union_type_or(type, Py_None);
1877
10
        cond = type != NULL;
1878
10
        if (!cond) {
1879
0
            Py_DECREF(With_annotations);
1880
0
            return 0;
1881
0
        }
1882
10
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1883
10
                                    0;
1884
10
        Py_DECREF(type);
1885
10
        if (!cond) {
1886
0
            Py_DECREF(With_annotations);
1887
0
            return 0;
1888
0
        }
1889
10
    }
1890
10
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1891
10
                                  With_annotations) == 0;
1892
10
    if (!cond) {
1893
0
        Py_DECREF(With_annotations);
1894
0
        return 0;
1895
0
    }
1896
10
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1897
10
                                  With_annotations) == 0;
1898
10
    if (!cond) {
1899
0
        Py_DECREF(With_annotations);
1900
0
        return 0;
1901
0
    }
1902
10
    Py_DECREF(With_annotations);
1903
10
    PyObject *AsyncWith_annotations = PyDict_New();
1904
10
    if (!AsyncWith_annotations) return 0;
1905
10
    {
1906
10
        PyObject *type = state->withitem_type;
1907
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1908
10
        cond = type != NULL;
1909
10
        if (!cond) {
1910
0
            Py_DECREF(AsyncWith_annotations);
1911
0
            return 0;
1912
0
        }
1913
10
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1914
10
        Py_DECREF(type);
1915
10
        if (!cond) {
1916
0
            Py_DECREF(AsyncWith_annotations);
1917
0
            return 0;
1918
0
        }
1919
10
    }
1920
10
    {
1921
10
        PyObject *type = state->stmt_type;
1922
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1923
10
        cond = type != NULL;
1924
10
        if (!cond) {
1925
0
            Py_DECREF(AsyncWith_annotations);
1926
0
            return 0;
1927
0
        }
1928
10
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1929
10
        Py_DECREF(type);
1930
10
        if (!cond) {
1931
0
            Py_DECREF(AsyncWith_annotations);
1932
0
            return 0;
1933
0
        }
1934
10
    }
1935
10
    {
1936
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
1937
10
        type = _Py_union_type_or(type, Py_None);
1938
10
        cond = type != NULL;
1939
10
        if (!cond) {
1940
0
            Py_DECREF(AsyncWith_annotations);
1941
0
            return 0;
1942
0
        }
1943
10
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1944
10
                                    type) == 0;
1945
10
        Py_DECREF(type);
1946
10
        if (!cond) {
1947
0
            Py_DECREF(AsyncWith_annotations);
1948
0
            return 0;
1949
0
        }
1950
10
    }
1951
10
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1952
10
                                  AsyncWith_annotations) == 0;
1953
10
    if (!cond) {
1954
0
        Py_DECREF(AsyncWith_annotations);
1955
0
        return 0;
1956
0
    }
1957
10
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1958
10
                                  AsyncWith_annotations) == 0;
1959
10
    if (!cond) {
1960
0
        Py_DECREF(AsyncWith_annotations);
1961
0
        return 0;
1962
0
    }
1963
10
    Py_DECREF(AsyncWith_annotations);
1964
10
    PyObject *Match_annotations = PyDict_New();
1965
10
    if (!Match_annotations) return 0;
1966
10
    {
1967
10
        PyObject *type = state->expr_type;
1968
10
        Py_INCREF(type);
1969
10
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1970
10
        Py_DECREF(type);
1971
10
        if (!cond) {
1972
0
            Py_DECREF(Match_annotations);
1973
0
            return 0;
1974
0
        }
1975
10
    }
1976
10
    {
1977
10
        PyObject *type = state->match_case_type;
1978
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1979
10
        cond = type != NULL;
1980
10
        if (!cond) {
1981
0
            Py_DECREF(Match_annotations);
1982
0
            return 0;
1983
0
        }
1984
10
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1985
10
        Py_DECREF(type);
1986
10
        if (!cond) {
1987
0
            Py_DECREF(Match_annotations);
1988
0
            return 0;
1989
0
        }
1990
10
    }
1991
10
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1992
10
                                  Match_annotations) == 0;
1993
10
    if (!cond) {
1994
0
        Py_DECREF(Match_annotations);
1995
0
        return 0;
1996
0
    }
1997
10
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
1998
10
                                  Match_annotations) == 0;
1999
10
    if (!cond) {
2000
0
        Py_DECREF(Match_annotations);
2001
0
        return 0;
2002
0
    }
2003
10
    Py_DECREF(Match_annotations);
2004
10
    PyObject *Raise_annotations = PyDict_New();
2005
10
    if (!Raise_annotations) return 0;
2006
10
    {
2007
10
        PyObject *type = state->expr_type;
2008
10
        type = _Py_union_type_or(type, Py_None);
2009
10
        cond = type != NULL;
2010
10
        if (!cond) {
2011
0
            Py_DECREF(Raise_annotations);
2012
0
            return 0;
2013
0
        }
2014
10
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2015
10
        Py_DECREF(type);
2016
10
        if (!cond) {
2017
0
            Py_DECREF(Raise_annotations);
2018
0
            return 0;
2019
0
        }
2020
10
    }
2021
10
    {
2022
10
        PyObject *type = state->expr_type;
2023
10
        type = _Py_union_type_or(type, Py_None);
2024
10
        cond = type != NULL;
2025
10
        if (!cond) {
2026
0
            Py_DECREF(Raise_annotations);
2027
0
            return 0;
2028
0
        }
2029
10
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2030
10
        Py_DECREF(type);
2031
10
        if (!cond) {
2032
0
            Py_DECREF(Raise_annotations);
2033
0
            return 0;
2034
0
        }
2035
10
    }
2036
10
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2037
10
                                  Raise_annotations) == 0;
2038
10
    if (!cond) {
2039
0
        Py_DECREF(Raise_annotations);
2040
0
        return 0;
2041
0
    }
2042
10
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2043
10
                                  Raise_annotations) == 0;
2044
10
    if (!cond) {
2045
0
        Py_DECREF(Raise_annotations);
2046
0
        return 0;
2047
0
    }
2048
10
    Py_DECREF(Raise_annotations);
2049
10
    PyObject *Try_annotations = PyDict_New();
2050
10
    if (!Try_annotations) return 0;
2051
10
    {
2052
10
        PyObject *type = state->stmt_type;
2053
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2054
10
        cond = type != NULL;
2055
10
        if (!cond) {
2056
0
            Py_DECREF(Try_annotations);
2057
0
            return 0;
2058
0
        }
2059
10
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2060
10
        Py_DECREF(type);
2061
10
        if (!cond) {
2062
0
            Py_DECREF(Try_annotations);
2063
0
            return 0;
2064
0
        }
2065
10
    }
2066
10
    {
2067
10
        PyObject *type = state->excepthandler_type;
2068
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2069
10
        cond = type != NULL;
2070
10
        if (!cond) {
2071
0
            Py_DECREF(Try_annotations);
2072
0
            return 0;
2073
0
        }
2074
10
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2075
10
        Py_DECREF(type);
2076
10
        if (!cond) {
2077
0
            Py_DECREF(Try_annotations);
2078
0
            return 0;
2079
0
        }
2080
10
    }
2081
10
    {
2082
10
        PyObject *type = state->stmt_type;
2083
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2084
10
        cond = type != NULL;
2085
10
        if (!cond) {
2086
0
            Py_DECREF(Try_annotations);
2087
0
            return 0;
2088
0
        }
2089
10
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2090
10
        Py_DECREF(type);
2091
10
        if (!cond) {
2092
0
            Py_DECREF(Try_annotations);
2093
0
            return 0;
2094
0
        }
2095
10
    }
2096
10
    {
2097
10
        PyObject *type = state->stmt_type;
2098
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2099
10
        cond = type != NULL;
2100
10
        if (!cond) {
2101
0
            Py_DECREF(Try_annotations);
2102
0
            return 0;
2103
0
        }
2104
10
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2105
10
        Py_DECREF(type);
2106
10
        if (!cond) {
2107
0
            Py_DECREF(Try_annotations);
2108
0
            return 0;
2109
0
        }
2110
10
    }
2111
10
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2112
10
                                  Try_annotations) == 0;
2113
10
    if (!cond) {
2114
0
        Py_DECREF(Try_annotations);
2115
0
        return 0;
2116
0
    }
2117
10
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2118
10
                                  Try_annotations) == 0;
2119
10
    if (!cond) {
2120
0
        Py_DECREF(Try_annotations);
2121
0
        return 0;
2122
0
    }
2123
10
    Py_DECREF(Try_annotations);
2124
10
    PyObject *TryStar_annotations = PyDict_New();
2125
10
    if (!TryStar_annotations) return 0;
2126
10
    {
2127
10
        PyObject *type = state->stmt_type;
2128
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2129
10
        cond = type != NULL;
2130
10
        if (!cond) {
2131
0
            Py_DECREF(TryStar_annotations);
2132
0
            return 0;
2133
0
        }
2134
10
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2135
10
        Py_DECREF(type);
2136
10
        if (!cond) {
2137
0
            Py_DECREF(TryStar_annotations);
2138
0
            return 0;
2139
0
        }
2140
10
    }
2141
10
    {
2142
10
        PyObject *type = state->excepthandler_type;
2143
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2144
10
        cond = type != NULL;
2145
10
        if (!cond) {
2146
0
            Py_DECREF(TryStar_annotations);
2147
0
            return 0;
2148
0
        }
2149
10
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2150
10
        Py_DECREF(type);
2151
10
        if (!cond) {
2152
0
            Py_DECREF(TryStar_annotations);
2153
0
            return 0;
2154
0
        }
2155
10
    }
2156
10
    {
2157
10
        PyObject *type = state->stmt_type;
2158
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2159
10
        cond = type != NULL;
2160
10
        if (!cond) {
2161
0
            Py_DECREF(TryStar_annotations);
2162
0
            return 0;
2163
0
        }
2164
10
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2165
10
        Py_DECREF(type);
2166
10
        if (!cond) {
2167
0
            Py_DECREF(TryStar_annotations);
2168
0
            return 0;
2169
0
        }
2170
10
    }
2171
10
    {
2172
10
        PyObject *type = state->stmt_type;
2173
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2174
10
        cond = type != NULL;
2175
10
        if (!cond) {
2176
0
            Py_DECREF(TryStar_annotations);
2177
0
            return 0;
2178
0
        }
2179
10
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2180
10
                                    0;
2181
10
        Py_DECREF(type);
2182
10
        if (!cond) {
2183
0
            Py_DECREF(TryStar_annotations);
2184
0
            return 0;
2185
0
        }
2186
10
    }
2187
10
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2188
10
                                  TryStar_annotations) == 0;
2189
10
    if (!cond) {
2190
0
        Py_DECREF(TryStar_annotations);
2191
0
        return 0;
2192
0
    }
2193
10
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2194
10
                                  TryStar_annotations) == 0;
2195
10
    if (!cond) {
2196
0
        Py_DECREF(TryStar_annotations);
2197
0
        return 0;
2198
0
    }
2199
10
    Py_DECREF(TryStar_annotations);
2200
10
    PyObject *Assert_annotations = PyDict_New();
2201
10
    if (!Assert_annotations) return 0;
2202
10
    {
2203
10
        PyObject *type = state->expr_type;
2204
10
        Py_INCREF(type);
2205
10
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2206
10
        Py_DECREF(type);
2207
10
        if (!cond) {
2208
0
            Py_DECREF(Assert_annotations);
2209
0
            return 0;
2210
0
        }
2211
10
    }
2212
10
    {
2213
10
        PyObject *type = state->expr_type;
2214
10
        type = _Py_union_type_or(type, Py_None);
2215
10
        cond = type != NULL;
2216
10
        if (!cond) {
2217
0
            Py_DECREF(Assert_annotations);
2218
0
            return 0;
2219
0
        }
2220
10
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2221
10
        Py_DECREF(type);
2222
10
        if (!cond) {
2223
0
            Py_DECREF(Assert_annotations);
2224
0
            return 0;
2225
0
        }
2226
10
    }
2227
10
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2228
10
                                  Assert_annotations) == 0;
2229
10
    if (!cond) {
2230
0
        Py_DECREF(Assert_annotations);
2231
0
        return 0;
2232
0
    }
2233
10
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2234
10
                                  Assert_annotations) == 0;
2235
10
    if (!cond) {
2236
0
        Py_DECREF(Assert_annotations);
2237
0
        return 0;
2238
0
    }
2239
10
    Py_DECREF(Assert_annotations);
2240
10
    PyObject *Import_annotations = PyDict_New();
2241
10
    if (!Import_annotations) return 0;
2242
10
    {
2243
10
        PyObject *type = state->alias_type;
2244
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2245
10
        cond = type != NULL;
2246
10
        if (!cond) {
2247
0
            Py_DECREF(Import_annotations);
2248
0
            return 0;
2249
0
        }
2250
10
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2251
10
        Py_DECREF(type);
2252
10
        if (!cond) {
2253
0
            Py_DECREF(Import_annotations);
2254
0
            return 0;
2255
0
        }
2256
10
    }
2257
10
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2258
10
                                  Import_annotations) == 0;
2259
10
    if (!cond) {
2260
0
        Py_DECREF(Import_annotations);
2261
0
        return 0;
2262
0
    }
2263
10
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2264
10
                                  Import_annotations) == 0;
2265
10
    if (!cond) {
2266
0
        Py_DECREF(Import_annotations);
2267
0
        return 0;
2268
0
    }
2269
10
    Py_DECREF(Import_annotations);
2270
10
    PyObject *ImportFrom_annotations = PyDict_New();
2271
10
    if (!ImportFrom_annotations) return 0;
2272
10
    {
2273
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
2274
10
        type = _Py_union_type_or(type, Py_None);
2275
10
        cond = type != NULL;
2276
10
        if (!cond) {
2277
0
            Py_DECREF(ImportFrom_annotations);
2278
0
            return 0;
2279
0
        }
2280
10
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2281
10
                                    0;
2282
10
        Py_DECREF(type);
2283
10
        if (!cond) {
2284
0
            Py_DECREF(ImportFrom_annotations);
2285
0
            return 0;
2286
0
        }
2287
10
    }
2288
10
    {
2289
10
        PyObject *type = state->alias_type;
2290
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2291
10
        cond = type != NULL;
2292
10
        if (!cond) {
2293
0
            Py_DECREF(ImportFrom_annotations);
2294
0
            return 0;
2295
0
        }
2296
10
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2297
10
        Py_DECREF(type);
2298
10
        if (!cond) {
2299
0
            Py_DECREF(ImportFrom_annotations);
2300
0
            return 0;
2301
0
        }
2302
10
    }
2303
10
    {
2304
10
        PyObject *type = (PyObject *)&PyLong_Type;
2305
10
        type = _Py_union_type_or(type, Py_None);
2306
10
        cond = type != NULL;
2307
10
        if (!cond) {
2308
0
            Py_DECREF(ImportFrom_annotations);
2309
0
            return 0;
2310
0
        }
2311
10
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2312
10
        Py_DECREF(type);
2313
10
        if (!cond) {
2314
0
            Py_DECREF(ImportFrom_annotations);
2315
0
            return 0;
2316
0
        }
2317
10
    }
2318
10
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2319
10
                                  ImportFrom_annotations) == 0;
2320
10
    if (!cond) {
2321
0
        Py_DECREF(ImportFrom_annotations);
2322
0
        return 0;
2323
0
    }
2324
10
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2325
10
                                  ImportFrom_annotations) == 0;
2326
10
    if (!cond) {
2327
0
        Py_DECREF(ImportFrom_annotations);
2328
0
        return 0;
2329
0
    }
2330
10
    Py_DECREF(ImportFrom_annotations);
2331
10
    PyObject *Global_annotations = PyDict_New();
2332
10
    if (!Global_annotations) return 0;
2333
10
    {
2334
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
2335
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2336
10
        cond = type != NULL;
2337
10
        if (!cond) {
2338
0
            Py_DECREF(Global_annotations);
2339
0
            return 0;
2340
0
        }
2341
10
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2342
10
        Py_DECREF(type);
2343
10
        if (!cond) {
2344
0
            Py_DECREF(Global_annotations);
2345
0
            return 0;
2346
0
        }
2347
10
    }
2348
10
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2349
10
                                  Global_annotations) == 0;
2350
10
    if (!cond) {
2351
0
        Py_DECREF(Global_annotations);
2352
0
        return 0;
2353
0
    }
2354
10
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2355
10
                                  Global_annotations) == 0;
2356
10
    if (!cond) {
2357
0
        Py_DECREF(Global_annotations);
2358
0
        return 0;
2359
0
    }
2360
10
    Py_DECREF(Global_annotations);
2361
10
    PyObject *Nonlocal_annotations = PyDict_New();
2362
10
    if (!Nonlocal_annotations) return 0;
2363
10
    {
2364
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
2365
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2366
10
        cond = type != NULL;
2367
10
        if (!cond) {
2368
0
            Py_DECREF(Nonlocal_annotations);
2369
0
            return 0;
2370
0
        }
2371
10
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2372
10
        Py_DECREF(type);
2373
10
        if (!cond) {
2374
0
            Py_DECREF(Nonlocal_annotations);
2375
0
            return 0;
2376
0
        }
2377
10
    }
2378
10
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2379
10
                                  Nonlocal_annotations) == 0;
2380
10
    if (!cond) {
2381
0
        Py_DECREF(Nonlocal_annotations);
2382
0
        return 0;
2383
0
    }
2384
10
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2385
10
                                  Nonlocal_annotations) == 0;
2386
10
    if (!cond) {
2387
0
        Py_DECREF(Nonlocal_annotations);
2388
0
        return 0;
2389
0
    }
2390
10
    Py_DECREF(Nonlocal_annotations);
2391
10
    PyObject *Expr_annotations = PyDict_New();
2392
10
    if (!Expr_annotations) return 0;
2393
10
    {
2394
10
        PyObject *type = state->expr_type;
2395
10
        Py_INCREF(type);
2396
10
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2397
10
        Py_DECREF(type);
2398
10
        if (!cond) {
2399
0
            Py_DECREF(Expr_annotations);
2400
0
            return 0;
2401
0
        }
2402
10
    }
2403
10
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2404
10
                                  Expr_annotations) == 0;
2405
10
    if (!cond) {
2406
0
        Py_DECREF(Expr_annotations);
2407
0
        return 0;
2408
0
    }
2409
10
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2410
10
                                  Expr_annotations) == 0;
2411
10
    if (!cond) {
2412
0
        Py_DECREF(Expr_annotations);
2413
0
        return 0;
2414
0
    }
2415
10
    Py_DECREF(Expr_annotations);
2416
10
    PyObject *Pass_annotations = PyDict_New();
2417
10
    if (!Pass_annotations) return 0;
2418
10
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2419
10
                                  Pass_annotations) == 0;
2420
10
    if (!cond) {
2421
0
        Py_DECREF(Pass_annotations);
2422
0
        return 0;
2423
0
    }
2424
10
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2425
10
                                  Pass_annotations) == 0;
2426
10
    if (!cond) {
2427
0
        Py_DECREF(Pass_annotations);
2428
0
        return 0;
2429
0
    }
2430
10
    Py_DECREF(Pass_annotations);
2431
10
    PyObject *Break_annotations = PyDict_New();
2432
10
    if (!Break_annotations) return 0;
2433
10
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2434
10
                                  Break_annotations) == 0;
2435
10
    if (!cond) {
2436
0
        Py_DECREF(Break_annotations);
2437
0
        return 0;
2438
0
    }
2439
10
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2440
10
                                  Break_annotations) == 0;
2441
10
    if (!cond) {
2442
0
        Py_DECREF(Break_annotations);
2443
0
        return 0;
2444
0
    }
2445
10
    Py_DECREF(Break_annotations);
2446
10
    PyObject *Continue_annotations = PyDict_New();
2447
10
    if (!Continue_annotations) return 0;
2448
10
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2449
10
                                  Continue_annotations) == 0;
2450
10
    if (!cond) {
2451
0
        Py_DECREF(Continue_annotations);
2452
0
        return 0;
2453
0
    }
2454
10
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2455
10
                                  Continue_annotations) == 0;
2456
10
    if (!cond) {
2457
0
        Py_DECREF(Continue_annotations);
2458
0
        return 0;
2459
0
    }
2460
10
    Py_DECREF(Continue_annotations);
2461
10
    PyObject *BoolOp_annotations = PyDict_New();
2462
10
    if (!BoolOp_annotations) return 0;
2463
10
    {
2464
10
        PyObject *type = state->boolop_type;
2465
10
        Py_INCREF(type);
2466
10
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2467
10
        Py_DECREF(type);
2468
10
        if (!cond) {
2469
0
            Py_DECREF(BoolOp_annotations);
2470
0
            return 0;
2471
0
        }
2472
10
    }
2473
10
    {
2474
10
        PyObject *type = state->expr_type;
2475
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2476
10
        cond = type != NULL;
2477
10
        if (!cond) {
2478
0
            Py_DECREF(BoolOp_annotations);
2479
0
            return 0;
2480
0
        }
2481
10
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2482
10
        Py_DECREF(type);
2483
10
        if (!cond) {
2484
0
            Py_DECREF(BoolOp_annotations);
2485
0
            return 0;
2486
0
        }
2487
10
    }
2488
10
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2489
10
                                  BoolOp_annotations) == 0;
2490
10
    if (!cond) {
2491
0
        Py_DECREF(BoolOp_annotations);
2492
0
        return 0;
2493
0
    }
2494
10
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2495
10
                                  BoolOp_annotations) == 0;
2496
10
    if (!cond) {
2497
0
        Py_DECREF(BoolOp_annotations);
2498
0
        return 0;
2499
0
    }
2500
10
    Py_DECREF(BoolOp_annotations);
2501
10
    PyObject *NamedExpr_annotations = PyDict_New();
2502
10
    if (!NamedExpr_annotations) return 0;
2503
10
    {
2504
10
        PyObject *type = state->expr_type;
2505
10
        Py_INCREF(type);
2506
10
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2507
10
        Py_DECREF(type);
2508
10
        if (!cond) {
2509
0
            Py_DECREF(NamedExpr_annotations);
2510
0
            return 0;
2511
0
        }
2512
10
    }
2513
10
    {
2514
10
        PyObject *type = state->expr_type;
2515
10
        Py_INCREF(type);
2516
10
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2517
10
        Py_DECREF(type);
2518
10
        if (!cond) {
2519
0
            Py_DECREF(NamedExpr_annotations);
2520
0
            return 0;
2521
0
        }
2522
10
    }
2523
10
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2524
10
                                  NamedExpr_annotations) == 0;
2525
10
    if (!cond) {
2526
0
        Py_DECREF(NamedExpr_annotations);
2527
0
        return 0;
2528
0
    }
2529
10
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2530
10
                                  NamedExpr_annotations) == 0;
2531
10
    if (!cond) {
2532
0
        Py_DECREF(NamedExpr_annotations);
2533
0
        return 0;
2534
0
    }
2535
10
    Py_DECREF(NamedExpr_annotations);
2536
10
    PyObject *BinOp_annotations = PyDict_New();
2537
10
    if (!BinOp_annotations) return 0;
2538
10
    {
2539
10
        PyObject *type = state->expr_type;
2540
10
        Py_INCREF(type);
2541
10
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2542
10
        Py_DECREF(type);
2543
10
        if (!cond) {
2544
0
            Py_DECREF(BinOp_annotations);
2545
0
            return 0;
2546
0
        }
2547
10
    }
2548
10
    {
2549
10
        PyObject *type = state->operator_type;
2550
10
        Py_INCREF(type);
2551
10
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2552
10
        Py_DECREF(type);
2553
10
        if (!cond) {
2554
0
            Py_DECREF(BinOp_annotations);
2555
0
            return 0;
2556
0
        }
2557
10
    }
2558
10
    {
2559
10
        PyObject *type = state->expr_type;
2560
10
        Py_INCREF(type);
2561
10
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2562
10
        Py_DECREF(type);
2563
10
        if (!cond) {
2564
0
            Py_DECREF(BinOp_annotations);
2565
0
            return 0;
2566
0
        }
2567
10
    }
2568
10
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2569
10
                                  BinOp_annotations) == 0;
2570
10
    if (!cond) {
2571
0
        Py_DECREF(BinOp_annotations);
2572
0
        return 0;
2573
0
    }
2574
10
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2575
10
                                  BinOp_annotations) == 0;
2576
10
    if (!cond) {
2577
0
        Py_DECREF(BinOp_annotations);
2578
0
        return 0;
2579
0
    }
2580
10
    Py_DECREF(BinOp_annotations);
2581
10
    PyObject *UnaryOp_annotations = PyDict_New();
2582
10
    if (!UnaryOp_annotations) return 0;
2583
10
    {
2584
10
        PyObject *type = state->unaryop_type;
2585
10
        Py_INCREF(type);
2586
10
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2587
10
        Py_DECREF(type);
2588
10
        if (!cond) {
2589
0
            Py_DECREF(UnaryOp_annotations);
2590
0
            return 0;
2591
0
        }
2592
10
    }
2593
10
    {
2594
10
        PyObject *type = state->expr_type;
2595
10
        Py_INCREF(type);
2596
10
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2597
10
        Py_DECREF(type);
2598
10
        if (!cond) {
2599
0
            Py_DECREF(UnaryOp_annotations);
2600
0
            return 0;
2601
0
        }
2602
10
    }
2603
10
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2604
10
                                  UnaryOp_annotations) == 0;
2605
10
    if (!cond) {
2606
0
        Py_DECREF(UnaryOp_annotations);
2607
0
        return 0;
2608
0
    }
2609
10
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2610
10
                                  UnaryOp_annotations) == 0;
2611
10
    if (!cond) {
2612
0
        Py_DECREF(UnaryOp_annotations);
2613
0
        return 0;
2614
0
    }
2615
10
    Py_DECREF(UnaryOp_annotations);
2616
10
    PyObject *Lambda_annotations = PyDict_New();
2617
10
    if (!Lambda_annotations) return 0;
2618
10
    {
2619
10
        PyObject *type = state->arguments_type;
2620
10
        Py_INCREF(type);
2621
10
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2622
10
        Py_DECREF(type);
2623
10
        if (!cond) {
2624
0
            Py_DECREF(Lambda_annotations);
2625
0
            return 0;
2626
0
        }
2627
10
    }
2628
10
    {
2629
10
        PyObject *type = state->expr_type;
2630
10
        Py_INCREF(type);
2631
10
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2632
10
        Py_DECREF(type);
2633
10
        if (!cond) {
2634
0
            Py_DECREF(Lambda_annotations);
2635
0
            return 0;
2636
0
        }
2637
10
    }
2638
10
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2639
10
                                  Lambda_annotations) == 0;
2640
10
    if (!cond) {
2641
0
        Py_DECREF(Lambda_annotations);
2642
0
        return 0;
2643
0
    }
2644
10
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2645
10
                                  Lambda_annotations) == 0;
2646
10
    if (!cond) {
2647
0
        Py_DECREF(Lambda_annotations);
2648
0
        return 0;
2649
0
    }
2650
10
    Py_DECREF(Lambda_annotations);
2651
10
    PyObject *IfExp_annotations = PyDict_New();
2652
10
    if (!IfExp_annotations) return 0;
2653
10
    {
2654
10
        PyObject *type = state->expr_type;
2655
10
        Py_INCREF(type);
2656
10
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2657
10
        Py_DECREF(type);
2658
10
        if (!cond) {
2659
0
            Py_DECREF(IfExp_annotations);
2660
0
            return 0;
2661
0
        }
2662
10
    }
2663
10
    {
2664
10
        PyObject *type = state->expr_type;
2665
10
        Py_INCREF(type);
2666
10
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2667
10
        Py_DECREF(type);
2668
10
        if (!cond) {
2669
0
            Py_DECREF(IfExp_annotations);
2670
0
            return 0;
2671
0
        }
2672
10
    }
2673
10
    {
2674
10
        PyObject *type = state->expr_type;
2675
10
        Py_INCREF(type);
2676
10
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2677
10
        Py_DECREF(type);
2678
10
        if (!cond) {
2679
0
            Py_DECREF(IfExp_annotations);
2680
0
            return 0;
2681
0
        }
2682
10
    }
2683
10
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2684
10
                                  IfExp_annotations) == 0;
2685
10
    if (!cond) {
2686
0
        Py_DECREF(IfExp_annotations);
2687
0
        return 0;
2688
0
    }
2689
10
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2690
10
                                  IfExp_annotations) == 0;
2691
10
    if (!cond) {
2692
0
        Py_DECREF(IfExp_annotations);
2693
0
        return 0;
2694
0
    }
2695
10
    Py_DECREF(IfExp_annotations);
2696
10
    PyObject *Dict_annotations = PyDict_New();
2697
10
    if (!Dict_annotations) return 0;
2698
10
    {
2699
10
        PyObject *type = state->expr_type;
2700
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2701
10
        cond = type != NULL;
2702
10
        if (!cond) {
2703
0
            Py_DECREF(Dict_annotations);
2704
0
            return 0;
2705
0
        }
2706
10
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2707
10
        Py_DECREF(type);
2708
10
        if (!cond) {
2709
0
            Py_DECREF(Dict_annotations);
2710
0
            return 0;
2711
0
        }
2712
10
    }
2713
10
    {
2714
10
        PyObject *type = state->expr_type;
2715
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2716
10
        cond = type != NULL;
2717
10
        if (!cond) {
2718
0
            Py_DECREF(Dict_annotations);
2719
0
            return 0;
2720
0
        }
2721
10
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2722
10
        Py_DECREF(type);
2723
10
        if (!cond) {
2724
0
            Py_DECREF(Dict_annotations);
2725
0
            return 0;
2726
0
        }
2727
10
    }
2728
10
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2729
10
                                  Dict_annotations) == 0;
2730
10
    if (!cond) {
2731
0
        Py_DECREF(Dict_annotations);
2732
0
        return 0;
2733
0
    }
2734
10
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2735
10
                                  Dict_annotations) == 0;
2736
10
    if (!cond) {
2737
0
        Py_DECREF(Dict_annotations);
2738
0
        return 0;
2739
0
    }
2740
10
    Py_DECREF(Dict_annotations);
2741
10
    PyObject *Set_annotations = PyDict_New();
2742
10
    if (!Set_annotations) return 0;
2743
10
    {
2744
10
        PyObject *type = state->expr_type;
2745
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2746
10
        cond = type != NULL;
2747
10
        if (!cond) {
2748
0
            Py_DECREF(Set_annotations);
2749
0
            return 0;
2750
0
        }
2751
10
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2752
10
        Py_DECREF(type);
2753
10
        if (!cond) {
2754
0
            Py_DECREF(Set_annotations);
2755
0
            return 0;
2756
0
        }
2757
10
    }
2758
10
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2759
10
                                  Set_annotations) == 0;
2760
10
    if (!cond) {
2761
0
        Py_DECREF(Set_annotations);
2762
0
        return 0;
2763
0
    }
2764
10
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2765
10
                                  Set_annotations) == 0;
2766
10
    if (!cond) {
2767
0
        Py_DECREF(Set_annotations);
2768
0
        return 0;
2769
0
    }
2770
10
    Py_DECREF(Set_annotations);
2771
10
    PyObject *ListComp_annotations = PyDict_New();
2772
10
    if (!ListComp_annotations) return 0;
2773
10
    {
2774
10
        PyObject *type = state->expr_type;
2775
10
        Py_INCREF(type);
2776
10
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2777
10
        Py_DECREF(type);
2778
10
        if (!cond) {
2779
0
            Py_DECREF(ListComp_annotations);
2780
0
            return 0;
2781
0
        }
2782
10
    }
2783
10
    {
2784
10
        PyObject *type = state->comprehension_type;
2785
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2786
10
        cond = type != NULL;
2787
10
        if (!cond) {
2788
0
            Py_DECREF(ListComp_annotations);
2789
0
            return 0;
2790
0
        }
2791
10
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2792
10
                                    == 0;
2793
10
        Py_DECREF(type);
2794
10
        if (!cond) {
2795
0
            Py_DECREF(ListComp_annotations);
2796
0
            return 0;
2797
0
        }
2798
10
    }
2799
10
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2800
10
                                  ListComp_annotations) == 0;
2801
10
    if (!cond) {
2802
0
        Py_DECREF(ListComp_annotations);
2803
0
        return 0;
2804
0
    }
2805
10
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2806
10
                                  ListComp_annotations) == 0;
2807
10
    if (!cond) {
2808
0
        Py_DECREF(ListComp_annotations);
2809
0
        return 0;
2810
0
    }
2811
10
    Py_DECREF(ListComp_annotations);
2812
10
    PyObject *SetComp_annotations = PyDict_New();
2813
10
    if (!SetComp_annotations) return 0;
2814
10
    {
2815
10
        PyObject *type = state->expr_type;
2816
10
        Py_INCREF(type);
2817
10
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2818
10
        Py_DECREF(type);
2819
10
        if (!cond) {
2820
0
            Py_DECREF(SetComp_annotations);
2821
0
            return 0;
2822
0
        }
2823
10
    }
2824
10
    {
2825
10
        PyObject *type = state->comprehension_type;
2826
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2827
10
        cond = type != NULL;
2828
10
        if (!cond) {
2829
0
            Py_DECREF(SetComp_annotations);
2830
0
            return 0;
2831
0
        }
2832
10
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2833
10
                                    0;
2834
10
        Py_DECREF(type);
2835
10
        if (!cond) {
2836
0
            Py_DECREF(SetComp_annotations);
2837
0
            return 0;
2838
0
        }
2839
10
    }
2840
10
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2841
10
                                  SetComp_annotations) == 0;
2842
10
    if (!cond) {
2843
0
        Py_DECREF(SetComp_annotations);
2844
0
        return 0;
2845
0
    }
2846
10
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2847
10
                                  SetComp_annotations) == 0;
2848
10
    if (!cond) {
2849
0
        Py_DECREF(SetComp_annotations);
2850
0
        return 0;
2851
0
    }
2852
10
    Py_DECREF(SetComp_annotations);
2853
10
    PyObject *DictComp_annotations = PyDict_New();
2854
10
    if (!DictComp_annotations) return 0;
2855
10
    {
2856
10
        PyObject *type = state->expr_type;
2857
10
        Py_INCREF(type);
2858
10
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2859
10
        Py_DECREF(type);
2860
10
        if (!cond) {
2861
0
            Py_DECREF(DictComp_annotations);
2862
0
            return 0;
2863
0
        }
2864
10
    }
2865
10
    {
2866
10
        PyObject *type = state->expr_type;
2867
10
        Py_INCREF(type);
2868
10
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2869
10
        Py_DECREF(type);
2870
10
        if (!cond) {
2871
0
            Py_DECREF(DictComp_annotations);
2872
0
            return 0;
2873
0
        }
2874
10
    }
2875
10
    {
2876
10
        PyObject *type = state->comprehension_type;
2877
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2878
10
        cond = type != NULL;
2879
10
        if (!cond) {
2880
0
            Py_DECREF(DictComp_annotations);
2881
0
            return 0;
2882
0
        }
2883
10
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2884
10
                                    == 0;
2885
10
        Py_DECREF(type);
2886
10
        if (!cond) {
2887
0
            Py_DECREF(DictComp_annotations);
2888
0
            return 0;
2889
0
        }
2890
10
    }
2891
10
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2892
10
                                  DictComp_annotations) == 0;
2893
10
    if (!cond) {
2894
0
        Py_DECREF(DictComp_annotations);
2895
0
        return 0;
2896
0
    }
2897
10
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2898
10
                                  DictComp_annotations) == 0;
2899
10
    if (!cond) {
2900
0
        Py_DECREF(DictComp_annotations);
2901
0
        return 0;
2902
0
    }
2903
10
    Py_DECREF(DictComp_annotations);
2904
10
    PyObject *GeneratorExp_annotations = PyDict_New();
2905
10
    if (!GeneratorExp_annotations) return 0;
2906
10
    {
2907
10
        PyObject *type = state->expr_type;
2908
10
        Py_INCREF(type);
2909
10
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2910
10
        Py_DECREF(type);
2911
10
        if (!cond) {
2912
0
            Py_DECREF(GeneratorExp_annotations);
2913
0
            return 0;
2914
0
        }
2915
10
    }
2916
10
    {
2917
10
        PyObject *type = state->comprehension_type;
2918
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2919
10
        cond = type != NULL;
2920
10
        if (!cond) {
2921
0
            Py_DECREF(GeneratorExp_annotations);
2922
0
            return 0;
2923
0
        }
2924
10
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2925
10
                                    type) == 0;
2926
10
        Py_DECREF(type);
2927
10
        if (!cond) {
2928
0
            Py_DECREF(GeneratorExp_annotations);
2929
0
            return 0;
2930
0
        }
2931
10
    }
2932
10
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2933
10
                                  GeneratorExp_annotations) == 0;
2934
10
    if (!cond) {
2935
0
        Py_DECREF(GeneratorExp_annotations);
2936
0
        return 0;
2937
0
    }
2938
10
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2939
10
                                  GeneratorExp_annotations) == 0;
2940
10
    if (!cond) {
2941
0
        Py_DECREF(GeneratorExp_annotations);
2942
0
        return 0;
2943
0
    }
2944
10
    Py_DECREF(GeneratorExp_annotations);
2945
10
    PyObject *Await_annotations = PyDict_New();
2946
10
    if (!Await_annotations) return 0;
2947
10
    {
2948
10
        PyObject *type = state->expr_type;
2949
10
        Py_INCREF(type);
2950
10
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2951
10
        Py_DECREF(type);
2952
10
        if (!cond) {
2953
0
            Py_DECREF(Await_annotations);
2954
0
            return 0;
2955
0
        }
2956
10
    }
2957
10
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2958
10
                                  Await_annotations) == 0;
2959
10
    if (!cond) {
2960
0
        Py_DECREF(Await_annotations);
2961
0
        return 0;
2962
0
    }
2963
10
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
2964
10
                                  Await_annotations) == 0;
2965
10
    if (!cond) {
2966
0
        Py_DECREF(Await_annotations);
2967
0
        return 0;
2968
0
    }
2969
10
    Py_DECREF(Await_annotations);
2970
10
    PyObject *Yield_annotations = PyDict_New();
2971
10
    if (!Yield_annotations) return 0;
2972
10
    {
2973
10
        PyObject *type = state->expr_type;
2974
10
        type = _Py_union_type_or(type, Py_None);
2975
10
        cond = type != NULL;
2976
10
        if (!cond) {
2977
0
            Py_DECREF(Yield_annotations);
2978
0
            return 0;
2979
0
        }
2980
10
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
2981
10
        Py_DECREF(type);
2982
10
        if (!cond) {
2983
0
            Py_DECREF(Yield_annotations);
2984
0
            return 0;
2985
0
        }
2986
10
    }
2987
10
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
2988
10
                                  Yield_annotations) == 0;
2989
10
    if (!cond) {
2990
0
        Py_DECREF(Yield_annotations);
2991
0
        return 0;
2992
0
    }
2993
10
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
2994
10
                                  Yield_annotations) == 0;
2995
10
    if (!cond) {
2996
0
        Py_DECREF(Yield_annotations);
2997
0
        return 0;
2998
0
    }
2999
10
    Py_DECREF(Yield_annotations);
3000
10
    PyObject *YieldFrom_annotations = PyDict_New();
3001
10
    if (!YieldFrom_annotations) return 0;
3002
10
    {
3003
10
        PyObject *type = state->expr_type;
3004
10
        Py_INCREF(type);
3005
10
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3006
10
        Py_DECREF(type);
3007
10
        if (!cond) {
3008
0
            Py_DECREF(YieldFrom_annotations);
3009
0
            return 0;
3010
0
        }
3011
10
    }
3012
10
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3013
10
                                  YieldFrom_annotations) == 0;
3014
10
    if (!cond) {
3015
0
        Py_DECREF(YieldFrom_annotations);
3016
0
        return 0;
3017
0
    }
3018
10
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3019
10
                                  YieldFrom_annotations) == 0;
3020
10
    if (!cond) {
3021
0
        Py_DECREF(YieldFrom_annotations);
3022
0
        return 0;
3023
0
    }
3024
10
    Py_DECREF(YieldFrom_annotations);
3025
10
    PyObject *Compare_annotations = PyDict_New();
3026
10
    if (!Compare_annotations) return 0;
3027
10
    {
3028
10
        PyObject *type = state->expr_type;
3029
10
        Py_INCREF(type);
3030
10
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3031
10
        Py_DECREF(type);
3032
10
        if (!cond) {
3033
0
            Py_DECREF(Compare_annotations);
3034
0
            return 0;
3035
0
        }
3036
10
    }
3037
10
    {
3038
10
        PyObject *type = state->cmpop_type;
3039
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3040
10
        cond = type != NULL;
3041
10
        if (!cond) {
3042
0
            Py_DECREF(Compare_annotations);
3043
0
            return 0;
3044
0
        }
3045
10
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3046
10
        Py_DECREF(type);
3047
10
        if (!cond) {
3048
0
            Py_DECREF(Compare_annotations);
3049
0
            return 0;
3050
0
        }
3051
10
    }
3052
10
    {
3053
10
        PyObject *type = state->expr_type;
3054
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3055
10
        cond = type != NULL;
3056
10
        if (!cond) {
3057
0
            Py_DECREF(Compare_annotations);
3058
0
            return 0;
3059
0
        }
3060
10
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3061
10
                                    == 0;
3062
10
        Py_DECREF(type);
3063
10
        if (!cond) {
3064
0
            Py_DECREF(Compare_annotations);
3065
0
            return 0;
3066
0
        }
3067
10
    }
3068
10
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3069
10
                                  Compare_annotations) == 0;
3070
10
    if (!cond) {
3071
0
        Py_DECREF(Compare_annotations);
3072
0
        return 0;
3073
0
    }
3074
10
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3075
10
                                  Compare_annotations) == 0;
3076
10
    if (!cond) {
3077
0
        Py_DECREF(Compare_annotations);
3078
0
        return 0;
3079
0
    }
3080
10
    Py_DECREF(Compare_annotations);
3081
10
    PyObject *Call_annotations = PyDict_New();
3082
10
    if (!Call_annotations) return 0;
3083
10
    {
3084
10
        PyObject *type = state->expr_type;
3085
10
        Py_INCREF(type);
3086
10
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3087
10
        Py_DECREF(type);
3088
10
        if (!cond) {
3089
0
            Py_DECREF(Call_annotations);
3090
0
            return 0;
3091
0
        }
3092
10
    }
3093
10
    {
3094
10
        PyObject *type = state->expr_type;
3095
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3096
10
        cond = type != NULL;
3097
10
        if (!cond) {
3098
0
            Py_DECREF(Call_annotations);
3099
0
            return 0;
3100
0
        }
3101
10
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3102
10
        Py_DECREF(type);
3103
10
        if (!cond) {
3104
0
            Py_DECREF(Call_annotations);
3105
0
            return 0;
3106
0
        }
3107
10
    }
3108
10
    {
3109
10
        PyObject *type = state->keyword_type;
3110
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3111
10
        cond = type != NULL;
3112
10
        if (!cond) {
3113
0
            Py_DECREF(Call_annotations);
3114
0
            return 0;
3115
0
        }
3116
10
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3117
10
        Py_DECREF(type);
3118
10
        if (!cond) {
3119
0
            Py_DECREF(Call_annotations);
3120
0
            return 0;
3121
0
        }
3122
10
    }
3123
10
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3124
10
                                  Call_annotations) == 0;
3125
10
    if (!cond) {
3126
0
        Py_DECREF(Call_annotations);
3127
0
        return 0;
3128
0
    }
3129
10
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3130
10
                                  Call_annotations) == 0;
3131
10
    if (!cond) {
3132
0
        Py_DECREF(Call_annotations);
3133
0
        return 0;
3134
0
    }
3135
10
    Py_DECREF(Call_annotations);
3136
10
    PyObject *FormattedValue_annotations = PyDict_New();
3137
10
    if (!FormattedValue_annotations) return 0;
3138
10
    {
3139
10
        PyObject *type = state->expr_type;
3140
10
        Py_INCREF(type);
3141
10
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3142
10
                                    == 0;
3143
10
        Py_DECREF(type);
3144
10
        if (!cond) {
3145
0
            Py_DECREF(FormattedValue_annotations);
3146
0
            return 0;
3147
0
        }
3148
10
    }
3149
10
    {
3150
10
        PyObject *type = (PyObject *)&PyLong_Type;
3151
10
        Py_INCREF(type);
3152
10
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3153
10
                                    type) == 0;
3154
10
        Py_DECREF(type);
3155
10
        if (!cond) {
3156
0
            Py_DECREF(FormattedValue_annotations);
3157
0
            return 0;
3158
0
        }
3159
10
    }
3160
10
    {
3161
10
        PyObject *type = state->expr_type;
3162
10
        type = _Py_union_type_or(type, Py_None);
3163
10
        cond = type != NULL;
3164
10
        if (!cond) {
3165
0
            Py_DECREF(FormattedValue_annotations);
3166
0
            return 0;
3167
0
        }
3168
10
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3169
10
                                    type) == 0;
3170
10
        Py_DECREF(type);
3171
10
        if (!cond) {
3172
0
            Py_DECREF(FormattedValue_annotations);
3173
0
            return 0;
3174
0
        }
3175
10
    }
3176
10
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3177
10
                                  FormattedValue_annotations) == 0;
3178
10
    if (!cond) {
3179
0
        Py_DECREF(FormattedValue_annotations);
3180
0
        return 0;
3181
0
    }
3182
10
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3183
10
                                  "__annotations__",
3184
10
                                  FormattedValue_annotations) == 0;
3185
10
    if (!cond) {
3186
0
        Py_DECREF(FormattedValue_annotations);
3187
0
        return 0;
3188
0
    }
3189
10
    Py_DECREF(FormattedValue_annotations);
3190
10
    PyObject *Interpolation_annotations = PyDict_New();
3191
10
    if (!Interpolation_annotations) return 0;
3192
10
    {
3193
10
        PyObject *type = state->expr_type;
3194
10
        Py_INCREF(type);
3195
10
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3196
10
                                    == 0;
3197
10
        Py_DECREF(type);
3198
10
        if (!cond) {
3199
0
            Py_DECREF(Interpolation_annotations);
3200
0
            return 0;
3201
0
        }
3202
10
    }
3203
10
    {
3204
10
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3205
10
        Py_INCREF(type);
3206
10
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3207
10
                                    0;
3208
10
        Py_DECREF(type);
3209
10
        if (!cond) {
3210
0
            Py_DECREF(Interpolation_annotations);
3211
0
            return 0;
3212
0
        }
3213
10
    }
3214
10
    {
3215
10
        PyObject *type = (PyObject *)&PyLong_Type;
3216
10
        Py_INCREF(type);
3217
10
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3218
10
                                    type) == 0;
3219
10
        Py_DECREF(type);
3220
10
        if (!cond) {
3221
0
            Py_DECREF(Interpolation_annotations);
3222
0
            return 0;
3223
0
        }
3224
10
    }
3225
10
    {
3226
10
        PyObject *type = state->expr_type;
3227
10
        type = _Py_union_type_or(type, Py_None);
3228
10
        cond = type != NULL;
3229
10
        if (!cond) {
3230
0
            Py_DECREF(Interpolation_annotations);
3231
0
            return 0;
3232
0
        }
3233
10
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3234
10
                                    type) == 0;
3235
10
        Py_DECREF(type);
3236
10
        if (!cond) {
3237
0
            Py_DECREF(Interpolation_annotations);
3238
0
            return 0;
3239
0
        }
3240
10
    }
3241
10
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3242
10
                                  Interpolation_annotations) == 0;
3243
10
    if (!cond) {
3244
0
        Py_DECREF(Interpolation_annotations);
3245
0
        return 0;
3246
0
    }
3247
10
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3248
10
                                  Interpolation_annotations) == 0;
3249
10
    if (!cond) {
3250
0
        Py_DECREF(Interpolation_annotations);
3251
0
        return 0;
3252
0
    }
3253
10
    Py_DECREF(Interpolation_annotations);
3254
10
    PyObject *JoinedStr_annotations = PyDict_New();
3255
10
    if (!JoinedStr_annotations) return 0;
3256
10
    {
3257
10
        PyObject *type = state->expr_type;
3258
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3259
10
        cond = type != NULL;
3260
10
        if (!cond) {
3261
0
            Py_DECREF(JoinedStr_annotations);
3262
0
            return 0;
3263
0
        }
3264
10
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3265
10
        Py_DECREF(type);
3266
10
        if (!cond) {
3267
0
            Py_DECREF(JoinedStr_annotations);
3268
0
            return 0;
3269
0
        }
3270
10
    }
3271
10
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3272
10
                                  JoinedStr_annotations) == 0;
3273
10
    if (!cond) {
3274
0
        Py_DECREF(JoinedStr_annotations);
3275
0
        return 0;
3276
0
    }
3277
10
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3278
10
                                  JoinedStr_annotations) == 0;
3279
10
    if (!cond) {
3280
0
        Py_DECREF(JoinedStr_annotations);
3281
0
        return 0;
3282
0
    }
3283
10
    Py_DECREF(JoinedStr_annotations);
3284
10
    PyObject *TemplateStr_annotations = PyDict_New();
3285
10
    if (!TemplateStr_annotations) return 0;
3286
10
    {
3287
10
        PyObject *type = state->expr_type;
3288
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3289
10
        cond = type != NULL;
3290
10
        if (!cond) {
3291
0
            Py_DECREF(TemplateStr_annotations);
3292
0
            return 0;
3293
0
        }
3294
10
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3295
10
                                    0;
3296
10
        Py_DECREF(type);
3297
10
        if (!cond) {
3298
0
            Py_DECREF(TemplateStr_annotations);
3299
0
            return 0;
3300
0
        }
3301
10
    }
3302
10
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3303
10
                                  TemplateStr_annotations) == 0;
3304
10
    if (!cond) {
3305
0
        Py_DECREF(TemplateStr_annotations);
3306
0
        return 0;
3307
0
    }
3308
10
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3309
10
                                  TemplateStr_annotations) == 0;
3310
10
    if (!cond) {
3311
0
        Py_DECREF(TemplateStr_annotations);
3312
0
        return 0;
3313
0
    }
3314
10
    Py_DECREF(TemplateStr_annotations);
3315
10
    PyObject *Constant_annotations = PyDict_New();
3316
10
    if (!Constant_annotations) return 0;
3317
10
    {
3318
10
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3319
10
        Py_INCREF(type);
3320
10
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3321
10
        Py_DECREF(type);
3322
10
        if (!cond) {
3323
0
            Py_DECREF(Constant_annotations);
3324
0
            return 0;
3325
0
        }
3326
10
    }
3327
10
    {
3328
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
3329
10
        type = _Py_union_type_or(type, Py_None);
3330
10
        cond = type != NULL;
3331
10
        if (!cond) {
3332
0
            Py_DECREF(Constant_annotations);
3333
0
            return 0;
3334
0
        }
3335
10
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3336
10
        Py_DECREF(type);
3337
10
        if (!cond) {
3338
0
            Py_DECREF(Constant_annotations);
3339
0
            return 0;
3340
0
        }
3341
10
    }
3342
10
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3343
10
                                  Constant_annotations) == 0;
3344
10
    if (!cond) {
3345
0
        Py_DECREF(Constant_annotations);
3346
0
        return 0;
3347
0
    }
3348
10
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3349
10
                                  Constant_annotations) == 0;
3350
10
    if (!cond) {
3351
0
        Py_DECREF(Constant_annotations);
3352
0
        return 0;
3353
0
    }
3354
10
    Py_DECREF(Constant_annotations);
3355
10
    PyObject *Attribute_annotations = PyDict_New();
3356
10
    if (!Attribute_annotations) return 0;
3357
10
    {
3358
10
        PyObject *type = state->expr_type;
3359
10
        Py_INCREF(type);
3360
10
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3361
10
        Py_DECREF(type);
3362
10
        if (!cond) {
3363
0
            Py_DECREF(Attribute_annotations);
3364
0
            return 0;
3365
0
        }
3366
10
    }
3367
10
    {
3368
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
3369
10
        Py_INCREF(type);
3370
10
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3371
10
        Py_DECREF(type);
3372
10
        if (!cond) {
3373
0
            Py_DECREF(Attribute_annotations);
3374
0
            return 0;
3375
0
        }
3376
10
    }
3377
10
    {
3378
10
        PyObject *type = state->expr_context_type;
3379
10
        Py_INCREF(type);
3380
10
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3381
10
        Py_DECREF(type);
3382
10
        if (!cond) {
3383
0
            Py_DECREF(Attribute_annotations);
3384
0
            return 0;
3385
0
        }
3386
10
    }
3387
10
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3388
10
                                  Attribute_annotations) == 0;
3389
10
    if (!cond) {
3390
0
        Py_DECREF(Attribute_annotations);
3391
0
        return 0;
3392
0
    }
3393
10
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3394
10
                                  Attribute_annotations) == 0;
3395
10
    if (!cond) {
3396
0
        Py_DECREF(Attribute_annotations);
3397
0
        return 0;
3398
0
    }
3399
10
    Py_DECREF(Attribute_annotations);
3400
10
    PyObject *Subscript_annotations = PyDict_New();
3401
10
    if (!Subscript_annotations) return 0;
3402
10
    {
3403
10
        PyObject *type = state->expr_type;
3404
10
        Py_INCREF(type);
3405
10
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3406
10
        Py_DECREF(type);
3407
10
        if (!cond) {
3408
0
            Py_DECREF(Subscript_annotations);
3409
0
            return 0;
3410
0
        }
3411
10
    }
3412
10
    {
3413
10
        PyObject *type = state->expr_type;
3414
10
        Py_INCREF(type);
3415
10
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3416
10
        Py_DECREF(type);
3417
10
        if (!cond) {
3418
0
            Py_DECREF(Subscript_annotations);
3419
0
            return 0;
3420
0
        }
3421
10
    }
3422
10
    {
3423
10
        PyObject *type = state->expr_context_type;
3424
10
        Py_INCREF(type);
3425
10
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3426
10
        Py_DECREF(type);
3427
10
        if (!cond) {
3428
0
            Py_DECREF(Subscript_annotations);
3429
0
            return 0;
3430
0
        }
3431
10
    }
3432
10
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3433
10
                                  Subscript_annotations) == 0;
3434
10
    if (!cond) {
3435
0
        Py_DECREF(Subscript_annotations);
3436
0
        return 0;
3437
0
    }
3438
10
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3439
10
                                  Subscript_annotations) == 0;
3440
10
    if (!cond) {
3441
0
        Py_DECREF(Subscript_annotations);
3442
0
        return 0;
3443
0
    }
3444
10
    Py_DECREF(Subscript_annotations);
3445
10
    PyObject *Starred_annotations = PyDict_New();
3446
10
    if (!Starred_annotations) return 0;
3447
10
    {
3448
10
        PyObject *type = state->expr_type;
3449
10
        Py_INCREF(type);
3450
10
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3451
10
        Py_DECREF(type);
3452
10
        if (!cond) {
3453
0
            Py_DECREF(Starred_annotations);
3454
0
            return 0;
3455
0
        }
3456
10
    }
3457
10
    {
3458
10
        PyObject *type = state->expr_context_type;
3459
10
        Py_INCREF(type);
3460
10
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3461
10
        Py_DECREF(type);
3462
10
        if (!cond) {
3463
0
            Py_DECREF(Starred_annotations);
3464
0
            return 0;
3465
0
        }
3466
10
    }
3467
10
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3468
10
                                  Starred_annotations) == 0;
3469
10
    if (!cond) {
3470
0
        Py_DECREF(Starred_annotations);
3471
0
        return 0;
3472
0
    }
3473
10
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3474
10
                                  Starred_annotations) == 0;
3475
10
    if (!cond) {
3476
0
        Py_DECREF(Starred_annotations);
3477
0
        return 0;
3478
0
    }
3479
10
    Py_DECREF(Starred_annotations);
3480
10
    PyObject *Name_annotations = PyDict_New();
3481
10
    if (!Name_annotations) return 0;
3482
10
    {
3483
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
3484
10
        Py_INCREF(type);
3485
10
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3486
10
        Py_DECREF(type);
3487
10
        if (!cond) {
3488
0
            Py_DECREF(Name_annotations);
3489
0
            return 0;
3490
0
        }
3491
10
    }
3492
10
    {
3493
10
        PyObject *type = state->expr_context_type;
3494
10
        Py_INCREF(type);
3495
10
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3496
10
        Py_DECREF(type);
3497
10
        if (!cond) {
3498
0
            Py_DECREF(Name_annotations);
3499
0
            return 0;
3500
0
        }
3501
10
    }
3502
10
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3503
10
                                  Name_annotations) == 0;
3504
10
    if (!cond) {
3505
0
        Py_DECREF(Name_annotations);
3506
0
        return 0;
3507
0
    }
3508
10
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3509
10
                                  Name_annotations) == 0;
3510
10
    if (!cond) {
3511
0
        Py_DECREF(Name_annotations);
3512
0
        return 0;
3513
0
    }
3514
10
    Py_DECREF(Name_annotations);
3515
10
    PyObject *List_annotations = PyDict_New();
3516
10
    if (!List_annotations) return 0;
3517
10
    {
3518
10
        PyObject *type = state->expr_type;
3519
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3520
10
        cond = type != NULL;
3521
10
        if (!cond) {
3522
0
            Py_DECREF(List_annotations);
3523
0
            return 0;
3524
0
        }
3525
10
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3526
10
        Py_DECREF(type);
3527
10
        if (!cond) {
3528
0
            Py_DECREF(List_annotations);
3529
0
            return 0;
3530
0
        }
3531
10
    }
3532
10
    {
3533
10
        PyObject *type = state->expr_context_type;
3534
10
        Py_INCREF(type);
3535
10
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3536
10
        Py_DECREF(type);
3537
10
        if (!cond) {
3538
0
            Py_DECREF(List_annotations);
3539
0
            return 0;
3540
0
        }
3541
10
    }
3542
10
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3543
10
                                  List_annotations) == 0;
3544
10
    if (!cond) {
3545
0
        Py_DECREF(List_annotations);
3546
0
        return 0;
3547
0
    }
3548
10
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3549
10
                                  List_annotations) == 0;
3550
10
    if (!cond) {
3551
0
        Py_DECREF(List_annotations);
3552
0
        return 0;
3553
0
    }
3554
10
    Py_DECREF(List_annotations);
3555
10
    PyObject *Tuple_annotations = PyDict_New();
3556
10
    if (!Tuple_annotations) return 0;
3557
10
    {
3558
10
        PyObject *type = state->expr_type;
3559
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3560
10
        cond = type != NULL;
3561
10
        if (!cond) {
3562
0
            Py_DECREF(Tuple_annotations);
3563
0
            return 0;
3564
0
        }
3565
10
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3566
10
        Py_DECREF(type);
3567
10
        if (!cond) {
3568
0
            Py_DECREF(Tuple_annotations);
3569
0
            return 0;
3570
0
        }
3571
10
    }
3572
10
    {
3573
10
        PyObject *type = state->expr_context_type;
3574
10
        Py_INCREF(type);
3575
10
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3576
10
        Py_DECREF(type);
3577
10
        if (!cond) {
3578
0
            Py_DECREF(Tuple_annotations);
3579
0
            return 0;
3580
0
        }
3581
10
    }
3582
10
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3583
10
                                  Tuple_annotations) == 0;
3584
10
    if (!cond) {
3585
0
        Py_DECREF(Tuple_annotations);
3586
0
        return 0;
3587
0
    }
3588
10
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3589
10
                                  Tuple_annotations) == 0;
3590
10
    if (!cond) {
3591
0
        Py_DECREF(Tuple_annotations);
3592
0
        return 0;
3593
0
    }
3594
10
    Py_DECREF(Tuple_annotations);
3595
10
    PyObject *Slice_annotations = PyDict_New();
3596
10
    if (!Slice_annotations) return 0;
3597
10
    {
3598
10
        PyObject *type = state->expr_type;
3599
10
        type = _Py_union_type_or(type, Py_None);
3600
10
        cond = type != NULL;
3601
10
        if (!cond) {
3602
0
            Py_DECREF(Slice_annotations);
3603
0
            return 0;
3604
0
        }
3605
10
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3606
10
        Py_DECREF(type);
3607
10
        if (!cond) {
3608
0
            Py_DECREF(Slice_annotations);
3609
0
            return 0;
3610
0
        }
3611
10
    }
3612
10
    {
3613
10
        PyObject *type = state->expr_type;
3614
10
        type = _Py_union_type_or(type, Py_None);
3615
10
        cond = type != NULL;
3616
10
        if (!cond) {
3617
0
            Py_DECREF(Slice_annotations);
3618
0
            return 0;
3619
0
        }
3620
10
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3621
10
        Py_DECREF(type);
3622
10
        if (!cond) {
3623
0
            Py_DECREF(Slice_annotations);
3624
0
            return 0;
3625
0
        }
3626
10
    }
3627
10
    {
3628
10
        PyObject *type = state->expr_type;
3629
10
        type = _Py_union_type_or(type, Py_None);
3630
10
        cond = type != NULL;
3631
10
        if (!cond) {
3632
0
            Py_DECREF(Slice_annotations);
3633
0
            return 0;
3634
0
        }
3635
10
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3636
10
        Py_DECREF(type);
3637
10
        if (!cond) {
3638
0
            Py_DECREF(Slice_annotations);
3639
0
            return 0;
3640
0
        }
3641
10
    }
3642
10
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3643
10
                                  Slice_annotations) == 0;
3644
10
    if (!cond) {
3645
0
        Py_DECREF(Slice_annotations);
3646
0
        return 0;
3647
0
    }
3648
10
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3649
10
                                  Slice_annotations) == 0;
3650
10
    if (!cond) {
3651
0
        Py_DECREF(Slice_annotations);
3652
0
        return 0;
3653
0
    }
3654
10
    Py_DECREF(Slice_annotations);
3655
10
    PyObject *Load_annotations = PyDict_New();
3656
10
    if (!Load_annotations) return 0;
3657
10
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3658
10
                                  Load_annotations) == 0;
3659
10
    if (!cond) {
3660
0
        Py_DECREF(Load_annotations);
3661
0
        return 0;
3662
0
    }
3663
10
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3664
10
                                  Load_annotations) == 0;
3665
10
    if (!cond) {
3666
0
        Py_DECREF(Load_annotations);
3667
0
        return 0;
3668
0
    }
3669
10
    Py_DECREF(Load_annotations);
3670
10
    PyObject *Store_annotations = PyDict_New();
3671
10
    if (!Store_annotations) return 0;
3672
10
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3673
10
                                  Store_annotations) == 0;
3674
10
    if (!cond) {
3675
0
        Py_DECREF(Store_annotations);
3676
0
        return 0;
3677
0
    }
3678
10
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3679
10
                                  Store_annotations) == 0;
3680
10
    if (!cond) {
3681
0
        Py_DECREF(Store_annotations);
3682
0
        return 0;
3683
0
    }
3684
10
    Py_DECREF(Store_annotations);
3685
10
    PyObject *Del_annotations = PyDict_New();
3686
10
    if (!Del_annotations) return 0;
3687
10
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3688
10
                                  Del_annotations) == 0;
3689
10
    if (!cond) {
3690
0
        Py_DECREF(Del_annotations);
3691
0
        return 0;
3692
0
    }
3693
10
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3694
10
                                  Del_annotations) == 0;
3695
10
    if (!cond) {
3696
0
        Py_DECREF(Del_annotations);
3697
0
        return 0;
3698
0
    }
3699
10
    Py_DECREF(Del_annotations);
3700
10
    PyObject *And_annotations = PyDict_New();
3701
10
    if (!And_annotations) return 0;
3702
10
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3703
10
                                  And_annotations) == 0;
3704
10
    if (!cond) {
3705
0
        Py_DECREF(And_annotations);
3706
0
        return 0;
3707
0
    }
3708
10
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3709
10
                                  And_annotations) == 0;
3710
10
    if (!cond) {
3711
0
        Py_DECREF(And_annotations);
3712
0
        return 0;
3713
0
    }
3714
10
    Py_DECREF(And_annotations);
3715
10
    PyObject *Or_annotations = PyDict_New();
3716
10
    if (!Or_annotations) return 0;
3717
10
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3718
10
                                  Or_annotations) == 0;
3719
10
    if (!cond) {
3720
0
        Py_DECREF(Or_annotations);
3721
0
        return 0;
3722
0
    }
3723
10
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3724
10
                                  Or_annotations) == 0;
3725
10
    if (!cond) {
3726
0
        Py_DECREF(Or_annotations);
3727
0
        return 0;
3728
0
    }
3729
10
    Py_DECREF(Or_annotations);
3730
10
    PyObject *Add_annotations = PyDict_New();
3731
10
    if (!Add_annotations) return 0;
3732
10
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3733
10
                                  Add_annotations) == 0;
3734
10
    if (!cond) {
3735
0
        Py_DECREF(Add_annotations);
3736
0
        return 0;
3737
0
    }
3738
10
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3739
10
                                  Add_annotations) == 0;
3740
10
    if (!cond) {
3741
0
        Py_DECREF(Add_annotations);
3742
0
        return 0;
3743
0
    }
3744
10
    Py_DECREF(Add_annotations);
3745
10
    PyObject *Sub_annotations = PyDict_New();
3746
10
    if (!Sub_annotations) return 0;
3747
10
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3748
10
                                  Sub_annotations) == 0;
3749
10
    if (!cond) {
3750
0
        Py_DECREF(Sub_annotations);
3751
0
        return 0;
3752
0
    }
3753
10
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3754
10
                                  Sub_annotations) == 0;
3755
10
    if (!cond) {
3756
0
        Py_DECREF(Sub_annotations);
3757
0
        return 0;
3758
0
    }
3759
10
    Py_DECREF(Sub_annotations);
3760
10
    PyObject *Mult_annotations = PyDict_New();
3761
10
    if (!Mult_annotations) return 0;
3762
10
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3763
10
                                  Mult_annotations) == 0;
3764
10
    if (!cond) {
3765
0
        Py_DECREF(Mult_annotations);
3766
0
        return 0;
3767
0
    }
3768
10
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3769
10
                                  Mult_annotations) == 0;
3770
10
    if (!cond) {
3771
0
        Py_DECREF(Mult_annotations);
3772
0
        return 0;
3773
0
    }
3774
10
    Py_DECREF(Mult_annotations);
3775
10
    PyObject *MatMult_annotations = PyDict_New();
3776
10
    if (!MatMult_annotations) return 0;
3777
10
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3778
10
                                  MatMult_annotations) == 0;
3779
10
    if (!cond) {
3780
0
        Py_DECREF(MatMult_annotations);
3781
0
        return 0;
3782
0
    }
3783
10
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3784
10
                                  MatMult_annotations) == 0;
3785
10
    if (!cond) {
3786
0
        Py_DECREF(MatMult_annotations);
3787
0
        return 0;
3788
0
    }
3789
10
    Py_DECREF(MatMult_annotations);
3790
10
    PyObject *Div_annotations = PyDict_New();
3791
10
    if (!Div_annotations) return 0;
3792
10
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3793
10
                                  Div_annotations) == 0;
3794
10
    if (!cond) {
3795
0
        Py_DECREF(Div_annotations);
3796
0
        return 0;
3797
0
    }
3798
10
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3799
10
                                  Div_annotations) == 0;
3800
10
    if (!cond) {
3801
0
        Py_DECREF(Div_annotations);
3802
0
        return 0;
3803
0
    }
3804
10
    Py_DECREF(Div_annotations);
3805
10
    PyObject *Mod_annotations = PyDict_New();
3806
10
    if (!Mod_annotations) return 0;
3807
10
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3808
10
                                  Mod_annotations) == 0;
3809
10
    if (!cond) {
3810
0
        Py_DECREF(Mod_annotations);
3811
0
        return 0;
3812
0
    }
3813
10
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3814
10
                                  Mod_annotations) == 0;
3815
10
    if (!cond) {
3816
0
        Py_DECREF(Mod_annotations);
3817
0
        return 0;
3818
0
    }
3819
10
    Py_DECREF(Mod_annotations);
3820
10
    PyObject *Pow_annotations = PyDict_New();
3821
10
    if (!Pow_annotations) return 0;
3822
10
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3823
10
                                  Pow_annotations) == 0;
3824
10
    if (!cond) {
3825
0
        Py_DECREF(Pow_annotations);
3826
0
        return 0;
3827
0
    }
3828
10
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3829
10
                                  Pow_annotations) == 0;
3830
10
    if (!cond) {
3831
0
        Py_DECREF(Pow_annotations);
3832
0
        return 0;
3833
0
    }
3834
10
    Py_DECREF(Pow_annotations);
3835
10
    PyObject *LShift_annotations = PyDict_New();
3836
10
    if (!LShift_annotations) return 0;
3837
10
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3838
10
                                  LShift_annotations) == 0;
3839
10
    if (!cond) {
3840
0
        Py_DECREF(LShift_annotations);
3841
0
        return 0;
3842
0
    }
3843
10
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3844
10
                                  LShift_annotations) == 0;
3845
10
    if (!cond) {
3846
0
        Py_DECREF(LShift_annotations);
3847
0
        return 0;
3848
0
    }
3849
10
    Py_DECREF(LShift_annotations);
3850
10
    PyObject *RShift_annotations = PyDict_New();
3851
10
    if (!RShift_annotations) return 0;
3852
10
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3853
10
                                  RShift_annotations) == 0;
3854
10
    if (!cond) {
3855
0
        Py_DECREF(RShift_annotations);
3856
0
        return 0;
3857
0
    }
3858
10
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3859
10
                                  RShift_annotations) == 0;
3860
10
    if (!cond) {
3861
0
        Py_DECREF(RShift_annotations);
3862
0
        return 0;
3863
0
    }
3864
10
    Py_DECREF(RShift_annotations);
3865
10
    PyObject *BitOr_annotations = PyDict_New();
3866
10
    if (!BitOr_annotations) return 0;
3867
10
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3868
10
                                  BitOr_annotations) == 0;
3869
10
    if (!cond) {
3870
0
        Py_DECREF(BitOr_annotations);
3871
0
        return 0;
3872
0
    }
3873
10
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3874
10
                                  BitOr_annotations) == 0;
3875
10
    if (!cond) {
3876
0
        Py_DECREF(BitOr_annotations);
3877
0
        return 0;
3878
0
    }
3879
10
    Py_DECREF(BitOr_annotations);
3880
10
    PyObject *BitXor_annotations = PyDict_New();
3881
10
    if (!BitXor_annotations) return 0;
3882
10
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3883
10
                                  BitXor_annotations) == 0;
3884
10
    if (!cond) {
3885
0
        Py_DECREF(BitXor_annotations);
3886
0
        return 0;
3887
0
    }
3888
10
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3889
10
                                  BitXor_annotations) == 0;
3890
10
    if (!cond) {
3891
0
        Py_DECREF(BitXor_annotations);
3892
0
        return 0;
3893
0
    }
3894
10
    Py_DECREF(BitXor_annotations);
3895
10
    PyObject *BitAnd_annotations = PyDict_New();
3896
10
    if (!BitAnd_annotations) return 0;
3897
10
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3898
10
                                  BitAnd_annotations) == 0;
3899
10
    if (!cond) {
3900
0
        Py_DECREF(BitAnd_annotations);
3901
0
        return 0;
3902
0
    }
3903
10
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3904
10
                                  BitAnd_annotations) == 0;
3905
10
    if (!cond) {
3906
0
        Py_DECREF(BitAnd_annotations);
3907
0
        return 0;
3908
0
    }
3909
10
    Py_DECREF(BitAnd_annotations);
3910
10
    PyObject *FloorDiv_annotations = PyDict_New();
3911
10
    if (!FloorDiv_annotations) return 0;
3912
10
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3913
10
                                  FloorDiv_annotations) == 0;
3914
10
    if (!cond) {
3915
0
        Py_DECREF(FloorDiv_annotations);
3916
0
        return 0;
3917
0
    }
3918
10
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3919
10
                                  FloorDiv_annotations) == 0;
3920
10
    if (!cond) {
3921
0
        Py_DECREF(FloorDiv_annotations);
3922
0
        return 0;
3923
0
    }
3924
10
    Py_DECREF(FloorDiv_annotations);
3925
10
    PyObject *Invert_annotations = PyDict_New();
3926
10
    if (!Invert_annotations) return 0;
3927
10
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3928
10
                                  Invert_annotations) == 0;
3929
10
    if (!cond) {
3930
0
        Py_DECREF(Invert_annotations);
3931
0
        return 0;
3932
0
    }
3933
10
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3934
10
                                  Invert_annotations) == 0;
3935
10
    if (!cond) {
3936
0
        Py_DECREF(Invert_annotations);
3937
0
        return 0;
3938
0
    }
3939
10
    Py_DECREF(Invert_annotations);
3940
10
    PyObject *Not_annotations = PyDict_New();
3941
10
    if (!Not_annotations) return 0;
3942
10
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3943
10
                                  Not_annotations) == 0;
3944
10
    if (!cond) {
3945
0
        Py_DECREF(Not_annotations);
3946
0
        return 0;
3947
0
    }
3948
10
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3949
10
                                  Not_annotations) == 0;
3950
10
    if (!cond) {
3951
0
        Py_DECREF(Not_annotations);
3952
0
        return 0;
3953
0
    }
3954
10
    Py_DECREF(Not_annotations);
3955
10
    PyObject *UAdd_annotations = PyDict_New();
3956
10
    if (!UAdd_annotations) return 0;
3957
10
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3958
10
                                  UAdd_annotations) == 0;
3959
10
    if (!cond) {
3960
0
        Py_DECREF(UAdd_annotations);
3961
0
        return 0;
3962
0
    }
3963
10
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
3964
10
                                  UAdd_annotations) == 0;
3965
10
    if (!cond) {
3966
0
        Py_DECREF(UAdd_annotations);
3967
0
        return 0;
3968
0
    }
3969
10
    Py_DECREF(UAdd_annotations);
3970
10
    PyObject *USub_annotations = PyDict_New();
3971
10
    if (!USub_annotations) return 0;
3972
10
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
3973
10
                                  USub_annotations) == 0;
3974
10
    if (!cond) {
3975
0
        Py_DECREF(USub_annotations);
3976
0
        return 0;
3977
0
    }
3978
10
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
3979
10
                                  USub_annotations) == 0;
3980
10
    if (!cond) {
3981
0
        Py_DECREF(USub_annotations);
3982
0
        return 0;
3983
0
    }
3984
10
    Py_DECREF(USub_annotations);
3985
10
    PyObject *Eq_annotations = PyDict_New();
3986
10
    if (!Eq_annotations) return 0;
3987
10
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
3988
10
                                  Eq_annotations) == 0;
3989
10
    if (!cond) {
3990
0
        Py_DECREF(Eq_annotations);
3991
0
        return 0;
3992
0
    }
3993
10
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
3994
10
                                  Eq_annotations) == 0;
3995
10
    if (!cond) {
3996
0
        Py_DECREF(Eq_annotations);
3997
0
        return 0;
3998
0
    }
3999
10
    Py_DECREF(Eq_annotations);
4000
10
    PyObject *NotEq_annotations = PyDict_New();
4001
10
    if (!NotEq_annotations) return 0;
4002
10
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4003
10
                                  NotEq_annotations) == 0;
4004
10
    if (!cond) {
4005
0
        Py_DECREF(NotEq_annotations);
4006
0
        return 0;
4007
0
    }
4008
10
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4009
10
                                  NotEq_annotations) == 0;
4010
10
    if (!cond) {
4011
0
        Py_DECREF(NotEq_annotations);
4012
0
        return 0;
4013
0
    }
4014
10
    Py_DECREF(NotEq_annotations);
4015
10
    PyObject *Lt_annotations = PyDict_New();
4016
10
    if (!Lt_annotations) return 0;
4017
10
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4018
10
                                  Lt_annotations) == 0;
4019
10
    if (!cond) {
4020
0
        Py_DECREF(Lt_annotations);
4021
0
        return 0;
4022
0
    }
4023
10
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4024
10
                                  Lt_annotations) == 0;
4025
10
    if (!cond) {
4026
0
        Py_DECREF(Lt_annotations);
4027
0
        return 0;
4028
0
    }
4029
10
    Py_DECREF(Lt_annotations);
4030
10
    PyObject *LtE_annotations = PyDict_New();
4031
10
    if (!LtE_annotations) return 0;
4032
10
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4033
10
                                  LtE_annotations) == 0;
4034
10
    if (!cond) {
4035
0
        Py_DECREF(LtE_annotations);
4036
0
        return 0;
4037
0
    }
4038
10
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4039
10
                                  LtE_annotations) == 0;
4040
10
    if (!cond) {
4041
0
        Py_DECREF(LtE_annotations);
4042
0
        return 0;
4043
0
    }
4044
10
    Py_DECREF(LtE_annotations);
4045
10
    PyObject *Gt_annotations = PyDict_New();
4046
10
    if (!Gt_annotations) return 0;
4047
10
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4048
10
                                  Gt_annotations) == 0;
4049
10
    if (!cond) {
4050
0
        Py_DECREF(Gt_annotations);
4051
0
        return 0;
4052
0
    }
4053
10
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4054
10
                                  Gt_annotations) == 0;
4055
10
    if (!cond) {
4056
0
        Py_DECREF(Gt_annotations);
4057
0
        return 0;
4058
0
    }
4059
10
    Py_DECREF(Gt_annotations);
4060
10
    PyObject *GtE_annotations = PyDict_New();
4061
10
    if (!GtE_annotations) return 0;
4062
10
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4063
10
                                  GtE_annotations) == 0;
4064
10
    if (!cond) {
4065
0
        Py_DECREF(GtE_annotations);
4066
0
        return 0;
4067
0
    }
4068
10
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4069
10
                                  GtE_annotations) == 0;
4070
10
    if (!cond) {
4071
0
        Py_DECREF(GtE_annotations);
4072
0
        return 0;
4073
0
    }
4074
10
    Py_DECREF(GtE_annotations);
4075
10
    PyObject *Is_annotations = PyDict_New();
4076
10
    if (!Is_annotations) return 0;
4077
10
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4078
10
                                  Is_annotations) == 0;
4079
10
    if (!cond) {
4080
0
        Py_DECREF(Is_annotations);
4081
0
        return 0;
4082
0
    }
4083
10
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4084
10
                                  Is_annotations) == 0;
4085
10
    if (!cond) {
4086
0
        Py_DECREF(Is_annotations);
4087
0
        return 0;
4088
0
    }
4089
10
    Py_DECREF(Is_annotations);
4090
10
    PyObject *IsNot_annotations = PyDict_New();
4091
10
    if (!IsNot_annotations) return 0;
4092
10
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4093
10
                                  IsNot_annotations) == 0;
4094
10
    if (!cond) {
4095
0
        Py_DECREF(IsNot_annotations);
4096
0
        return 0;
4097
0
    }
4098
10
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4099
10
                                  IsNot_annotations) == 0;
4100
10
    if (!cond) {
4101
0
        Py_DECREF(IsNot_annotations);
4102
0
        return 0;
4103
0
    }
4104
10
    Py_DECREF(IsNot_annotations);
4105
10
    PyObject *In_annotations = PyDict_New();
4106
10
    if (!In_annotations) return 0;
4107
10
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4108
10
                                  In_annotations) == 0;
4109
10
    if (!cond) {
4110
0
        Py_DECREF(In_annotations);
4111
0
        return 0;
4112
0
    }
4113
10
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4114
10
                                  In_annotations) == 0;
4115
10
    if (!cond) {
4116
0
        Py_DECREF(In_annotations);
4117
0
        return 0;
4118
0
    }
4119
10
    Py_DECREF(In_annotations);
4120
10
    PyObject *NotIn_annotations = PyDict_New();
4121
10
    if (!NotIn_annotations) return 0;
4122
10
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4123
10
                                  NotIn_annotations) == 0;
4124
10
    if (!cond) {
4125
0
        Py_DECREF(NotIn_annotations);
4126
0
        return 0;
4127
0
    }
4128
10
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4129
10
                                  NotIn_annotations) == 0;
4130
10
    if (!cond) {
4131
0
        Py_DECREF(NotIn_annotations);
4132
0
        return 0;
4133
0
    }
4134
10
    Py_DECREF(NotIn_annotations);
4135
10
    PyObject *comprehension_annotations = PyDict_New();
4136
10
    if (!comprehension_annotations) return 0;
4137
10
    {
4138
10
        PyObject *type = state->expr_type;
4139
10
        Py_INCREF(type);
4140
10
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4141
10
                                    == 0;
4142
10
        Py_DECREF(type);
4143
10
        if (!cond) {
4144
0
            Py_DECREF(comprehension_annotations);
4145
0
            return 0;
4146
0
        }
4147
10
    }
4148
10
    {
4149
10
        PyObject *type = state->expr_type;
4150
10
        Py_INCREF(type);
4151
10
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4152
10
                                    0;
4153
10
        Py_DECREF(type);
4154
10
        if (!cond) {
4155
0
            Py_DECREF(comprehension_annotations);
4156
0
            return 0;
4157
0
        }
4158
10
    }
4159
10
    {
4160
10
        PyObject *type = state->expr_type;
4161
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4162
10
        cond = type != NULL;
4163
10
        if (!cond) {
4164
0
            Py_DECREF(comprehension_annotations);
4165
0
            return 0;
4166
0
        }
4167
10
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4168
10
                                    0;
4169
10
        Py_DECREF(type);
4170
10
        if (!cond) {
4171
0
            Py_DECREF(comprehension_annotations);
4172
0
            return 0;
4173
0
        }
4174
10
    }
4175
10
    {
4176
10
        PyObject *type = (PyObject *)&PyLong_Type;
4177
10
        Py_INCREF(type);
4178
10
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4179
10
                                    type) == 0;
4180
10
        Py_DECREF(type);
4181
10
        if (!cond) {
4182
0
            Py_DECREF(comprehension_annotations);
4183
0
            return 0;
4184
0
        }
4185
10
    }
4186
10
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4187
10
                                  comprehension_annotations) == 0;
4188
10
    if (!cond) {
4189
0
        Py_DECREF(comprehension_annotations);
4190
0
        return 0;
4191
0
    }
4192
10
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4193
10
                                  comprehension_annotations) == 0;
4194
10
    if (!cond) {
4195
0
        Py_DECREF(comprehension_annotations);
4196
0
        return 0;
4197
0
    }
4198
10
    Py_DECREF(comprehension_annotations);
4199
10
    PyObject *ExceptHandler_annotations = PyDict_New();
4200
10
    if (!ExceptHandler_annotations) return 0;
4201
10
    {
4202
10
        PyObject *type = state->expr_type;
4203
10
        type = _Py_union_type_or(type, Py_None);
4204
10
        cond = type != NULL;
4205
10
        if (!cond) {
4206
0
            Py_DECREF(ExceptHandler_annotations);
4207
0
            return 0;
4208
0
        }
4209
10
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4210
10
                                    0;
4211
10
        Py_DECREF(type);
4212
10
        if (!cond) {
4213
0
            Py_DECREF(ExceptHandler_annotations);
4214
0
            return 0;
4215
0
        }
4216
10
    }
4217
10
    {
4218
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4219
10
        type = _Py_union_type_or(type, Py_None);
4220
10
        cond = type != NULL;
4221
10
        if (!cond) {
4222
0
            Py_DECREF(ExceptHandler_annotations);
4223
0
            return 0;
4224
0
        }
4225
10
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4226
10
                                    0;
4227
10
        Py_DECREF(type);
4228
10
        if (!cond) {
4229
0
            Py_DECREF(ExceptHandler_annotations);
4230
0
            return 0;
4231
0
        }
4232
10
    }
4233
10
    {
4234
10
        PyObject *type = state->stmt_type;
4235
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4236
10
        cond = type != NULL;
4237
10
        if (!cond) {
4238
0
            Py_DECREF(ExceptHandler_annotations);
4239
0
            return 0;
4240
0
        }
4241
10
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4242
10
                                    0;
4243
10
        Py_DECREF(type);
4244
10
        if (!cond) {
4245
0
            Py_DECREF(ExceptHandler_annotations);
4246
0
            return 0;
4247
0
        }
4248
10
    }
4249
10
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4250
10
                                  ExceptHandler_annotations) == 0;
4251
10
    if (!cond) {
4252
0
        Py_DECREF(ExceptHandler_annotations);
4253
0
        return 0;
4254
0
    }
4255
10
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4256
10
                                  ExceptHandler_annotations) == 0;
4257
10
    if (!cond) {
4258
0
        Py_DECREF(ExceptHandler_annotations);
4259
0
        return 0;
4260
0
    }
4261
10
    Py_DECREF(ExceptHandler_annotations);
4262
10
    PyObject *arguments_annotations = PyDict_New();
4263
10
    if (!arguments_annotations) return 0;
4264
10
    {
4265
10
        PyObject *type = state->arg_type;
4266
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4267
10
        cond = type != NULL;
4268
10
        if (!cond) {
4269
0
            Py_DECREF(arguments_annotations);
4270
0
            return 0;
4271
0
        }
4272
10
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4273
10
                                    == 0;
4274
10
        Py_DECREF(type);
4275
10
        if (!cond) {
4276
0
            Py_DECREF(arguments_annotations);
4277
0
            return 0;
4278
0
        }
4279
10
    }
4280
10
    {
4281
10
        PyObject *type = state->arg_type;
4282
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4283
10
        cond = type != NULL;
4284
10
        if (!cond) {
4285
0
            Py_DECREF(arguments_annotations);
4286
0
            return 0;
4287
0
        }
4288
10
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4289
10
        Py_DECREF(type);
4290
10
        if (!cond) {
4291
0
            Py_DECREF(arguments_annotations);
4292
0
            return 0;
4293
0
        }
4294
10
    }
4295
10
    {
4296
10
        PyObject *type = state->arg_type;
4297
10
        type = _Py_union_type_or(type, Py_None);
4298
10
        cond = type != NULL;
4299
10
        if (!cond) {
4300
0
            Py_DECREF(arguments_annotations);
4301
0
            return 0;
4302
0
        }
4303
10
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4304
10
        Py_DECREF(type);
4305
10
        if (!cond) {
4306
0
            Py_DECREF(arguments_annotations);
4307
0
            return 0;
4308
0
        }
4309
10
    }
4310
10
    {
4311
10
        PyObject *type = state->arg_type;
4312
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4313
10
        cond = type != NULL;
4314
10
        if (!cond) {
4315
0
            Py_DECREF(arguments_annotations);
4316
0
            return 0;
4317
0
        }
4318
10
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4319
10
                                    == 0;
4320
10
        Py_DECREF(type);
4321
10
        if (!cond) {
4322
0
            Py_DECREF(arguments_annotations);
4323
0
            return 0;
4324
0
        }
4325
10
    }
4326
10
    {
4327
10
        PyObject *type = state->expr_type;
4328
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4329
10
        cond = type != NULL;
4330
10
        if (!cond) {
4331
0
            Py_DECREF(arguments_annotations);
4332
0
            return 0;
4333
0
        }
4334
10
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4335
10
                                    == 0;
4336
10
        Py_DECREF(type);
4337
10
        if (!cond) {
4338
0
            Py_DECREF(arguments_annotations);
4339
0
            return 0;
4340
0
        }
4341
10
    }
4342
10
    {
4343
10
        PyObject *type = state->arg_type;
4344
10
        type = _Py_union_type_or(type, Py_None);
4345
10
        cond = type != NULL;
4346
10
        if (!cond) {
4347
0
            Py_DECREF(arguments_annotations);
4348
0
            return 0;
4349
0
        }
4350
10
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4351
10
        Py_DECREF(type);
4352
10
        if (!cond) {
4353
0
            Py_DECREF(arguments_annotations);
4354
0
            return 0;
4355
0
        }
4356
10
    }
4357
10
    {
4358
10
        PyObject *type = state->expr_type;
4359
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4360
10
        cond = type != NULL;
4361
10
        if (!cond) {
4362
0
            Py_DECREF(arguments_annotations);
4363
0
            return 0;
4364
0
        }
4365
10
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4366
10
                                    0;
4367
10
        Py_DECREF(type);
4368
10
        if (!cond) {
4369
0
            Py_DECREF(arguments_annotations);
4370
0
            return 0;
4371
0
        }
4372
10
    }
4373
10
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4374
10
                                  arguments_annotations) == 0;
4375
10
    if (!cond) {
4376
0
        Py_DECREF(arguments_annotations);
4377
0
        return 0;
4378
0
    }
4379
10
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4380
10
                                  arguments_annotations) == 0;
4381
10
    if (!cond) {
4382
0
        Py_DECREF(arguments_annotations);
4383
0
        return 0;
4384
0
    }
4385
10
    Py_DECREF(arguments_annotations);
4386
10
    PyObject *arg_annotations = PyDict_New();
4387
10
    if (!arg_annotations) return 0;
4388
10
    {
4389
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4390
10
        Py_INCREF(type);
4391
10
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4392
10
        Py_DECREF(type);
4393
10
        if (!cond) {
4394
0
            Py_DECREF(arg_annotations);
4395
0
            return 0;
4396
0
        }
4397
10
    }
4398
10
    {
4399
10
        PyObject *type = state->expr_type;
4400
10
        type = _Py_union_type_or(type, Py_None);
4401
10
        cond = type != NULL;
4402
10
        if (!cond) {
4403
0
            Py_DECREF(arg_annotations);
4404
0
            return 0;
4405
0
        }
4406
10
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4407
10
        Py_DECREF(type);
4408
10
        if (!cond) {
4409
0
            Py_DECREF(arg_annotations);
4410
0
            return 0;
4411
0
        }
4412
10
    }
4413
10
    {
4414
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4415
10
        type = _Py_union_type_or(type, Py_None);
4416
10
        cond = type != NULL;
4417
10
        if (!cond) {
4418
0
            Py_DECREF(arg_annotations);
4419
0
            return 0;
4420
0
        }
4421
10
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4422
10
        Py_DECREF(type);
4423
10
        if (!cond) {
4424
0
            Py_DECREF(arg_annotations);
4425
0
            return 0;
4426
0
        }
4427
10
    }
4428
10
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4429
10
                                  arg_annotations) == 0;
4430
10
    if (!cond) {
4431
0
        Py_DECREF(arg_annotations);
4432
0
        return 0;
4433
0
    }
4434
10
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4435
10
                                  arg_annotations) == 0;
4436
10
    if (!cond) {
4437
0
        Py_DECREF(arg_annotations);
4438
0
        return 0;
4439
0
    }
4440
10
    Py_DECREF(arg_annotations);
4441
10
    PyObject *keyword_annotations = PyDict_New();
4442
10
    if (!keyword_annotations) return 0;
4443
10
    {
4444
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4445
10
        type = _Py_union_type_or(type, Py_None);
4446
10
        cond = type != NULL;
4447
10
        if (!cond) {
4448
0
            Py_DECREF(keyword_annotations);
4449
0
            return 0;
4450
0
        }
4451
10
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4452
10
        Py_DECREF(type);
4453
10
        if (!cond) {
4454
0
            Py_DECREF(keyword_annotations);
4455
0
            return 0;
4456
0
        }
4457
10
    }
4458
10
    {
4459
10
        PyObject *type = state->expr_type;
4460
10
        Py_INCREF(type);
4461
10
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4462
10
        Py_DECREF(type);
4463
10
        if (!cond) {
4464
0
            Py_DECREF(keyword_annotations);
4465
0
            return 0;
4466
0
        }
4467
10
    }
4468
10
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4469
10
                                  keyword_annotations) == 0;
4470
10
    if (!cond) {
4471
0
        Py_DECREF(keyword_annotations);
4472
0
        return 0;
4473
0
    }
4474
10
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4475
10
                                  keyword_annotations) == 0;
4476
10
    if (!cond) {
4477
0
        Py_DECREF(keyword_annotations);
4478
0
        return 0;
4479
0
    }
4480
10
    Py_DECREF(keyword_annotations);
4481
10
    PyObject *alias_annotations = PyDict_New();
4482
10
    if (!alias_annotations) return 0;
4483
10
    {
4484
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4485
10
        Py_INCREF(type);
4486
10
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4487
10
        Py_DECREF(type);
4488
10
        if (!cond) {
4489
0
            Py_DECREF(alias_annotations);
4490
0
            return 0;
4491
0
        }
4492
10
    }
4493
10
    {
4494
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4495
10
        type = _Py_union_type_or(type, Py_None);
4496
10
        cond = type != NULL;
4497
10
        if (!cond) {
4498
0
            Py_DECREF(alias_annotations);
4499
0
            return 0;
4500
0
        }
4501
10
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4502
10
        Py_DECREF(type);
4503
10
        if (!cond) {
4504
0
            Py_DECREF(alias_annotations);
4505
0
            return 0;
4506
0
        }
4507
10
    }
4508
10
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4509
10
                                  alias_annotations) == 0;
4510
10
    if (!cond) {
4511
0
        Py_DECREF(alias_annotations);
4512
0
        return 0;
4513
0
    }
4514
10
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4515
10
                                  alias_annotations) == 0;
4516
10
    if (!cond) {
4517
0
        Py_DECREF(alias_annotations);
4518
0
        return 0;
4519
0
    }
4520
10
    Py_DECREF(alias_annotations);
4521
10
    PyObject *withitem_annotations = PyDict_New();
4522
10
    if (!withitem_annotations) return 0;
4523
10
    {
4524
10
        PyObject *type = state->expr_type;
4525
10
        Py_INCREF(type);
4526
10
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4527
10
                                    == 0;
4528
10
        Py_DECREF(type);
4529
10
        if (!cond) {
4530
0
            Py_DECREF(withitem_annotations);
4531
0
            return 0;
4532
0
        }
4533
10
    }
4534
10
    {
4535
10
        PyObject *type = state->expr_type;
4536
10
        type = _Py_union_type_or(type, Py_None);
4537
10
        cond = type != NULL;
4538
10
        if (!cond) {
4539
0
            Py_DECREF(withitem_annotations);
4540
0
            return 0;
4541
0
        }
4542
10
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4543
10
                                    type) == 0;
4544
10
        Py_DECREF(type);
4545
10
        if (!cond) {
4546
0
            Py_DECREF(withitem_annotations);
4547
0
            return 0;
4548
0
        }
4549
10
    }
4550
10
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4551
10
                                  withitem_annotations) == 0;
4552
10
    if (!cond) {
4553
0
        Py_DECREF(withitem_annotations);
4554
0
        return 0;
4555
0
    }
4556
10
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4557
10
                                  withitem_annotations) == 0;
4558
10
    if (!cond) {
4559
0
        Py_DECREF(withitem_annotations);
4560
0
        return 0;
4561
0
    }
4562
10
    Py_DECREF(withitem_annotations);
4563
10
    PyObject *match_case_annotations = PyDict_New();
4564
10
    if (!match_case_annotations) return 0;
4565
10
    {
4566
10
        PyObject *type = state->pattern_type;
4567
10
        Py_INCREF(type);
4568
10
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4569
10
                                    0;
4570
10
        Py_DECREF(type);
4571
10
        if (!cond) {
4572
0
            Py_DECREF(match_case_annotations);
4573
0
            return 0;
4574
0
        }
4575
10
    }
4576
10
    {
4577
10
        PyObject *type = state->expr_type;
4578
10
        type = _Py_union_type_or(type, Py_None);
4579
10
        cond = type != NULL;
4580
10
        if (!cond) {
4581
0
            Py_DECREF(match_case_annotations);
4582
0
            return 0;
4583
0
        }
4584
10
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4585
10
        Py_DECREF(type);
4586
10
        if (!cond) {
4587
0
            Py_DECREF(match_case_annotations);
4588
0
            return 0;
4589
0
        }
4590
10
    }
4591
10
    {
4592
10
        PyObject *type = state->stmt_type;
4593
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4594
10
        cond = type != NULL;
4595
10
        if (!cond) {
4596
0
            Py_DECREF(match_case_annotations);
4597
0
            return 0;
4598
0
        }
4599
10
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4600
10
        Py_DECREF(type);
4601
10
        if (!cond) {
4602
0
            Py_DECREF(match_case_annotations);
4603
0
            return 0;
4604
0
        }
4605
10
    }
4606
10
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4607
10
                                  match_case_annotations) == 0;
4608
10
    if (!cond) {
4609
0
        Py_DECREF(match_case_annotations);
4610
0
        return 0;
4611
0
    }
4612
10
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4613
10
                                  match_case_annotations) == 0;
4614
10
    if (!cond) {
4615
0
        Py_DECREF(match_case_annotations);
4616
0
        return 0;
4617
0
    }
4618
10
    Py_DECREF(match_case_annotations);
4619
10
    PyObject *MatchValue_annotations = PyDict_New();
4620
10
    if (!MatchValue_annotations) return 0;
4621
10
    {
4622
10
        PyObject *type = state->expr_type;
4623
10
        Py_INCREF(type);
4624
10
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4625
10
        Py_DECREF(type);
4626
10
        if (!cond) {
4627
0
            Py_DECREF(MatchValue_annotations);
4628
0
            return 0;
4629
0
        }
4630
10
    }
4631
10
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4632
10
                                  MatchValue_annotations) == 0;
4633
10
    if (!cond) {
4634
0
        Py_DECREF(MatchValue_annotations);
4635
0
        return 0;
4636
0
    }
4637
10
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4638
10
                                  MatchValue_annotations) == 0;
4639
10
    if (!cond) {
4640
0
        Py_DECREF(MatchValue_annotations);
4641
0
        return 0;
4642
0
    }
4643
10
    Py_DECREF(MatchValue_annotations);
4644
10
    PyObject *MatchSingleton_annotations = PyDict_New();
4645
10
    if (!MatchSingleton_annotations) return 0;
4646
10
    {
4647
10
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4648
10
        Py_INCREF(type);
4649
10
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4650
10
                                    == 0;
4651
10
        Py_DECREF(type);
4652
10
        if (!cond) {
4653
0
            Py_DECREF(MatchSingleton_annotations);
4654
0
            return 0;
4655
0
        }
4656
10
    }
4657
10
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4658
10
                                  MatchSingleton_annotations) == 0;
4659
10
    if (!cond) {
4660
0
        Py_DECREF(MatchSingleton_annotations);
4661
0
        return 0;
4662
0
    }
4663
10
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4664
10
                                  "__annotations__",
4665
10
                                  MatchSingleton_annotations) == 0;
4666
10
    if (!cond) {
4667
0
        Py_DECREF(MatchSingleton_annotations);
4668
0
        return 0;
4669
0
    }
4670
10
    Py_DECREF(MatchSingleton_annotations);
4671
10
    PyObject *MatchSequence_annotations = PyDict_New();
4672
10
    if (!MatchSequence_annotations) return 0;
4673
10
    {
4674
10
        PyObject *type = state->pattern_type;
4675
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4676
10
        cond = type != NULL;
4677
10
        if (!cond) {
4678
0
            Py_DECREF(MatchSequence_annotations);
4679
0
            return 0;
4680
0
        }
4681
10
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4682
10
                                    type) == 0;
4683
10
        Py_DECREF(type);
4684
10
        if (!cond) {
4685
0
            Py_DECREF(MatchSequence_annotations);
4686
0
            return 0;
4687
0
        }
4688
10
    }
4689
10
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4690
10
                                  MatchSequence_annotations) == 0;
4691
10
    if (!cond) {
4692
0
        Py_DECREF(MatchSequence_annotations);
4693
0
        return 0;
4694
0
    }
4695
10
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4696
10
                                  MatchSequence_annotations) == 0;
4697
10
    if (!cond) {
4698
0
        Py_DECREF(MatchSequence_annotations);
4699
0
        return 0;
4700
0
    }
4701
10
    Py_DECREF(MatchSequence_annotations);
4702
10
    PyObject *MatchMapping_annotations = PyDict_New();
4703
10
    if (!MatchMapping_annotations) return 0;
4704
10
    {
4705
10
        PyObject *type = state->expr_type;
4706
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4707
10
        cond = type != NULL;
4708
10
        if (!cond) {
4709
0
            Py_DECREF(MatchMapping_annotations);
4710
0
            return 0;
4711
0
        }
4712
10
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4713
10
                                    0;
4714
10
        Py_DECREF(type);
4715
10
        if (!cond) {
4716
0
            Py_DECREF(MatchMapping_annotations);
4717
0
            return 0;
4718
0
        }
4719
10
    }
4720
10
    {
4721
10
        PyObject *type = state->pattern_type;
4722
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4723
10
        cond = type != NULL;
4724
10
        if (!cond) {
4725
0
            Py_DECREF(MatchMapping_annotations);
4726
0
            return 0;
4727
0
        }
4728
10
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4729
10
                                    == 0;
4730
10
        Py_DECREF(type);
4731
10
        if (!cond) {
4732
0
            Py_DECREF(MatchMapping_annotations);
4733
0
            return 0;
4734
0
        }
4735
10
    }
4736
10
    {
4737
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4738
10
        type = _Py_union_type_or(type, Py_None);
4739
10
        cond = type != NULL;
4740
10
        if (!cond) {
4741
0
            Py_DECREF(MatchMapping_annotations);
4742
0
            return 0;
4743
0
        }
4744
10
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4745
10
                                    0;
4746
10
        Py_DECREF(type);
4747
10
        if (!cond) {
4748
0
            Py_DECREF(MatchMapping_annotations);
4749
0
            return 0;
4750
0
        }
4751
10
    }
4752
10
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4753
10
                                  MatchMapping_annotations) == 0;
4754
10
    if (!cond) {
4755
0
        Py_DECREF(MatchMapping_annotations);
4756
0
        return 0;
4757
0
    }
4758
10
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4759
10
                                  MatchMapping_annotations) == 0;
4760
10
    if (!cond) {
4761
0
        Py_DECREF(MatchMapping_annotations);
4762
0
        return 0;
4763
0
    }
4764
10
    Py_DECREF(MatchMapping_annotations);
4765
10
    PyObject *MatchClass_annotations = PyDict_New();
4766
10
    if (!MatchClass_annotations) return 0;
4767
10
    {
4768
10
        PyObject *type = state->expr_type;
4769
10
        Py_INCREF(type);
4770
10
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4771
10
        Py_DECREF(type);
4772
10
        if (!cond) {
4773
0
            Py_DECREF(MatchClass_annotations);
4774
0
            return 0;
4775
0
        }
4776
10
    }
4777
10
    {
4778
10
        PyObject *type = state->pattern_type;
4779
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4780
10
        cond = type != NULL;
4781
10
        if (!cond) {
4782
0
            Py_DECREF(MatchClass_annotations);
4783
0
            return 0;
4784
0
        }
4785
10
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4786
10
                                    == 0;
4787
10
        Py_DECREF(type);
4788
10
        if (!cond) {
4789
0
            Py_DECREF(MatchClass_annotations);
4790
0
            return 0;
4791
0
        }
4792
10
    }
4793
10
    {
4794
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4795
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4796
10
        cond = type != NULL;
4797
10
        if (!cond) {
4798
0
            Py_DECREF(MatchClass_annotations);
4799
0
            return 0;
4800
0
        }
4801
10
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4802
10
                                    == 0;
4803
10
        Py_DECREF(type);
4804
10
        if (!cond) {
4805
0
            Py_DECREF(MatchClass_annotations);
4806
0
            return 0;
4807
0
        }
4808
10
    }
4809
10
    {
4810
10
        PyObject *type = state->pattern_type;
4811
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4812
10
        cond = type != NULL;
4813
10
        if (!cond) {
4814
0
            Py_DECREF(MatchClass_annotations);
4815
0
            return 0;
4816
0
        }
4817
10
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4818
10
                                    type) == 0;
4819
10
        Py_DECREF(type);
4820
10
        if (!cond) {
4821
0
            Py_DECREF(MatchClass_annotations);
4822
0
            return 0;
4823
0
        }
4824
10
    }
4825
10
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4826
10
                                  MatchClass_annotations) == 0;
4827
10
    if (!cond) {
4828
0
        Py_DECREF(MatchClass_annotations);
4829
0
        return 0;
4830
0
    }
4831
10
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4832
10
                                  MatchClass_annotations) == 0;
4833
10
    if (!cond) {
4834
0
        Py_DECREF(MatchClass_annotations);
4835
0
        return 0;
4836
0
    }
4837
10
    Py_DECREF(MatchClass_annotations);
4838
10
    PyObject *MatchStar_annotations = PyDict_New();
4839
10
    if (!MatchStar_annotations) return 0;
4840
10
    {
4841
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4842
10
        type = _Py_union_type_or(type, Py_None);
4843
10
        cond = type != NULL;
4844
10
        if (!cond) {
4845
0
            Py_DECREF(MatchStar_annotations);
4846
0
            return 0;
4847
0
        }
4848
10
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4849
10
        Py_DECREF(type);
4850
10
        if (!cond) {
4851
0
            Py_DECREF(MatchStar_annotations);
4852
0
            return 0;
4853
0
        }
4854
10
    }
4855
10
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4856
10
                                  MatchStar_annotations) == 0;
4857
10
    if (!cond) {
4858
0
        Py_DECREF(MatchStar_annotations);
4859
0
        return 0;
4860
0
    }
4861
10
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4862
10
                                  MatchStar_annotations) == 0;
4863
10
    if (!cond) {
4864
0
        Py_DECREF(MatchStar_annotations);
4865
0
        return 0;
4866
0
    }
4867
10
    Py_DECREF(MatchStar_annotations);
4868
10
    PyObject *MatchAs_annotations = PyDict_New();
4869
10
    if (!MatchAs_annotations) return 0;
4870
10
    {
4871
10
        PyObject *type = state->pattern_type;
4872
10
        type = _Py_union_type_or(type, Py_None);
4873
10
        cond = type != NULL;
4874
10
        if (!cond) {
4875
0
            Py_DECREF(MatchAs_annotations);
4876
0
            return 0;
4877
0
        }
4878
10
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4879
10
        Py_DECREF(type);
4880
10
        if (!cond) {
4881
0
            Py_DECREF(MatchAs_annotations);
4882
0
            return 0;
4883
0
        }
4884
10
    }
4885
10
    {
4886
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4887
10
        type = _Py_union_type_or(type, Py_None);
4888
10
        cond = type != NULL;
4889
10
        if (!cond) {
4890
0
            Py_DECREF(MatchAs_annotations);
4891
0
            return 0;
4892
0
        }
4893
10
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4894
10
        Py_DECREF(type);
4895
10
        if (!cond) {
4896
0
            Py_DECREF(MatchAs_annotations);
4897
0
            return 0;
4898
0
        }
4899
10
    }
4900
10
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4901
10
                                  MatchAs_annotations) == 0;
4902
10
    if (!cond) {
4903
0
        Py_DECREF(MatchAs_annotations);
4904
0
        return 0;
4905
0
    }
4906
10
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4907
10
                                  MatchAs_annotations) == 0;
4908
10
    if (!cond) {
4909
0
        Py_DECREF(MatchAs_annotations);
4910
0
        return 0;
4911
0
    }
4912
10
    Py_DECREF(MatchAs_annotations);
4913
10
    PyObject *MatchOr_annotations = PyDict_New();
4914
10
    if (!MatchOr_annotations) return 0;
4915
10
    {
4916
10
        PyObject *type = state->pattern_type;
4917
10
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4918
10
        cond = type != NULL;
4919
10
        if (!cond) {
4920
0
            Py_DECREF(MatchOr_annotations);
4921
0
            return 0;
4922
0
        }
4923
10
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4924
10
        Py_DECREF(type);
4925
10
        if (!cond) {
4926
0
            Py_DECREF(MatchOr_annotations);
4927
0
            return 0;
4928
0
        }
4929
10
    }
4930
10
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4931
10
                                  MatchOr_annotations) == 0;
4932
10
    if (!cond) {
4933
0
        Py_DECREF(MatchOr_annotations);
4934
0
        return 0;
4935
0
    }
4936
10
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4937
10
                                  MatchOr_annotations) == 0;
4938
10
    if (!cond) {
4939
0
        Py_DECREF(MatchOr_annotations);
4940
0
        return 0;
4941
0
    }
4942
10
    Py_DECREF(MatchOr_annotations);
4943
10
    PyObject *TypeIgnore_annotations = PyDict_New();
4944
10
    if (!TypeIgnore_annotations) return 0;
4945
10
    {
4946
10
        PyObject *type = (PyObject *)&PyLong_Type;
4947
10
        Py_INCREF(type);
4948
10
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4949
10
                                    0;
4950
10
        Py_DECREF(type);
4951
10
        if (!cond) {
4952
0
            Py_DECREF(TypeIgnore_annotations);
4953
0
            return 0;
4954
0
        }
4955
10
    }
4956
10
    {
4957
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4958
10
        Py_INCREF(type);
4959
10
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
4960
10
        Py_DECREF(type);
4961
10
        if (!cond) {
4962
0
            Py_DECREF(TypeIgnore_annotations);
4963
0
            return 0;
4964
0
        }
4965
10
    }
4966
10
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
4967
10
                                  TypeIgnore_annotations) == 0;
4968
10
    if (!cond) {
4969
0
        Py_DECREF(TypeIgnore_annotations);
4970
0
        return 0;
4971
0
    }
4972
10
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
4973
10
                                  TypeIgnore_annotations) == 0;
4974
10
    if (!cond) {
4975
0
        Py_DECREF(TypeIgnore_annotations);
4976
0
        return 0;
4977
0
    }
4978
10
    Py_DECREF(TypeIgnore_annotations);
4979
10
    PyObject *TypeVar_annotations = PyDict_New();
4980
10
    if (!TypeVar_annotations) return 0;
4981
10
    {
4982
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
4983
10
        Py_INCREF(type);
4984
10
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
4985
10
        Py_DECREF(type);
4986
10
        if (!cond) {
4987
0
            Py_DECREF(TypeVar_annotations);
4988
0
            return 0;
4989
0
        }
4990
10
    }
4991
10
    {
4992
10
        PyObject *type = state->expr_type;
4993
10
        type = _Py_union_type_or(type, Py_None);
4994
10
        cond = type != NULL;
4995
10
        if (!cond) {
4996
0
            Py_DECREF(TypeVar_annotations);
4997
0
            return 0;
4998
0
        }
4999
10
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5000
10
        Py_DECREF(type);
5001
10
        if (!cond) {
5002
0
            Py_DECREF(TypeVar_annotations);
5003
0
            return 0;
5004
0
        }
5005
10
    }
5006
10
    {
5007
10
        PyObject *type = state->expr_type;
5008
10
        type = _Py_union_type_or(type, Py_None);
5009
10
        cond = type != NULL;
5010
10
        if (!cond) {
5011
0
            Py_DECREF(TypeVar_annotations);
5012
0
            return 0;
5013
0
        }
5014
10
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5015
10
                                    == 0;
5016
10
        Py_DECREF(type);
5017
10
        if (!cond) {
5018
0
            Py_DECREF(TypeVar_annotations);
5019
0
            return 0;
5020
0
        }
5021
10
    }
5022
10
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5023
10
                                  TypeVar_annotations) == 0;
5024
10
    if (!cond) {
5025
0
        Py_DECREF(TypeVar_annotations);
5026
0
        return 0;
5027
0
    }
5028
10
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5029
10
                                  TypeVar_annotations) == 0;
5030
10
    if (!cond) {
5031
0
        Py_DECREF(TypeVar_annotations);
5032
0
        return 0;
5033
0
    }
5034
10
    Py_DECREF(TypeVar_annotations);
5035
10
    PyObject *ParamSpec_annotations = PyDict_New();
5036
10
    if (!ParamSpec_annotations) return 0;
5037
10
    {
5038
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
5039
10
        Py_INCREF(type);
5040
10
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5041
10
        Py_DECREF(type);
5042
10
        if (!cond) {
5043
0
            Py_DECREF(ParamSpec_annotations);
5044
0
            return 0;
5045
0
        }
5046
10
    }
5047
10
    {
5048
10
        PyObject *type = state->expr_type;
5049
10
        type = _Py_union_type_or(type, Py_None);
5050
10
        cond = type != NULL;
5051
10
        if (!cond) {
5052
0
            Py_DECREF(ParamSpec_annotations);
5053
0
            return 0;
5054
0
        }
5055
10
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5056
10
                                    type) == 0;
5057
10
        Py_DECREF(type);
5058
10
        if (!cond) {
5059
0
            Py_DECREF(ParamSpec_annotations);
5060
0
            return 0;
5061
0
        }
5062
10
    }
5063
10
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5064
10
                                  ParamSpec_annotations) == 0;
5065
10
    if (!cond) {
5066
0
        Py_DECREF(ParamSpec_annotations);
5067
0
        return 0;
5068
0
    }
5069
10
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5070
10
                                  ParamSpec_annotations) == 0;
5071
10
    if (!cond) {
5072
0
        Py_DECREF(ParamSpec_annotations);
5073
0
        return 0;
5074
0
    }
5075
10
    Py_DECREF(ParamSpec_annotations);
5076
10
    PyObject *TypeVarTuple_annotations = PyDict_New();
5077
10
    if (!TypeVarTuple_annotations) return 0;
5078
10
    {
5079
10
        PyObject *type = (PyObject *)&PyUnicode_Type;
5080
10
        Py_INCREF(type);
5081
10
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5082
10
                                    0;
5083
10
        Py_DECREF(type);
5084
10
        if (!cond) {
5085
0
            Py_DECREF(TypeVarTuple_annotations);
5086
0
            return 0;
5087
0
        }
5088
10
    }
5089
10
    {
5090
10
        PyObject *type = state->expr_type;
5091
10
        type = _Py_union_type_or(type, Py_None);
5092
10
        cond = type != NULL;
5093
10
        if (!cond) {
5094
0
            Py_DECREF(TypeVarTuple_annotations);
5095
0
            return 0;
5096
0
        }
5097
10
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5098
10
                                    type) == 0;
5099
10
        Py_DECREF(type);
5100
10
        if (!cond) {
5101
0
            Py_DECREF(TypeVarTuple_annotations);
5102
0
            return 0;
5103
0
        }
5104
10
    }
5105
10
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5106
10
                                  TypeVarTuple_annotations) == 0;
5107
10
    if (!cond) {
5108
0
        Py_DECREF(TypeVarTuple_annotations);
5109
0
        return 0;
5110
0
    }
5111
10
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5112
10
                                  TypeVarTuple_annotations) == 0;
5113
10
    if (!cond) {
5114
0
        Py_DECREF(TypeVarTuple_annotations);
5115
0
        return 0;
5116
0
    }
5117
10
    Py_DECREF(TypeVarTuple_annotations);
5118
5119
10
    return 1;
5120
10
}
5121
5122
5123
5124
typedef struct {
5125
    PyObject_HEAD
5126
    PyObject *dict;
5127
} AST_object;
5128
5129
static void
5130
ast_dealloc(PyObject *op)
5131
521k
{
5132
521k
    AST_object *self = (AST_object*)op;
5133
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5134
521k
    PyTypeObject *tp = Py_TYPE(self);
5135
521k
    PyObject_GC_UnTrack(self);
5136
521k
    Py_CLEAR(self->dict);
5137
521k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5138
521k
    assert(free_func != NULL);
5139
521k
    free_func(self);
5140
521k
    Py_DECREF(tp);
5141
521k
}
5142
5143
static int
5144
ast_traverse(PyObject *op, visitproc visit, void *arg)
5145
307k
{
5146
307k
    AST_object *self = (AST_object*)op;
5147
307k
    Py_VISIT(Py_TYPE(self));
5148
307k
    Py_VISIT(self->dict);
5149
307k
    return 0;
5150
307k
}
5151
5152
static int
5153
ast_clear(PyObject *op)
5154
0
{
5155
0
    AST_object *self = (AST_object*)op;
5156
0
    Py_CLEAR(self->dict);
5157
0
    return 0;
5158
0
}
5159
5160
static int
5161
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
5162
0
{
5163
0
    struct ast_state *state = get_ast_state();
5164
0
    if (state == NULL) {
5165
0
        return -1;
5166
0
    }
5167
5168
0
    Py_ssize_t i, numfields = 0;
5169
0
    int res = -1;
5170
0
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5171
5172
0
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5173
0
    if (fields == NULL) {
5174
0
        goto cleanup;
5175
0
    }
5176
5177
0
    numfields = PySequence_Size(fields);
5178
0
    if (numfields == -1) {
5179
0
        goto cleanup;
5180
0
    }
5181
0
    remaining_fields = PySet_New(fields);
5182
0
    if (remaining_fields == NULL) {
5183
0
        goto cleanup;
5184
0
    }
5185
5186
0
    res = 0; /* if no error occurs, this stays 0 to the end */
5187
0
    if (numfields < PyTuple_GET_SIZE(args)) {
5188
0
        PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
5189
0
                     "%zd positional argument%s",
5190
0
                     _PyType_Name(Py_TYPE(self)),
5191
0
                     numfields, numfields == 1 ? "" : "s");
5192
0
        res = -1;
5193
0
        goto cleanup;
5194
0
    }
5195
0
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5196
        /* cannot be reached when fields is NULL */
5197
0
        PyObject *name = PySequence_GetItem(fields, i);
5198
0
        if (!name) {
5199
0
            res = -1;
5200
0
            goto cleanup;
5201
0
        }
5202
0
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5203
0
        if (PySet_Discard(remaining_fields, name) < 0) {
5204
0
            res = -1;
5205
0
            Py_DECREF(name);
5206
0
            goto cleanup;
5207
0
        }
5208
0
        Py_DECREF(name);
5209
0
        if (res < 0) {
5210
0
            goto cleanup;
5211
0
        }
5212
0
    }
5213
0
    if (kw) {
5214
0
        i = 0;  /* needed by PyDict_Next */
5215
0
        while (PyDict_Next(kw, &i, &key, &value)) {
5216
0
            int contains = PySequence_Contains(fields, key);
5217
0
            if (contains == -1) {
5218
0
                res = -1;
5219
0
                goto cleanup;
5220
0
            }
5221
0
            else if (contains == 1) {
5222
0
                int p = PySet_Discard(remaining_fields, key);
5223
0
                if (p == -1) {
5224
0
                    res = -1;
5225
0
                    goto cleanup;
5226
0
                }
5227
0
                if (p == 0) {
5228
0
                    PyErr_Format(PyExc_TypeError,
5229
0
                        "%.400s got multiple values for argument '%U'",
5230
0
                        Py_TYPE(self)->tp_name, key);
5231
0
                    res = -1;
5232
0
                    goto cleanup;
5233
0
                }
5234
0
            }
5235
0
            else {
5236
                // Lazily initialize "attributes"
5237
0
                if (attributes == NULL) {
5238
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5239
0
                    if (attributes == NULL) {
5240
0
                        res = -1;
5241
0
                        goto cleanup;
5242
0
                    }
5243
0
                }
5244
0
                int contains = PySequence_Contains(attributes, key);
5245
0
                if (contains == -1) {
5246
0
                    res = -1;
5247
0
                    goto cleanup;
5248
0
                }
5249
0
                else if (contains == 0) {
5250
0
                    if (PyErr_WarnFormat(
5251
0
                        PyExc_DeprecationWarning, 1,
5252
0
                        "%.400s.__init__ got an unexpected keyword argument '%U'. "
5253
0
                        "Support for arbitrary keyword arguments is deprecated "
5254
0
                        "and will be removed in Python 3.15.",
5255
0
                        Py_TYPE(self)->tp_name, key
5256
0
                    ) < 0) {
5257
0
                        res = -1;
5258
0
                        goto cleanup;
5259
0
                    }
5260
0
                }
5261
0
            }
5262
0
            res = PyObject_SetAttr(self, key, value);
5263
0
            if (res < 0) {
5264
0
                goto cleanup;
5265
0
            }
5266
0
        }
5267
0
    }
5268
0
    Py_ssize_t size = PySet_Size(remaining_fields);
5269
0
    PyObject *field_types = NULL, *remaining_list = NULL;
5270
0
    if (size > 0) {
5271
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5272
0
                                     &field_types) < 0) {
5273
0
            res = -1;
5274
0
            goto cleanup;
5275
0
        }
5276
0
        if (field_types == NULL) {
5277
            // Probably a user-defined subclass of AST that lacks _field_types.
5278
            // This will continue to work as it did before 3.13; i.e., attributes
5279
            // that are not passed in simply do not exist on the instance.
5280
0
            goto cleanup;
5281
0
        }
5282
0
        remaining_list = PySequence_List(remaining_fields);
5283
0
        if (!remaining_list) {
5284
0
            goto set_remaining_cleanup;
5285
0
        }
5286
0
        for (Py_ssize_t i = 0; i < size; i++) {
5287
0
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5288
0
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5289
0
            if (!type) {
5290
0
                if (PyErr_Occurred()) {
5291
0
                    goto set_remaining_cleanup;
5292
0
                }
5293
0
                else {
5294
0
                    if (PyErr_WarnFormat(
5295
0
                        PyExc_DeprecationWarning, 1,
5296
0
                        "Field '%U' is missing from %.400s._field_types. "
5297
0
                        "This will become an error in Python 3.15.",
5298
0
                        name, Py_TYPE(self)->tp_name
5299
0
                    ) < 0) {
5300
0
                        goto set_remaining_cleanup;
5301
0
                    }
5302
0
                }
5303
0
            }
5304
0
            else if (_PyUnion_Check(type)) {
5305
                // optional field
5306
                // do nothing, we'll have set a None default on the class
5307
0
            }
5308
0
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5309
                // list field
5310
0
                PyObject *empty = PyList_New(0);
5311
0
                if (!empty) {
5312
0
                    goto set_remaining_cleanup;
5313
0
                }
5314
0
                res = PyObject_SetAttr(self, name, empty);
5315
0
                Py_DECREF(empty);
5316
0
                if (res < 0) {
5317
0
                    goto set_remaining_cleanup;
5318
0
                }
5319
0
            }
5320
0
            else if (type == state->expr_context_type) {
5321
                // special case for expr_context: default to Load()
5322
0
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5323
0
                if (res < 0) {
5324
0
                    goto set_remaining_cleanup;
5325
0
                }
5326
0
            }
5327
0
            else {
5328
                // simple field (e.g., identifier)
5329
0
                if (PyErr_WarnFormat(
5330
0
                    PyExc_DeprecationWarning, 1,
5331
0
                    "%.400s.__init__ missing 1 required positional argument: '%U'. "
5332
0
                    "This will become an error in Python 3.15.",
5333
0
                    Py_TYPE(self)->tp_name, name
5334
0
                ) < 0) {
5335
0
                    goto set_remaining_cleanup;
5336
0
                }
5337
0
            }
5338
0
        }
5339
0
        Py_DECREF(remaining_list);
5340
0
        Py_DECREF(field_types);
5341
0
    }
5342
0
  cleanup:
5343
0
    Py_XDECREF(attributes);
5344
0
    Py_XDECREF(fields);
5345
0
    Py_XDECREF(remaining_fields);
5346
0
    return res;
5347
0
  set_remaining_cleanup:
5348
0
    Py_XDECREF(remaining_list);
5349
0
    Py_XDECREF(field_types);
5350
0
    res = -1;
5351
0
    goto cleanup;
5352
0
}
5353
5354
/* Pickling support */
5355
static PyObject *
5356
ast_type_reduce(PyObject *self, PyObject *unused)
5357
0
{
5358
0
    struct ast_state *state = get_ast_state();
5359
0
    if (state == NULL) {
5360
0
        return NULL;
5361
0
    }
5362
5363
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5364
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5365
0
        return NULL;
5366
0
    }
5367
0
    PyObject *result = NULL;
5368
0
    if (dict) {
5369
        // Unpickling (or copying) works as follows:
5370
        // - Construct the object with only positional arguments
5371
        // - Set the fields from the dict
5372
        // We have two constraints:
5373
        // - We must set all the required fields in the initial constructor call,
5374
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5375
        // - We must not include child nodes in the positional args, because
5376
        //   that may trigger runaway recursion during copying (gh-120108).
5377
        // To satisfy both constraints, we set all the fields to None in the
5378
        // initial list of positional args, and then set the fields from the dict.
5379
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5380
0
            goto cleanup;
5381
0
        }
5382
0
        if (fields) {
5383
0
            Py_ssize_t numfields = PySequence_Size(fields);
5384
0
            if (numfields == -1) {
5385
0
                Py_DECREF(dict);
5386
0
                goto cleanup;
5387
0
            }
5388
0
            positional_args = PyList_New(0);
5389
0
            if (!positional_args) {
5390
0
                goto cleanup;
5391
0
            }
5392
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5393
0
                PyObject *name = PySequence_GetItem(fields, i);
5394
0
                if (!name) {
5395
0
                    goto cleanup;
5396
0
                }
5397
0
                PyObject *value;
5398
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5399
0
                Py_DECREF(name);
5400
0
                if (rc < 0) {
5401
0
                    goto cleanup;
5402
0
                }
5403
0
                if (!value) {
5404
0
                    break;
5405
0
                }
5406
0
                rc = PyList_Append(positional_args, Py_None);
5407
0
                Py_DECREF(value);
5408
0
                if (rc < 0) {
5409
0
                    goto cleanup;
5410
0
                }
5411
0
            }
5412
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5413
0
            if (!args_tuple) {
5414
0
                goto cleanup;
5415
0
            }
5416
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5417
0
        }
5418
0
        else {
5419
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5420
0
        }
5421
0
    }
5422
0
    else {
5423
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5424
0
    }
5425
0
cleanup:
5426
0
    Py_XDECREF(fields);
5427
0
    Py_XDECREF(positional_args);
5428
0
    return result;
5429
0
}
5430
5431
/*
5432
 * Perform the following validations:
5433
 *
5434
 *   - All keyword arguments are known 'fields' or 'attributes'.
5435
 *   - No field or attribute would be left unfilled after copy.replace().
5436
 *
5437
 * On success, this returns 1. Otherwise, set a TypeError
5438
 * exception and returns -1 (no exception is set if some
5439
 * other internal errors occur).
5440
 *
5441
 * Parameters
5442
 *
5443
 *      self          The AST node instance.
5444
 *      dict          The AST node instance dictionary (self.__dict__).
5445
 *      fields        The list of fields (self._fields).
5446
 *      attributes    The list of attributes (self._attributes).
5447
 *      kwargs        Keyword arguments passed to ast_type_replace().
5448
 *
5449
 * The 'dict', 'fields', 'attributes' and 'kwargs' arguments can be NULL.
5450
 *
5451
 * Note: this function can be removed in 3.15 since the verification
5452
 *       will be done inside the constructor.
5453
 */
5454
static inline int
5455
ast_type_replace_check(PyObject *self,
5456
                       PyObject *dict,
5457
                       PyObject *fields,
5458
                       PyObject *attributes,
5459
                       PyObject *kwargs)
5460
0
{
5461
    // While it is possible to make some fast paths that would avoid
5462
    // allocating objects on the stack, this would cost us readability.
5463
    // For instance, if 'fields' and 'attributes' are both empty, and
5464
    // 'kwargs' is not empty, we could raise a TypeError immediately.
5465
0
    PyObject *expecting = PySet_New(fields);
5466
0
    if (expecting == NULL) {
5467
0
        return -1;
5468
0
    }
5469
0
    if (attributes) {
5470
0
        if (_PySet_Update(expecting, attributes) < 0) {
5471
0
            Py_DECREF(expecting);
5472
0
            return -1;
5473
0
        }
5474
0
    }
5475
    // Any keyword argument that is neither a field nor attribute is rejected.
5476
    // We first need to check whether a keyword argument is accepted or not.
5477
    // If all keyword arguments are accepted, we compute the required fields
5478
    // and attributes. A field or attribute is not needed if:
5479
    //
5480
    //  1) it is given in 'kwargs', or
5481
    //  2) it already exists on 'self'.
5482
0
    if (kwargs) {
5483
0
        Py_ssize_t pos = 0;
5484
0
        PyObject *key, *value;
5485
0
        while (PyDict_Next(kwargs, &pos, &key, &value)) {
5486
0
            int rc = PySet_Discard(expecting, key);
5487
0
            if (rc < 0) {
5488
0
                Py_DECREF(expecting);
5489
0
                return -1;
5490
0
            }
5491
0
            if (rc == 0) {
5492
0
                PyErr_Format(PyExc_TypeError,
5493
0
                             "%.400s.__replace__ got an unexpected keyword "
5494
0
                             "argument '%U'.", Py_TYPE(self)->tp_name, key);
5495
0
                Py_DECREF(expecting);
5496
0
                return -1;
5497
0
            }
5498
0
        }
5499
0
    }
5500
    // check that the remaining fields or attributes would be filled
5501
0
    if (dict) {
5502
0
        Py_ssize_t pos = 0;
5503
0
        PyObject *key, *value;
5504
0
        while (PyDict_Next(dict, &pos, &key, &value)) {
5505
            // Mark fields or attributes that are found on the instance
5506
            // as non-mandatory. If they are not given in 'kwargs', they
5507
            // will be shallow-coied; otherwise, they would be replaced
5508
            // (not in this function).
5509
0
            if (PySet_Discard(expecting, key) < 0) {
5510
0
                Py_DECREF(expecting);
5511
0
                return -1;
5512
0
            }
5513
0
        }
5514
0
        if (attributes) {
5515
            // Some attributes may or may not be present at runtime.
5516
            // In particular, now that we checked whether 'kwargs'
5517
            // is correct or not, we allow any attribute to be missing.
5518
            //
5519
            // Note that fields must still be entirely determined when
5520
            // calling the constructor later.
5521
0
            PyObject *unused = PyObject_CallMethodOneArg(expecting,
5522
0
                                                         &_Py_ID(difference_update),
5523
0
                                                         attributes);
5524
0
            if (unused == NULL) {
5525
0
                Py_DECREF(expecting);
5526
0
                return -1;
5527
0
            }
5528
0
            Py_DECREF(unused);
5529
0
        }
5530
0
    }
5531
5532
    // Discard fields from 'expecting' that default to None
5533
0
    PyObject *field_types = NULL;
5534
0
    if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self),
5535
0
                                 &_Py_ID(_field_types),
5536
0
                                 &field_types) < 0)
5537
0
    {
5538
0
        Py_DECREF(expecting);
5539
0
        return -1;
5540
0
    }
5541
0
    if (field_types != NULL) {
5542
0
        Py_ssize_t pos = 0;
5543
0
        PyObject *field_name, *field_type;
5544
0
        while (PyDict_Next(field_types, &pos, &field_name, &field_type)) {
5545
0
            if (_PyUnion_Check(field_type)) {
5546
                // optional field
5547
0
                if (PySet_Discard(expecting, field_name) < 0) {
5548
0
                    Py_DECREF(expecting);
5549
0
                    Py_DECREF(field_types);
5550
0
                    return -1;
5551
0
                }
5552
0
            }
5553
0
        }
5554
0
        Py_DECREF(field_types);
5555
0
    }
5556
5557
    // Now 'expecting' contains the fields or attributes
5558
    // that would not be filled inside ast_type_replace().
5559
0
    Py_ssize_t m = PySet_GET_SIZE(expecting);
5560
0
    if (m > 0) {
5561
0
        PyObject *names = PyList_New(m);
5562
0
        if (names == NULL) {
5563
0
            Py_DECREF(expecting);
5564
0
            return -1;
5565
0
        }
5566
0
        Py_ssize_t i = 0, pos = 0;
5567
0
        PyObject *item;
5568
0
        Py_hash_t hash;
5569
0
        while (_PySet_NextEntry(expecting, &pos, &item, &hash)) {
5570
0
            PyObject *name = PyObject_Repr(item);
5571
0
            if (name == NULL) {
5572
0
                Py_DECREF(expecting);
5573
0
                Py_DECREF(names);
5574
0
                return -1;
5575
0
            }
5576
            // steal the reference 'name'
5577
0
            PyList_SET_ITEM(names, i++, name);
5578
0
        }
5579
0
        Py_DECREF(expecting);
5580
0
        if (PyList_Sort(names) < 0) {
5581
0
            Py_DECREF(names);
5582
0
            return -1;
5583
0
        }
5584
0
        PyObject *sep = PyUnicode_FromString(", ");
5585
0
        if (sep == NULL) {
5586
0
            Py_DECREF(names);
5587
0
            return -1;
5588
0
        }
5589
0
        PyObject *str_names = PyUnicode_Join(sep, names);
5590
0
        Py_DECREF(sep);
5591
0
        Py_DECREF(names);
5592
0
        if (str_names == NULL) {
5593
0
            return -1;
5594
0
        }
5595
0
        PyErr_Format(PyExc_TypeError,
5596
0
                     "%.400s.__replace__ missing %ld keyword argument%s: %U.",
5597
0
                     Py_TYPE(self)->tp_name, m, m == 1 ? "" : "s", str_names);
5598
0
        Py_DECREF(str_names);
5599
0
        return -1;
5600
0
    }
5601
0
    else {
5602
0
        Py_DECREF(expecting);
5603
0
        return 1;
5604
0
    }
5605
0
}
5606
5607
/*
5608
 * Python equivalent:
5609
 *
5610
 *   for key in keys:
5611
 *       if hasattr(self, key):
5612
 *           payload[key] = getattr(self, key)
5613
 *
5614
 * The 'keys' argument is a sequence corresponding to
5615
 * the '_fields' or the '_attributes' of an AST node.
5616
 *
5617
 * This returns -1 if an error occurs and 0 otherwise.
5618
 *
5619
 * Parameters
5620
 *
5621
 *      payload   A dictionary to fill.
5622
 *      keys      A sequence of keys or NULL for an empty sequence.
5623
 *      dict      The AST node instance dictionary (must not be NULL).
5624
 */
5625
static inline int
5626
ast_type_replace_update_payload(PyObject *payload,
5627
                                PyObject *keys,
5628
                                PyObject *dict)
5629
0
{
5630
0
    assert(dict != NULL);
5631
0
    if (keys == NULL) {
5632
0
        return 0;
5633
0
    }
5634
0
    Py_ssize_t n = PySequence_Size(keys);
5635
0
    if (n == -1) {
5636
0
        return -1;
5637
0
    }
5638
0
    for (Py_ssize_t i = 0; i < n; i++) {
5639
0
        PyObject *key = PySequence_GetItem(keys, i);
5640
0
        if (key == NULL) {
5641
0
            return -1;
5642
0
        }
5643
0
        PyObject *value;
5644
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5645
0
            Py_DECREF(key);
5646
0
            return -1;
5647
0
        }
5648
0
        if (value == NULL) {
5649
0
            Py_DECREF(key);
5650
            // If a field or attribute is not present at runtime, it should
5651
            // be explicitly given in 'kwargs'. If not, the constructor will
5652
            // issue a warning (which becomes an error in 3.15).
5653
0
            continue;
5654
0
        }
5655
0
        int rc = PyDict_SetItem(payload, key, value);
5656
0
        Py_DECREF(key);
5657
0
        Py_DECREF(value);
5658
0
        if (rc < 0) {
5659
0
            return -1;
5660
0
        }
5661
0
    }
5662
0
    return 0;
5663
0
}
5664
5665
/* copy.replace() support (shallow copy) */
5666
static PyObject *
5667
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5668
0
{
5669
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5670
0
        return NULL;
5671
0
    }
5672
5673
0
    struct ast_state *state = get_ast_state();
5674
0
    if (state == NULL) {
5675
0
        return NULL;
5676
0
    }
5677
5678
0
    PyObject *result = NULL;
5679
    // known AST class fields and attributes
5680
0
    PyObject *fields = NULL, *attributes = NULL;
5681
    // current instance dictionary
5682
0
    PyObject *dict = NULL;
5683
    // constructor positional and keyword arguments
5684
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5685
5686
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5687
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5688
0
        goto cleanup;
5689
0
    }
5690
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5691
0
        goto cleanup;
5692
0
    }
5693
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5694
0
        goto cleanup;
5695
0
    }
5696
0
    if (ast_type_replace_check(self, dict, fields, attributes, kwargs) < 0) {
5697
0
        goto cleanup;
5698
0
    }
5699
0
    empty_tuple = PyTuple_New(0);
5700
0
    if (empty_tuple == NULL) {
5701
0
        goto cleanup;
5702
0
    }
5703
0
    payload = PyDict_New();
5704
0
    if (payload == NULL) {
5705
0
        goto cleanup;
5706
0
    }
5707
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5708
        // copy the instance's fields (possibly NULL)
5709
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5710
0
            goto cleanup;
5711
0
        }
5712
        // copy the instance's attributes (possibly NULL)
5713
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5714
0
            goto cleanup;
5715
0
        }
5716
0
    }
5717
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5718
0
        goto cleanup;
5719
0
    }
5720
0
    result = PyObject_Call(type, empty_tuple, payload);
5721
0
cleanup:
5722
0
    Py_XDECREF(payload);
5723
0
    Py_XDECREF(empty_tuple);
5724
0
    Py_XDECREF(dict);
5725
0
    Py_XDECREF(attributes);
5726
0
    Py_XDECREF(fields);
5727
0
    return result;
5728
0
}
5729
5730
static PyMemberDef ast_type_members[] = {
5731
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5732
    {NULL}  /* Sentinel */
5733
};
5734
5735
static PyMethodDef ast_type_methods[] = {
5736
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5737
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5738
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5739
               "Return a copy of the AST node with new values "
5740
               "for the specified fields.")},
5741
    {NULL}
5742
};
5743
5744
static PyGetSetDef ast_type_getsets[] = {
5745
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5746
    {NULL}
5747
};
5748
5749
static PyObject *
5750
ast_repr_max_depth(AST_object *self, int depth);
5751
5752
/* Format list and tuple properties of AST nodes.
5753
   Note that, only the first and last elements are shown.
5754
   Anything in between is represented with an ellipsis ('...').
5755
   For example, the list [1, 2, 3] is formatted as
5756
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5757
static PyObject *
5758
ast_repr_list(PyObject *list, int depth)
5759
0
{
5760
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5761
5762
0
    struct ast_state *state = get_ast_state();
5763
0
    if (state == NULL) {
5764
0
        return NULL;
5765
0
    }
5766
5767
0
    Py_ssize_t length = PySequence_Size(list);
5768
0
    if (length < 0) {
5769
0
        return NULL;
5770
0
    }
5771
0
    else if (length == 0) {
5772
0
        return PyObject_Repr(list);
5773
0
    }
5774
5775
0
    PyObject *items[2] = {NULL, NULL};
5776
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5777
0
    if (writer == NULL) {
5778
0
        goto error;
5779
0
    }
5780
5781
0
    items[0] = PySequence_GetItem(list, 0);
5782
0
    if (!items[0]) {
5783
0
        goto error;
5784
0
    }
5785
0
    if (length > 1) {
5786
0
        items[1] = PySequence_GetItem(list, length - 1);
5787
0
        if (!items[1]) {
5788
0
            goto error;
5789
0
        }
5790
0
    }
5791
5792
0
    bool is_list = PyList_Check(list);
5793
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5794
0
        goto error;
5795
0
    }
5796
5797
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5798
0
        if (i > 0) {
5799
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5800
0
                goto error;
5801
0
            }
5802
0
        }
5803
5804
0
        PyObject *item = items[i];
5805
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5806
0
            PyObject *item_repr;
5807
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5808
0
            if (!item_repr) {
5809
0
                goto error;
5810
0
            }
5811
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5812
0
                Py_DECREF(item_repr);
5813
0
                goto error;
5814
0
            }
5815
0
            Py_DECREF(item_repr);
5816
0
        } else {
5817
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5818
0
                goto error;
5819
0
            }
5820
0
        }
5821
5822
0
        if (i == 0 && length > 2) {
5823
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5824
0
                goto error;
5825
0
            }
5826
0
        }
5827
0
    }
5828
5829
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5830
0
        goto error;
5831
0
    }
5832
5833
0
    Py_XDECREF(items[0]);
5834
0
    Py_XDECREF(items[1]);
5835
0
    return PyUnicodeWriter_Finish(writer);
5836
5837
0
error:
5838
0
    Py_XDECREF(items[0]);
5839
0
    Py_XDECREF(items[1]);
5840
0
    PyUnicodeWriter_Discard(writer);
5841
0
    return NULL;
5842
0
}
5843
5844
static PyObject *
5845
ast_repr_max_depth(AST_object *self, int depth)
5846
0
{
5847
0
    struct ast_state *state = get_ast_state();
5848
0
    if (state == NULL) {
5849
0
        return NULL;
5850
0
    }
5851
5852
0
    if (depth <= 0) {
5853
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5854
0
    }
5855
5856
0
    int status = Py_ReprEnter((PyObject *)self);
5857
0
    if (status != 0) {
5858
0
        if (status < 0) {
5859
0
            return NULL;
5860
0
        }
5861
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5862
0
    }
5863
5864
0
    PyObject *fields;
5865
0
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5866
0
        Py_ReprLeave((PyObject *)self);
5867
0
        return NULL;
5868
0
    }
5869
5870
0
    Py_ssize_t numfields = PySequence_Size(fields);
5871
0
    if (numfields < 0) {
5872
0
        Py_ReprLeave((PyObject *)self);
5873
0
        Py_DECREF(fields);
5874
0
        return NULL;
5875
0
    }
5876
5877
0
    if (numfields == 0) {
5878
0
        Py_ReprLeave((PyObject *)self);
5879
0
        Py_DECREF(fields);
5880
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5881
0
    }
5882
5883
0
    const char* tp_name = Py_TYPE(self)->tp_name;
5884
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5885
0
    if (writer == NULL) {
5886
0
        goto error;
5887
0
    }
5888
5889
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5890
0
        goto error;
5891
0
    }
5892
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5893
0
        goto error;
5894
0
    }
5895
5896
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
5897
0
        PyObject *name = PySequence_GetItem(fields, i);
5898
0
        if (!name) {
5899
0
            goto error;
5900
0
        }
5901
5902
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5903
0
        if (!value) {
5904
0
            Py_DECREF(name);
5905
0
            goto error;
5906
0
        }
5907
5908
0
        PyObject *value_repr;
5909
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
5910
0
            value_repr = ast_repr_list(value, depth);
5911
0
        }
5912
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5913
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5914
0
        }
5915
0
        else {
5916
0
            value_repr = PyObject_Repr(value);
5917
0
        }
5918
5919
0
        Py_DECREF(value);
5920
5921
0
        if (!value_repr) {
5922
0
            Py_DECREF(name);
5923
0
            goto error;
5924
0
        }
5925
5926
0
        if (i > 0) {
5927
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5928
0
                Py_DECREF(name);
5929
0
                Py_DECREF(value_repr);
5930
0
                goto error;
5931
0
            }
5932
0
        }
5933
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5934
0
            Py_DECREF(name);
5935
0
            Py_DECREF(value_repr);
5936
0
            goto error;
5937
0
        }
5938
5939
0
        Py_DECREF(name);
5940
5941
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5942
0
            Py_DECREF(value_repr);
5943
0
            goto error;
5944
0
        }
5945
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5946
0
            Py_DECREF(value_repr);
5947
0
            goto error;
5948
0
        }
5949
5950
0
        Py_DECREF(value_repr);
5951
0
    }
5952
5953
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5954
0
        goto error;
5955
0
    }
5956
0
    Py_ReprLeave((PyObject *)self);
5957
0
    Py_DECREF(fields);
5958
0
    return PyUnicodeWriter_Finish(writer);
5959
5960
0
error:
5961
0
    Py_ReprLeave((PyObject *)self);
5962
0
    Py_DECREF(fields);
5963
0
    PyUnicodeWriter_Discard(writer);
5964
0
    return NULL;
5965
0
}
5966
5967
static PyObject *
5968
ast_repr(PyObject *self)
5969
0
{
5970
0
    return ast_repr_max_depth((AST_object*)self, 3);
5971
0
}
5972
5973
static PyType_Slot AST_type_slots[] = {
5974
    {Py_tp_dealloc, ast_dealloc},
5975
    {Py_tp_repr, ast_repr},
5976
    {Py_tp_getattro, PyObject_GenericGetAttr},
5977
    {Py_tp_setattro, PyObject_GenericSetAttr},
5978
    {Py_tp_traverse, ast_traverse},
5979
    {Py_tp_clear, ast_clear},
5980
    {Py_tp_members, ast_type_members},
5981
    {Py_tp_methods, ast_type_methods},
5982
    {Py_tp_getset, ast_type_getsets},
5983
    {Py_tp_init, ast_type_init},
5984
    {Py_tp_alloc, PyType_GenericAlloc},
5985
    {Py_tp_new, PyType_GenericNew},
5986
    {Py_tp_free, PyObject_GC_Del},
5987
    {0, 0},
5988
};
5989
5990
static PyType_Spec AST_type_spec = {
5991
    "ast.AST",
5992
    sizeof(AST_object),
5993
    0,
5994
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
5995
    AST_type_slots
5996
};
5997
5998
static PyObject *
5999
make_type(struct ast_state *state, const char *type, PyObject* base,
6000
          const char* const* fields, int num_fields, const char *doc)
6001
1.25k
{
6002
1.25k
    PyObject *fnames, *result;
6003
1.25k
    int i;
6004
1.25k
    fnames = PyTuple_New(num_fields);
6005
1.25k
    if (!fnames) return NULL;
6006
3.21k
    for (i = 0; i < num_fields; i++) {
6007
1.96k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
6008
1.96k
        if (!field) {
6009
0
            Py_DECREF(fnames);
6010
0
            return NULL;
6011
0
        }
6012
1.96k
        PyTuple_SET_ITEM(fnames, i, field);
6013
1.96k
    }
6014
1.25k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
6015
1.25k
                    type, base,
6016
1.25k
                    state->_fields, fnames,
6017
1.25k
                    state->__match_args__, fnames,
6018
1.25k
                    state->__module__,
6019
1.25k
                    state->ast,
6020
1.25k
                    state->__doc__, doc);
6021
1.25k
    Py_DECREF(fnames);
6022
1.25k
    return result;
6023
1.25k
}
6024
6025
static int
6026
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
6027
190
{
6028
190
    int i, result;
6029
190
    PyObject *s, *l = PyTuple_New(num_fields);
6030
190
    if (!l)
6031
0
        return -1;
6032
510
    for (i = 0; i < num_fields; i++) {
6033
320
        s = PyUnicode_InternFromString(attrs[i]);
6034
320
        if (!s) {
6035
0
            Py_DECREF(l);
6036
0
            return -1;
6037
0
        }
6038
320
        PyTuple_SET_ITEM(l, i, s);
6039
320
    }
6040
190
    result = PyObject_SetAttr(type, state->_attributes, l);
6041
190
    Py_DECREF(l);
6042
190
    return result;
6043
190
}
6044
6045
/* Conversion AST -> Python */
6046
6047
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
6048
                              PyObject* (*func)(struct ast_state *state, void*))
6049
120k
{
6050
120k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
6051
120k
    PyObject *result = PyList_New(n);
6052
120k
    PyObject *value;
6053
120k
    if (!result)
6054
0
        return NULL;
6055
301k
    for (i = 0; i < n; i++) {
6056
180k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6057
180k
        if (!value) {
6058
0
            Py_DECREF(result);
6059
0
            return NULL;
6060
0
        }
6061
180k
        PyList_SET_ITEM(result, i, value);
6062
180k
    }
6063
120k
    return result;
6064
120k
}
6065
6066
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6067
269k
{
6068
269k
    PyObject *op = (PyObject*)o;
6069
269k
    if (!op) {
6070
89.8k
        op = Py_None;
6071
89.8k
    }
6072
269k
    return Py_NewRef(op);
6073
269k
}
6074
66.7k
#define ast2obj_constant ast2obj_object
6075
120k
#define ast2obj_identifier ast2obj_object
6076
81.3k
#define ast2obj_string ast2obj_object
6077
6078
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6079
2.03M
{
6080
2.03M
    return PyLong_FromLong(b);
6081
2.03M
}
6082
6083
/* Conversion Python -> AST */
6084
6085
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6086
0
{
6087
0
    if (obj == Py_None)
6088
0
        obj = NULL;
6089
0
    if (obj) {
6090
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6091
0
            *out = NULL;
6092
0
            return -1;
6093
0
        }
6094
0
        *out = Py_NewRef(obj);
6095
0
    }
6096
0
    else {
6097
0
        *out = NULL;
6098
0
    }
6099
0
    return 0;
6100
0
}
6101
6102
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6103
0
{
6104
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6105
0
        *out = NULL;
6106
0
        return -1;
6107
0
    }
6108
0
    *out = Py_NewRef(obj);
6109
0
    return 0;
6110
0
}
6111
6112
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6113
0
{
6114
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6115
0
        PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
6116
0
        return -1;
6117
0
    }
6118
0
    return obj2ast_object(state, obj, out, arena);
6119
0
}
6120
6121
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6122
0
{
6123
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6124
0
        PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
6125
0
        return -1;
6126
0
    }
6127
0
    return obj2ast_object(state, obj, out, arena);
6128
0
}
6129
6130
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
6131
0
{
6132
0
    int i;
6133
0
    if (!PyLong_Check(obj)) {
6134
0
        PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
6135
0
        return -1;
6136
0
    }
6137
6138
0
    i = PyLong_AsInt(obj);
6139
0
    if (i == -1 && PyErr_Occurred())
6140
0
        return -1;
6141
0
    *out = i;
6142
0
    return 0;
6143
0
}
6144
6145
static int add_ast_fields(struct ast_state *state)
6146
10
{
6147
10
    PyObject *empty_tuple;
6148
10
    empty_tuple = PyTuple_New(0);
6149
10
    if (!empty_tuple ||
6150
10
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6151
10
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6152
10
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6153
0
        Py_XDECREF(empty_tuple);
6154
0
        return -1;
6155
0
    }
6156
10
    Py_DECREF(empty_tuple);
6157
10
    return 0;
6158
10
}
6159
6160
6161
6162
static int
6163
init_types(void *arg)
6164
10
{
6165
10
    struct ast_state *state = arg;
6166
10
    if (init_identifiers(state) < 0) {
6167
0
        return -1;
6168
0
    }
6169
10
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6170
10
    if (!state->AST_type) {
6171
0
        return -1;
6172
0
    }
6173
10
    if (add_ast_fields(state) < 0) {
6174
0
        return -1;
6175
0
    }
6176
10
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6177
10
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6178
10
        "    | Interactive(stmt* body)\n"
6179
10
        "    | Expression(expr body)\n"
6180
10
        "    | FunctionType(expr* argtypes, expr returns)");
6181
10
    if (!state->mod_type) return -1;
6182
10
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6183
10
    state->Module_type = make_type(state, "Module", state->mod_type,
6184
10
                                   Module_fields, 2,
6185
10
        "Module(stmt* body, type_ignore* type_ignores)");
6186
10
    if (!state->Module_type) return -1;
6187
10
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6188
10
                                        Interactive_fields, 1,
6189
10
        "Interactive(stmt* body)");
6190
10
    if (!state->Interactive_type) return -1;
6191
10
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6192
10
                                       Expression_fields, 1,
6193
10
        "Expression(expr body)");
6194
10
    if (!state->Expression_type) return -1;
6195
10
    state->FunctionType_type = make_type(state, "FunctionType",
6196
10
                                         state->mod_type, FunctionType_fields,
6197
10
                                         2,
6198
10
        "FunctionType(expr* argtypes, expr returns)");
6199
10
    if (!state->FunctionType_type) return -1;
6200
10
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6201
10
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6202
10
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6203
10
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6204
10
        "     | Return(expr? value)\n"
6205
10
        "     | Delete(expr* targets)\n"
6206
10
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6207
10
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6208
10
        "     | AugAssign(expr target, operator op, expr value)\n"
6209
10
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6210
10
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6211
10
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6212
10
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6213
10
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6214
10
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6215
10
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6216
10
        "     | Match(expr subject, match_case* cases)\n"
6217
10
        "     | Raise(expr? exc, expr? cause)\n"
6218
10
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6219
10
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6220
10
        "     | Assert(expr test, expr? msg)\n"
6221
10
        "     | Import(alias* names)\n"
6222
10
        "     | ImportFrom(identifier? module, alias* names, int? level)\n"
6223
10
        "     | Global(identifier* names)\n"
6224
10
        "     | Nonlocal(identifier* names)\n"
6225
10
        "     | Expr(expr value)\n"
6226
10
        "     | Pass\n"
6227
10
        "     | Break\n"
6228
10
        "     | Continue");
6229
10
    if (!state->stmt_type) return -1;
6230
10
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6231
0
        -1;
6232
10
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6233
0
        return -1;
6234
10
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6235
10
        -1)
6236
0
        return -1;
6237
10
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6238
10
                                        FunctionDef_fields, 7,
6239
10
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6240
10
    if (!state->FunctionDef_type) return -1;
6241
10
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6242
10
        -1)
6243
0
        return -1;
6244
10
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6245
10
        == -1)
6246
0
        return -1;
6247
10
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6248
10
                                             state->stmt_type,
6249
10
                                             AsyncFunctionDef_fields, 7,
6250
10
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6251
10
    if (!state->AsyncFunctionDef_type) return -1;
6252
10
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6253
10
        == -1)
6254
0
        return -1;
6255
10
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6256
10
        Py_None) == -1)
6257
0
        return -1;
6258
10
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6259
10
                                     ClassDef_fields, 6,
6260
10
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6261
10
    if (!state->ClassDef_type) return -1;
6262
10
    state->Return_type = make_type(state, "Return", state->stmt_type,
6263
10
                                   Return_fields, 1,
6264
10
        "Return(expr? value)");
6265
10
    if (!state->Return_type) return -1;
6266
10
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6267
0
        return -1;
6268
10
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6269
10
                                   Delete_fields, 1,
6270
10
        "Delete(expr* targets)");
6271
10
    if (!state->Delete_type) return -1;
6272
10
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6273
10
                                   Assign_fields, 3,
6274
10
        "Assign(expr* targets, expr value, string? type_comment)");
6275
10
    if (!state->Assign_type) return -1;
6276
10
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6277
10
        -1)
6278
0
        return -1;
6279
10
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6280
10
                                      TypeAlias_fields, 3,
6281
10
        "TypeAlias(expr name, type_param* type_params, expr value)");
6282
10
    if (!state->TypeAlias_type) return -1;
6283
10
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6284
10
                                      AugAssign_fields, 3,
6285
10
        "AugAssign(expr target, operator op, expr value)");
6286
10
    if (!state->AugAssign_type) return -1;
6287
10
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6288
10
                                      AnnAssign_fields, 4,
6289
10
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6290
10
    if (!state->AnnAssign_type) return -1;
6291
10
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6292
0
        return -1;
6293
10
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6294
10
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6295
10
    if (!state->For_type) return -1;
6296
10
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6297
0
        return -1;
6298
10
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6299
10
                                     AsyncFor_fields, 5,
6300
10
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6301
10
    if (!state->AsyncFor_type) return -1;
6302
10
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6303
10
        -1)
6304
0
        return -1;
6305
10
    state->While_type = make_type(state, "While", state->stmt_type,
6306
10
                                  While_fields, 3,
6307
10
        "While(expr test, stmt* body, stmt* orelse)");
6308
10
    if (!state->While_type) return -1;
6309
10
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6310
10
        "If(expr test, stmt* body, stmt* orelse)");
6311
10
    if (!state->If_type) return -1;
6312
10
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6313
10
                                 3,
6314
10
        "With(withitem* items, stmt* body, string? type_comment)");
6315
10
    if (!state->With_type) return -1;
6316
10
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6317
0
        return -1;
6318
10
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6319
10
                                      AsyncWith_fields, 3,
6320
10
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6321
10
    if (!state->AsyncWith_type) return -1;
6322
10
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6323
10
        == -1)
6324
0
        return -1;
6325
10
    state->Match_type = make_type(state, "Match", state->stmt_type,
6326
10
                                  Match_fields, 2,
6327
10
        "Match(expr subject, match_case* cases)");
6328
10
    if (!state->Match_type) return -1;
6329
10
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6330
10
                                  Raise_fields, 2,
6331
10
        "Raise(expr? exc, expr? cause)");
6332
10
    if (!state->Raise_type) return -1;
6333
10
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6334
0
        return -1;
6335
10
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6336
0
        return -1;
6337
10
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6338
10
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6339
10
    if (!state->Try_type) return -1;
6340
10
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6341
10
                                    TryStar_fields, 4,
6342
10
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6343
10
    if (!state->TryStar_type) return -1;
6344
10
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6345
10
                                   Assert_fields, 2,
6346
10
        "Assert(expr test, expr? msg)");
6347
10
    if (!state->Assert_type) return -1;
6348
10
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6349
0
        return -1;
6350
10
    state->Import_type = make_type(state, "Import", state->stmt_type,
6351
10
                                   Import_fields, 1,
6352
10
        "Import(alias* names)");
6353
10
    if (!state->Import_type) return -1;
6354
10
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6355
10
                                       ImportFrom_fields, 3,
6356
10
        "ImportFrom(identifier? module, alias* names, int? level)");
6357
10
    if (!state->ImportFrom_type) return -1;
6358
10
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6359
0
        return -1;
6360
10
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6361
0
        return -1;
6362
10
    state->Global_type = make_type(state, "Global", state->stmt_type,
6363
10
                                   Global_fields, 1,
6364
10
        "Global(identifier* names)");
6365
10
    if (!state->Global_type) return -1;
6366
10
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6367
10
                                     Nonlocal_fields, 1,
6368
10
        "Nonlocal(identifier* names)");
6369
10
    if (!state->Nonlocal_type) return -1;
6370
10
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6371
10
                                 1,
6372
10
        "Expr(expr value)");
6373
10
    if (!state->Expr_type) return -1;
6374
10
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6375
10
        "Pass");
6376
10
    if (!state->Pass_type) return -1;
6377
10
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6378
10
        "Break");
6379
10
    if (!state->Break_type) return -1;
6380
10
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6381
10
                                     0,
6382
10
        "Continue");
6383
10
    if (!state->Continue_type) return -1;
6384
10
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6385
10
        "expr = BoolOp(boolop op, expr* values)\n"
6386
10
        "     | NamedExpr(expr target, expr value)\n"
6387
10
        "     | BinOp(expr left, operator op, expr right)\n"
6388
10
        "     | UnaryOp(unaryop op, expr operand)\n"
6389
10
        "     | Lambda(arguments args, expr body)\n"
6390
10
        "     | IfExp(expr test, expr body, expr orelse)\n"
6391
10
        "     | Dict(expr?* keys, expr* values)\n"
6392
10
        "     | Set(expr* elts)\n"
6393
10
        "     | ListComp(expr elt, comprehension* generators)\n"
6394
10
        "     | SetComp(expr elt, comprehension* generators)\n"
6395
10
        "     | DictComp(expr key, expr value, comprehension* generators)\n"
6396
10
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6397
10
        "     | Await(expr value)\n"
6398
10
        "     | Yield(expr? value)\n"
6399
10
        "     | YieldFrom(expr value)\n"
6400
10
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6401
10
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6402
10
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6403
10
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6404
10
        "     | JoinedStr(expr* values)\n"
6405
10
        "     | TemplateStr(expr* values)\n"
6406
10
        "     | Constant(constant value, string? kind)\n"
6407
10
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6408
10
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6409
10
        "     | Starred(expr value, expr_context ctx)\n"
6410
10
        "     | Name(identifier id, expr_context ctx)\n"
6411
10
        "     | List(expr* elts, expr_context ctx)\n"
6412
10
        "     | Tuple(expr* elts, expr_context ctx)\n"
6413
10
        "     | Slice(expr? lower, expr? upper, expr? step)");
6414
10
    if (!state->expr_type) return -1;
6415
10
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6416
0
        -1;
6417
10
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6418
0
        return -1;
6419
10
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6420
10
        -1)
6421
0
        return -1;
6422
10
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6423
10
                                   BoolOp_fields, 2,
6424
10
        "BoolOp(boolop op, expr* values)");
6425
10
    if (!state->BoolOp_type) return -1;
6426
10
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6427
10
                                      NamedExpr_fields, 2,
6428
10
        "NamedExpr(expr target, expr value)");
6429
10
    if (!state->NamedExpr_type) return -1;
6430
10
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6431
10
                                  BinOp_fields, 3,
6432
10
        "BinOp(expr left, operator op, expr right)");
6433
10
    if (!state->BinOp_type) return -1;
6434
10
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6435
10
                                    UnaryOp_fields, 2,
6436
10
        "UnaryOp(unaryop op, expr operand)");
6437
10
    if (!state->UnaryOp_type) return -1;
6438
10
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6439
10
                                   Lambda_fields, 2,
6440
10
        "Lambda(arguments args, expr body)");
6441
10
    if (!state->Lambda_type) return -1;
6442
10
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6443
10
                                  IfExp_fields, 3,
6444
10
        "IfExp(expr test, expr body, expr orelse)");
6445
10
    if (!state->IfExp_type) return -1;
6446
10
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6447
10
                                 2,
6448
10
        "Dict(expr?* keys, expr* values)");
6449
10
    if (!state->Dict_type) return -1;
6450
10
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6451
10
        "Set(expr* elts)");
6452
10
    if (!state->Set_type) return -1;
6453
10
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6454
10
                                     ListComp_fields, 2,
6455
10
        "ListComp(expr elt, comprehension* generators)");
6456
10
    if (!state->ListComp_type) return -1;
6457
10
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6458
10
                                    SetComp_fields, 2,
6459
10
        "SetComp(expr elt, comprehension* generators)");
6460
10
    if (!state->SetComp_type) return -1;
6461
10
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6462
10
                                     DictComp_fields, 3,
6463
10
        "DictComp(expr key, expr value, comprehension* generators)");
6464
10
    if (!state->DictComp_type) return -1;
6465
10
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6466
10
                                         state->expr_type, GeneratorExp_fields,
6467
10
                                         2,
6468
10
        "GeneratorExp(expr elt, comprehension* generators)");
6469
10
    if (!state->GeneratorExp_type) return -1;
6470
10
    state->Await_type = make_type(state, "Await", state->expr_type,
6471
10
                                  Await_fields, 1,
6472
10
        "Await(expr value)");
6473
10
    if (!state->Await_type) return -1;
6474
10
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6475
10
                                  Yield_fields, 1,
6476
10
        "Yield(expr? value)");
6477
10
    if (!state->Yield_type) return -1;
6478
10
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6479
0
        return -1;
6480
10
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6481
10
                                      YieldFrom_fields, 1,
6482
10
        "YieldFrom(expr value)");
6483
10
    if (!state->YieldFrom_type) return -1;
6484
10
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6485
10
                                    Compare_fields, 3,
6486
10
        "Compare(expr left, cmpop* ops, expr* comparators)");
6487
10
    if (!state->Compare_type) return -1;
6488
10
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6489
10
                                 3,
6490
10
        "Call(expr func, expr* args, keyword* keywords)");
6491
10
    if (!state->Call_type) return -1;
6492
10
    state->FormattedValue_type = make_type(state, "FormattedValue",
6493
10
                                           state->expr_type,
6494
10
                                           FormattedValue_fields, 3,
6495
10
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6496
10
    if (!state->FormattedValue_type) return -1;
6497
10
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6498
10
        Py_None) == -1)
6499
0
        return -1;
6500
10
    state->Interpolation_type = make_type(state, "Interpolation",
6501
10
                                          state->expr_type,
6502
10
                                          Interpolation_fields, 4,
6503
10
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6504
10
    if (!state->Interpolation_type) return -1;
6505
10
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6506
10
        Py_None) == -1)
6507
0
        return -1;
6508
10
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6509
10
                                      JoinedStr_fields, 1,
6510
10
        "JoinedStr(expr* values)");
6511
10
    if (!state->JoinedStr_type) return -1;
6512
10
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6513
10
                                        TemplateStr_fields, 1,
6514
10
        "TemplateStr(expr* values)");
6515
10
    if (!state->TemplateStr_type) return -1;
6516
10
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6517
10
                                     Constant_fields, 2,
6518
10
        "Constant(constant value, string? kind)");
6519
10
    if (!state->Constant_type) return -1;
6520
10
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6521
0
        return -1;
6522
10
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6523
10
                                      Attribute_fields, 3,
6524
10
        "Attribute(expr value, identifier attr, expr_context ctx)");
6525
10
    if (!state->Attribute_type) return -1;
6526
10
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6527
10
                                      Subscript_fields, 3,
6528
10
        "Subscript(expr value, expr slice, expr_context ctx)");
6529
10
    if (!state->Subscript_type) return -1;
6530
10
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6531
10
                                    Starred_fields, 2,
6532
10
        "Starred(expr value, expr_context ctx)");
6533
10
    if (!state->Starred_type) return -1;
6534
10
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6535
10
                                 2,
6536
10
        "Name(identifier id, expr_context ctx)");
6537
10
    if (!state->Name_type) return -1;
6538
10
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6539
10
                                 2,
6540
10
        "List(expr* elts, expr_context ctx)");
6541
10
    if (!state->List_type) return -1;
6542
10
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6543
10
                                  Tuple_fields, 2,
6544
10
        "Tuple(expr* elts, expr_context ctx)");
6545
10
    if (!state->Tuple_type) return -1;
6546
10
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6547
10
                                  Slice_fields, 3,
6548
10
        "Slice(expr? lower, expr? upper, expr? step)");
6549
10
    if (!state->Slice_type) return -1;
6550
10
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6551
0
        return -1;
6552
10
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6553
0
        return -1;
6554
10
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6555
0
        return -1;
6556
10
    state->expr_context_type = make_type(state, "expr_context",
6557
10
                                         state->AST_type, NULL, 0,
6558
10
        "expr_context = Load | Store | Del");
6559
10
    if (!state->expr_context_type) return -1;
6560
10
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6561
10
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6562
10
                                 0,
6563
10
        "Load");
6564
10
    if (!state->Load_type) return -1;
6565
10
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6566
10
                                              NULL, NULL);
6567
10
    if (!state->Load_singleton) return -1;
6568
10
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6569
10
                                  NULL, 0,
6570
10
        "Store");
6571
10
    if (!state->Store_type) return -1;
6572
10
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6573
10
                                               *)state->Store_type, NULL, NULL);
6574
10
    if (!state->Store_singleton) return -1;
6575
10
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6576
10
        "Del");
6577
10
    if (!state->Del_type) return -1;
6578
10
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6579
10
                                             NULL, NULL);
6580
10
    if (!state->Del_singleton) return -1;
6581
10
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6582
10
        "boolop = And | Or");
6583
10
    if (!state->boolop_type) return -1;
6584
10
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6585
10
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6586
10
        "And");
6587
10
    if (!state->And_type) return -1;
6588
10
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6589
10
                                             NULL, NULL);
6590
10
    if (!state->And_singleton) return -1;
6591
10
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6592
10
        "Or");
6593
10
    if (!state->Or_type) return -1;
6594
10
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6595
10
                                            NULL, NULL);
6596
10
    if (!state->Or_singleton) return -1;
6597
10
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6598
10
                                     0,
6599
10
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6600
10
    if (!state->operator_type) return -1;
6601
10
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6602
10
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6603
10
        "Add");
6604
10
    if (!state->Add_type) return -1;
6605
10
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6606
10
                                             NULL, NULL);
6607
10
    if (!state->Add_singleton) return -1;
6608
10
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6609
10
        "Sub");
6610
10
    if (!state->Sub_type) return -1;
6611
10
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6612
10
                                             NULL, NULL);
6613
10
    if (!state->Sub_singleton) return -1;
6614
10
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6615
10
        "Mult");
6616
10
    if (!state->Mult_type) return -1;
6617
10
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6618
10
                                              NULL, NULL);
6619
10
    if (!state->Mult_singleton) return -1;
6620
10
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6621
10
                                    NULL, 0,
6622
10
        "MatMult");
6623
10
    if (!state->MatMult_type) return -1;
6624
10
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6625
10
                                                 *)state->MatMult_type, NULL,
6626
10
                                                 NULL);
6627
10
    if (!state->MatMult_singleton) return -1;
6628
10
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6629
10
        "Div");
6630
10
    if (!state->Div_type) return -1;
6631
10
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6632
10
                                             NULL, NULL);
6633
10
    if (!state->Div_singleton) return -1;
6634
10
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6635
10
        "Mod");
6636
10
    if (!state->Mod_type) return -1;
6637
10
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6638
10
                                             NULL, NULL);
6639
10
    if (!state->Mod_singleton) return -1;
6640
10
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6641
10
        "Pow");
6642
10
    if (!state->Pow_type) return -1;
6643
10
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6644
10
                                             NULL, NULL);
6645
10
    if (!state->Pow_singleton) return -1;
6646
10
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6647
10
                                   0,
6648
10
        "LShift");
6649
10
    if (!state->LShift_type) return -1;
6650
10
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6651
10
                                                *)state->LShift_type, NULL,
6652
10
                                                NULL);
6653
10
    if (!state->LShift_singleton) return -1;
6654
10
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6655
10
                                   0,
6656
10
        "RShift");
6657
10
    if (!state->RShift_type) return -1;
6658
10
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6659
10
                                                *)state->RShift_type, NULL,
6660
10
                                                NULL);
6661
10
    if (!state->RShift_singleton) return -1;
6662
10
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6663
10
        "BitOr");
6664
10
    if (!state->BitOr_type) return -1;
6665
10
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6666
10
                                               *)state->BitOr_type, NULL, NULL);
6667
10
    if (!state->BitOr_singleton) return -1;
6668
10
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6669
10
                                   0,
6670
10
        "BitXor");
6671
10
    if (!state->BitXor_type) return -1;
6672
10
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6673
10
                                                *)state->BitXor_type, NULL,
6674
10
                                                NULL);
6675
10
    if (!state->BitXor_singleton) return -1;
6676
10
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6677
10
                                   0,
6678
10
        "BitAnd");
6679
10
    if (!state->BitAnd_type) return -1;
6680
10
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6681
10
                                                *)state->BitAnd_type, NULL,
6682
10
                                                NULL);
6683
10
    if (!state->BitAnd_singleton) return -1;
6684
10
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6685
10
                                     NULL, 0,
6686
10
        "FloorDiv");
6687
10
    if (!state->FloorDiv_type) return -1;
6688
10
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6689
10
                                                  *)state->FloorDiv_type, NULL,
6690
10
                                                  NULL);
6691
10
    if (!state->FloorDiv_singleton) return -1;
6692
10
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6693
10
        "unaryop = Invert | Not | UAdd | USub");
6694
10
    if (!state->unaryop_type) return -1;
6695
10
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6696
10
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6697
10
                                   0,
6698
10
        "Invert");
6699
10
    if (!state->Invert_type) return -1;
6700
10
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6701
10
                                                *)state->Invert_type, NULL,
6702
10
                                                NULL);
6703
10
    if (!state->Invert_singleton) return -1;
6704
10
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6705
10
        "Not");
6706
10
    if (!state->Not_type) return -1;
6707
10
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6708
10
                                             NULL, NULL);
6709
10
    if (!state->Not_singleton) return -1;
6710
10
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6711
10
        "UAdd");
6712
10
    if (!state->UAdd_type) return -1;
6713
10
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6714
10
                                              NULL, NULL);
6715
10
    if (!state->UAdd_singleton) return -1;
6716
10
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6717
10
        "USub");
6718
10
    if (!state->USub_type) return -1;
6719
10
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6720
10
                                              NULL, NULL);
6721
10
    if (!state->USub_singleton) return -1;
6722
10
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6723
10
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6724
10
    if (!state->cmpop_type) return -1;
6725
10
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6726
10
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6727
10
        "Eq");
6728
10
    if (!state->Eq_type) return -1;
6729
10
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6730
10
                                            NULL, NULL);
6731
10
    if (!state->Eq_singleton) return -1;
6732
10
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6733
10
        "NotEq");
6734
10
    if (!state->NotEq_type) return -1;
6735
10
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6736
10
                                               *)state->NotEq_type, NULL, NULL);
6737
10
    if (!state->NotEq_singleton) return -1;
6738
10
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6739
10
        "Lt");
6740
10
    if (!state->Lt_type) return -1;
6741
10
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6742
10
                                            NULL, NULL);
6743
10
    if (!state->Lt_singleton) return -1;
6744
10
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6745
10
        "LtE");
6746
10
    if (!state->LtE_type) return -1;
6747
10
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6748
10
                                             NULL, NULL);
6749
10
    if (!state->LtE_singleton) return -1;
6750
10
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6751
10
        "Gt");
6752
10
    if (!state->Gt_type) return -1;
6753
10
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6754
10
                                            NULL, NULL);
6755
10
    if (!state->Gt_singleton) return -1;
6756
10
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6757
10
        "GtE");
6758
10
    if (!state->GtE_type) return -1;
6759
10
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6760
10
                                             NULL, NULL);
6761
10
    if (!state->GtE_singleton) return -1;
6762
10
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6763
10
        "Is");
6764
10
    if (!state->Is_type) return -1;
6765
10
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6766
10
                                            NULL, NULL);
6767
10
    if (!state->Is_singleton) return -1;
6768
10
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6769
10
        "IsNot");
6770
10
    if (!state->IsNot_type) return -1;
6771
10
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6772
10
                                               *)state->IsNot_type, NULL, NULL);
6773
10
    if (!state->IsNot_singleton) return -1;
6774
10
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6775
10
        "In");
6776
10
    if (!state->In_type) return -1;
6777
10
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6778
10
                                            NULL, NULL);
6779
10
    if (!state->In_singleton) return -1;
6780
10
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6781
10
        "NotIn");
6782
10
    if (!state->NotIn_type) return -1;
6783
10
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6784
10
                                               *)state->NotIn_type, NULL, NULL);
6785
10
    if (!state->NotIn_singleton) return -1;
6786
10
    state->comprehension_type = make_type(state, "comprehension",
6787
10
                                          state->AST_type,
6788
10
                                          comprehension_fields, 4,
6789
10
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6790
10
    if (!state->comprehension_type) return -1;
6791
10
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6792
0
        -1;
6793
10
    state->excepthandler_type = make_type(state, "excepthandler",
6794
10
                                          state->AST_type, NULL, 0,
6795
10
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6796
10
    if (!state->excepthandler_type) return -1;
6797
10
    if (add_attributes(state, state->excepthandler_type,
6798
10
        excepthandler_attributes, 4) < 0) return -1;
6799
10
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6800
10
        == -1)
6801
0
        return -1;
6802
10
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6803
10
        Py_None) == -1)
6804
0
        return -1;
6805
10
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6806
10
                                          state->excepthandler_type,
6807
10
                                          ExceptHandler_fields, 3,
6808
10
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6809
10
    if (!state->ExceptHandler_type) return -1;
6810
10
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6811
0
        return -1;
6812
10
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6813
0
        return -1;
6814
10
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6815
10
                                      arguments_fields, 7,
6816
10
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults, arg? kwarg, expr* defaults)");
6817
10
    if (!state->arguments_type) return -1;
6818
10
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6819
10
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6820
0
        return -1;
6821
10
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6822
0
        return -1;
6823
10
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6824
10
        "arg(identifier arg, expr? annotation, string? type_comment)");
6825
10
    if (!state->arg_type) return -1;
6826
10
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6827
0
        -1;
6828
10
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6829
0
        return -1;
6830
10
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6831
0
        return -1;
6832
10
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6833
0
        return -1;
6834
10
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6835
0
        return -1;
6836
10
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6837
10
                                    keyword_fields, 2,
6838
10
        "keyword(identifier? arg, expr value)");
6839
10
    if (!state->keyword_type) return -1;
6840
10
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6841
0
        return -1;
6842
10
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6843
0
        return -1;
6844
10
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6845
0
        return -1;
6846
10
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6847
10
        == -1)
6848
0
        return -1;
6849
10
    state->alias_type = make_type(state, "alias", state->AST_type,
6850
10
                                  alias_fields, 2,
6851
10
        "alias(identifier name, identifier? asname)");
6852
10
    if (!state->alias_type) return -1;
6853
10
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6854
0
        return -1;
6855
10
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6856
0
        return -1;
6857
10
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6858
0
        return -1;
6859
10
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6860
10
        -1)
6861
0
        return -1;
6862
10
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6863
10
                                     withitem_fields, 2,
6864
10
        "withitem(expr context_expr, expr? optional_vars)");
6865
10
    if (!state->withitem_type) return -1;
6866
10
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6867
10
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6868
10
        == -1)
6869
0
        return -1;
6870
10
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6871
10
                                       match_case_fields, 3,
6872
10
        "match_case(pattern pattern, expr? guard, stmt* body)");
6873
10
    if (!state->match_case_type) return -1;
6874
10
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6875
10
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6876
0
        return -1;
6877
10
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6878
10
        "pattern = MatchValue(expr value)\n"
6879
10
        "        | MatchSingleton(constant value)\n"
6880
10
        "        | MatchSequence(pattern* patterns)\n"
6881
10
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6882
10
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6883
10
        "        | MatchStar(identifier? name)\n"
6884
10
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6885
10
        "        | MatchOr(pattern* patterns)");
6886
10
    if (!state->pattern_type) return -1;
6887
10
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6888
0
        return -1;
6889
10
    state->MatchValue_type = make_type(state, "MatchValue",
6890
10
                                       state->pattern_type, MatchValue_fields,
6891
10
                                       1,
6892
10
        "MatchValue(expr value)");
6893
10
    if (!state->MatchValue_type) return -1;
6894
10
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6895
10
                                           state->pattern_type,
6896
10
                                           MatchSingleton_fields, 1,
6897
10
        "MatchSingleton(constant value)");
6898
10
    if (!state->MatchSingleton_type) return -1;
6899
10
    state->MatchSequence_type = make_type(state, "MatchSequence",
6900
10
                                          state->pattern_type,
6901
10
                                          MatchSequence_fields, 1,
6902
10
        "MatchSequence(pattern* patterns)");
6903
10
    if (!state->MatchSequence_type) return -1;
6904
10
    state->MatchMapping_type = make_type(state, "MatchMapping",
6905
10
                                         state->pattern_type,
6906
10
                                         MatchMapping_fields, 3,
6907
10
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6908
10
    if (!state->MatchMapping_type) return -1;
6909
10
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6910
0
        return -1;
6911
10
    state->MatchClass_type = make_type(state, "MatchClass",
6912
10
                                       state->pattern_type, MatchClass_fields,
6913
10
                                       4,
6914
10
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6915
10
    if (!state->MatchClass_type) return -1;
6916
10
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6917
10
                                      MatchStar_fields, 1,
6918
10
        "MatchStar(identifier? name)");
6919
10
    if (!state->MatchStar_type) return -1;
6920
10
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6921
0
        return -1;
6922
10
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6923
10
                                    MatchAs_fields, 2,
6924
10
        "MatchAs(pattern? pattern, identifier? name)");
6925
10
    if (!state->MatchAs_type) return -1;
6926
10
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6927
0
        return -1;
6928
10
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6929
0
        return -1;
6930
10
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6931
10
                                    MatchOr_fields, 1,
6932
10
        "MatchOr(pattern* patterns)");
6933
10
    if (!state->MatchOr_type) return -1;
6934
10
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6935
10
                                        NULL, 0,
6936
10
        "type_ignore = TypeIgnore(int lineno, string tag)");
6937
10
    if (!state->type_ignore_type) return -1;
6938
10
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6939
10
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6940
10
                                       state->type_ignore_type,
6941
10
                                       TypeIgnore_fields, 2,
6942
10
        "TypeIgnore(int lineno, string tag)");
6943
10
    if (!state->TypeIgnore_type) return -1;
6944
10
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6945
10
                                       NULL, 0,
6946
10
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6947
10
        "           | ParamSpec(identifier name, expr? default_value)\n"
6948
10
        "           | TypeVarTuple(identifier name, expr? default_value)");
6949
10
    if (!state->type_param_type) return -1;
6950
10
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6951
10
        < 0) return -1;
6952
10
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6953
10
                                    TypeVar_fields, 3,
6954
10
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6955
10
    if (!state->TypeVar_type) return -1;
6956
10
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6957
0
        return -1;
6958
10
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6959
10
        -1)
6960
0
        return -1;
6961
10
    state->ParamSpec_type = make_type(state, "ParamSpec",
6962
10
                                      state->type_param_type, ParamSpec_fields,
6963
10
                                      2,
6964
10
        "ParamSpec(identifier name, expr? default_value)");
6965
10
    if (!state->ParamSpec_type) return -1;
6966
10
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6967
10
        == -1)
6968
0
        return -1;
6969
10
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6970
10
                                         state->type_param_type,
6971
10
                                         TypeVarTuple_fields, 2,
6972
10
        "TypeVarTuple(identifier name, expr? default_value)");
6973
10
    if (!state->TypeVarTuple_type) return -1;
6974
10
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6975
10
        Py_None) == -1)
6976
0
        return -1;
6977
6978
10
    if (!add_ast_annotations(state)) {
6979
0
        return -1;
6980
0
    }
6981
10
    return 0;
6982
10
}
6983
6984
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6985
                       PyArena* arena);
6986
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6987
                        PyArena* arena);
6988
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6989
                        PyArena* arena);
6990
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6991
                                expr_context_ty* out, PyArena* arena);
6992
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
6993
                          out, PyArena* arena);
6994
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
6995
                            operator_ty* out, PyArena* arena);
6996
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
6997
                           out, PyArena* arena);
6998
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
6999
                         PyArena* arena);
7000
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
7001
                                 comprehension_ty* out, PyArena* arena);
7002
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
7003
                                 excepthandler_ty* out, PyArena* arena);
7004
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
7005
                             arguments_ty* out, PyArena* arena);
7006
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
7007
                       PyArena* arena);
7008
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
7009
                           out, PyArena* arena);
7010
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
7011
                         PyArena* arena);
7012
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
7013
                            withitem_ty* out, PyArena* arena);
7014
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
7015
                              match_case_ty* out, PyArena* arena);
7016
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
7017
                           out, PyArena* arena);
7018
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
7019
                               type_ignore_ty* out, PyArena* arena);
7020
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
7021
                              type_param_ty* out, PyArena* arena);
7022
7023
mod_ty
7024
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
7025
              PyArena *arena)
7026
7.86k
{
7027
7.86k
    mod_ty p;
7028
7.86k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7029
7.86k
    if (!p)
7030
0
        return NULL;
7031
7.86k
    p->kind = Module_kind;
7032
7.86k
    p->v.Module.body = body;
7033
7.86k
    p->v.Module.type_ignores = type_ignores;
7034
7.86k
    return p;
7035
7.86k
}
7036
7037
mod_ty
7038
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7039
0
{
7040
0
    mod_ty p;
7041
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7042
0
    if (!p)
7043
0
        return NULL;
7044
0
    p->kind = Interactive_kind;
7045
0
    p->v.Interactive.body = body;
7046
0
    return p;
7047
0
}
7048
7049
mod_ty
7050
_PyAST_Expression(expr_ty body, PyArena *arena)
7051
43
{
7052
43
    mod_ty p;
7053
43
    if (!body) {
7054
0
        PyErr_SetString(PyExc_ValueError,
7055
0
                        "field 'body' is required for Expression");
7056
0
        return NULL;
7057
0
    }
7058
43
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7059
43
    if (!p)
7060
0
        return NULL;
7061
43
    p->kind = Expression_kind;
7062
43
    p->v.Expression.body = body;
7063
43
    return p;
7064
43
}
7065
7066
mod_ty
7067
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7068
0
{
7069
0
    mod_ty p;
7070
0
    if (!returns) {
7071
0
        PyErr_SetString(PyExc_ValueError,
7072
0
                        "field 'returns' is required for FunctionType");
7073
0
        return NULL;
7074
0
    }
7075
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7076
0
    if (!p)
7077
0
        return NULL;
7078
0
    p->kind = FunctionType_kind;
7079
0
    p->v.FunctionType.argtypes = argtypes;
7080
0
    p->v.FunctionType.returns = returns;
7081
0
    return p;
7082
0
}
7083
7084
stmt_ty
7085
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7086
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7087
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7088
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7089
                   *arena)
7090
8.56k
{
7091
8.56k
    stmt_ty p;
7092
8.56k
    if (!name) {
7093
0
        PyErr_SetString(PyExc_ValueError,
7094
0
                        "field 'name' is required for FunctionDef");
7095
0
        return NULL;
7096
0
    }
7097
8.56k
    if (!args) {
7098
0
        PyErr_SetString(PyExc_ValueError,
7099
0
                        "field 'args' is required for FunctionDef");
7100
0
        return NULL;
7101
0
    }
7102
8.56k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7103
8.56k
    if (!p)
7104
0
        return NULL;
7105
8.56k
    p->kind = FunctionDef_kind;
7106
8.56k
    p->v.FunctionDef.name = name;
7107
8.56k
    p->v.FunctionDef.args = args;
7108
8.56k
    p->v.FunctionDef.body = body;
7109
8.56k
    p->v.FunctionDef.decorator_list = decorator_list;
7110
8.56k
    p->v.FunctionDef.returns = returns;
7111
8.56k
    p->v.FunctionDef.type_comment = type_comment;
7112
8.56k
    p->v.FunctionDef.type_params = type_params;
7113
8.56k
    p->lineno = lineno;
7114
8.56k
    p->col_offset = col_offset;
7115
8.56k
    p->end_lineno = end_lineno;
7116
8.56k
    p->end_col_offset = end_col_offset;
7117
8.56k
    return p;
7118
8.56k
}
7119
7120
stmt_ty
7121
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7122
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7123
                        string type_comment, asdl_type_param_seq * type_params,
7124
                        int lineno, int col_offset, int end_lineno, int
7125
                        end_col_offset, PyArena *arena)
7126
822
{
7127
822
    stmt_ty p;
7128
822
    if (!name) {
7129
0
        PyErr_SetString(PyExc_ValueError,
7130
0
                        "field 'name' is required for AsyncFunctionDef");
7131
0
        return NULL;
7132
0
    }
7133
822
    if (!args) {
7134
0
        PyErr_SetString(PyExc_ValueError,
7135
0
                        "field 'args' is required for AsyncFunctionDef");
7136
0
        return NULL;
7137
0
    }
7138
822
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7139
822
    if (!p)
7140
0
        return NULL;
7141
822
    p->kind = AsyncFunctionDef_kind;
7142
822
    p->v.AsyncFunctionDef.name = name;
7143
822
    p->v.AsyncFunctionDef.args = args;
7144
822
    p->v.AsyncFunctionDef.body = body;
7145
822
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7146
822
    p->v.AsyncFunctionDef.returns = returns;
7147
822
    p->v.AsyncFunctionDef.type_comment = type_comment;
7148
822
    p->v.AsyncFunctionDef.type_params = type_params;
7149
822
    p->lineno = lineno;
7150
822
    p->col_offset = col_offset;
7151
822
    p->end_lineno = end_lineno;
7152
822
    p->end_col_offset = end_col_offset;
7153
822
    return p;
7154
822
}
7155
7156
stmt_ty
7157
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7158
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7159
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7160
                int end_lineno, int end_col_offset, PyArena *arena)
7161
4.38k
{
7162
4.38k
    stmt_ty p;
7163
4.38k
    if (!name) {
7164
0
        PyErr_SetString(PyExc_ValueError,
7165
0
                        "field 'name' is required for ClassDef");
7166
0
        return NULL;
7167
0
    }
7168
4.38k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7169
4.38k
    if (!p)
7170
0
        return NULL;
7171
4.38k
    p->kind = ClassDef_kind;
7172
4.38k
    p->v.ClassDef.name = name;
7173
4.38k
    p->v.ClassDef.bases = bases;
7174
4.38k
    p->v.ClassDef.keywords = keywords;
7175
4.38k
    p->v.ClassDef.body = body;
7176
4.38k
    p->v.ClassDef.decorator_list = decorator_list;
7177
4.38k
    p->v.ClassDef.type_params = type_params;
7178
4.38k
    p->lineno = lineno;
7179
4.38k
    p->col_offset = col_offset;
7180
4.38k
    p->end_lineno = end_lineno;
7181
4.38k
    p->end_col_offset = end_col_offset;
7182
4.38k
    return p;
7183
4.38k
}
7184
7185
stmt_ty
7186
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7187
              end_col_offset, PyArena *arena)
7188
7.48k
{
7189
7.48k
    stmt_ty p;
7190
7.48k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7191
7.48k
    if (!p)
7192
0
        return NULL;
7193
7.48k
    p->kind = Return_kind;
7194
7.48k
    p->v.Return.value = value;
7195
7.48k
    p->lineno = lineno;
7196
7.48k
    p->col_offset = col_offset;
7197
7.48k
    p->end_lineno = end_lineno;
7198
7.48k
    p->end_col_offset = end_col_offset;
7199
7.48k
    return p;
7200
7.48k
}
7201
7202
stmt_ty
7203
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7204
              end_lineno, int end_col_offset, PyArena *arena)
7205
901
{
7206
901
    stmt_ty p;
7207
901
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7208
901
    if (!p)
7209
0
        return NULL;
7210
901
    p->kind = Delete_kind;
7211
901
    p->v.Delete.targets = targets;
7212
901
    p->lineno = lineno;
7213
901
    p->col_offset = col_offset;
7214
901
    p->end_lineno = end_lineno;
7215
901
    p->end_col_offset = end_col_offset;
7216
901
    return p;
7217
901
}
7218
7219
stmt_ty
7220
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7221
              lineno, int col_offset, int end_lineno, int end_col_offset,
7222
              PyArena *arena)
7223
12.9k
{
7224
12.9k
    stmt_ty p;
7225
12.9k
    if (!value) {
7226
0
        PyErr_SetString(PyExc_ValueError,
7227
0
                        "field 'value' is required for Assign");
7228
0
        return NULL;
7229
0
    }
7230
12.9k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7231
12.9k
    if (!p)
7232
0
        return NULL;
7233
12.9k
    p->kind = Assign_kind;
7234
12.9k
    p->v.Assign.targets = targets;
7235
12.9k
    p->v.Assign.value = value;
7236
12.9k
    p->v.Assign.type_comment = type_comment;
7237
12.9k
    p->lineno = lineno;
7238
12.9k
    p->col_offset = col_offset;
7239
12.9k
    p->end_lineno = end_lineno;
7240
12.9k
    p->end_col_offset = end_col_offset;
7241
12.9k
    return p;
7242
12.9k
}
7243
7244
stmt_ty
7245
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7246
                 value, int lineno, int col_offset, int end_lineno, int
7247
                 end_col_offset, PyArena *arena)
7248
410
{
7249
410
    stmt_ty p;
7250
410
    if (!name) {
7251
0
        PyErr_SetString(PyExc_ValueError,
7252
0
                        "field 'name' is required for TypeAlias");
7253
0
        return NULL;
7254
0
    }
7255
410
    if (!value) {
7256
0
        PyErr_SetString(PyExc_ValueError,
7257
0
                        "field 'value' is required for TypeAlias");
7258
0
        return NULL;
7259
0
    }
7260
410
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7261
410
    if (!p)
7262
0
        return NULL;
7263
410
    p->kind = TypeAlias_kind;
7264
410
    p->v.TypeAlias.name = name;
7265
410
    p->v.TypeAlias.type_params = type_params;
7266
410
    p->v.TypeAlias.value = value;
7267
410
    p->lineno = lineno;
7268
410
    p->col_offset = col_offset;
7269
410
    p->end_lineno = end_lineno;
7270
410
    p->end_col_offset = end_col_offset;
7271
410
    return p;
7272
410
}
7273
7274
stmt_ty
7275
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7276
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7277
2.77k
{
7278
2.77k
    stmt_ty p;
7279
2.77k
    if (!target) {
7280
0
        PyErr_SetString(PyExc_ValueError,
7281
0
                        "field 'target' is required for AugAssign");
7282
0
        return NULL;
7283
0
    }
7284
2.77k
    if (!op) {
7285
0
        PyErr_SetString(PyExc_ValueError,
7286
0
                        "field 'op' is required for AugAssign");
7287
0
        return NULL;
7288
0
    }
7289
2.77k
    if (!value) {
7290
0
        PyErr_SetString(PyExc_ValueError,
7291
0
                        "field 'value' is required for AugAssign");
7292
0
        return NULL;
7293
0
    }
7294
2.77k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7295
2.77k
    if (!p)
7296
0
        return NULL;
7297
2.77k
    p->kind = AugAssign_kind;
7298
2.77k
    p->v.AugAssign.target = target;
7299
2.77k
    p->v.AugAssign.op = op;
7300
2.77k
    p->v.AugAssign.value = value;
7301
2.77k
    p->lineno = lineno;
7302
2.77k
    p->col_offset = col_offset;
7303
2.77k
    p->end_lineno = end_lineno;
7304
2.77k
    p->end_col_offset = end_col_offset;
7305
2.77k
    return p;
7306
2.77k
}
7307
7308
stmt_ty
7309
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7310
                 int lineno, int col_offset, int end_lineno, int
7311
                 end_col_offset, PyArena *arena)
7312
3.25k
{
7313
3.25k
    stmt_ty p;
7314
3.25k
    if (!target) {
7315
0
        PyErr_SetString(PyExc_ValueError,
7316
0
                        "field 'target' is required for AnnAssign");
7317
0
        return NULL;
7318
0
    }
7319
3.25k
    if (!annotation) {
7320
0
        PyErr_SetString(PyExc_ValueError,
7321
0
                        "field 'annotation' is required for AnnAssign");
7322
0
        return NULL;
7323
0
    }
7324
3.25k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7325
3.25k
    if (!p)
7326
0
        return NULL;
7327
3.25k
    p->kind = AnnAssign_kind;
7328
3.25k
    p->v.AnnAssign.target = target;
7329
3.25k
    p->v.AnnAssign.annotation = annotation;
7330
3.25k
    p->v.AnnAssign.value = value;
7331
3.25k
    p->v.AnnAssign.simple = simple;
7332
3.25k
    p->lineno = lineno;
7333
3.25k
    p->col_offset = col_offset;
7334
3.25k
    p->end_lineno = end_lineno;
7335
3.25k
    p->end_col_offset = end_col_offset;
7336
3.25k
    return p;
7337
3.25k
}
7338
7339
stmt_ty
7340
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7341
           orelse, string type_comment, int lineno, int col_offset, int
7342
           end_lineno, int end_col_offset, PyArena *arena)
7343
1.63k
{
7344
1.63k
    stmt_ty p;
7345
1.63k
    if (!target) {
7346
0
        PyErr_SetString(PyExc_ValueError,
7347
0
                        "field 'target' is required for For");
7348
0
        return NULL;
7349
0
    }
7350
1.63k
    if (!iter) {
7351
0
        PyErr_SetString(PyExc_ValueError,
7352
0
                        "field 'iter' is required for For");
7353
0
        return NULL;
7354
0
    }
7355
1.63k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7356
1.63k
    if (!p)
7357
0
        return NULL;
7358
1.63k
    p->kind = For_kind;
7359
1.63k
    p->v.For.target = target;
7360
1.63k
    p->v.For.iter = iter;
7361
1.63k
    p->v.For.body = body;
7362
1.63k
    p->v.For.orelse = orelse;
7363
1.63k
    p->v.For.type_comment = type_comment;
7364
1.63k
    p->lineno = lineno;
7365
1.63k
    p->col_offset = col_offset;
7366
1.63k
    p->end_lineno = end_lineno;
7367
1.63k
    p->end_col_offset = end_col_offset;
7368
1.63k
    return p;
7369
1.63k
}
7370
7371
stmt_ty
7372
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7373
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7374
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7375
698
{
7376
698
    stmt_ty p;
7377
698
    if (!target) {
7378
0
        PyErr_SetString(PyExc_ValueError,
7379
0
                        "field 'target' is required for AsyncFor");
7380
0
        return NULL;
7381
0
    }
7382
698
    if (!iter) {
7383
0
        PyErr_SetString(PyExc_ValueError,
7384
0
                        "field 'iter' is required for AsyncFor");
7385
0
        return NULL;
7386
0
    }
7387
698
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7388
698
    if (!p)
7389
0
        return NULL;
7390
698
    p->kind = AsyncFor_kind;
7391
698
    p->v.AsyncFor.target = target;
7392
698
    p->v.AsyncFor.iter = iter;
7393
698
    p->v.AsyncFor.body = body;
7394
698
    p->v.AsyncFor.orelse = orelse;
7395
698
    p->v.AsyncFor.type_comment = type_comment;
7396
698
    p->lineno = lineno;
7397
698
    p->col_offset = col_offset;
7398
698
    p->end_lineno = end_lineno;
7399
698
    p->end_col_offset = end_col_offset;
7400
698
    return p;
7401
698
}
7402
7403
stmt_ty
7404
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7405
             lineno, int col_offset, int end_lineno, int end_col_offset,
7406
             PyArena *arena)
7407
1.23k
{
7408
1.23k
    stmt_ty p;
7409
1.23k
    if (!test) {
7410
0
        PyErr_SetString(PyExc_ValueError,
7411
0
                        "field 'test' is required for While");
7412
0
        return NULL;
7413
0
    }
7414
1.23k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7415
1.23k
    if (!p)
7416
0
        return NULL;
7417
1.23k
    p->kind = While_kind;
7418
1.23k
    p->v.While.test = test;
7419
1.23k
    p->v.While.body = body;
7420
1.23k
    p->v.While.orelse = orelse;
7421
1.23k
    p->lineno = lineno;
7422
1.23k
    p->col_offset = col_offset;
7423
1.23k
    p->end_lineno = end_lineno;
7424
1.23k
    p->end_col_offset = end_col_offset;
7425
1.23k
    return p;
7426
1.23k
}
7427
7428
stmt_ty
7429
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7430
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7431
          *arena)
7432
8.97k
{
7433
8.97k
    stmt_ty p;
7434
8.97k
    if (!test) {
7435
0
        PyErr_SetString(PyExc_ValueError,
7436
0
                        "field 'test' is required for If");
7437
0
        return NULL;
7438
0
    }
7439
8.97k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7440
8.97k
    if (!p)
7441
0
        return NULL;
7442
8.97k
    p->kind = If_kind;
7443
8.97k
    p->v.If.test = test;
7444
8.97k
    p->v.If.body = body;
7445
8.97k
    p->v.If.orelse = orelse;
7446
8.97k
    p->lineno = lineno;
7447
8.97k
    p->col_offset = col_offset;
7448
8.97k
    p->end_lineno = end_lineno;
7449
8.97k
    p->end_col_offset = end_col_offset;
7450
8.97k
    return p;
7451
8.97k
}
7452
7453
stmt_ty
7454
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7455
            type_comment, int lineno, int col_offset, int end_lineno, int
7456
            end_col_offset, PyArena *arena)
7457
3.43k
{
7458
3.43k
    stmt_ty p;
7459
3.43k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7460
3.43k
    if (!p)
7461
0
        return NULL;
7462
3.43k
    p->kind = With_kind;
7463
3.43k
    p->v.With.items = items;
7464
3.43k
    p->v.With.body = body;
7465
3.43k
    p->v.With.type_comment = type_comment;
7466
3.43k
    p->lineno = lineno;
7467
3.43k
    p->col_offset = col_offset;
7468
3.43k
    p->end_lineno = end_lineno;
7469
3.43k
    p->end_col_offset = end_col_offset;
7470
3.43k
    return p;
7471
3.43k
}
7472
7473
stmt_ty
7474
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7475
                 type_comment, int lineno, int col_offset, int end_lineno, int
7476
                 end_col_offset, PyArena *arena)
7477
1.29k
{
7478
1.29k
    stmt_ty p;
7479
1.29k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7480
1.29k
    if (!p)
7481
0
        return NULL;
7482
1.29k
    p->kind = AsyncWith_kind;
7483
1.29k
    p->v.AsyncWith.items = items;
7484
1.29k
    p->v.AsyncWith.body = body;
7485
1.29k
    p->v.AsyncWith.type_comment = type_comment;
7486
1.29k
    p->lineno = lineno;
7487
1.29k
    p->col_offset = col_offset;
7488
1.29k
    p->end_lineno = end_lineno;
7489
1.29k
    p->end_col_offset = end_col_offset;
7490
1.29k
    return p;
7491
1.29k
}
7492
7493
stmt_ty
7494
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7495
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7496
624
{
7497
624
    stmt_ty p;
7498
624
    if (!subject) {
7499
0
        PyErr_SetString(PyExc_ValueError,
7500
0
                        "field 'subject' is required for Match");
7501
0
        return NULL;
7502
0
    }
7503
624
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7504
624
    if (!p)
7505
0
        return NULL;
7506
624
    p->kind = Match_kind;
7507
624
    p->v.Match.subject = subject;
7508
624
    p->v.Match.cases = cases;
7509
624
    p->lineno = lineno;
7510
624
    p->col_offset = col_offset;
7511
624
    p->end_lineno = end_lineno;
7512
624
    p->end_col_offset = end_col_offset;
7513
624
    return p;
7514
624
}
7515
7516
stmt_ty
7517
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7518
             end_lineno, int end_col_offset, PyArena *arena)
7519
3.33k
{
7520
3.33k
    stmt_ty p;
7521
3.33k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7522
3.33k
    if (!p)
7523
0
        return NULL;
7524
3.33k
    p->kind = Raise_kind;
7525
3.33k
    p->v.Raise.exc = exc;
7526
3.33k
    p->v.Raise.cause = cause;
7527
3.33k
    p->lineno = lineno;
7528
3.33k
    p->col_offset = col_offset;
7529
3.33k
    p->end_lineno = end_lineno;
7530
3.33k
    p->end_col_offset = end_col_offset;
7531
3.33k
    return p;
7532
3.33k
}
7533
7534
stmt_ty
7535
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7536
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7537
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7538
3.42k
{
7539
3.42k
    stmt_ty p;
7540
3.42k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7541
3.42k
    if (!p)
7542
0
        return NULL;
7543
3.42k
    p->kind = Try_kind;
7544
3.42k
    p->v.Try.body = body;
7545
3.42k
    p->v.Try.handlers = handlers;
7546
3.42k
    p->v.Try.orelse = orelse;
7547
3.42k
    p->v.Try.finalbody = finalbody;
7548
3.42k
    p->lineno = lineno;
7549
3.42k
    p->col_offset = col_offset;
7550
3.42k
    p->end_lineno = end_lineno;
7551
3.42k
    p->end_col_offset = end_col_offset;
7552
3.42k
    return p;
7553
3.42k
}
7554
7555
stmt_ty
7556
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7557
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7558
               int col_offset, int end_lineno, int end_col_offset, PyArena
7559
               *arena)
7560
1.83k
{
7561
1.83k
    stmt_ty p;
7562
1.83k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7563
1.83k
    if (!p)
7564
0
        return NULL;
7565
1.83k
    p->kind = TryStar_kind;
7566
1.83k
    p->v.TryStar.body = body;
7567
1.83k
    p->v.TryStar.handlers = handlers;
7568
1.83k
    p->v.TryStar.orelse = orelse;
7569
1.83k
    p->v.TryStar.finalbody = finalbody;
7570
1.83k
    p->lineno = lineno;
7571
1.83k
    p->col_offset = col_offset;
7572
1.83k
    p->end_lineno = end_lineno;
7573
1.83k
    p->end_col_offset = end_col_offset;
7574
1.83k
    return p;
7575
1.83k
}
7576
7577
stmt_ty
7578
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7579
              end_lineno, int end_col_offset, PyArena *arena)
7580
709
{
7581
709
    stmt_ty p;
7582
709
    if (!test) {
7583
0
        PyErr_SetString(PyExc_ValueError,
7584
0
                        "field 'test' is required for Assert");
7585
0
        return NULL;
7586
0
    }
7587
709
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7588
709
    if (!p)
7589
0
        return NULL;
7590
709
    p->kind = Assert_kind;
7591
709
    p->v.Assert.test = test;
7592
709
    p->v.Assert.msg = msg;
7593
709
    p->lineno = lineno;
7594
709
    p->col_offset = col_offset;
7595
709
    p->end_lineno = end_lineno;
7596
709
    p->end_col_offset = end_col_offset;
7597
709
    return p;
7598
709
}
7599
7600
stmt_ty
7601
_PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
7602
              end_lineno, int end_col_offset, PyArena *arena)
7603
2.56k
{
7604
2.56k
    stmt_ty p;
7605
2.56k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7606
2.56k
    if (!p)
7607
0
        return NULL;
7608
2.56k
    p->kind = Import_kind;
7609
2.56k
    p->v.Import.names = names;
7610
2.56k
    p->lineno = lineno;
7611
2.56k
    p->col_offset = col_offset;
7612
2.56k
    p->end_lineno = end_lineno;
7613
2.56k
    p->end_col_offset = end_col_offset;
7614
2.56k
    return p;
7615
2.56k
}
7616
7617
stmt_ty
7618
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7619
                  lineno, int col_offset, int end_lineno, int end_col_offset,
7620
                  PyArena *arena)
7621
2.87k
{
7622
2.87k
    stmt_ty p;
7623
2.87k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7624
2.87k
    if (!p)
7625
0
        return NULL;
7626
2.87k
    p->kind = ImportFrom_kind;
7627
2.87k
    p->v.ImportFrom.module = module;
7628
2.87k
    p->v.ImportFrom.names = names;
7629
2.87k
    p->v.ImportFrom.level = level;
7630
2.87k
    p->lineno = lineno;
7631
2.87k
    p->col_offset = col_offset;
7632
2.87k
    p->end_lineno = end_lineno;
7633
2.87k
    p->end_col_offset = end_col_offset;
7634
2.87k
    return p;
7635
2.87k
}
7636
7637
stmt_ty
7638
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7639
              end_lineno, int end_col_offset, PyArena *arena)
7640
681
{
7641
681
    stmt_ty p;
7642
681
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7643
681
    if (!p)
7644
0
        return NULL;
7645
681
    p->kind = Global_kind;
7646
681
    p->v.Global.names = names;
7647
681
    p->lineno = lineno;
7648
681
    p->col_offset = col_offset;
7649
681
    p->end_lineno = end_lineno;
7650
681
    p->end_col_offset = end_col_offset;
7651
681
    return p;
7652
681
}
7653
7654
stmt_ty
7655
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7656
                end_lineno, int end_col_offset, PyArena *arena)
7657
1.01k
{
7658
1.01k
    stmt_ty p;
7659
1.01k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7660
1.01k
    if (!p)
7661
0
        return NULL;
7662
1.01k
    p->kind = Nonlocal_kind;
7663
1.01k
    p->v.Nonlocal.names = names;
7664
1.01k
    p->lineno = lineno;
7665
1.01k
    p->col_offset = col_offset;
7666
1.01k
    p->end_lineno = end_lineno;
7667
1.01k
    p->end_col_offset = end_col_offset;
7668
1.01k
    return p;
7669
1.01k
}
7670
7671
stmt_ty
7672
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7673
            end_col_offset, PyArena *arena)
7674
103k
{
7675
103k
    stmt_ty p;
7676
103k
    if (!value) {
7677
0
        PyErr_SetString(PyExc_ValueError,
7678
0
                        "field 'value' is required for Expr");
7679
0
        return NULL;
7680
0
    }
7681
103k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7682
103k
    if (!p)
7683
0
        return NULL;
7684
103k
    p->kind = Expr_kind;
7685
103k
    p->v.Expr.value = value;
7686
103k
    p->lineno = lineno;
7687
103k
    p->col_offset = col_offset;
7688
103k
    p->end_lineno = end_lineno;
7689
103k
    p->end_col_offset = end_col_offset;
7690
103k
    return p;
7691
103k
}
7692
7693
stmt_ty
7694
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7695
            PyArena *arena)
7696
1.82k
{
7697
1.82k
    stmt_ty p;
7698
1.82k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7699
1.82k
    if (!p)
7700
0
        return NULL;
7701
1.82k
    p->kind = Pass_kind;
7702
1.82k
    p->lineno = lineno;
7703
1.82k
    p->col_offset = col_offset;
7704
1.82k
    p->end_lineno = end_lineno;
7705
1.82k
    p->end_col_offset = end_col_offset;
7706
1.82k
    return p;
7707
1.82k
}
7708
7709
stmt_ty
7710
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7711
             PyArena *arena)
7712
1.47k
{
7713
1.47k
    stmt_ty p;
7714
1.47k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7715
1.47k
    if (!p)
7716
0
        return NULL;
7717
1.47k
    p->kind = Break_kind;
7718
1.47k
    p->lineno = lineno;
7719
1.47k
    p->col_offset = col_offset;
7720
1.47k
    p->end_lineno = end_lineno;
7721
1.47k
    p->end_col_offset = end_col_offset;
7722
1.47k
    return p;
7723
1.47k
}
7724
7725
stmt_ty
7726
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7727
                PyArena *arena)
7728
2.58k
{
7729
2.58k
    stmt_ty p;
7730
2.58k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7731
2.58k
    if (!p)
7732
0
        return NULL;
7733
2.58k
    p->kind = Continue_kind;
7734
2.58k
    p->lineno = lineno;
7735
2.58k
    p->col_offset = col_offset;
7736
2.58k
    p->end_lineno = end_lineno;
7737
2.58k
    p->end_col_offset = end_col_offset;
7738
2.58k
    return p;
7739
2.58k
}
7740
7741
expr_ty
7742
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7743
              int end_lineno, int end_col_offset, PyArena *arena)
7744
2.95k
{
7745
2.95k
    expr_ty p;
7746
2.95k
    if (!op) {
7747
0
        PyErr_SetString(PyExc_ValueError,
7748
0
                        "field 'op' is required for BoolOp");
7749
0
        return NULL;
7750
0
    }
7751
2.95k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7752
2.95k
    if (!p)
7753
0
        return NULL;
7754
2.95k
    p->kind = BoolOp_kind;
7755
2.95k
    p->v.BoolOp.op = op;
7756
2.95k
    p->v.BoolOp.values = values;
7757
2.95k
    p->lineno = lineno;
7758
2.95k
    p->col_offset = col_offset;
7759
2.95k
    p->end_lineno = end_lineno;
7760
2.95k
    p->end_col_offset = end_col_offset;
7761
2.95k
    return p;
7762
2.95k
}
7763
7764
expr_ty
7765
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7766
                 end_lineno, int end_col_offset, PyArena *arena)
7767
1.18k
{
7768
1.18k
    expr_ty p;
7769
1.18k
    if (!target) {
7770
0
        PyErr_SetString(PyExc_ValueError,
7771
0
                        "field 'target' is required for NamedExpr");
7772
0
        return NULL;
7773
0
    }
7774
1.18k
    if (!value) {
7775
0
        PyErr_SetString(PyExc_ValueError,
7776
0
                        "field 'value' is required for NamedExpr");
7777
0
        return NULL;
7778
0
    }
7779
1.18k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7780
1.18k
    if (!p)
7781
0
        return NULL;
7782
1.18k
    p->kind = NamedExpr_kind;
7783
1.18k
    p->v.NamedExpr.target = target;
7784
1.18k
    p->v.NamedExpr.value = value;
7785
1.18k
    p->lineno = lineno;
7786
1.18k
    p->col_offset = col_offset;
7787
1.18k
    p->end_lineno = end_lineno;
7788
1.18k
    p->end_col_offset = end_col_offset;
7789
1.18k
    return p;
7790
1.18k
}
7791
7792
expr_ty
7793
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7794
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7795
49.1k
{
7796
49.1k
    expr_ty p;
7797
49.1k
    if (!left) {
7798
0
        PyErr_SetString(PyExc_ValueError,
7799
0
                        "field 'left' is required for BinOp");
7800
0
        return NULL;
7801
0
    }
7802
49.1k
    if (!op) {
7803
0
        PyErr_SetString(PyExc_ValueError,
7804
0
                        "field 'op' is required for BinOp");
7805
0
        return NULL;
7806
0
    }
7807
49.1k
    if (!right) {
7808
0
        PyErr_SetString(PyExc_ValueError,
7809
0
                        "field 'right' is required for BinOp");
7810
0
        return NULL;
7811
0
    }
7812
49.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7813
49.1k
    if (!p)
7814
0
        return NULL;
7815
49.1k
    p->kind = BinOp_kind;
7816
49.1k
    p->v.BinOp.left = left;
7817
49.1k
    p->v.BinOp.op = op;
7818
49.1k
    p->v.BinOp.right = right;
7819
49.1k
    p->lineno = lineno;
7820
49.1k
    p->col_offset = col_offset;
7821
49.1k
    p->end_lineno = end_lineno;
7822
49.1k
    p->end_col_offset = end_col_offset;
7823
49.1k
    return p;
7824
49.1k
}
7825
7826
expr_ty
7827
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7828
               end_lineno, int end_col_offset, PyArena *arena)
7829
193k
{
7830
193k
    expr_ty p;
7831
193k
    if (!op) {
7832
0
        PyErr_SetString(PyExc_ValueError,
7833
0
                        "field 'op' is required for UnaryOp");
7834
0
        return NULL;
7835
0
    }
7836
193k
    if (!operand) {
7837
0
        PyErr_SetString(PyExc_ValueError,
7838
0
                        "field 'operand' is required for UnaryOp");
7839
0
        return NULL;
7840
0
    }
7841
193k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7842
193k
    if (!p)
7843
0
        return NULL;
7844
193k
    p->kind = UnaryOp_kind;
7845
193k
    p->v.UnaryOp.op = op;
7846
193k
    p->v.UnaryOp.operand = operand;
7847
193k
    p->lineno = lineno;
7848
193k
    p->col_offset = col_offset;
7849
193k
    p->end_lineno = end_lineno;
7850
193k
    p->end_col_offset = end_col_offset;
7851
193k
    return p;
7852
193k
}
7853
7854
expr_ty
7855
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7856
              end_lineno, int end_col_offset, PyArena *arena)
7857
3.01k
{
7858
3.01k
    expr_ty p;
7859
3.01k
    if (!args) {
7860
0
        PyErr_SetString(PyExc_ValueError,
7861
0
                        "field 'args' is required for Lambda");
7862
0
        return NULL;
7863
0
    }
7864
3.01k
    if (!body) {
7865
0
        PyErr_SetString(PyExc_ValueError,
7866
0
                        "field 'body' is required for Lambda");
7867
0
        return NULL;
7868
0
    }
7869
3.01k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7870
3.01k
    if (!p)
7871
0
        return NULL;
7872
3.01k
    p->kind = Lambda_kind;
7873
3.01k
    p->v.Lambda.args = args;
7874
3.01k
    p->v.Lambda.body = body;
7875
3.01k
    p->lineno = lineno;
7876
3.01k
    p->col_offset = col_offset;
7877
3.01k
    p->end_lineno = end_lineno;
7878
3.01k
    p->end_col_offset = end_col_offset;
7879
3.01k
    return p;
7880
3.01k
}
7881
7882
expr_ty
7883
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7884
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7885
1.15k
{
7886
1.15k
    expr_ty p;
7887
1.15k
    if (!test) {
7888
0
        PyErr_SetString(PyExc_ValueError,
7889
0
                        "field 'test' is required for IfExp");
7890
0
        return NULL;
7891
0
    }
7892
1.15k
    if (!body) {
7893
0
        PyErr_SetString(PyExc_ValueError,
7894
0
                        "field 'body' is required for IfExp");
7895
0
        return NULL;
7896
0
    }
7897
1.15k
    if (!orelse) {
7898
0
        PyErr_SetString(PyExc_ValueError,
7899
0
                        "field 'orelse' is required for IfExp");
7900
0
        return NULL;
7901
0
    }
7902
1.15k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7903
1.15k
    if (!p)
7904
0
        return NULL;
7905
1.15k
    p->kind = IfExp_kind;
7906
1.15k
    p->v.IfExp.test = test;
7907
1.15k
    p->v.IfExp.body = body;
7908
1.15k
    p->v.IfExp.orelse = orelse;
7909
1.15k
    p->lineno = lineno;
7910
1.15k
    p->col_offset = col_offset;
7911
1.15k
    p->end_lineno = end_lineno;
7912
1.15k
    p->end_col_offset = end_col_offset;
7913
1.15k
    return p;
7914
1.15k
}
7915
7916
expr_ty
7917
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7918
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7919
4.97k
{
7920
4.97k
    expr_ty p;
7921
4.97k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7922
4.97k
    if (!p)
7923
0
        return NULL;
7924
4.97k
    p->kind = Dict_kind;
7925
4.97k
    p->v.Dict.keys = keys;
7926
4.97k
    p->v.Dict.values = values;
7927
4.97k
    p->lineno = lineno;
7928
4.97k
    p->col_offset = col_offset;
7929
4.97k
    p->end_lineno = end_lineno;
7930
4.97k
    p->end_col_offset = end_col_offset;
7931
4.97k
    return p;
7932
4.97k
}
7933
7934
expr_ty
7935
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7936
           int end_col_offset, PyArena *arena)
7937
1.52k
{
7938
1.52k
    expr_ty p;
7939
1.52k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7940
1.52k
    if (!p)
7941
0
        return NULL;
7942
1.52k
    p->kind = Set_kind;
7943
1.52k
    p->v.Set.elts = elts;
7944
1.52k
    p->lineno = lineno;
7945
1.52k
    p->col_offset = col_offset;
7946
1.52k
    p->end_lineno = end_lineno;
7947
1.52k
    p->end_col_offset = end_col_offset;
7948
1.52k
    return p;
7949
1.52k
}
7950
7951
expr_ty
7952
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7953
                int col_offset, int end_lineno, int end_col_offset, PyArena
7954
                *arena)
7955
1.25k
{
7956
1.25k
    expr_ty p;
7957
1.25k
    if (!elt) {
7958
0
        PyErr_SetString(PyExc_ValueError,
7959
0
                        "field 'elt' is required for ListComp");
7960
0
        return NULL;
7961
0
    }
7962
1.25k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7963
1.25k
    if (!p)
7964
0
        return NULL;
7965
1.25k
    p->kind = ListComp_kind;
7966
1.25k
    p->v.ListComp.elt = elt;
7967
1.25k
    p->v.ListComp.generators = generators;
7968
1.25k
    p->lineno = lineno;
7969
1.25k
    p->col_offset = col_offset;
7970
1.25k
    p->end_lineno = end_lineno;
7971
1.25k
    p->end_col_offset = end_col_offset;
7972
1.25k
    return p;
7973
1.25k
}
7974
7975
expr_ty
7976
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7977
               int col_offset, int end_lineno, int end_col_offset, PyArena
7978
               *arena)
7979
525
{
7980
525
    expr_ty p;
7981
525
    if (!elt) {
7982
0
        PyErr_SetString(PyExc_ValueError,
7983
0
                        "field 'elt' is required for SetComp");
7984
0
        return NULL;
7985
0
    }
7986
525
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7987
525
    if (!p)
7988
0
        return NULL;
7989
525
    p->kind = SetComp_kind;
7990
525
    p->v.SetComp.elt = elt;
7991
525
    p->v.SetComp.generators = generators;
7992
525
    p->lineno = lineno;
7993
525
    p->col_offset = col_offset;
7994
525
    p->end_lineno = end_lineno;
7995
525
    p->end_col_offset = end_col_offset;
7996
525
    return p;
7997
525
}
7998
7999
expr_ty
8000
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
8001
                generators, int lineno, int col_offset, int end_lineno, int
8002
                end_col_offset, PyArena *arena)
8003
1.39k
{
8004
1.39k
    expr_ty p;
8005
1.39k
    if (!key) {
8006
0
        PyErr_SetString(PyExc_ValueError,
8007
0
                        "field 'key' is required for DictComp");
8008
0
        return NULL;
8009
0
    }
8010
1.39k
    if (!value) {
8011
0
        PyErr_SetString(PyExc_ValueError,
8012
0
                        "field 'value' is required for DictComp");
8013
0
        return NULL;
8014
0
    }
8015
1.39k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8016
1.39k
    if (!p)
8017
0
        return NULL;
8018
1.39k
    p->kind = DictComp_kind;
8019
1.39k
    p->v.DictComp.key = key;
8020
1.39k
    p->v.DictComp.value = value;
8021
1.39k
    p->v.DictComp.generators = generators;
8022
1.39k
    p->lineno = lineno;
8023
1.39k
    p->col_offset = col_offset;
8024
1.39k
    p->end_lineno = end_lineno;
8025
1.39k
    p->end_col_offset = end_col_offset;
8026
1.39k
    return p;
8027
1.39k
}
8028
8029
expr_ty
8030
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8031
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8032
                    PyArena *arena)
8033
4.96k
{
8034
4.96k
    expr_ty p;
8035
4.96k
    if (!elt) {
8036
0
        PyErr_SetString(PyExc_ValueError,
8037
0
                        "field 'elt' is required for GeneratorExp");
8038
0
        return NULL;
8039
0
    }
8040
4.96k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8041
4.96k
    if (!p)
8042
0
        return NULL;
8043
4.96k
    p->kind = GeneratorExp_kind;
8044
4.96k
    p->v.GeneratorExp.elt = elt;
8045
4.96k
    p->v.GeneratorExp.generators = generators;
8046
4.96k
    p->lineno = lineno;
8047
4.96k
    p->col_offset = col_offset;
8048
4.96k
    p->end_lineno = end_lineno;
8049
4.96k
    p->end_col_offset = end_col_offset;
8050
4.96k
    return p;
8051
4.96k
}
8052
8053
expr_ty
8054
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8055
             end_col_offset, PyArena *arena)
8056
390
{
8057
390
    expr_ty p;
8058
390
    if (!value) {
8059
0
        PyErr_SetString(PyExc_ValueError,
8060
0
                        "field 'value' is required for Await");
8061
0
        return NULL;
8062
0
    }
8063
390
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8064
390
    if (!p)
8065
0
        return NULL;
8066
390
    p->kind = Await_kind;
8067
390
    p->v.Await.value = value;
8068
390
    p->lineno = lineno;
8069
390
    p->col_offset = col_offset;
8070
390
    p->end_lineno = end_lineno;
8071
390
    p->end_col_offset = end_col_offset;
8072
390
    return p;
8073
390
}
8074
8075
expr_ty
8076
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8077
             end_col_offset, PyArena *arena)
8078
2.61k
{
8079
2.61k
    expr_ty p;
8080
2.61k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8081
2.61k
    if (!p)
8082
0
        return NULL;
8083
2.61k
    p->kind = Yield_kind;
8084
2.61k
    p->v.Yield.value = value;
8085
2.61k
    p->lineno = lineno;
8086
2.61k
    p->col_offset = col_offset;
8087
2.61k
    p->end_lineno = end_lineno;
8088
2.61k
    p->end_col_offset = end_col_offset;
8089
2.61k
    return p;
8090
2.61k
}
8091
8092
expr_ty
8093
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8094
                 end_col_offset, PyArena *arena)
8095
290
{
8096
290
    expr_ty p;
8097
290
    if (!value) {
8098
0
        PyErr_SetString(PyExc_ValueError,
8099
0
                        "field 'value' is required for YieldFrom");
8100
0
        return NULL;
8101
0
    }
8102
290
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8103
290
    if (!p)
8104
0
        return NULL;
8105
290
    p->kind = YieldFrom_kind;
8106
290
    p->v.YieldFrom.value = value;
8107
290
    p->lineno = lineno;
8108
290
    p->col_offset = col_offset;
8109
290
    p->end_lineno = end_lineno;
8110
290
    p->end_col_offset = end_col_offset;
8111
290
    return p;
8112
290
}
8113
8114
expr_ty
8115
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8116
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8117
               PyArena *arena)
8118
9.67k
{
8119
9.67k
    expr_ty p;
8120
9.67k
    if (!left) {
8121
0
        PyErr_SetString(PyExc_ValueError,
8122
0
                        "field 'left' is required for Compare");
8123
0
        return NULL;
8124
0
    }
8125
9.67k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8126
9.67k
    if (!p)
8127
0
        return NULL;
8128
9.67k
    p->kind = Compare_kind;
8129
9.67k
    p->v.Compare.left = left;
8130
9.67k
    p->v.Compare.ops = ops;
8131
9.67k
    p->v.Compare.comparators = comparators;
8132
9.67k
    p->lineno = lineno;
8133
9.67k
    p->col_offset = col_offset;
8134
9.67k
    p->end_lineno = end_lineno;
8135
9.67k
    p->end_col_offset = end_col_offset;
8136
9.67k
    return p;
8137
9.67k
}
8138
8139
expr_ty
8140
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8141
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8142
            PyArena *arena)
8143
77.2k
{
8144
77.2k
    expr_ty p;
8145
77.2k
    if (!func) {
8146
0
        PyErr_SetString(PyExc_ValueError,
8147
0
                        "field 'func' is required for Call");
8148
0
        return NULL;
8149
0
    }
8150
77.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8151
77.2k
    if (!p)
8152
0
        return NULL;
8153
77.2k
    p->kind = Call_kind;
8154
77.2k
    p->v.Call.func = func;
8155
77.2k
    p->v.Call.args = args;
8156
77.2k
    p->v.Call.keywords = keywords;
8157
77.2k
    p->lineno = lineno;
8158
77.2k
    p->col_offset = col_offset;
8159
77.2k
    p->end_lineno = end_lineno;
8160
77.2k
    p->end_col_offset = end_col_offset;
8161
77.2k
    return p;
8162
77.2k
}
8163
8164
expr_ty
8165
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8166
                      lineno, int col_offset, int end_lineno, int
8167
                      end_col_offset, PyArena *arena)
8168
21.5k
{
8169
21.5k
    expr_ty p;
8170
21.5k
    if (!value) {
8171
0
        PyErr_SetString(PyExc_ValueError,
8172
0
                        "field 'value' is required for FormattedValue");
8173
0
        return NULL;
8174
0
    }
8175
21.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8176
21.5k
    if (!p)
8177
0
        return NULL;
8178
21.5k
    p->kind = FormattedValue_kind;
8179
21.5k
    p->v.FormattedValue.value = value;
8180
21.5k
    p->v.FormattedValue.conversion = conversion;
8181
21.5k
    p->v.FormattedValue.format_spec = format_spec;
8182
21.5k
    p->lineno = lineno;
8183
21.5k
    p->col_offset = col_offset;
8184
21.5k
    p->end_lineno = end_lineno;
8185
21.5k
    p->end_col_offset = end_col_offset;
8186
21.5k
    return p;
8187
21.5k
}
8188
8189
expr_ty
8190
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8191
                     format_spec, int lineno, int col_offset, int end_lineno,
8192
                     int end_col_offset, PyArena *arena)
8193
4.35k
{
8194
4.35k
    expr_ty p;
8195
4.35k
    if (!value) {
8196
0
        PyErr_SetString(PyExc_ValueError,
8197
0
                        "field 'value' is required for Interpolation");
8198
0
        return NULL;
8199
0
    }
8200
4.35k
    if (!str) {
8201
0
        PyErr_SetString(PyExc_ValueError,
8202
0
                        "field 'str' is required for Interpolation");
8203
0
        return NULL;
8204
0
    }
8205
4.35k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8206
4.35k
    if (!p)
8207
0
        return NULL;
8208
4.35k
    p->kind = Interpolation_kind;
8209
4.35k
    p->v.Interpolation.value = value;
8210
4.35k
    p->v.Interpolation.str = str;
8211
4.35k
    p->v.Interpolation.conversion = conversion;
8212
4.35k
    p->v.Interpolation.format_spec = format_spec;
8213
4.35k
    p->lineno = lineno;
8214
4.35k
    p->col_offset = col_offset;
8215
4.35k
    p->end_lineno = end_lineno;
8216
4.35k
    p->end_col_offset = end_col_offset;
8217
4.35k
    return p;
8218
4.35k
}
8219
8220
expr_ty
8221
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8222
                 end_lineno, int end_col_offset, PyArena *arena)
8223
34.8k
{
8224
34.8k
    expr_ty p;
8225
34.8k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8226
34.8k
    if (!p)
8227
0
        return NULL;
8228
34.8k
    p->kind = JoinedStr_kind;
8229
34.8k
    p->v.JoinedStr.values = values;
8230
34.8k
    p->lineno = lineno;
8231
34.8k
    p->col_offset = col_offset;
8232
34.8k
    p->end_lineno = end_lineno;
8233
34.8k
    p->end_col_offset = end_col_offset;
8234
34.8k
    return p;
8235
34.8k
}
8236
8237
expr_ty
8238
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8239
                   end_lineno, int end_col_offset, PyArena *arena)
8240
4.71k
{
8241
4.71k
    expr_ty p;
8242
4.71k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8243
4.71k
    if (!p)
8244
0
        return NULL;
8245
4.71k
    p->kind = TemplateStr_kind;
8246
4.71k
    p->v.TemplateStr.values = values;
8247
4.71k
    p->lineno = lineno;
8248
4.71k
    p->col_offset = col_offset;
8249
4.71k
    p->end_lineno = end_lineno;
8250
4.71k
    p->end_col_offset = end_col_offset;
8251
4.71k
    return p;
8252
4.71k
}
8253
8254
expr_ty
8255
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8256
                end_lineno, int end_col_offset, PyArena *arena)
8257
406k
{
8258
406k
    expr_ty p;
8259
406k
    if (!value) {
8260
3
        PyErr_SetString(PyExc_ValueError,
8261
3
                        "field 'value' is required for Constant");
8262
3
        return NULL;
8263
3
    }
8264
406k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8265
406k
    if (!p)
8266
0
        return NULL;
8267
406k
    p->kind = Constant_kind;
8268
406k
    p->v.Constant.value = value;
8269
406k
    p->v.Constant.kind = kind;
8270
406k
    p->lineno = lineno;
8271
406k
    p->col_offset = col_offset;
8272
406k
    p->end_lineno = end_lineno;
8273
406k
    p->end_col_offset = end_col_offset;
8274
406k
    return p;
8275
406k
}
8276
8277
expr_ty
8278
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8279
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8280
                 PyArena *arena)
8281
37.3k
{
8282
37.3k
    expr_ty p;
8283
37.3k
    if (!value) {
8284
0
        PyErr_SetString(PyExc_ValueError,
8285
0
                        "field 'value' is required for Attribute");
8286
0
        return NULL;
8287
0
    }
8288
37.3k
    if (!attr) {
8289
0
        PyErr_SetString(PyExc_ValueError,
8290
0
                        "field 'attr' is required for Attribute");
8291
0
        return NULL;
8292
0
    }
8293
37.3k
    if (!ctx) {
8294
0
        PyErr_SetString(PyExc_ValueError,
8295
0
                        "field 'ctx' is required for Attribute");
8296
0
        return NULL;
8297
0
    }
8298
37.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8299
37.3k
    if (!p)
8300
0
        return NULL;
8301
37.3k
    p->kind = Attribute_kind;
8302
37.3k
    p->v.Attribute.value = value;
8303
37.3k
    p->v.Attribute.attr = attr;
8304
37.3k
    p->v.Attribute.ctx = ctx;
8305
37.3k
    p->lineno = lineno;
8306
37.3k
    p->col_offset = col_offset;
8307
37.3k
    p->end_lineno = end_lineno;
8308
37.3k
    p->end_col_offset = end_col_offset;
8309
37.3k
    return p;
8310
37.3k
}
8311
8312
expr_ty
8313
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8314
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8315
                 *arena)
8316
9.09k
{
8317
9.09k
    expr_ty p;
8318
9.09k
    if (!value) {
8319
0
        PyErr_SetString(PyExc_ValueError,
8320
0
                        "field 'value' is required for Subscript");
8321
0
        return NULL;
8322
0
    }
8323
9.09k
    if (!slice) {
8324
0
        PyErr_SetString(PyExc_ValueError,
8325
0
                        "field 'slice' is required for Subscript");
8326
0
        return NULL;
8327
0
    }
8328
9.09k
    if (!ctx) {
8329
0
        PyErr_SetString(PyExc_ValueError,
8330
0
                        "field 'ctx' is required for Subscript");
8331
0
        return NULL;
8332
0
    }
8333
9.09k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8334
9.09k
    if (!p)
8335
0
        return NULL;
8336
9.09k
    p->kind = Subscript_kind;
8337
9.09k
    p->v.Subscript.value = value;
8338
9.09k
    p->v.Subscript.slice = slice;
8339
9.09k
    p->v.Subscript.ctx = ctx;
8340
9.09k
    p->lineno = lineno;
8341
9.09k
    p->col_offset = col_offset;
8342
9.09k
    p->end_lineno = end_lineno;
8343
9.09k
    p->end_col_offset = end_col_offset;
8344
9.09k
    return p;
8345
9.09k
}
8346
8347
expr_ty
8348
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8349
               int end_lineno, int end_col_offset, PyArena *arena)
8350
24.1k
{
8351
24.1k
    expr_ty p;
8352
24.1k
    if (!value) {
8353
0
        PyErr_SetString(PyExc_ValueError,
8354
0
                        "field 'value' is required for Starred");
8355
0
        return NULL;
8356
0
    }
8357
24.1k
    if (!ctx) {
8358
0
        PyErr_SetString(PyExc_ValueError,
8359
0
                        "field 'ctx' is required for Starred");
8360
0
        return NULL;
8361
0
    }
8362
24.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8363
24.1k
    if (!p)
8364
0
        return NULL;
8365
24.1k
    p->kind = Starred_kind;
8366
24.1k
    p->v.Starred.value = value;
8367
24.1k
    p->v.Starred.ctx = ctx;
8368
24.1k
    p->lineno = lineno;
8369
24.1k
    p->col_offset = col_offset;
8370
24.1k
    p->end_lineno = end_lineno;
8371
24.1k
    p->end_col_offset = end_col_offset;
8372
24.1k
    return p;
8373
24.1k
}
8374
8375
expr_ty
8376
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8377
            end_lineno, int end_col_offset, PyArena *arena)
8378
2.71M
{
8379
2.71M
    expr_ty p;
8380
2.71M
    if (!id) {
8381
0
        PyErr_SetString(PyExc_ValueError,
8382
0
                        "field 'id' is required for Name");
8383
0
        return NULL;
8384
0
    }
8385
2.71M
    if (!ctx) {
8386
0
        PyErr_SetString(PyExc_ValueError,
8387
0
                        "field 'ctx' is required for Name");
8388
0
        return NULL;
8389
0
    }
8390
2.71M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8391
2.71M
    if (!p)
8392
0
        return NULL;
8393
2.71M
    p->kind = Name_kind;
8394
2.71M
    p->v.Name.id = id;
8395
2.71M
    p->v.Name.ctx = ctx;
8396
2.71M
    p->lineno = lineno;
8397
2.71M
    p->col_offset = col_offset;
8398
2.71M
    p->end_lineno = end_lineno;
8399
2.71M
    p->end_col_offset = end_col_offset;
8400
2.71M
    return p;
8401
2.71M
}
8402
8403
expr_ty
8404
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8405
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8406
22.5k
{
8407
22.5k
    expr_ty p;
8408
22.5k
    if (!ctx) {
8409
0
        PyErr_SetString(PyExc_ValueError,
8410
0
                        "field 'ctx' is required for List");
8411
0
        return NULL;
8412
0
    }
8413
22.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8414
22.5k
    if (!p)
8415
0
        return NULL;
8416
22.5k
    p->kind = List_kind;
8417
22.5k
    p->v.List.elts = elts;
8418
22.5k
    p->v.List.ctx = ctx;
8419
22.5k
    p->lineno = lineno;
8420
22.5k
    p->col_offset = col_offset;
8421
22.5k
    p->end_lineno = end_lineno;
8422
22.5k
    p->end_col_offset = end_col_offset;
8423
22.5k
    return p;
8424
22.5k
}
8425
8426
expr_ty
8427
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8428
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8429
103k
{
8430
103k
    expr_ty p;
8431
103k
    if (!ctx) {
8432
0
        PyErr_SetString(PyExc_ValueError,
8433
0
                        "field 'ctx' is required for Tuple");
8434
0
        return NULL;
8435
0
    }
8436
103k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8437
103k
    if (!p)
8438
0
        return NULL;
8439
103k
    p->kind = Tuple_kind;
8440
103k
    p->v.Tuple.elts = elts;
8441
103k
    p->v.Tuple.ctx = ctx;
8442
103k
    p->lineno = lineno;
8443
103k
    p->col_offset = col_offset;
8444
103k
    p->end_lineno = end_lineno;
8445
103k
    p->end_col_offset = end_col_offset;
8446
103k
    return p;
8447
103k
}
8448
8449
expr_ty
8450
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8451
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8452
19.5k
{
8453
19.5k
    expr_ty p;
8454
19.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8455
19.5k
    if (!p)
8456
0
        return NULL;
8457
19.5k
    p->kind = Slice_kind;
8458
19.5k
    p->v.Slice.lower = lower;
8459
19.5k
    p->v.Slice.upper = upper;
8460
19.5k
    p->v.Slice.step = step;
8461
19.5k
    p->lineno = lineno;
8462
19.5k
    p->col_offset = col_offset;
8463
19.5k
    p->end_lineno = end_lineno;
8464
19.5k
    p->end_col_offset = end_col_offset;
8465
19.5k
    return p;
8466
19.5k
}
8467
8468
comprehension_ty
8469
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8470
                     is_async, PyArena *arena)
8471
10.9k
{
8472
10.9k
    comprehension_ty p;
8473
10.9k
    if (!target) {
8474
0
        PyErr_SetString(PyExc_ValueError,
8475
0
                        "field 'target' is required for comprehension");
8476
0
        return NULL;
8477
0
    }
8478
10.9k
    if (!iter) {
8479
0
        PyErr_SetString(PyExc_ValueError,
8480
0
                        "field 'iter' is required for comprehension");
8481
0
        return NULL;
8482
0
    }
8483
10.9k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8484
10.9k
    if (!p)
8485
0
        return NULL;
8486
10.9k
    p->target = target;
8487
10.9k
    p->iter = iter;
8488
10.9k
    p->ifs = ifs;
8489
10.9k
    p->is_async = is_async;
8490
10.9k
    return p;
8491
10.9k
}
8492
8493
excepthandler_ty
8494
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8495
                     lineno, int col_offset, int end_lineno, int
8496
                     end_col_offset, PyArena *arena)
8497
11.0k
{
8498
11.0k
    excepthandler_ty p;
8499
11.0k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8500
11.0k
    if (!p)
8501
0
        return NULL;
8502
11.0k
    p->kind = ExceptHandler_kind;
8503
11.0k
    p->v.ExceptHandler.type = type;
8504
11.0k
    p->v.ExceptHandler.name = name;
8505
11.0k
    p->v.ExceptHandler.body = body;
8506
11.0k
    p->lineno = lineno;
8507
11.0k
    p->col_offset = col_offset;
8508
11.0k
    p->end_lineno = end_lineno;
8509
11.0k
    p->end_col_offset = end_col_offset;
8510
11.0k
    return p;
8511
11.0k
}
8512
8513
arguments_ty
8514
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8515
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8516
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8517
                 *arena)
8518
21.3k
{
8519
21.3k
    arguments_ty p;
8520
21.3k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8521
21.3k
    if (!p)
8522
0
        return NULL;
8523
21.3k
    p->posonlyargs = posonlyargs;
8524
21.3k
    p->args = args;
8525
21.3k
    p->vararg = vararg;
8526
21.3k
    p->kwonlyargs = kwonlyargs;
8527
21.3k
    p->kw_defaults = kw_defaults;
8528
21.3k
    p->kwarg = kwarg;
8529
21.3k
    p->defaults = defaults;
8530
21.3k
    return p;
8531
21.3k
}
8532
8533
arg_ty
8534
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8535
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8536
662k
{
8537
662k
    arg_ty p;
8538
662k
    if (!arg) {
8539
0
        PyErr_SetString(PyExc_ValueError,
8540
0
                        "field 'arg' is required for arg");
8541
0
        return NULL;
8542
0
    }
8543
662k
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8544
662k
    if (!p)
8545
0
        return NULL;
8546
662k
    p->arg = arg;
8547
662k
    p->annotation = annotation;
8548
662k
    p->type_comment = type_comment;
8549
662k
    p->lineno = lineno;
8550
662k
    p->col_offset = col_offset;
8551
662k
    p->end_lineno = end_lineno;
8552
662k
    p->end_col_offset = end_col_offset;
8553
662k
    return p;
8554
662k
}
8555
8556
keyword_ty
8557
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8558
               end_lineno, int end_col_offset, PyArena *arena)
8559
32.4k
{
8560
32.4k
    keyword_ty p;
8561
32.4k
    if (!value) {
8562
0
        PyErr_SetString(PyExc_ValueError,
8563
0
                        "field 'value' is required for keyword");
8564
0
        return NULL;
8565
0
    }
8566
32.4k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8567
32.4k
    if (!p)
8568
0
        return NULL;
8569
32.4k
    p->arg = arg;
8570
32.4k
    p->value = value;
8571
32.4k
    p->lineno = lineno;
8572
32.4k
    p->col_offset = col_offset;
8573
32.4k
    p->end_lineno = end_lineno;
8574
32.4k
    p->end_col_offset = end_col_offset;
8575
32.4k
    return p;
8576
32.4k
}
8577
8578
alias_ty
8579
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8580
             int end_lineno, int end_col_offset, PyArena *arena)
8581
13.4k
{
8582
13.4k
    alias_ty p;
8583
13.4k
    if (!name) {
8584
0
        PyErr_SetString(PyExc_ValueError,
8585
0
                        "field 'name' is required for alias");
8586
0
        return NULL;
8587
0
    }
8588
13.4k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8589
13.4k
    if (!p)
8590
0
        return NULL;
8591
13.4k
    p->name = name;
8592
13.4k
    p->asname = asname;
8593
13.4k
    p->lineno = lineno;
8594
13.4k
    p->col_offset = col_offset;
8595
13.4k
    p->end_lineno = end_lineno;
8596
13.4k
    p->end_col_offset = end_col_offset;
8597
13.4k
    return p;
8598
13.4k
}
8599
8600
withitem_ty
8601
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8602
13.5k
{
8603
13.5k
    withitem_ty p;
8604
13.5k
    if (!context_expr) {
8605
0
        PyErr_SetString(PyExc_ValueError,
8606
0
                        "field 'context_expr' is required for withitem");
8607
0
        return NULL;
8608
0
    }
8609
13.5k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8610
13.5k
    if (!p)
8611
0
        return NULL;
8612
13.5k
    p->context_expr = context_expr;
8613
13.5k
    p->optional_vars = optional_vars;
8614
13.5k
    return p;
8615
13.5k
}
8616
8617
match_case_ty
8618
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8619
                  PyArena *arena)
8620
4.99k
{
8621
4.99k
    match_case_ty p;
8622
4.99k
    if (!pattern) {
8623
0
        PyErr_SetString(PyExc_ValueError,
8624
0
                        "field 'pattern' is required for match_case");
8625
0
        return NULL;
8626
0
    }
8627
4.99k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8628
4.99k
    if (!p)
8629
0
        return NULL;
8630
4.99k
    p->pattern = pattern;
8631
4.99k
    p->guard = guard;
8632
4.99k
    p->body = body;
8633
4.99k
    return p;
8634
4.99k
}
8635
8636
pattern_ty
8637
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8638
                  int end_col_offset, PyArena *arena)
8639
5.67k
{
8640
5.67k
    pattern_ty p;
8641
5.67k
    if (!value) {
8642
0
        PyErr_SetString(PyExc_ValueError,
8643
0
                        "field 'value' is required for MatchValue");
8644
0
        return NULL;
8645
0
    }
8646
5.67k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8647
5.67k
    if (!p)
8648
0
        return NULL;
8649
5.67k
    p->kind = MatchValue_kind;
8650
5.67k
    p->v.MatchValue.value = value;
8651
5.67k
    p->lineno = lineno;
8652
5.67k
    p->col_offset = col_offset;
8653
5.67k
    p->end_lineno = end_lineno;
8654
5.67k
    p->end_col_offset = end_col_offset;
8655
5.67k
    return p;
8656
5.67k
}
8657
8658
pattern_ty
8659
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8660
                      end_lineno, int end_col_offset, PyArena *arena)
8661
623
{
8662
623
    pattern_ty p;
8663
623
    if (!value) {
8664
0
        PyErr_SetString(PyExc_ValueError,
8665
0
                        "field 'value' is required for MatchSingleton");
8666
0
        return NULL;
8667
0
    }
8668
623
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8669
623
    if (!p)
8670
0
        return NULL;
8671
623
    p->kind = MatchSingleton_kind;
8672
623
    p->v.MatchSingleton.value = value;
8673
623
    p->lineno = lineno;
8674
623
    p->col_offset = col_offset;
8675
623
    p->end_lineno = end_lineno;
8676
623
    p->end_col_offset = end_col_offset;
8677
623
    return p;
8678
623
}
8679
8680
pattern_ty
8681
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8682
                     int end_lineno, int end_col_offset, PyArena *arena)
8683
5.07k
{
8684
5.07k
    pattern_ty p;
8685
5.07k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8686
5.07k
    if (!p)
8687
0
        return NULL;
8688
5.07k
    p->kind = MatchSequence_kind;
8689
5.07k
    p->v.MatchSequence.patterns = patterns;
8690
5.07k
    p->lineno = lineno;
8691
5.07k
    p->col_offset = col_offset;
8692
5.07k
    p->end_lineno = end_lineno;
8693
5.07k
    p->end_col_offset = end_col_offset;
8694
5.07k
    return p;
8695
5.07k
}
8696
8697
pattern_ty
8698
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8699
                    identifier rest, int lineno, int col_offset, int
8700
                    end_lineno, int end_col_offset, PyArena *arena)
8701
2.70k
{
8702
2.70k
    pattern_ty p;
8703
2.70k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8704
2.70k
    if (!p)
8705
0
        return NULL;
8706
2.70k
    p->kind = MatchMapping_kind;
8707
2.70k
    p->v.MatchMapping.keys = keys;
8708
2.70k
    p->v.MatchMapping.patterns = patterns;
8709
2.70k
    p->v.MatchMapping.rest = rest;
8710
2.70k
    p->lineno = lineno;
8711
2.70k
    p->col_offset = col_offset;
8712
2.70k
    p->end_lineno = end_lineno;
8713
2.70k
    p->end_col_offset = end_col_offset;
8714
2.70k
    return p;
8715
2.70k
}
8716
8717
pattern_ty
8718
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8719
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8720
                  col_offset, int end_lineno, int end_col_offset, PyArena
8721
                  *arena)
8722
2.26k
{
8723
2.26k
    pattern_ty p;
8724
2.26k
    if (!cls) {
8725
0
        PyErr_SetString(PyExc_ValueError,
8726
0
                        "field 'cls' is required for MatchClass");
8727
0
        return NULL;
8728
0
    }
8729
2.26k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8730
2.26k
    if (!p)
8731
0
        return NULL;
8732
2.26k
    p->kind = MatchClass_kind;
8733
2.26k
    p->v.MatchClass.cls = cls;
8734
2.26k
    p->v.MatchClass.patterns = patterns;
8735
2.26k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8736
2.26k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8737
2.26k
    p->lineno = lineno;
8738
2.26k
    p->col_offset = col_offset;
8739
2.26k
    p->end_lineno = end_lineno;
8740
2.26k
    p->end_col_offset = end_col_offset;
8741
2.26k
    return p;
8742
2.26k
}
8743
8744
pattern_ty
8745
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8746
                 int end_col_offset, PyArena *arena)
8747
1.94k
{
8748
1.94k
    pattern_ty p;
8749
1.94k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8750
1.94k
    if (!p)
8751
0
        return NULL;
8752
1.94k
    p->kind = MatchStar_kind;
8753
1.94k
    p->v.MatchStar.name = name;
8754
1.94k
    p->lineno = lineno;
8755
1.94k
    p->col_offset = col_offset;
8756
1.94k
    p->end_lineno = end_lineno;
8757
1.94k
    p->end_col_offset = end_col_offset;
8758
1.94k
    return p;
8759
1.94k
}
8760
8761
pattern_ty
8762
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8763
               int end_lineno, int end_col_offset, PyArena *arena)
8764
21.7k
{
8765
21.7k
    pattern_ty p;
8766
21.7k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8767
21.7k
    if (!p)
8768
0
        return NULL;
8769
21.7k
    p->kind = MatchAs_kind;
8770
21.7k
    p->v.MatchAs.pattern = pattern;
8771
21.7k
    p->v.MatchAs.name = name;
8772
21.7k
    p->lineno = lineno;
8773
21.7k
    p->col_offset = col_offset;
8774
21.7k
    p->end_lineno = end_lineno;
8775
21.7k
    p->end_col_offset = end_col_offset;
8776
21.7k
    return p;
8777
21.7k
}
8778
8779
pattern_ty
8780
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8781
               end_lineno, int end_col_offset, PyArena *arena)
8782
6.03k
{
8783
6.03k
    pattern_ty p;
8784
6.03k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8785
6.03k
    if (!p)
8786
0
        return NULL;
8787
6.03k
    p->kind = MatchOr_kind;
8788
6.03k
    p->v.MatchOr.patterns = patterns;
8789
6.03k
    p->lineno = lineno;
8790
6.03k
    p->col_offset = col_offset;
8791
6.03k
    p->end_lineno = end_lineno;
8792
6.03k
    p->end_col_offset = end_col_offset;
8793
6.03k
    return p;
8794
6.03k
}
8795
8796
type_ignore_ty
8797
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8798
0
{
8799
0
    type_ignore_ty p;
8800
0
    if (!tag) {
8801
0
        PyErr_SetString(PyExc_ValueError,
8802
0
                        "field 'tag' is required for TypeIgnore");
8803
0
        return NULL;
8804
0
    }
8805
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8806
0
    if (!p)
8807
0
        return NULL;
8808
0
    p->kind = TypeIgnore_kind;
8809
0
    p->v.TypeIgnore.lineno = lineno;
8810
0
    p->v.TypeIgnore.tag = tag;
8811
0
    return p;
8812
0
}
8813
8814
type_param_ty
8815
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8816
               lineno, int col_offset, int end_lineno, int end_col_offset,
8817
               PyArena *arena)
8818
5.48k
{
8819
5.48k
    type_param_ty p;
8820
5.48k
    if (!name) {
8821
0
        PyErr_SetString(PyExc_ValueError,
8822
0
                        "field 'name' is required for TypeVar");
8823
0
        return NULL;
8824
0
    }
8825
5.48k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8826
5.48k
    if (!p)
8827
0
        return NULL;
8828
5.48k
    p->kind = TypeVar_kind;
8829
5.48k
    p->v.TypeVar.name = name;
8830
5.48k
    p->v.TypeVar.bound = bound;
8831
5.48k
    p->v.TypeVar.default_value = default_value;
8832
5.48k
    p->lineno = lineno;
8833
5.48k
    p->col_offset = col_offset;
8834
5.48k
    p->end_lineno = end_lineno;
8835
5.48k
    p->end_col_offset = end_col_offset;
8836
5.48k
    return p;
8837
5.48k
}
8838
8839
type_param_ty
8840
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8841
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8842
1.02k
{
8843
1.02k
    type_param_ty p;
8844
1.02k
    if (!name) {
8845
0
        PyErr_SetString(PyExc_ValueError,
8846
0
                        "field 'name' is required for ParamSpec");
8847
0
        return NULL;
8848
0
    }
8849
1.02k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8850
1.02k
    if (!p)
8851
0
        return NULL;
8852
1.02k
    p->kind = ParamSpec_kind;
8853
1.02k
    p->v.ParamSpec.name = name;
8854
1.02k
    p->v.ParamSpec.default_value = default_value;
8855
1.02k
    p->lineno = lineno;
8856
1.02k
    p->col_offset = col_offset;
8857
1.02k
    p->end_lineno = end_lineno;
8858
1.02k
    p->end_col_offset = end_col_offset;
8859
1.02k
    return p;
8860
1.02k
}
8861
8862
type_param_ty
8863
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8864
                    col_offset, int end_lineno, int end_col_offset, PyArena
8865
                    *arena)
8866
1.76k
{
8867
1.76k
    type_param_ty p;
8868
1.76k
    if (!name) {
8869
0
        PyErr_SetString(PyExc_ValueError,
8870
0
                        "field 'name' is required for TypeVarTuple");
8871
0
        return NULL;
8872
0
    }
8873
1.76k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8874
1.76k
    if (!p)
8875
0
        return NULL;
8876
1.76k
    p->kind = TypeVarTuple_kind;
8877
1.76k
    p->v.TypeVarTuple.name = name;
8878
1.76k
    p->v.TypeVarTuple.default_value = default_value;
8879
1.76k
    p->lineno = lineno;
8880
1.76k
    p->col_offset = col_offset;
8881
1.76k
    p->end_lineno = end_lineno;
8882
1.76k
    p->end_col_offset = end_col_offset;
8883
1.76k
    return p;
8884
1.76k
}
8885
8886
8887
PyObject*
8888
ast2obj_mod(struct ast_state *state, void* _o)
8889
7.57k
{
8890
7.57k
    mod_ty o = (mod_ty)_o;
8891
7.57k
    PyObject *result = NULL, *value = NULL;
8892
7.57k
    PyTypeObject *tp;
8893
7.57k
    if (!o) {
8894
0
        Py_RETURN_NONE;
8895
0
    }
8896
7.57k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8897
0
        return NULL;
8898
0
    }
8899
7.57k
    switch (o->kind) {
8900
7.57k
    case Module_kind:
8901
7.57k
        tp = (PyTypeObject *)state->Module_type;
8902
7.57k
        result = PyType_GenericNew(tp, NULL, NULL);
8903
7.57k
        if (!result) goto failed;
8904
7.57k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8905
7.57k
        if (!value) goto failed;
8906
7.57k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8907
0
            goto failed;
8908
7.57k
        Py_DECREF(value);
8909
7.57k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8910
7.57k
                             ast2obj_type_ignore);
8911
7.57k
        if (!value) goto failed;
8912
7.57k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8913
0
            goto failed;
8914
7.57k
        Py_DECREF(value);
8915
7.57k
        break;
8916
0
    case Interactive_kind:
8917
0
        tp = (PyTypeObject *)state->Interactive_type;
8918
0
        result = PyType_GenericNew(tp, NULL, NULL);
8919
0
        if (!result) goto failed;
8920
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8921
0
                             ast2obj_stmt);
8922
0
        if (!value) goto failed;
8923
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8924
0
            goto failed;
8925
0
        Py_DECREF(value);
8926
0
        break;
8927
0
    case Expression_kind:
8928
0
        tp = (PyTypeObject *)state->Expression_type;
8929
0
        result = PyType_GenericNew(tp, NULL, NULL);
8930
0
        if (!result) goto failed;
8931
0
        value = ast2obj_expr(state, o->v.Expression.body);
8932
0
        if (!value) goto failed;
8933
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8934
0
            goto failed;
8935
0
        Py_DECREF(value);
8936
0
        break;
8937
0
    case FunctionType_kind:
8938
0
        tp = (PyTypeObject *)state->FunctionType_type;
8939
0
        result = PyType_GenericNew(tp, NULL, NULL);
8940
0
        if (!result) goto failed;
8941
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8942
0
                             ast2obj_expr);
8943
0
        if (!value) goto failed;
8944
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8945
0
            goto failed;
8946
0
        Py_DECREF(value);
8947
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8948
0
        if (!value) goto failed;
8949
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8950
0
            goto failed;
8951
0
        Py_DECREF(value);
8952
0
        break;
8953
7.57k
    }
8954
7.57k
    Py_LeaveRecursiveCall();
8955
7.57k
    return result;
8956
0
failed:
8957
0
    Py_LeaveRecursiveCall();
8958
0
    Py_XDECREF(value);
8959
0
    Py_XDECREF(result);
8960
0
    return NULL;
8961
7.57k
}
8962
8963
PyObject*
8964
ast2obj_stmt(struct ast_state *state, void* _o)
8965
56.1k
{
8966
56.1k
    stmt_ty o = (stmt_ty)_o;
8967
56.1k
    PyObject *result = NULL, *value = NULL;
8968
56.1k
    PyTypeObject *tp;
8969
56.1k
    if (!o) {
8970
0
        Py_RETURN_NONE;
8971
0
    }
8972
56.1k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8973
0
        return NULL;
8974
0
    }
8975
56.1k
    switch (o->kind) {
8976
1.84k
    case FunctionDef_kind:
8977
1.84k
        tp = (PyTypeObject *)state->FunctionDef_type;
8978
1.84k
        result = PyType_GenericNew(tp, NULL, NULL);
8979
1.84k
        if (!result) goto failed;
8980
1.84k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8981
1.84k
        if (!value) goto failed;
8982
1.84k
        if (PyObject_SetAttr(result, state->name, value) == -1)
8983
0
            goto failed;
8984
1.84k
        Py_DECREF(value);
8985
1.84k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8986
1.84k
        if (!value) goto failed;
8987
1.84k
        if (PyObject_SetAttr(result, state->args, value) == -1)
8988
0
            goto failed;
8989
1.84k
        Py_DECREF(value);
8990
1.84k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8991
1.84k
                             ast2obj_stmt);
8992
1.84k
        if (!value) goto failed;
8993
1.84k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8994
0
            goto failed;
8995
1.84k
        Py_DECREF(value);
8996
1.84k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8997
1.84k
                             ast2obj_expr);
8998
1.84k
        if (!value) goto failed;
8999
1.84k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9000
0
            goto failed;
9001
1.84k
        Py_DECREF(value);
9002
1.84k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
9003
1.84k
        if (!value) goto failed;
9004
1.84k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9005
0
            goto failed;
9006
1.84k
        Py_DECREF(value);
9007
1.84k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
9008
1.84k
        if (!value) goto failed;
9009
1.84k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9010
0
            goto failed;
9011
1.84k
        Py_DECREF(value);
9012
1.84k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
9013
1.84k
                             ast2obj_type_param);
9014
1.84k
        if (!value) goto failed;
9015
1.84k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9016
0
            goto failed;
9017
1.84k
        Py_DECREF(value);
9018
1.84k
        break;
9019
387
    case AsyncFunctionDef_kind:
9020
387
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9021
387
        result = PyType_GenericNew(tp, NULL, NULL);
9022
387
        if (!result) goto failed;
9023
387
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9024
387
        if (!value) goto failed;
9025
387
        if (PyObject_SetAttr(result, state->name, value) == -1)
9026
0
            goto failed;
9027
387
        Py_DECREF(value);
9028
387
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9029
387
        if (!value) goto failed;
9030
387
        if (PyObject_SetAttr(result, state->args, value) == -1)
9031
0
            goto failed;
9032
387
        Py_DECREF(value);
9033
387
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9034
387
                             ast2obj_stmt);
9035
387
        if (!value) goto failed;
9036
387
        if (PyObject_SetAttr(result, state->body, value) == -1)
9037
0
            goto failed;
9038
387
        Py_DECREF(value);
9039
387
        value = ast2obj_list(state,
9040
387
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9041
387
                             ast2obj_expr);
9042
387
        if (!value) goto failed;
9043
387
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9044
0
            goto failed;
9045
387
        Py_DECREF(value);
9046
387
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9047
387
        if (!value) goto failed;
9048
387
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9049
0
            goto failed;
9050
387
        Py_DECREF(value);
9051
387
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9052
387
        if (!value) goto failed;
9053
387
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9054
0
            goto failed;
9055
387
        Py_DECREF(value);
9056
387
        value = ast2obj_list(state,
9057
387
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9058
387
                             ast2obj_type_param);
9059
387
        if (!value) goto failed;
9060
387
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9061
0
            goto failed;
9062
387
        Py_DECREF(value);
9063
387
        break;
9064
934
    case ClassDef_kind:
9065
934
        tp = (PyTypeObject *)state->ClassDef_type;
9066
934
        result = PyType_GenericNew(tp, NULL, NULL);
9067
934
        if (!result) goto failed;
9068
934
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9069
934
        if (!value) goto failed;
9070
934
        if (PyObject_SetAttr(result, state->name, value) == -1)
9071
0
            goto failed;
9072
934
        Py_DECREF(value);
9073
934
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9074
934
                             ast2obj_expr);
9075
934
        if (!value) goto failed;
9076
934
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9077
0
            goto failed;
9078
934
        Py_DECREF(value);
9079
934
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9080
934
                             ast2obj_keyword);
9081
934
        if (!value) goto failed;
9082
934
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9083
0
            goto failed;
9084
934
        Py_DECREF(value);
9085
934
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9086
934
                             ast2obj_stmt);
9087
934
        if (!value) goto failed;
9088
934
        if (PyObject_SetAttr(result, state->body, value) == -1)
9089
0
            goto failed;
9090
934
        Py_DECREF(value);
9091
934
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9092
934
                             ast2obj_expr);
9093
934
        if (!value) goto failed;
9094
934
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9095
0
            goto failed;
9096
934
        Py_DECREF(value);
9097
934
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9098
934
                             ast2obj_type_param);
9099
934
        if (!value) goto failed;
9100
934
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9101
0
            goto failed;
9102
934
        Py_DECREF(value);
9103
934
        break;
9104
2.80k
    case Return_kind:
9105
2.80k
        tp = (PyTypeObject *)state->Return_type;
9106
2.80k
        result = PyType_GenericNew(tp, NULL, NULL);
9107
2.80k
        if (!result) goto failed;
9108
2.80k
        value = ast2obj_expr(state, o->v.Return.value);
9109
2.80k
        if (!value) goto failed;
9110
2.80k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9111
0
            goto failed;
9112
2.80k
        Py_DECREF(value);
9113
2.80k
        break;
9114
360
    case Delete_kind:
9115
360
        tp = (PyTypeObject *)state->Delete_type;
9116
360
        result = PyType_GenericNew(tp, NULL, NULL);
9117
360
        if (!result) goto failed;
9118
360
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9119
360
                             ast2obj_expr);
9120
360
        if (!value) goto failed;
9121
360
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9122
0
            goto failed;
9123
360
        Py_DECREF(value);
9124
360
        break;
9125
991
    case Assign_kind:
9126
991
        tp = (PyTypeObject *)state->Assign_type;
9127
991
        result = PyType_GenericNew(tp, NULL, NULL);
9128
991
        if (!result) goto failed;
9129
991
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9130
991
                             ast2obj_expr);
9131
991
        if (!value) goto failed;
9132
991
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9133
0
            goto failed;
9134
991
        Py_DECREF(value);
9135
991
        value = ast2obj_expr(state, o->v.Assign.value);
9136
991
        if (!value) goto failed;
9137
991
        if (PyObject_SetAttr(result, state->value, value) == -1)
9138
0
            goto failed;
9139
991
        Py_DECREF(value);
9140
991
        value = ast2obj_string(state, o->v.Assign.type_comment);
9141
991
        if (!value) goto failed;
9142
991
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9143
0
            goto failed;
9144
991
        Py_DECREF(value);
9145
991
        break;
9146
217
    case TypeAlias_kind:
9147
217
        tp = (PyTypeObject *)state->TypeAlias_type;
9148
217
        result = PyType_GenericNew(tp, NULL, NULL);
9149
217
        if (!result) goto failed;
9150
217
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9151
217
        if (!value) goto failed;
9152
217
        if (PyObject_SetAttr(result, state->name, value) == -1)
9153
0
            goto failed;
9154
217
        Py_DECREF(value);
9155
217
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9156
217
                             ast2obj_type_param);
9157
217
        if (!value) goto failed;
9158
217
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9159
0
            goto failed;
9160
217
        Py_DECREF(value);
9161
217
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9162
217
        if (!value) goto failed;
9163
217
        if (PyObject_SetAttr(result, state->value, value) == -1)
9164
0
            goto failed;
9165
217
        Py_DECREF(value);
9166
217
        break;
9167
238
    case AugAssign_kind:
9168
238
        tp = (PyTypeObject *)state->AugAssign_type;
9169
238
        result = PyType_GenericNew(tp, NULL, NULL);
9170
238
        if (!result) goto failed;
9171
238
        value = ast2obj_expr(state, o->v.AugAssign.target);
9172
238
        if (!value) goto failed;
9173
238
        if (PyObject_SetAttr(result, state->target, value) == -1)
9174
0
            goto failed;
9175
238
        Py_DECREF(value);
9176
238
        value = ast2obj_operator(state, o->v.AugAssign.op);
9177
238
        if (!value) goto failed;
9178
238
        if (PyObject_SetAttr(result, state->op, value) == -1)
9179
0
            goto failed;
9180
238
        Py_DECREF(value);
9181
238
        value = ast2obj_expr(state, o->v.AugAssign.value);
9182
238
        if (!value) goto failed;
9183
238
        if (PyObject_SetAttr(result, state->value, value) == -1)
9184
0
            goto failed;
9185
238
        Py_DECREF(value);
9186
238
        break;
9187
1.18k
    case AnnAssign_kind:
9188
1.18k
        tp = (PyTypeObject *)state->AnnAssign_type;
9189
1.18k
        result = PyType_GenericNew(tp, NULL, NULL);
9190
1.18k
        if (!result) goto failed;
9191
1.18k
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9192
1.18k
        if (!value) goto failed;
9193
1.18k
        if (PyObject_SetAttr(result, state->target, value) == -1)
9194
0
            goto failed;
9195
1.18k
        Py_DECREF(value);
9196
1.18k
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9197
1.18k
        if (!value) goto failed;
9198
1.18k
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9199
0
            goto failed;
9200
1.18k
        Py_DECREF(value);
9201
1.18k
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9202
1.18k
        if (!value) goto failed;
9203
1.18k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9204
0
            goto failed;
9205
1.18k
        Py_DECREF(value);
9206
1.18k
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9207
1.18k
        if (!value) goto failed;
9208
1.18k
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9209
0
            goto failed;
9210
1.18k
        Py_DECREF(value);
9211
1.18k
        break;
9212
290
    case For_kind:
9213
290
        tp = (PyTypeObject *)state->For_type;
9214
290
        result = PyType_GenericNew(tp, NULL, NULL);
9215
290
        if (!result) goto failed;
9216
290
        value = ast2obj_expr(state, o->v.For.target);
9217
290
        if (!value) goto failed;
9218
290
        if (PyObject_SetAttr(result, state->target, value) == -1)
9219
0
            goto failed;
9220
290
        Py_DECREF(value);
9221
290
        value = ast2obj_expr(state, o->v.For.iter);
9222
290
        if (!value) goto failed;
9223
290
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9224
0
            goto failed;
9225
290
        Py_DECREF(value);
9226
290
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9227
290
        if (!value) goto failed;
9228
290
        if (PyObject_SetAttr(result, state->body, value) == -1)
9229
0
            goto failed;
9230
290
        Py_DECREF(value);
9231
290
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9232
290
        if (!value) goto failed;
9233
290
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9234
0
            goto failed;
9235
290
        Py_DECREF(value);
9236
290
        value = ast2obj_string(state, o->v.For.type_comment);
9237
290
        if (!value) goto failed;
9238
290
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9239
0
            goto failed;
9240
290
        Py_DECREF(value);
9241
290
        break;
9242
138
    case AsyncFor_kind:
9243
138
        tp = (PyTypeObject *)state->AsyncFor_type;
9244
138
        result = PyType_GenericNew(tp, NULL, NULL);
9245
138
        if (!result) goto failed;
9246
138
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9247
138
        if (!value) goto failed;
9248
138
        if (PyObject_SetAttr(result, state->target, value) == -1)
9249
0
            goto failed;
9250
138
        Py_DECREF(value);
9251
138
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9252
138
        if (!value) goto failed;
9253
138
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9254
0
            goto failed;
9255
138
        Py_DECREF(value);
9256
138
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9257
138
                             ast2obj_stmt);
9258
138
        if (!value) goto failed;
9259
138
        if (PyObject_SetAttr(result, state->body, value) == -1)
9260
0
            goto failed;
9261
138
        Py_DECREF(value);
9262
138
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9263
138
                             ast2obj_stmt);
9264
138
        if (!value) goto failed;
9265
138
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9266
0
            goto failed;
9267
138
        Py_DECREF(value);
9268
138
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9269
138
        if (!value) goto failed;
9270
138
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9271
0
            goto failed;
9272
138
        Py_DECREF(value);
9273
138
        break;
9274
280
    case While_kind:
9275
280
        tp = (PyTypeObject *)state->While_type;
9276
280
        result = PyType_GenericNew(tp, NULL, NULL);
9277
280
        if (!result) goto failed;
9278
280
        value = ast2obj_expr(state, o->v.While.test);
9279
280
        if (!value) goto failed;
9280
280
        if (PyObject_SetAttr(result, state->test, value) == -1)
9281
0
            goto failed;
9282
280
        Py_DECREF(value);
9283
280
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9284
280
        if (!value) goto failed;
9285
280
        if (PyObject_SetAttr(result, state->body, value) == -1)
9286
0
            goto failed;
9287
280
        Py_DECREF(value);
9288
280
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9289
280
        if (!value) goto failed;
9290
280
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9291
0
            goto failed;
9292
280
        Py_DECREF(value);
9293
280
        break;
9294
656
    case If_kind:
9295
656
        tp = (PyTypeObject *)state->If_type;
9296
656
        result = PyType_GenericNew(tp, NULL, NULL);
9297
656
        if (!result) goto failed;
9298
656
        value = ast2obj_expr(state, o->v.If.test);
9299
656
        if (!value) goto failed;
9300
656
        if (PyObject_SetAttr(result, state->test, value) == -1)
9301
0
            goto failed;
9302
656
        Py_DECREF(value);
9303
656
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9304
656
        if (!value) goto failed;
9305
656
        if (PyObject_SetAttr(result, state->body, value) == -1)
9306
0
            goto failed;
9307
656
        Py_DECREF(value);
9308
656
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9309
656
        if (!value) goto failed;
9310
656
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9311
0
            goto failed;
9312
656
        Py_DECREF(value);
9313
656
        break;
9314
358
    case With_kind:
9315
358
        tp = (PyTypeObject *)state->With_type;
9316
358
        result = PyType_GenericNew(tp, NULL, NULL);
9317
358
        if (!result) goto failed;
9318
358
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9319
358
                             ast2obj_withitem);
9320
358
        if (!value) goto failed;
9321
358
        if (PyObject_SetAttr(result, state->items, value) == -1)
9322
0
            goto failed;
9323
358
        Py_DECREF(value);
9324
358
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9325
358
        if (!value) goto failed;
9326
358
        if (PyObject_SetAttr(result, state->body, value) == -1)
9327
0
            goto failed;
9328
358
        Py_DECREF(value);
9329
358
        value = ast2obj_string(state, o->v.With.type_comment);
9330
358
        if (!value) goto failed;
9331
358
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9332
0
            goto failed;
9333
358
        Py_DECREF(value);
9334
358
        break;
9335
127
    case AsyncWith_kind:
9336
127
        tp = (PyTypeObject *)state->AsyncWith_type;
9337
127
        result = PyType_GenericNew(tp, NULL, NULL);
9338
127
        if (!result) goto failed;
9339
127
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9340
127
                             ast2obj_withitem);
9341
127
        if (!value) goto failed;
9342
127
        if (PyObject_SetAttr(result, state->items, value) == -1)
9343
0
            goto failed;
9344
127
        Py_DECREF(value);
9345
127
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9346
127
                             ast2obj_stmt);
9347
127
        if (!value) goto failed;
9348
127
        if (PyObject_SetAttr(result, state->body, value) == -1)
9349
0
            goto failed;
9350
127
        Py_DECREF(value);
9351
127
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9352
127
        if (!value) goto failed;
9353
127
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9354
0
            goto failed;
9355
127
        Py_DECREF(value);
9356
127
        break;
9357
300
    case Match_kind:
9358
300
        tp = (PyTypeObject *)state->Match_type;
9359
300
        result = PyType_GenericNew(tp, NULL, NULL);
9360
300
        if (!result) goto failed;
9361
300
        value = ast2obj_expr(state, o->v.Match.subject);
9362
300
        if (!value) goto failed;
9363
300
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9364
0
            goto failed;
9365
300
        Py_DECREF(value);
9366
300
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9367
300
                             ast2obj_match_case);
9368
300
        if (!value) goto failed;
9369
300
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9370
0
            goto failed;
9371
300
        Py_DECREF(value);
9372
300
        break;
9373
669
    case Raise_kind:
9374
669
        tp = (PyTypeObject *)state->Raise_type;
9375
669
        result = PyType_GenericNew(tp, NULL, NULL);
9376
669
        if (!result) goto failed;
9377
669
        value = ast2obj_expr(state, o->v.Raise.exc);
9378
669
        if (!value) goto failed;
9379
669
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9380
0
            goto failed;
9381
669
        Py_DECREF(value);
9382
669
        value = ast2obj_expr(state, o->v.Raise.cause);
9383
669
        if (!value) goto failed;
9384
669
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9385
0
            goto failed;
9386
669
        Py_DECREF(value);
9387
669
        break;
9388
747
    case Try_kind:
9389
747
        tp = (PyTypeObject *)state->Try_type;
9390
747
        result = PyType_GenericNew(tp, NULL, NULL);
9391
747
        if (!result) goto failed;
9392
747
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9393
747
        if (!value) goto failed;
9394
747
        if (PyObject_SetAttr(result, state->body, value) == -1)
9395
0
            goto failed;
9396
747
        Py_DECREF(value);
9397
747
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9398
747
                             ast2obj_excepthandler);
9399
747
        if (!value) goto failed;
9400
747
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9401
0
            goto failed;
9402
747
        Py_DECREF(value);
9403
747
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9404
747
        if (!value) goto failed;
9405
747
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9406
0
            goto failed;
9407
747
        Py_DECREF(value);
9408
747
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9409
747
                             ast2obj_stmt);
9410
747
        if (!value) goto failed;
9411
747
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9412
0
            goto failed;
9413
747
        Py_DECREF(value);
9414
747
        break;
9415
432
    case TryStar_kind:
9416
432
        tp = (PyTypeObject *)state->TryStar_type;
9417
432
        result = PyType_GenericNew(tp, NULL, NULL);
9418
432
        if (!result) goto failed;
9419
432
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9420
432
        if (!value) goto failed;
9421
432
        if (PyObject_SetAttr(result, state->body, value) == -1)
9422
0
            goto failed;
9423
432
        Py_DECREF(value);
9424
432
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9425
432
                             ast2obj_excepthandler);
9426
432
        if (!value) goto failed;
9427
432
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9428
0
            goto failed;
9429
432
        Py_DECREF(value);
9430
432
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9431
432
                             ast2obj_stmt);
9432
432
        if (!value) goto failed;
9433
432
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9434
0
            goto failed;
9435
432
        Py_DECREF(value);
9436
432
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9437
432
                             ast2obj_stmt);
9438
432
        if (!value) goto failed;
9439
432
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9440
0
            goto failed;
9441
432
        Py_DECREF(value);
9442
432
        break;
9443
261
    case Assert_kind:
9444
261
        tp = (PyTypeObject *)state->Assert_type;
9445
261
        result = PyType_GenericNew(tp, NULL, NULL);
9446
261
        if (!result) goto failed;
9447
261
        value = ast2obj_expr(state, o->v.Assert.test);
9448
261
        if (!value) goto failed;
9449
261
        if (PyObject_SetAttr(result, state->test, value) == -1)
9450
0
            goto failed;
9451
261
        Py_DECREF(value);
9452
261
        value = ast2obj_expr(state, o->v.Assert.msg);
9453
261
        if (!value) goto failed;
9454
261
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9455
0
            goto failed;
9456
261
        Py_DECREF(value);
9457
261
        break;
9458
443
    case Import_kind:
9459
443
        tp = (PyTypeObject *)state->Import_type;
9460
443
        result = PyType_GenericNew(tp, NULL, NULL);
9461
443
        if (!result) goto failed;
9462
443
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9463
443
                             ast2obj_alias);
9464
443
        if (!value) goto failed;
9465
443
        if (PyObject_SetAttr(result, state->names, value) == -1)
9466
0
            goto failed;
9467
443
        Py_DECREF(value);
9468
443
        break;
9469
838
    case ImportFrom_kind:
9470
838
        tp = (PyTypeObject *)state->ImportFrom_type;
9471
838
        result = PyType_GenericNew(tp, NULL, NULL);
9472
838
        if (!result) goto failed;
9473
838
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9474
838
        if (!value) goto failed;
9475
838
        if (PyObject_SetAttr(result, state->module, value) == -1)
9476
0
            goto failed;
9477
838
        Py_DECREF(value);
9478
838
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9479
838
                             ast2obj_alias);
9480
838
        if (!value) goto failed;
9481
838
        if (PyObject_SetAttr(result, state->names, value) == -1)
9482
0
            goto failed;
9483
838
        Py_DECREF(value);
9484
838
        value = ast2obj_int(state, o->v.ImportFrom.level);
9485
838
        if (!value) goto failed;
9486
838
        if (PyObject_SetAttr(result, state->level, value) == -1)
9487
0
            goto failed;
9488
838
        Py_DECREF(value);
9489
838
        break;
9490
161
    case Global_kind:
9491
161
        tp = (PyTypeObject *)state->Global_type;
9492
161
        result = PyType_GenericNew(tp, NULL, NULL);
9493
161
        if (!result) goto failed;
9494
161
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9495
161
                             ast2obj_identifier);
9496
161
        if (!value) goto failed;
9497
161
        if (PyObject_SetAttr(result, state->names, value) == -1)
9498
0
            goto failed;
9499
161
        Py_DECREF(value);
9500
161
        break;
9501
746
    case Nonlocal_kind:
9502
746
        tp = (PyTypeObject *)state->Nonlocal_type;
9503
746
        result = PyType_GenericNew(tp, NULL, NULL);
9504
746
        if (!result) goto failed;
9505
746
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9506
746
                             ast2obj_identifier);
9507
746
        if (!value) goto failed;
9508
746
        if (PyObject_SetAttr(result, state->names, value) == -1)
9509
0
            goto failed;
9510
746
        Py_DECREF(value);
9511
746
        break;
9512
40.0k
    case Expr_kind:
9513
40.0k
        tp = (PyTypeObject *)state->Expr_type;
9514
40.0k
        result = PyType_GenericNew(tp, NULL, NULL);
9515
40.0k
        if (!result) goto failed;
9516
40.0k
        value = ast2obj_expr(state, o->v.Expr.value);
9517
40.0k
        if (!value) goto failed;
9518
40.0k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9519
0
            goto failed;
9520
40.0k
        Py_DECREF(value);
9521
40.0k
        break;
9522
219
    case Pass_kind:
9523
219
        tp = (PyTypeObject *)state->Pass_type;
9524
219
        result = PyType_GenericNew(tp, NULL, NULL);
9525
219
        if (!result) goto failed;
9526
219
        break;
9527
293
    case Break_kind:
9528
293
        tp = (PyTypeObject *)state->Break_type;
9529
293
        result = PyType_GenericNew(tp, NULL, NULL);
9530
293
        if (!result) goto failed;
9531
293
        break;
9532
293
    case Continue_kind:
9533
212
        tp = (PyTypeObject *)state->Continue_type;
9534
212
        result = PyType_GenericNew(tp, NULL, NULL);
9535
212
        if (!result) goto failed;
9536
212
        break;
9537
56.1k
    }
9538
56.1k
    value = ast2obj_int(state, o->lineno);
9539
56.1k
    if (!value) goto failed;
9540
56.1k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9541
0
        goto failed;
9542
56.1k
    Py_DECREF(value);
9543
56.1k
    value = ast2obj_int(state, o->col_offset);
9544
56.1k
    if (!value) goto failed;
9545
56.1k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9546
0
        goto failed;
9547
56.1k
    Py_DECREF(value);
9548
56.1k
    value = ast2obj_int(state, o->end_lineno);
9549
56.1k
    if (!value) goto failed;
9550
56.1k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9551
0
        goto failed;
9552
56.1k
    Py_DECREF(value);
9553
56.1k
    value = ast2obj_int(state, o->end_col_offset);
9554
56.1k
    if (!value) goto failed;
9555
56.1k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9556
0
        goto failed;
9557
56.1k
    Py_DECREF(value);
9558
56.1k
    Py_LeaveRecursiveCall();
9559
56.1k
    return result;
9560
0
failed:
9561
0
    Py_LeaveRecursiveCall();
9562
0
    Py_XDECREF(value);
9563
0
    Py_XDECREF(result);
9564
0
    return NULL;
9565
56.1k
}
9566
9567
PyObject*
9568
ast2obj_expr(struct ast_state *state, void* _o)
9569
464k
{
9570
464k
    expr_ty o = (expr_ty)_o;
9571
464k
    PyObject *result = NULL, *value = NULL;
9572
464k
    PyTypeObject *tp;
9573
464k
    if (!o) {
9574
48.8k
        Py_RETURN_NONE;
9575
48.8k
    }
9576
415k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9577
0
        return NULL;
9578
0
    }
9579
415k
    switch (o->kind) {
9580
666
    case BoolOp_kind:
9581
666
        tp = (PyTypeObject *)state->BoolOp_type;
9582
666
        result = PyType_GenericNew(tp, NULL, NULL);
9583
666
        if (!result) goto failed;
9584
666
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9585
666
        if (!value) goto failed;
9586
666
        if (PyObject_SetAttr(result, state->op, value) == -1)
9587
0
            goto failed;
9588
666
        Py_DECREF(value);
9589
666
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9590
666
                             ast2obj_expr);
9591
666
        if (!value) goto failed;
9592
666
        if (PyObject_SetAttr(result, state->values, value) == -1)
9593
0
            goto failed;
9594
666
        Py_DECREF(value);
9595
666
        break;
9596
223
    case NamedExpr_kind:
9597
223
        tp = (PyTypeObject *)state->NamedExpr_type;
9598
223
        result = PyType_GenericNew(tp, NULL, NULL);
9599
223
        if (!result) goto failed;
9600
223
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9601
223
        if (!value) goto failed;
9602
223
        if (PyObject_SetAttr(result, state->target, value) == -1)
9603
0
            goto failed;
9604
223
        Py_DECREF(value);
9605
223
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9606
223
        if (!value) goto failed;
9607
223
        if (PyObject_SetAttr(result, state->value, value) == -1)
9608
0
            goto failed;
9609
223
        Py_DECREF(value);
9610
223
        break;
9611
26.3k
    case BinOp_kind:
9612
26.3k
        tp = (PyTypeObject *)state->BinOp_type;
9613
26.3k
        result = PyType_GenericNew(tp, NULL, NULL);
9614
26.3k
        if (!result) goto failed;
9615
26.3k
        value = ast2obj_expr(state, o->v.BinOp.left);
9616
26.3k
        if (!value) goto failed;
9617
26.3k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9618
0
            goto failed;
9619
26.3k
        Py_DECREF(value);
9620
26.3k
        value = ast2obj_operator(state, o->v.BinOp.op);
9621
26.3k
        if (!value) goto failed;
9622
26.3k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9623
0
            goto failed;
9624
26.3k
        Py_DECREF(value);
9625
26.3k
        value = ast2obj_expr(state, o->v.BinOp.right);
9626
26.3k
        if (!value) goto failed;
9627
26.3k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9628
0
            goto failed;
9629
26.3k
        Py_DECREF(value);
9630
26.3k
        break;
9631
177k
    case UnaryOp_kind:
9632
177k
        tp = (PyTypeObject *)state->UnaryOp_type;
9633
177k
        result = PyType_GenericNew(tp, NULL, NULL);
9634
177k
        if (!result) goto failed;
9635
177k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9636
177k
        if (!value) goto failed;
9637
177k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9638
0
            goto failed;
9639
177k
        Py_DECREF(value);
9640
177k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9641
177k
        if (!value) goto failed;
9642
177k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9643
0
            goto failed;
9644
177k
        Py_DECREF(value);
9645
177k
        break;
9646
1.34k
    case Lambda_kind:
9647
1.34k
        tp = (PyTypeObject *)state->Lambda_type;
9648
1.34k
        result = PyType_GenericNew(tp, NULL, NULL);
9649
1.34k
        if (!result) goto failed;
9650
1.34k
        value = ast2obj_arguments(state, o->v.Lambda.args);
9651
1.34k
        if (!value) goto failed;
9652
1.34k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9653
0
            goto failed;
9654
1.34k
        Py_DECREF(value);
9655
1.34k
        value = ast2obj_expr(state, o->v.Lambda.body);
9656
1.34k
        if (!value) goto failed;
9657
1.34k
        if (PyObject_SetAttr(result, state->body, value) == -1)
9658
0
            goto failed;
9659
1.34k
        Py_DECREF(value);
9660
1.34k
        break;
9661
196
    case IfExp_kind:
9662
196
        tp = (PyTypeObject *)state->IfExp_type;
9663
196
        result = PyType_GenericNew(tp, NULL, NULL);
9664
196
        if (!result) goto failed;
9665
196
        value = ast2obj_expr(state, o->v.IfExp.test);
9666
196
        if (!value) goto failed;
9667
196
        if (PyObject_SetAttr(result, state->test, value) == -1)
9668
0
            goto failed;
9669
196
        Py_DECREF(value);
9670
196
        value = ast2obj_expr(state, o->v.IfExp.body);
9671
196
        if (!value) goto failed;
9672
196
        if (PyObject_SetAttr(result, state->body, value) == -1)
9673
0
            goto failed;
9674
196
        Py_DECREF(value);
9675
196
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9676
196
        if (!value) goto failed;
9677
196
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9678
0
            goto failed;
9679
196
        Py_DECREF(value);
9680
196
        break;
9681
1.64k
    case Dict_kind:
9682
1.64k
        tp = (PyTypeObject *)state->Dict_type;
9683
1.64k
        result = PyType_GenericNew(tp, NULL, NULL);
9684
1.64k
        if (!result) goto failed;
9685
1.64k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9686
1.64k
        if (!value) goto failed;
9687
1.64k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9688
0
            goto failed;
9689
1.64k
        Py_DECREF(value);
9690
1.64k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9691
1.64k
        if (!value) goto failed;
9692
1.64k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9693
0
            goto failed;
9694
1.64k
        Py_DECREF(value);
9695
1.64k
        break;
9696
404
    case Set_kind:
9697
404
        tp = (PyTypeObject *)state->Set_type;
9698
404
        result = PyType_GenericNew(tp, NULL, NULL);
9699
404
        if (!result) goto failed;
9700
404
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9701
404
        if (!value) goto failed;
9702
404
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9703
0
            goto failed;
9704
404
        Py_DECREF(value);
9705
404
        break;
9706
326
    case ListComp_kind:
9707
326
        tp = (PyTypeObject *)state->ListComp_type;
9708
326
        result = PyType_GenericNew(tp, NULL, NULL);
9709
326
        if (!result) goto failed;
9710
326
        value = ast2obj_expr(state, o->v.ListComp.elt);
9711
326
        if (!value) goto failed;
9712
326
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9713
0
            goto failed;
9714
326
        Py_DECREF(value);
9715
326
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9716
326
                             ast2obj_comprehension);
9717
326
        if (!value) goto failed;
9718
326
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9719
0
            goto failed;
9720
326
        Py_DECREF(value);
9721
326
        break;
9722
155
    case SetComp_kind:
9723
155
        tp = (PyTypeObject *)state->SetComp_type;
9724
155
        result = PyType_GenericNew(tp, NULL, NULL);
9725
155
        if (!result) goto failed;
9726
155
        value = ast2obj_expr(state, o->v.SetComp.elt);
9727
155
        if (!value) goto failed;
9728
155
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9729
0
            goto failed;
9730
155
        Py_DECREF(value);
9731
155
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9732
155
                             ast2obj_comprehension);
9733
155
        if (!value) goto failed;
9734
155
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9735
0
            goto failed;
9736
155
        Py_DECREF(value);
9737
155
        break;
9738
573
    case DictComp_kind:
9739
573
        tp = (PyTypeObject *)state->DictComp_type;
9740
573
        result = PyType_GenericNew(tp, NULL, NULL);
9741
573
        if (!result) goto failed;
9742
573
        value = ast2obj_expr(state, o->v.DictComp.key);
9743
573
        if (!value) goto failed;
9744
573
        if (PyObject_SetAttr(result, state->key, value) == -1)
9745
0
            goto failed;
9746
573
        Py_DECREF(value);
9747
573
        value = ast2obj_expr(state, o->v.DictComp.value);
9748
573
        if (!value) goto failed;
9749
573
        if (PyObject_SetAttr(result, state->value, value) == -1)
9750
0
            goto failed;
9751
573
        Py_DECREF(value);
9752
573
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9753
573
                             ast2obj_comprehension);
9754
573
        if (!value) goto failed;
9755
573
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9756
0
            goto failed;
9757
573
        Py_DECREF(value);
9758
573
        break;
9759
662
    case GeneratorExp_kind:
9760
662
        tp = (PyTypeObject *)state->GeneratorExp_type;
9761
662
        result = PyType_GenericNew(tp, NULL, NULL);
9762
662
        if (!result) goto failed;
9763
662
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9764
662
        if (!value) goto failed;
9765
662
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9766
0
            goto failed;
9767
662
        Py_DECREF(value);
9768
662
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9769
662
                             ast2obj_comprehension);
9770
662
        if (!value) goto failed;
9771
662
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9772
0
            goto failed;
9773
662
        Py_DECREF(value);
9774
662
        break;
9775
194
    case Await_kind:
9776
194
        tp = (PyTypeObject *)state->Await_type;
9777
194
        result = PyType_GenericNew(tp, NULL, NULL);
9778
194
        if (!result) goto failed;
9779
194
        value = ast2obj_expr(state, o->v.Await.value);
9780
194
        if (!value) goto failed;
9781
194
        if (PyObject_SetAttr(result, state->value, value) == -1)
9782
0
            goto failed;
9783
194
        Py_DECREF(value);
9784
194
        break;
9785
484
    case Yield_kind:
9786
484
        tp = (PyTypeObject *)state->Yield_type;
9787
484
        result = PyType_GenericNew(tp, NULL, NULL);
9788
484
        if (!result) goto failed;
9789
484
        value = ast2obj_expr(state, o->v.Yield.value);
9790
484
        if (!value) goto failed;
9791
484
        if (PyObject_SetAttr(result, state->value, value) == -1)
9792
0
            goto failed;
9793
484
        Py_DECREF(value);
9794
484
        break;
9795
66
    case YieldFrom_kind:
9796
66
        tp = (PyTypeObject *)state->YieldFrom_type;
9797
66
        result = PyType_GenericNew(tp, NULL, NULL);
9798
66
        if (!result) goto failed;
9799
66
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9800
66
        if (!value) goto failed;
9801
66
        if (PyObject_SetAttr(result, state->value, value) == -1)
9802
0
            goto failed;
9803
66
        Py_DECREF(value);
9804
66
        break;
9805
3.01k
    case Compare_kind:
9806
3.01k
        tp = (PyTypeObject *)state->Compare_type;
9807
3.01k
        result = PyType_GenericNew(tp, NULL, NULL);
9808
3.01k
        if (!result) goto failed;
9809
3.01k
        value = ast2obj_expr(state, o->v.Compare.left);
9810
3.01k
        if (!value) goto failed;
9811
3.01k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9812
0
            goto failed;
9813
3.01k
        Py_DECREF(value);
9814
3.01k
        {
9815
3.01k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9816
3.01k
            value = PyList_New(n);
9817
3.01k
            if (!value) goto failed;
9818
16.5k
            for(i = 0; i < n; i++)
9819
13.5k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9820
3.01k
        }
9821
3.01k
        if (!value) goto failed;
9822
3.01k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9823
0
            goto failed;
9824
3.01k
        Py_DECREF(value);
9825
3.01k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9826
3.01k
                             ast2obj_expr);
9827
3.01k
        if (!value) goto failed;
9828
3.01k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9829
0
            goto failed;
9830
3.01k
        Py_DECREF(value);
9831
3.01k
        break;
9832
8.32k
    case Call_kind:
9833
8.32k
        tp = (PyTypeObject *)state->Call_type;
9834
8.32k
        result = PyType_GenericNew(tp, NULL, NULL);
9835
8.32k
        if (!result) goto failed;
9836
8.32k
        value = ast2obj_expr(state, o->v.Call.func);
9837
8.32k
        if (!value) goto failed;
9838
8.32k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9839
0
            goto failed;
9840
8.32k
        Py_DECREF(value);
9841
8.32k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9842
8.32k
        if (!value) goto failed;
9843
8.32k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9844
0
            goto failed;
9845
8.32k
        Py_DECREF(value);
9846
8.32k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9847
8.32k
                             ast2obj_keyword);
9848
8.32k
        if (!value) goto failed;
9849
8.32k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9850
0
            goto failed;
9851
8.32k
        Py_DECREF(value);
9852
8.32k
        break;
9853
13.4k
    case FormattedValue_kind:
9854
13.4k
        tp = (PyTypeObject *)state->FormattedValue_type;
9855
13.4k
        result = PyType_GenericNew(tp, NULL, NULL);
9856
13.4k
        if (!result) goto failed;
9857
13.4k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9858
13.4k
        if (!value) goto failed;
9859
13.4k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9860
0
            goto failed;
9861
13.4k
        Py_DECREF(value);
9862
13.4k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9863
13.4k
        if (!value) goto failed;
9864
13.4k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9865
0
            goto failed;
9866
13.4k
        Py_DECREF(value);
9867
13.4k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9868
13.4k
        if (!value) goto failed;
9869
13.4k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9870
0
            goto failed;
9871
13.4k
        Py_DECREF(value);
9872
13.4k
        break;
9873
874
    case Interpolation_kind:
9874
874
        tp = (PyTypeObject *)state->Interpolation_type;
9875
874
        result = PyType_GenericNew(tp, NULL, NULL);
9876
874
        if (!result) goto failed;
9877
874
        value = ast2obj_expr(state, o->v.Interpolation.value);
9878
874
        if (!value) goto failed;
9879
874
        if (PyObject_SetAttr(result, state->value, value) == -1)
9880
0
            goto failed;
9881
874
        Py_DECREF(value);
9882
874
        value = ast2obj_constant(state, o->v.Interpolation.str);
9883
874
        if (!value) goto failed;
9884
874
        if (PyObject_SetAttr(result, state->str, value) == -1)
9885
0
            goto failed;
9886
874
        Py_DECREF(value);
9887
874
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9888
874
        if (!value) goto failed;
9889
874
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9890
0
            goto failed;
9891
874
        Py_DECREF(value);
9892
874
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9893
874
        if (!value) goto failed;
9894
874
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9895
0
            goto failed;
9896
874
        Py_DECREF(value);
9897
874
        break;
9898
6.56k
    case JoinedStr_kind:
9899
6.56k
        tp = (PyTypeObject *)state->JoinedStr_type;
9900
6.56k
        result = PyType_GenericNew(tp, NULL, NULL);
9901
6.56k
        if (!result) goto failed;
9902
6.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9903
6.56k
                             ast2obj_expr);
9904
6.56k
        if (!value) goto failed;
9905
6.56k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9906
0
            goto failed;
9907
6.56k
        Py_DECREF(value);
9908
6.56k
        break;
9909
357
    case TemplateStr_kind:
9910
357
        tp = (PyTypeObject *)state->TemplateStr_type;
9911
357
        result = PyType_GenericNew(tp, NULL, NULL);
9912
357
        if (!result) goto failed;
9913
357
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9914
357
                             ast2obj_expr);
9915
357
        if (!value) goto failed;
9916
357
        if (PyObject_SetAttr(result, state->values, value) == -1)
9917
0
            goto failed;
9918
357
        Py_DECREF(value);
9919
357
        break;
9920
65.7k
    case Constant_kind:
9921
65.7k
        tp = (PyTypeObject *)state->Constant_type;
9922
65.7k
        result = PyType_GenericNew(tp, NULL, NULL);
9923
65.7k
        if (!result) goto failed;
9924
65.7k
        value = ast2obj_constant(state, o->v.Constant.value);
9925
65.7k
        if (!value) goto failed;
9926
65.7k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9927
0
            goto failed;
9928
65.7k
        Py_DECREF(value);
9929
65.7k
        value = ast2obj_string(state, o->v.Constant.kind);
9930
65.7k
        if (!value) goto failed;
9931
65.7k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9932
0
            goto failed;
9933
65.7k
        Py_DECREF(value);
9934
65.7k
        break;
9935
1.77k
    case Attribute_kind:
9936
1.77k
        tp = (PyTypeObject *)state->Attribute_type;
9937
1.77k
        result = PyType_GenericNew(tp, NULL, NULL);
9938
1.77k
        if (!result) goto failed;
9939
1.77k
        value = ast2obj_expr(state, o->v.Attribute.value);
9940
1.77k
        if (!value) goto failed;
9941
1.77k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9942
0
            goto failed;
9943
1.77k
        Py_DECREF(value);
9944
1.77k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9945
1.77k
        if (!value) goto failed;
9946
1.77k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9947
0
            goto failed;
9948
1.77k
        Py_DECREF(value);
9949
1.77k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9950
1.77k
        if (!value) goto failed;
9951
1.77k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9952
0
            goto failed;
9953
1.77k
        Py_DECREF(value);
9954
1.77k
        break;
9955
853
    case Subscript_kind:
9956
853
        tp = (PyTypeObject *)state->Subscript_type;
9957
853
        result = PyType_GenericNew(tp, NULL, NULL);
9958
853
        if (!result) goto failed;
9959
853
        value = ast2obj_expr(state, o->v.Subscript.value);
9960
853
        if (!value) goto failed;
9961
853
        if (PyObject_SetAttr(result, state->value, value) == -1)
9962
0
            goto failed;
9963
853
        Py_DECREF(value);
9964
853
        value = ast2obj_expr(state, o->v.Subscript.slice);
9965
853
        if (!value) goto failed;
9966
853
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9967
0
            goto failed;
9968
853
        Py_DECREF(value);
9969
853
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9970
853
        if (!value) goto failed;
9971
853
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9972
0
            goto failed;
9973
853
        Py_DECREF(value);
9974
853
        break;
9975
827
    case Starred_kind:
9976
827
        tp = (PyTypeObject *)state->Starred_type;
9977
827
        result = PyType_GenericNew(tp, NULL, NULL);
9978
827
        if (!result) goto failed;
9979
827
        value = ast2obj_expr(state, o->v.Starred.value);
9980
827
        if (!value) goto failed;
9981
827
        if (PyObject_SetAttr(result, state->value, value) == -1)
9982
0
            goto failed;
9983
827
        Py_DECREF(value);
9984
827
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9985
827
        if (!value) goto failed;
9986
827
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9987
0
            goto failed;
9988
827
        Py_DECREF(value);
9989
827
        break;
9990
81.2k
    case Name_kind:
9991
81.2k
        tp = (PyTypeObject *)state->Name_type;
9992
81.2k
        result = PyType_GenericNew(tp, NULL, NULL);
9993
81.2k
        if (!result) goto failed;
9994
81.2k
        value = ast2obj_identifier(state, o->v.Name.id);
9995
81.2k
        if (!value) goto failed;
9996
81.2k
        if (PyObject_SetAttr(result, state->id, value) == -1)
9997
0
            goto failed;
9998
81.2k
        Py_DECREF(value);
9999
81.2k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
10000
81.2k
        if (!value) goto failed;
10001
81.2k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10002
0
            goto failed;
10003
81.2k
        Py_DECREF(value);
10004
81.2k
        break;
10005
3.17k
    case List_kind:
10006
3.17k
        tp = (PyTypeObject *)state->List_type;
10007
3.17k
        result = PyType_GenericNew(tp, NULL, NULL);
10008
3.17k
        if (!result) goto failed;
10009
3.17k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10010
3.17k
        if (!value) goto failed;
10011
3.17k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10012
0
            goto failed;
10013
3.17k
        Py_DECREF(value);
10014
3.17k
        value = ast2obj_expr_context(state, o->v.List.ctx);
10015
3.17k
        if (!value) goto failed;
10016
3.17k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10017
0
            goto failed;
10018
3.17k
        Py_DECREF(value);
10019
3.17k
        break;
10020
14.7k
    case Tuple_kind:
10021
14.7k
        tp = (PyTypeObject *)state->Tuple_type;
10022
14.7k
        result = PyType_GenericNew(tp, NULL, NULL);
10023
14.7k
        if (!result) goto failed;
10024
14.7k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10025
14.7k
        if (!value) goto failed;
10026
14.7k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10027
0
            goto failed;
10028
14.7k
        Py_DECREF(value);
10029
14.7k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10030
14.7k
        if (!value) goto failed;
10031
14.7k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10032
0
            goto failed;
10033
14.7k
        Py_DECREF(value);
10034
14.7k
        break;
10035
3.41k
    case Slice_kind:
10036
3.41k
        tp = (PyTypeObject *)state->Slice_type;
10037
3.41k
        result = PyType_GenericNew(tp, NULL, NULL);
10038
3.41k
        if (!result) goto failed;
10039
3.41k
        value = ast2obj_expr(state, o->v.Slice.lower);
10040
3.41k
        if (!value) goto failed;
10041
3.41k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10042
0
            goto failed;
10043
3.41k
        Py_DECREF(value);
10044
3.41k
        value = ast2obj_expr(state, o->v.Slice.upper);
10045
3.41k
        if (!value) goto failed;
10046
3.41k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10047
0
            goto failed;
10048
3.41k
        Py_DECREF(value);
10049
3.41k
        value = ast2obj_expr(state, o->v.Slice.step);
10050
3.41k
        if (!value) goto failed;
10051
3.41k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10052
0
            goto failed;
10053
3.41k
        Py_DECREF(value);
10054
3.41k
        break;
10055
415k
    }
10056
415k
    value = ast2obj_int(state, o->lineno);
10057
415k
    if (!value) goto failed;
10058
415k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10059
0
        goto failed;
10060
415k
    Py_DECREF(value);
10061
415k
    value = ast2obj_int(state, o->col_offset);
10062
415k
    if (!value) goto failed;
10063
415k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10064
0
        goto failed;
10065
415k
    Py_DECREF(value);
10066
415k
    value = ast2obj_int(state, o->end_lineno);
10067
415k
    if (!value) goto failed;
10068
415k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10069
0
        goto failed;
10070
415k
    Py_DECREF(value);
10071
415k
    value = ast2obj_int(state, o->end_col_offset);
10072
415k
    if (!value) goto failed;
10073
415k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10074
0
        goto failed;
10075
415k
    Py_DECREF(value);
10076
415k
    Py_LeaveRecursiveCall();
10077
415k
    return result;
10078
0
failed:
10079
0
    Py_LeaveRecursiveCall();
10080
0
    Py_XDECREF(value);
10081
0
    Py_XDECREF(result);
10082
0
    return NULL;
10083
415k
}
10084
10085
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10086
102k
{
10087
102k
    switch(o) {
10088
95.1k
        case Load:
10089
95.1k
            return Py_NewRef(state->Load_singleton);
10090
6.50k
        case Store:
10091
6.50k
            return Py_NewRef(state->Store_singleton);
10092
884
        case Del:
10093
884
            return Py_NewRef(state->Del_singleton);
10094
102k
    }
10095
102k
    Py_UNREACHABLE();
10096
102k
}
10097
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10098
666
{
10099
666
    switch(o) {
10100
183
        case And:
10101
183
            return Py_NewRef(state->And_singleton);
10102
483
        case Or:
10103
483
            return Py_NewRef(state->Or_singleton);
10104
666
    }
10105
666
    Py_UNREACHABLE();
10106
666
}
10107
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10108
26.5k
{
10109
26.5k
    switch(o) {
10110
6.47k
        case Add:
10111
6.47k
            return Py_NewRef(state->Add_singleton);
10112
7.86k
        case Sub:
10113
7.86k
            return Py_NewRef(state->Sub_singleton);
10114
2.68k
        case Mult:
10115
2.68k
            return Py_NewRef(state->Mult_singleton);
10116
1.87k
        case MatMult:
10117
1.87k
            return Py_NewRef(state->MatMult_singleton);
10118
1.91k
        case Div:
10119
1.91k
            return Py_NewRef(state->Div_singleton);
10120
1.51k
        case Mod:
10121
1.51k
            return Py_NewRef(state->Mod_singleton);
10122
1.07k
        case Pow:
10123
1.07k
            return Py_NewRef(state->Pow_singleton);
10124
444
        case LShift:
10125
444
            return Py_NewRef(state->LShift_singleton);
10126
332
        case RShift:
10127
332
            return Py_NewRef(state->RShift_singleton);
10128
351
        case BitOr:
10129
351
            return Py_NewRef(state->BitOr_singleton);
10130
303
        case BitXor:
10131
303
            return Py_NewRef(state->BitXor_singleton);
10132
1.44k
        case BitAnd:
10133
1.44k
            return Py_NewRef(state->BitAnd_singleton);
10134
309
        case FloorDiv:
10135
309
            return Py_NewRef(state->FloorDiv_singleton);
10136
26.5k
    }
10137
26.5k
    Py_UNREACHABLE();
10138
26.5k
}
10139
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10140
177k
{
10141
177k
    switch(o) {
10142
19.0k
        case Invert:
10143
19.0k
            return Py_NewRef(state->Invert_singleton);
10144
100
        case Not:
10145
100
            return Py_NewRef(state->Not_singleton);
10146
66.8k
        case UAdd:
10147
66.8k
            return Py_NewRef(state->UAdd_singleton);
10148
91.5k
        case USub:
10149
91.5k
            return Py_NewRef(state->USub_singleton);
10150
177k
    }
10151
177k
    Py_UNREACHABLE();
10152
177k
}
10153
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10154
13.5k
{
10155
13.5k
    switch(o) {
10156
231
        case Eq:
10157
231
            return Py_NewRef(state->Eq_singleton);
10158
215
        case NotEq:
10159
215
            return Py_NewRef(state->NotEq_singleton);
10160
5.33k
        case Lt:
10161
5.33k
            return Py_NewRef(state->Lt_singleton);
10162
207
        case LtE:
10163
207
            return Py_NewRef(state->LtE_singleton);
10164
6.54k
        case Gt:
10165
6.54k
            return Py_NewRef(state->Gt_singleton);
10166
249
        case GtE:
10167
249
            return Py_NewRef(state->GtE_singleton);
10168
281
        case Is:
10169
281
            return Py_NewRef(state->Is_singleton);
10170
85
        case IsNot:
10171
85
            return Py_NewRef(state->IsNot_singleton);
10172
313
        case In:
10173
313
            return Py_NewRef(state->In_singleton);
10174
72
        case NotIn:
10175
72
            return Py_NewRef(state->NotIn_singleton);
10176
13.5k
    }
10177
13.5k
    Py_UNREACHABLE();
10178
13.5k
}
10179
PyObject*
10180
ast2obj_comprehension(struct ast_state *state, void* _o)
10181
1.82k
{
10182
1.82k
    comprehension_ty o = (comprehension_ty)_o;
10183
1.82k
    PyObject *result = NULL, *value = NULL;
10184
1.82k
    PyTypeObject *tp;
10185
1.82k
    if (!o) {
10186
0
        Py_RETURN_NONE;
10187
0
    }
10188
1.82k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10189
0
        return NULL;
10190
0
    }
10191
1.82k
    tp = (PyTypeObject *)state->comprehension_type;
10192
1.82k
    result = PyType_GenericNew(tp, NULL, NULL);
10193
1.82k
    if (!result) return NULL;
10194
1.82k
    value = ast2obj_expr(state, o->target);
10195
1.82k
    if (!value) goto failed;
10196
1.82k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10197
0
        goto failed;
10198
1.82k
    Py_DECREF(value);
10199
1.82k
    value = ast2obj_expr(state, o->iter);
10200
1.82k
    if (!value) goto failed;
10201
1.82k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10202
0
        goto failed;
10203
1.82k
    Py_DECREF(value);
10204
1.82k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10205
1.82k
    if (!value) goto failed;
10206
1.82k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10207
0
        goto failed;
10208
1.82k
    Py_DECREF(value);
10209
1.82k
    value = ast2obj_int(state, o->is_async);
10210
1.82k
    if (!value) goto failed;
10211
1.82k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10212
0
        goto failed;
10213
1.82k
    Py_DECREF(value);
10214
1.82k
    Py_LeaveRecursiveCall();
10215
1.82k
    return result;
10216
0
failed:
10217
0
    Py_LeaveRecursiveCall();
10218
0
    Py_XDECREF(value);
10219
0
    Py_XDECREF(result);
10220
0
    return NULL;
10221
1.82k
}
10222
10223
PyObject*
10224
ast2obj_excepthandler(struct ast_state *state, void* _o)
10225
1.85k
{
10226
1.85k
    excepthandler_ty o = (excepthandler_ty)_o;
10227
1.85k
    PyObject *result = NULL, *value = NULL;
10228
1.85k
    PyTypeObject *tp;
10229
1.85k
    if (!o) {
10230
0
        Py_RETURN_NONE;
10231
0
    }
10232
1.85k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10233
0
        return NULL;
10234
0
    }
10235
1.85k
    switch (o->kind) {
10236
1.85k
    case ExceptHandler_kind:
10237
1.85k
        tp = (PyTypeObject *)state->ExceptHandler_type;
10238
1.85k
        result = PyType_GenericNew(tp, NULL, NULL);
10239
1.85k
        if (!result) goto failed;
10240
1.85k
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10241
1.85k
        if (!value) goto failed;
10242
1.85k
        if (PyObject_SetAttr(result, state->type, value) == -1)
10243
0
            goto failed;
10244
1.85k
        Py_DECREF(value);
10245
1.85k
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10246
1.85k
        if (!value) goto failed;
10247
1.85k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10248
0
            goto failed;
10249
1.85k
        Py_DECREF(value);
10250
1.85k
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10251
1.85k
                             ast2obj_stmt);
10252
1.85k
        if (!value) goto failed;
10253
1.85k
        if (PyObject_SetAttr(result, state->body, value) == -1)
10254
0
            goto failed;
10255
1.85k
        Py_DECREF(value);
10256
1.85k
        break;
10257
1.85k
    }
10258
1.85k
    value = ast2obj_int(state, o->lineno);
10259
1.85k
    if (!value) goto failed;
10260
1.85k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10261
0
        goto failed;
10262
1.85k
    Py_DECREF(value);
10263
1.85k
    value = ast2obj_int(state, o->col_offset);
10264
1.85k
    if (!value) goto failed;
10265
1.85k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10266
0
        goto failed;
10267
1.85k
    Py_DECREF(value);
10268
1.85k
    value = ast2obj_int(state, o->end_lineno);
10269
1.85k
    if (!value) goto failed;
10270
1.85k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10271
0
        goto failed;
10272
1.85k
    Py_DECREF(value);
10273
1.85k
    value = ast2obj_int(state, o->end_col_offset);
10274
1.85k
    if (!value) goto failed;
10275
1.85k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10276
0
        goto failed;
10277
1.85k
    Py_DECREF(value);
10278
1.85k
    Py_LeaveRecursiveCall();
10279
1.85k
    return result;
10280
0
failed:
10281
0
    Py_LeaveRecursiveCall();
10282
0
    Py_XDECREF(value);
10283
0
    Py_XDECREF(result);
10284
0
    return NULL;
10285
1.85k
}
10286
10287
PyObject*
10288
ast2obj_arguments(struct ast_state *state, void* _o)
10289
3.57k
{
10290
3.57k
    arguments_ty o = (arguments_ty)_o;
10291
3.57k
    PyObject *result = NULL, *value = NULL;
10292
3.57k
    PyTypeObject *tp;
10293
3.57k
    if (!o) {
10294
0
        Py_RETURN_NONE;
10295
0
    }
10296
3.57k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10297
0
        return NULL;
10298
0
    }
10299
3.57k
    tp = (PyTypeObject *)state->arguments_type;
10300
3.57k
    result = PyType_GenericNew(tp, NULL, NULL);
10301
3.57k
    if (!result) return NULL;
10302
3.57k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10303
3.57k
    if (!value) goto failed;
10304
3.57k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10305
0
        goto failed;
10306
3.57k
    Py_DECREF(value);
10307
3.57k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10308
3.57k
    if (!value) goto failed;
10309
3.57k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10310
0
        goto failed;
10311
3.57k
    Py_DECREF(value);
10312
3.57k
    value = ast2obj_arg(state, o->vararg);
10313
3.57k
    if (!value) goto failed;
10314
3.57k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10315
0
        goto failed;
10316
3.57k
    Py_DECREF(value);
10317
3.57k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10318
3.57k
    if (!value) goto failed;
10319
3.57k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10320
0
        goto failed;
10321
3.57k
    Py_DECREF(value);
10322
3.57k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10323
3.57k
    if (!value) goto failed;
10324
3.57k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10325
0
        goto failed;
10326
3.57k
    Py_DECREF(value);
10327
3.57k
    value = ast2obj_arg(state, o->kwarg);
10328
3.57k
    if (!value) goto failed;
10329
3.57k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10330
0
        goto failed;
10331
3.57k
    Py_DECREF(value);
10332
3.57k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10333
3.57k
    if (!value) goto failed;
10334
3.57k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10335
0
        goto failed;
10336
3.57k
    Py_DECREF(value);
10337
3.57k
    Py_LeaveRecursiveCall();
10338
3.57k
    return result;
10339
0
failed:
10340
0
    Py_LeaveRecursiveCall();
10341
0
    Py_XDECREF(value);
10342
0
    Py_XDECREF(result);
10343
0
    return NULL;
10344
3.57k
}
10345
10346
PyObject*
10347
ast2obj_arg(struct ast_state *state, void* _o)
10348
17.7k
{
10349
17.7k
    arg_ty o = (arg_ty)_o;
10350
17.7k
    PyObject *result = NULL, *value = NULL;
10351
17.7k
    PyTypeObject *tp;
10352
17.7k
    if (!o) {
10353
6.36k
        Py_RETURN_NONE;
10354
6.36k
    }
10355
11.3k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10356
0
        return NULL;
10357
0
    }
10358
11.3k
    tp = (PyTypeObject *)state->arg_type;
10359
11.3k
    result = PyType_GenericNew(tp, NULL, NULL);
10360
11.3k
    if (!result) return NULL;
10361
11.3k
    value = ast2obj_identifier(state, o->arg);
10362
11.3k
    if (!value) goto failed;
10363
11.3k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10364
0
        goto failed;
10365
11.3k
    Py_DECREF(value);
10366
11.3k
    value = ast2obj_expr(state, o->annotation);
10367
11.3k
    if (!value) goto failed;
10368
11.3k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10369
0
        goto failed;
10370
11.3k
    Py_DECREF(value);
10371
11.3k
    value = ast2obj_string(state, o->type_comment);
10372
11.3k
    if (!value) goto failed;
10373
11.3k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10374
0
        goto failed;
10375
11.3k
    Py_DECREF(value);
10376
11.3k
    value = ast2obj_int(state, o->lineno);
10377
11.3k
    if (!value) goto failed;
10378
11.3k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10379
0
        goto failed;
10380
11.3k
    Py_DECREF(value);
10381
11.3k
    value = ast2obj_int(state, o->col_offset);
10382
11.3k
    if (!value) goto failed;
10383
11.3k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10384
0
        goto failed;
10385
11.3k
    Py_DECREF(value);
10386
11.3k
    value = ast2obj_int(state, o->end_lineno);
10387
11.3k
    if (!value) goto failed;
10388
11.3k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10389
0
        goto failed;
10390
11.3k
    Py_DECREF(value);
10391
11.3k
    value = ast2obj_int(state, o->end_col_offset);
10392
11.3k
    if (!value) goto failed;
10393
11.3k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10394
0
        goto failed;
10395
11.3k
    Py_DECREF(value);
10396
11.3k
    Py_LeaveRecursiveCall();
10397
11.3k
    return result;
10398
0
failed:
10399
0
    Py_LeaveRecursiveCall();
10400
0
    Py_XDECREF(value);
10401
0
    Py_XDECREF(result);
10402
0
    return NULL;
10403
11.3k
}
10404
10405
PyObject*
10406
ast2obj_keyword(struct ast_state *state, void* _o)
10407
1.94k
{
10408
1.94k
    keyword_ty o = (keyword_ty)_o;
10409
1.94k
    PyObject *result = NULL, *value = NULL;
10410
1.94k
    PyTypeObject *tp;
10411
1.94k
    if (!o) {
10412
0
        Py_RETURN_NONE;
10413
0
    }
10414
1.94k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10415
0
        return NULL;
10416
0
    }
10417
1.94k
    tp = (PyTypeObject *)state->keyword_type;
10418
1.94k
    result = PyType_GenericNew(tp, NULL, NULL);
10419
1.94k
    if (!result) return NULL;
10420
1.94k
    value = ast2obj_identifier(state, o->arg);
10421
1.94k
    if (!value) goto failed;
10422
1.94k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10423
0
        goto failed;
10424
1.94k
    Py_DECREF(value);
10425
1.94k
    value = ast2obj_expr(state, o->value);
10426
1.94k
    if (!value) goto failed;
10427
1.94k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10428
0
        goto failed;
10429
1.94k
    Py_DECREF(value);
10430
1.94k
    value = ast2obj_int(state, o->lineno);
10431
1.94k
    if (!value) goto failed;
10432
1.94k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10433
0
        goto failed;
10434
1.94k
    Py_DECREF(value);
10435
1.94k
    value = ast2obj_int(state, o->col_offset);
10436
1.94k
    if (!value) goto failed;
10437
1.94k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10438
0
        goto failed;
10439
1.94k
    Py_DECREF(value);
10440
1.94k
    value = ast2obj_int(state, o->end_lineno);
10441
1.94k
    if (!value) goto failed;
10442
1.94k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10443
0
        goto failed;
10444
1.94k
    Py_DECREF(value);
10445
1.94k
    value = ast2obj_int(state, o->end_col_offset);
10446
1.94k
    if (!value) goto failed;
10447
1.94k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10448
0
        goto failed;
10449
1.94k
    Py_DECREF(value);
10450
1.94k
    Py_LeaveRecursiveCall();
10451
1.94k
    return result;
10452
0
failed:
10453
0
    Py_LeaveRecursiveCall();
10454
0
    Py_XDECREF(value);
10455
0
    Py_XDECREF(result);
10456
0
    return NULL;
10457
1.94k
}
10458
10459
PyObject*
10460
ast2obj_alias(struct ast_state *state, void* _o)
10461
2.56k
{
10462
2.56k
    alias_ty o = (alias_ty)_o;
10463
2.56k
    PyObject *result = NULL, *value = NULL;
10464
2.56k
    PyTypeObject *tp;
10465
2.56k
    if (!o) {
10466
0
        Py_RETURN_NONE;
10467
0
    }
10468
2.56k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10469
0
        return NULL;
10470
0
    }
10471
2.56k
    tp = (PyTypeObject *)state->alias_type;
10472
2.56k
    result = PyType_GenericNew(tp, NULL, NULL);
10473
2.56k
    if (!result) return NULL;
10474
2.56k
    value = ast2obj_identifier(state, o->name);
10475
2.56k
    if (!value) goto failed;
10476
2.56k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10477
0
        goto failed;
10478
2.56k
    Py_DECREF(value);
10479
2.56k
    value = ast2obj_identifier(state, o->asname);
10480
2.56k
    if (!value) goto failed;
10481
2.56k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10482
0
        goto failed;
10483
2.56k
    Py_DECREF(value);
10484
2.56k
    value = ast2obj_int(state, o->lineno);
10485
2.56k
    if (!value) goto failed;
10486
2.56k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10487
0
        goto failed;
10488
2.56k
    Py_DECREF(value);
10489
2.56k
    value = ast2obj_int(state, o->col_offset);
10490
2.56k
    if (!value) goto failed;
10491
2.56k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10492
0
        goto failed;
10493
2.56k
    Py_DECREF(value);
10494
2.56k
    value = ast2obj_int(state, o->end_lineno);
10495
2.56k
    if (!value) goto failed;
10496
2.56k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10497
0
        goto failed;
10498
2.56k
    Py_DECREF(value);
10499
2.56k
    value = ast2obj_int(state, o->end_col_offset);
10500
2.56k
    if (!value) goto failed;
10501
2.56k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10502
0
        goto failed;
10503
2.56k
    Py_DECREF(value);
10504
2.56k
    Py_LeaveRecursiveCall();
10505
2.56k
    return result;
10506
0
failed:
10507
0
    Py_LeaveRecursiveCall();
10508
0
    Py_XDECREF(value);
10509
0
    Py_XDECREF(result);
10510
0
    return NULL;
10511
2.56k
}
10512
10513
PyObject*
10514
ast2obj_withitem(struct ast_state *state, void* _o)
10515
2.29k
{
10516
2.29k
    withitem_ty o = (withitem_ty)_o;
10517
2.29k
    PyObject *result = NULL, *value = NULL;
10518
2.29k
    PyTypeObject *tp;
10519
2.29k
    if (!o) {
10520
0
        Py_RETURN_NONE;
10521
0
    }
10522
2.29k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10523
0
        return NULL;
10524
0
    }
10525
2.29k
    tp = (PyTypeObject *)state->withitem_type;
10526
2.29k
    result = PyType_GenericNew(tp, NULL, NULL);
10527
2.29k
    if (!result) return NULL;
10528
2.29k
    value = ast2obj_expr(state, o->context_expr);
10529
2.29k
    if (!value) goto failed;
10530
2.29k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10531
0
        goto failed;
10532
2.29k
    Py_DECREF(value);
10533
2.29k
    value = ast2obj_expr(state, o->optional_vars);
10534
2.29k
    if (!value) goto failed;
10535
2.29k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10536
0
        goto failed;
10537
2.29k
    Py_DECREF(value);
10538
2.29k
    Py_LeaveRecursiveCall();
10539
2.29k
    return result;
10540
0
failed:
10541
0
    Py_LeaveRecursiveCall();
10542
0
    Py_XDECREF(value);
10543
0
    Py_XDECREF(result);
10544
0
    return NULL;
10545
2.29k
}
10546
10547
PyObject*
10548
ast2obj_match_case(struct ast_state *state, void* _o)
10549
1.57k
{
10550
1.57k
    match_case_ty o = (match_case_ty)_o;
10551
1.57k
    PyObject *result = NULL, *value = NULL;
10552
1.57k
    PyTypeObject *tp;
10553
1.57k
    if (!o) {
10554
0
        Py_RETURN_NONE;
10555
0
    }
10556
1.57k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10557
0
        return NULL;
10558
0
    }
10559
1.57k
    tp = (PyTypeObject *)state->match_case_type;
10560
1.57k
    result = PyType_GenericNew(tp, NULL, NULL);
10561
1.57k
    if (!result) return NULL;
10562
1.57k
    value = ast2obj_pattern(state, o->pattern);
10563
1.57k
    if (!value) goto failed;
10564
1.57k
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10565
0
        goto failed;
10566
1.57k
    Py_DECREF(value);
10567
1.57k
    value = ast2obj_expr(state, o->guard);
10568
1.57k
    if (!value) goto failed;
10569
1.57k
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10570
0
        goto failed;
10571
1.57k
    Py_DECREF(value);
10572
1.57k
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10573
1.57k
    if (!value) goto failed;
10574
1.57k
    if (PyObject_SetAttr(result, state->body, value) == -1)
10575
0
        goto failed;
10576
1.57k
    Py_DECREF(value);
10577
1.57k
    Py_LeaveRecursiveCall();
10578
1.57k
    return result;
10579
0
failed:
10580
0
    Py_LeaveRecursiveCall();
10581
0
    Py_XDECREF(value);
10582
0
    Py_XDECREF(result);
10583
0
    return NULL;
10584
1.57k
}
10585
10586
PyObject*
10587
ast2obj_pattern(struct ast_state *state, void* _o)
10588
15.7k
{
10589
15.7k
    pattern_ty o = (pattern_ty)_o;
10590
15.7k
    PyObject *result = NULL, *value = NULL;
10591
15.7k
    PyTypeObject *tp;
10592
15.7k
    if (!o) {
10593
4.81k
        Py_RETURN_NONE;
10594
4.81k
    }
10595
10.9k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10596
0
        return NULL;
10597
0
    }
10598
10.9k
    switch (o->kind) {
10599
961
    case MatchValue_kind:
10600
961
        tp = (PyTypeObject *)state->MatchValue_type;
10601
961
        result = PyType_GenericNew(tp, NULL, NULL);
10602
961
        if (!result) goto failed;
10603
961
        value = ast2obj_expr(state, o->v.MatchValue.value);
10604
961
        if (!value) goto failed;
10605
961
        if (PyObject_SetAttr(result, state->value, value) == -1)
10606
0
            goto failed;
10607
961
        Py_DECREF(value);
10608
961
        break;
10609
88
    case MatchSingleton_kind:
10610
88
        tp = (PyTypeObject *)state->MatchSingleton_type;
10611
88
        result = PyType_GenericNew(tp, NULL, NULL);
10612
88
        if (!result) goto failed;
10613
88
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10614
88
        if (!value) goto failed;
10615
88
        if (PyObject_SetAttr(result, state->value, value) == -1)
10616
0
            goto failed;
10617
88
        Py_DECREF(value);
10618
88
        break;
10619
765
    case MatchSequence_kind:
10620
765
        tp = (PyTypeObject *)state->MatchSequence_type;
10621
765
        result = PyType_GenericNew(tp, NULL, NULL);
10622
765
        if (!result) goto failed;
10623
765
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10624
765
                             ast2obj_pattern);
10625
765
        if (!value) goto failed;
10626
765
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10627
0
            goto failed;
10628
765
        Py_DECREF(value);
10629
765
        break;
10630
1.38k
    case MatchMapping_kind:
10631
1.38k
        tp = (PyTypeObject *)state->MatchMapping_type;
10632
1.38k
        result = PyType_GenericNew(tp, NULL, NULL);
10633
1.38k
        if (!result) goto failed;
10634
1.38k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10635
1.38k
                             ast2obj_expr);
10636
1.38k
        if (!value) goto failed;
10637
1.38k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10638
0
            goto failed;
10639
1.38k
        Py_DECREF(value);
10640
1.38k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10641
1.38k
                             ast2obj_pattern);
10642
1.38k
        if (!value) goto failed;
10643
1.38k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10644
0
            goto failed;
10645
1.38k
        Py_DECREF(value);
10646
1.38k
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10647
1.38k
        if (!value) goto failed;
10648
1.38k
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10649
0
            goto failed;
10650
1.38k
        Py_DECREF(value);
10651
1.38k
        break;
10652
861
    case MatchClass_kind:
10653
861
        tp = (PyTypeObject *)state->MatchClass_type;
10654
861
        result = PyType_GenericNew(tp, NULL, NULL);
10655
861
        if (!result) goto failed;
10656
861
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10657
861
        if (!value) goto failed;
10658
861
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10659
0
            goto failed;
10660
861
        Py_DECREF(value);
10661
861
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10662
861
                             ast2obj_pattern);
10663
861
        if (!value) goto failed;
10664
861
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10665
0
            goto failed;
10666
861
        Py_DECREF(value);
10667
861
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10668
861
                             ast2obj_identifier);
10669
861
        if (!value) goto failed;
10670
861
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10671
0
            goto failed;
10672
861
        Py_DECREF(value);
10673
861
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10674
861
                             ast2obj_pattern);
10675
861
        if (!value) goto failed;
10676
861
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10677
0
            goto failed;
10678
861
        Py_DECREF(value);
10679
861
        break;
10680
544
    case MatchStar_kind:
10681
544
        tp = (PyTypeObject *)state->MatchStar_type;
10682
544
        result = PyType_GenericNew(tp, NULL, NULL);
10683
544
        if (!result) goto failed;
10684
544
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10685
544
        if (!value) goto failed;
10686
544
        if (PyObject_SetAttr(result, state->name, value) == -1)
10687
0
            goto failed;
10688
544
        Py_DECREF(value);
10689
544
        break;
10690
4.88k
    case MatchAs_kind:
10691
4.88k
        tp = (PyTypeObject *)state->MatchAs_type;
10692
4.88k
        result = PyType_GenericNew(tp, NULL, NULL);
10693
4.88k
        if (!result) goto failed;
10694
4.88k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10695
4.88k
        if (!value) goto failed;
10696
4.88k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10697
0
            goto failed;
10698
4.88k
        Py_DECREF(value);
10699
4.88k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10700
4.88k
        if (!value) goto failed;
10701
4.88k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10702
0
            goto failed;
10703
4.88k
        Py_DECREF(value);
10704
4.88k
        break;
10705
1.45k
    case MatchOr_kind:
10706
1.45k
        tp = (PyTypeObject *)state->MatchOr_type;
10707
1.45k
        result = PyType_GenericNew(tp, NULL, NULL);
10708
1.45k
        if (!result) goto failed;
10709
1.45k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10710
1.45k
                             ast2obj_pattern);
10711
1.45k
        if (!value) goto failed;
10712
1.45k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10713
0
            goto failed;
10714
1.45k
        Py_DECREF(value);
10715
1.45k
        break;
10716
10.9k
    }
10717
10.9k
    value = ast2obj_int(state, o->lineno);
10718
10.9k
    if (!value) goto failed;
10719
10.9k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10720
0
        goto failed;
10721
10.9k
    Py_DECREF(value);
10722
10.9k
    value = ast2obj_int(state, o->col_offset);
10723
10.9k
    if (!value) goto failed;
10724
10.9k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10725
0
        goto failed;
10726
10.9k
    Py_DECREF(value);
10727
10.9k
    value = ast2obj_int(state, o->end_lineno);
10728
10.9k
    if (!value) goto failed;
10729
10.9k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10730
0
        goto failed;
10731
10.9k
    Py_DECREF(value);
10732
10.9k
    value = ast2obj_int(state, o->end_col_offset);
10733
10.9k
    if (!value) goto failed;
10734
10.9k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10735
0
        goto failed;
10736
10.9k
    Py_DECREF(value);
10737
10.9k
    Py_LeaveRecursiveCall();
10738
10.9k
    return result;
10739
0
failed:
10740
0
    Py_LeaveRecursiveCall();
10741
0
    Py_XDECREF(value);
10742
0
    Py_XDECREF(result);
10743
0
    return NULL;
10744
10.9k
}
10745
10746
PyObject*
10747
ast2obj_type_ignore(struct ast_state *state, void* _o)
10748
0
{
10749
0
    type_ignore_ty o = (type_ignore_ty)_o;
10750
0
    PyObject *result = NULL, *value = NULL;
10751
0
    PyTypeObject *tp;
10752
0
    if (!o) {
10753
0
        Py_RETURN_NONE;
10754
0
    }
10755
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10756
0
        return NULL;
10757
0
    }
10758
0
    switch (o->kind) {
10759
0
    case TypeIgnore_kind:
10760
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10761
0
        result = PyType_GenericNew(tp, NULL, NULL);
10762
0
        if (!result) goto failed;
10763
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10764
0
        if (!value) goto failed;
10765
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10766
0
            goto failed;
10767
0
        Py_DECREF(value);
10768
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10769
0
        if (!value) goto failed;
10770
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10771
0
            goto failed;
10772
0
        Py_DECREF(value);
10773
0
        break;
10774
0
    }
10775
0
    Py_LeaveRecursiveCall();
10776
0
    return result;
10777
0
failed:
10778
0
    Py_LeaveRecursiveCall();
10779
0
    Py_XDECREF(value);
10780
0
    Py_XDECREF(result);
10781
0
    return NULL;
10782
0
}
10783
10784
PyObject*
10785
ast2obj_type_param(struct ast_state *state, void* _o)
10786
4.21k
{
10787
4.21k
    type_param_ty o = (type_param_ty)_o;
10788
4.21k
    PyObject *result = NULL, *value = NULL;
10789
4.21k
    PyTypeObject *tp;
10790
4.21k
    if (!o) {
10791
0
        Py_RETURN_NONE;
10792
0
    }
10793
4.21k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10794
0
        return NULL;
10795
0
    }
10796
4.21k
    switch (o->kind) {
10797
2.88k
    case TypeVar_kind:
10798
2.88k
        tp = (PyTypeObject *)state->TypeVar_type;
10799
2.88k
        result = PyType_GenericNew(tp, NULL, NULL);
10800
2.88k
        if (!result) goto failed;
10801
2.88k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10802
2.88k
        if (!value) goto failed;
10803
2.88k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10804
0
            goto failed;
10805
2.88k
        Py_DECREF(value);
10806
2.88k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10807
2.88k
        if (!value) goto failed;
10808
2.88k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10809
0
            goto failed;
10810
2.88k
        Py_DECREF(value);
10811
2.88k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10812
2.88k
        if (!value) goto failed;
10813
2.88k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10814
0
            goto failed;
10815
2.88k
        Py_DECREF(value);
10816
2.88k
        break;
10817
485
    case ParamSpec_kind:
10818
485
        tp = (PyTypeObject *)state->ParamSpec_type;
10819
485
        result = PyType_GenericNew(tp, NULL, NULL);
10820
485
        if (!result) goto failed;
10821
485
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10822
485
        if (!value) goto failed;
10823
485
        if (PyObject_SetAttr(result, state->name, value) == -1)
10824
0
            goto failed;
10825
485
        Py_DECREF(value);
10826
485
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10827
485
        if (!value) goto failed;
10828
485
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10829
0
            goto failed;
10830
485
        Py_DECREF(value);
10831
485
        break;
10832
843
    case TypeVarTuple_kind:
10833
843
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10834
843
        result = PyType_GenericNew(tp, NULL, NULL);
10835
843
        if (!result) goto failed;
10836
843
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10837
843
        if (!value) goto failed;
10838
843
        if (PyObject_SetAttr(result, state->name, value) == -1)
10839
0
            goto failed;
10840
843
        Py_DECREF(value);
10841
843
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10842
843
        if (!value) goto failed;
10843
843
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10844
0
            goto failed;
10845
843
        Py_DECREF(value);
10846
843
        break;
10847
4.21k
    }
10848
4.21k
    value = ast2obj_int(state, o->lineno);
10849
4.21k
    if (!value) goto failed;
10850
4.21k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10851
0
        goto failed;
10852
4.21k
    Py_DECREF(value);
10853
4.21k
    value = ast2obj_int(state, o->col_offset);
10854
4.21k
    if (!value) goto failed;
10855
4.21k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10856
0
        goto failed;
10857
4.21k
    Py_DECREF(value);
10858
4.21k
    value = ast2obj_int(state, o->end_lineno);
10859
4.21k
    if (!value) goto failed;
10860
4.21k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10861
0
        goto failed;
10862
4.21k
    Py_DECREF(value);
10863
4.21k
    value = ast2obj_int(state, o->end_col_offset);
10864
4.21k
    if (!value) goto failed;
10865
4.21k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10866
0
        goto failed;
10867
4.21k
    Py_DECREF(value);
10868
4.21k
    Py_LeaveRecursiveCall();
10869
4.21k
    return result;
10870
0
failed:
10871
0
    Py_LeaveRecursiveCall();
10872
0
    Py_XDECREF(value);
10873
0
    Py_XDECREF(result);
10874
0
    return NULL;
10875
4.21k
}
10876
10877
10878
int
10879
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
10880
0
{
10881
0
    int isinstance;
10882
10883
0
    PyObject *tmp = NULL;
10884
0
    PyObject *tp;
10885
10886
0
    if (obj == Py_None) {
10887
0
        *out = NULL;
10888
0
        return 0;
10889
0
    }
10890
0
    tp = state->Module_type;
10891
0
    isinstance = PyObject_IsInstance(obj, tp);
10892
0
    if (isinstance == -1) {
10893
0
        return -1;
10894
0
    }
10895
0
    if (isinstance) {
10896
0
        asdl_stmt_seq* body;
10897
0
        asdl_type_ignore_seq* type_ignores;
10898
10899
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10900
0
            return -1;
10901
0
        }
10902
0
        if (tmp == NULL) {
10903
0
            tmp = PyList_New(0);
10904
0
            if (tmp == NULL) {
10905
0
                return -1;
10906
0
            }
10907
0
        }
10908
0
        {
10909
0
            int res;
10910
0
            Py_ssize_t len;
10911
0
            Py_ssize_t i;
10912
0
            if (!PyList_Check(tmp)) {
10913
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10914
0
                goto failed;
10915
0
            }
10916
0
            len = PyList_GET_SIZE(tmp);
10917
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10918
0
            if (body == NULL) goto failed;
10919
0
            for (i = 0; i < len; i++) {
10920
0
                stmt_ty val;
10921
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10922
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10923
0
                    goto failed;
10924
0
                }
10925
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10926
0
                _Py_LeaveRecursiveCall();
10927
0
                Py_DECREF(tmp2);
10928
0
                if (res != 0) goto failed;
10929
0
                if (len != PyList_GET_SIZE(tmp)) {
10930
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10931
0
                    goto failed;
10932
0
                }
10933
0
                asdl_seq_SET(body, i, val);
10934
0
            }
10935
0
            Py_CLEAR(tmp);
10936
0
        }
10937
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10938
0
            return -1;
10939
0
        }
10940
0
        if (tmp == NULL) {
10941
0
            tmp = PyList_New(0);
10942
0
            if (tmp == NULL) {
10943
0
                return -1;
10944
0
            }
10945
0
        }
10946
0
        {
10947
0
            int res;
10948
0
            Py_ssize_t len;
10949
0
            Py_ssize_t i;
10950
0
            if (!PyList_Check(tmp)) {
10951
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10952
0
                goto failed;
10953
0
            }
10954
0
            len = PyList_GET_SIZE(tmp);
10955
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
10956
0
            if (type_ignores == NULL) goto failed;
10957
0
            for (i = 0; i < len; i++) {
10958
0
                type_ignore_ty val;
10959
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10960
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10961
0
                    goto failed;
10962
0
                }
10963
0
                res = obj2ast_type_ignore(state, tmp2, &val, arena);
10964
0
                _Py_LeaveRecursiveCall();
10965
0
                Py_DECREF(tmp2);
10966
0
                if (res != 0) goto failed;
10967
0
                if (len != PyList_GET_SIZE(tmp)) {
10968
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
10969
0
                    goto failed;
10970
0
                }
10971
0
                asdl_seq_SET(type_ignores, i, val);
10972
0
            }
10973
0
            Py_CLEAR(tmp);
10974
0
        }
10975
0
        *out = _PyAST_Module(body, type_ignores, arena);
10976
0
        if (*out == NULL) goto failed;
10977
0
        return 0;
10978
0
    }
10979
0
    tp = state->Interactive_type;
10980
0
    isinstance = PyObject_IsInstance(obj, tp);
10981
0
    if (isinstance == -1) {
10982
0
        return -1;
10983
0
    }
10984
0
    if (isinstance) {
10985
0
        asdl_stmt_seq* body;
10986
10987
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10988
0
            return -1;
10989
0
        }
10990
0
        if (tmp == NULL) {
10991
0
            tmp = PyList_New(0);
10992
0
            if (tmp == NULL) {
10993
0
                return -1;
10994
0
            }
10995
0
        }
10996
0
        {
10997
0
            int res;
10998
0
            Py_ssize_t len;
10999
0
            Py_ssize_t i;
11000
0
            if (!PyList_Check(tmp)) {
11001
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11002
0
                goto failed;
11003
0
            }
11004
0
            len = PyList_GET_SIZE(tmp);
11005
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11006
0
            if (body == NULL) goto failed;
11007
0
            for (i = 0; i < len; i++) {
11008
0
                stmt_ty val;
11009
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11010
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
11011
0
                    goto failed;
11012
0
                }
11013
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11014
0
                _Py_LeaveRecursiveCall();
11015
0
                Py_DECREF(tmp2);
11016
0
                if (res != 0) goto failed;
11017
0
                if (len != PyList_GET_SIZE(tmp)) {
11018
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
11019
0
                    goto failed;
11020
0
                }
11021
0
                asdl_seq_SET(body, i, val);
11022
0
            }
11023
0
            Py_CLEAR(tmp);
11024
0
        }
11025
0
        *out = _PyAST_Interactive(body, arena);
11026
0
        if (*out == NULL) goto failed;
11027
0
        return 0;
11028
0
    }
11029
0
    tp = state->Expression_type;
11030
0
    isinstance = PyObject_IsInstance(obj, tp);
11031
0
    if (isinstance == -1) {
11032
0
        return -1;
11033
0
    }
11034
0
    if (isinstance) {
11035
0
        expr_ty body;
11036
11037
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11038
0
            return -1;
11039
0
        }
11040
0
        if (tmp == NULL) {
11041
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11042
0
            return -1;
11043
0
        }
11044
0
        else {
11045
0
            int res;
11046
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11047
0
                goto failed;
11048
0
            }
11049
0
            res = obj2ast_expr(state, tmp, &body, arena);
11050
0
            _Py_LeaveRecursiveCall();
11051
0
            if (res != 0) goto failed;
11052
0
            Py_CLEAR(tmp);
11053
0
        }
11054
0
        *out = _PyAST_Expression(body, arena);
11055
0
        if (*out == NULL) goto failed;
11056
0
        return 0;
11057
0
    }
11058
0
    tp = state->FunctionType_type;
11059
0
    isinstance = PyObject_IsInstance(obj, tp);
11060
0
    if (isinstance == -1) {
11061
0
        return -1;
11062
0
    }
11063
0
    if (isinstance) {
11064
0
        asdl_expr_seq* argtypes;
11065
0
        expr_ty returns;
11066
11067
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11068
0
            return -1;
11069
0
        }
11070
0
        if (tmp == NULL) {
11071
0
            tmp = PyList_New(0);
11072
0
            if (tmp == NULL) {
11073
0
                return -1;
11074
0
            }
11075
0
        }
11076
0
        {
11077
0
            int res;
11078
0
            Py_ssize_t len;
11079
0
            Py_ssize_t i;
11080
0
            if (!PyList_Check(tmp)) {
11081
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11082
0
                goto failed;
11083
0
            }
11084
0
            len = PyList_GET_SIZE(tmp);
11085
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11086
0
            if (argtypes == NULL) goto failed;
11087
0
            for (i = 0; i < len; i++) {
11088
0
                expr_ty val;
11089
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11090
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11091
0
                    goto failed;
11092
0
                }
11093
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11094
0
                _Py_LeaveRecursiveCall();
11095
0
                Py_DECREF(tmp2);
11096
0
                if (res != 0) goto failed;
11097
0
                if (len != PyList_GET_SIZE(tmp)) {
11098
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11099
0
                    goto failed;
11100
0
                }
11101
0
                asdl_seq_SET(argtypes, i, val);
11102
0
            }
11103
0
            Py_CLEAR(tmp);
11104
0
        }
11105
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11106
0
            return -1;
11107
0
        }
11108
0
        if (tmp == NULL) {
11109
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11110
0
            return -1;
11111
0
        }
11112
0
        else {
11113
0
            int res;
11114
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11115
0
                goto failed;
11116
0
            }
11117
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11118
0
            _Py_LeaveRecursiveCall();
11119
0
            if (res != 0) goto failed;
11120
0
            Py_CLEAR(tmp);
11121
0
        }
11122
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11123
0
        if (*out == NULL) goto failed;
11124
0
        return 0;
11125
0
    }
11126
11127
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11128
0
    failed:
11129
0
    Py_XDECREF(tmp);
11130
0
    return -1;
11131
0
}
11132
11133
int
11134
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
11135
             arena)
11136
0
{
11137
0
    int isinstance;
11138
11139
0
    PyObject *tmp = NULL;
11140
0
    PyObject *tp;
11141
0
    int lineno;
11142
0
    int col_offset;
11143
0
    int end_lineno;
11144
0
    int end_col_offset;
11145
11146
0
    if (obj == Py_None) {
11147
0
        *out = NULL;
11148
0
        return 0;
11149
0
    }
11150
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11151
0
        return -1;
11152
0
    }
11153
0
    if (tmp == NULL) {
11154
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11155
0
        return -1;
11156
0
    }
11157
0
    else {
11158
0
        int res;
11159
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11160
0
            goto failed;
11161
0
        }
11162
0
        res = obj2ast_int(state, tmp, &lineno, arena);
11163
0
        _Py_LeaveRecursiveCall();
11164
0
        if (res != 0) goto failed;
11165
0
        Py_CLEAR(tmp);
11166
0
    }
11167
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11168
0
        return -1;
11169
0
    }
11170
0
    if (tmp == NULL) {
11171
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11172
0
        return -1;
11173
0
    }
11174
0
    else {
11175
0
        int res;
11176
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11177
0
            goto failed;
11178
0
        }
11179
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
11180
0
        _Py_LeaveRecursiveCall();
11181
0
        if (res != 0) goto failed;
11182
0
        Py_CLEAR(tmp);
11183
0
    }
11184
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11185
0
        return -1;
11186
0
    }
11187
0
    if (tmp == NULL || tmp == Py_None) {
11188
0
        Py_CLEAR(tmp);
11189
0
        end_lineno = lineno;
11190
0
    }
11191
0
    else {
11192
0
        int res;
11193
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11194
0
            goto failed;
11195
0
        }
11196
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
11197
0
        _Py_LeaveRecursiveCall();
11198
0
        if (res != 0) goto failed;
11199
0
        Py_CLEAR(tmp);
11200
0
    }
11201
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11202
0
        return -1;
11203
0
    }
11204
0
    if (tmp == NULL || tmp == Py_None) {
11205
0
        Py_CLEAR(tmp);
11206
0
        end_col_offset = col_offset;
11207
0
    }
11208
0
    else {
11209
0
        int res;
11210
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11211
0
            goto failed;
11212
0
        }
11213
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
11214
0
        _Py_LeaveRecursiveCall();
11215
0
        if (res != 0) goto failed;
11216
0
        Py_CLEAR(tmp);
11217
0
    }
11218
0
    tp = state->FunctionDef_type;
11219
0
    isinstance = PyObject_IsInstance(obj, tp);
11220
0
    if (isinstance == -1) {
11221
0
        return -1;
11222
0
    }
11223
0
    if (isinstance) {
11224
0
        identifier name;
11225
0
        arguments_ty args;
11226
0
        asdl_stmt_seq* body;
11227
0
        asdl_expr_seq* decorator_list;
11228
0
        expr_ty returns;
11229
0
        string type_comment;
11230
0
        asdl_type_param_seq* type_params;
11231
11232
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11233
0
            return -1;
11234
0
        }
11235
0
        if (tmp == NULL) {
11236
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11237
0
            return -1;
11238
0
        }
11239
0
        else {
11240
0
            int res;
11241
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11242
0
                goto failed;
11243
0
            }
11244
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11245
0
            _Py_LeaveRecursiveCall();
11246
0
            if (res != 0) goto failed;
11247
0
            Py_CLEAR(tmp);
11248
0
        }
11249
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11250
0
            return -1;
11251
0
        }
11252
0
        if (tmp == NULL) {
11253
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11254
0
            return -1;
11255
0
        }
11256
0
        else {
11257
0
            int res;
11258
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11259
0
                goto failed;
11260
0
            }
11261
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11262
0
            _Py_LeaveRecursiveCall();
11263
0
            if (res != 0) goto failed;
11264
0
            Py_CLEAR(tmp);
11265
0
        }
11266
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11267
0
            return -1;
11268
0
        }
11269
0
        if (tmp == NULL) {
11270
0
            tmp = PyList_New(0);
11271
0
            if (tmp == NULL) {
11272
0
                return -1;
11273
0
            }
11274
0
        }
11275
0
        {
11276
0
            int res;
11277
0
            Py_ssize_t len;
11278
0
            Py_ssize_t i;
11279
0
            if (!PyList_Check(tmp)) {
11280
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11281
0
                goto failed;
11282
0
            }
11283
0
            len = PyList_GET_SIZE(tmp);
11284
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11285
0
            if (body == NULL) goto failed;
11286
0
            for (i = 0; i < len; i++) {
11287
0
                stmt_ty val;
11288
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11289
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11290
0
                    goto failed;
11291
0
                }
11292
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11293
0
                _Py_LeaveRecursiveCall();
11294
0
                Py_DECREF(tmp2);
11295
0
                if (res != 0) goto failed;
11296
0
                if (len != PyList_GET_SIZE(tmp)) {
11297
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11298
0
                    goto failed;
11299
0
                }
11300
0
                asdl_seq_SET(body, i, val);
11301
0
            }
11302
0
            Py_CLEAR(tmp);
11303
0
        }
11304
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11305
0
            return -1;
11306
0
        }
11307
0
        if (tmp == NULL) {
11308
0
            tmp = PyList_New(0);
11309
0
            if (tmp == NULL) {
11310
0
                return -1;
11311
0
            }
11312
0
        }
11313
0
        {
11314
0
            int res;
11315
0
            Py_ssize_t len;
11316
0
            Py_ssize_t i;
11317
0
            if (!PyList_Check(tmp)) {
11318
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11319
0
                goto failed;
11320
0
            }
11321
0
            len = PyList_GET_SIZE(tmp);
11322
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11323
0
            if (decorator_list == NULL) goto failed;
11324
0
            for (i = 0; i < len; i++) {
11325
0
                expr_ty val;
11326
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11327
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11328
0
                    goto failed;
11329
0
                }
11330
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11331
0
                _Py_LeaveRecursiveCall();
11332
0
                Py_DECREF(tmp2);
11333
0
                if (res != 0) goto failed;
11334
0
                if (len != PyList_GET_SIZE(tmp)) {
11335
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11336
0
                    goto failed;
11337
0
                }
11338
0
                asdl_seq_SET(decorator_list, i, val);
11339
0
            }
11340
0
            Py_CLEAR(tmp);
11341
0
        }
11342
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11343
0
            return -1;
11344
0
        }
11345
0
        if (tmp == NULL || tmp == Py_None) {
11346
0
            Py_CLEAR(tmp);
11347
0
            returns = NULL;
11348
0
        }
11349
0
        else {
11350
0
            int res;
11351
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11352
0
                goto failed;
11353
0
            }
11354
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11355
0
            _Py_LeaveRecursiveCall();
11356
0
            if (res != 0) goto failed;
11357
0
            Py_CLEAR(tmp);
11358
0
        }
11359
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11360
0
            return -1;
11361
0
        }
11362
0
        if (tmp == NULL || tmp == Py_None) {
11363
0
            Py_CLEAR(tmp);
11364
0
            type_comment = NULL;
11365
0
        }
11366
0
        else {
11367
0
            int res;
11368
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11369
0
                goto failed;
11370
0
            }
11371
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11372
0
            _Py_LeaveRecursiveCall();
11373
0
            if (res != 0) goto failed;
11374
0
            Py_CLEAR(tmp);
11375
0
        }
11376
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11377
0
            return -1;
11378
0
        }
11379
0
        if (tmp == NULL) {
11380
0
            tmp = PyList_New(0);
11381
0
            if (tmp == NULL) {
11382
0
                return -1;
11383
0
            }
11384
0
        }
11385
0
        {
11386
0
            int res;
11387
0
            Py_ssize_t len;
11388
0
            Py_ssize_t i;
11389
0
            if (!PyList_Check(tmp)) {
11390
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11391
0
                goto failed;
11392
0
            }
11393
0
            len = PyList_GET_SIZE(tmp);
11394
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11395
0
            if (type_params == NULL) goto failed;
11396
0
            for (i = 0; i < len; i++) {
11397
0
                type_param_ty val;
11398
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11399
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11400
0
                    goto failed;
11401
0
                }
11402
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11403
0
                _Py_LeaveRecursiveCall();
11404
0
                Py_DECREF(tmp2);
11405
0
                if (res != 0) goto failed;
11406
0
                if (len != PyList_GET_SIZE(tmp)) {
11407
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11408
0
                    goto failed;
11409
0
                }
11410
0
                asdl_seq_SET(type_params, i, val);
11411
0
            }
11412
0
            Py_CLEAR(tmp);
11413
0
        }
11414
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11415
0
                                  type_comment, type_params, lineno,
11416
0
                                  col_offset, end_lineno, end_col_offset,
11417
0
                                  arena);
11418
0
        if (*out == NULL) goto failed;
11419
0
        return 0;
11420
0
    }
11421
0
    tp = state->AsyncFunctionDef_type;
11422
0
    isinstance = PyObject_IsInstance(obj, tp);
11423
0
    if (isinstance == -1) {
11424
0
        return -1;
11425
0
    }
11426
0
    if (isinstance) {
11427
0
        identifier name;
11428
0
        arguments_ty args;
11429
0
        asdl_stmt_seq* body;
11430
0
        asdl_expr_seq* decorator_list;
11431
0
        expr_ty returns;
11432
0
        string type_comment;
11433
0
        asdl_type_param_seq* type_params;
11434
11435
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11436
0
            return -1;
11437
0
        }
11438
0
        if (tmp == NULL) {
11439
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11440
0
            return -1;
11441
0
        }
11442
0
        else {
11443
0
            int res;
11444
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11445
0
                goto failed;
11446
0
            }
11447
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11448
0
            _Py_LeaveRecursiveCall();
11449
0
            if (res != 0) goto failed;
11450
0
            Py_CLEAR(tmp);
11451
0
        }
11452
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11453
0
            return -1;
11454
0
        }
11455
0
        if (tmp == NULL) {
11456
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11457
0
            return -1;
11458
0
        }
11459
0
        else {
11460
0
            int res;
11461
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11462
0
                goto failed;
11463
0
            }
11464
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11465
0
            _Py_LeaveRecursiveCall();
11466
0
            if (res != 0) goto failed;
11467
0
            Py_CLEAR(tmp);
11468
0
        }
11469
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11470
0
            return -1;
11471
0
        }
11472
0
        if (tmp == NULL) {
11473
0
            tmp = PyList_New(0);
11474
0
            if (tmp == NULL) {
11475
0
                return -1;
11476
0
            }
11477
0
        }
11478
0
        {
11479
0
            int res;
11480
0
            Py_ssize_t len;
11481
0
            Py_ssize_t i;
11482
0
            if (!PyList_Check(tmp)) {
11483
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11484
0
                goto failed;
11485
0
            }
11486
0
            len = PyList_GET_SIZE(tmp);
11487
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11488
0
            if (body == NULL) goto failed;
11489
0
            for (i = 0; i < len; i++) {
11490
0
                stmt_ty val;
11491
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11492
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11493
0
                    goto failed;
11494
0
                }
11495
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11496
0
                _Py_LeaveRecursiveCall();
11497
0
                Py_DECREF(tmp2);
11498
0
                if (res != 0) goto failed;
11499
0
                if (len != PyList_GET_SIZE(tmp)) {
11500
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11501
0
                    goto failed;
11502
0
                }
11503
0
                asdl_seq_SET(body, i, val);
11504
0
            }
11505
0
            Py_CLEAR(tmp);
11506
0
        }
11507
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11508
0
            return -1;
11509
0
        }
11510
0
        if (tmp == NULL) {
11511
0
            tmp = PyList_New(0);
11512
0
            if (tmp == NULL) {
11513
0
                return -1;
11514
0
            }
11515
0
        }
11516
0
        {
11517
0
            int res;
11518
0
            Py_ssize_t len;
11519
0
            Py_ssize_t i;
11520
0
            if (!PyList_Check(tmp)) {
11521
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11522
0
                goto failed;
11523
0
            }
11524
0
            len = PyList_GET_SIZE(tmp);
11525
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11526
0
            if (decorator_list == NULL) goto failed;
11527
0
            for (i = 0; i < len; i++) {
11528
0
                expr_ty val;
11529
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11530
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11531
0
                    goto failed;
11532
0
                }
11533
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11534
0
                _Py_LeaveRecursiveCall();
11535
0
                Py_DECREF(tmp2);
11536
0
                if (res != 0) goto failed;
11537
0
                if (len != PyList_GET_SIZE(tmp)) {
11538
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11539
0
                    goto failed;
11540
0
                }
11541
0
                asdl_seq_SET(decorator_list, i, val);
11542
0
            }
11543
0
            Py_CLEAR(tmp);
11544
0
        }
11545
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11546
0
            return -1;
11547
0
        }
11548
0
        if (tmp == NULL || tmp == Py_None) {
11549
0
            Py_CLEAR(tmp);
11550
0
            returns = NULL;
11551
0
        }
11552
0
        else {
11553
0
            int res;
11554
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11555
0
                goto failed;
11556
0
            }
11557
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11558
0
            _Py_LeaveRecursiveCall();
11559
0
            if (res != 0) goto failed;
11560
0
            Py_CLEAR(tmp);
11561
0
        }
11562
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11563
0
            return -1;
11564
0
        }
11565
0
        if (tmp == NULL || tmp == Py_None) {
11566
0
            Py_CLEAR(tmp);
11567
0
            type_comment = NULL;
11568
0
        }
11569
0
        else {
11570
0
            int res;
11571
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11572
0
                goto failed;
11573
0
            }
11574
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11575
0
            _Py_LeaveRecursiveCall();
11576
0
            if (res != 0) goto failed;
11577
0
            Py_CLEAR(tmp);
11578
0
        }
11579
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11580
0
            return -1;
11581
0
        }
11582
0
        if (tmp == NULL) {
11583
0
            tmp = PyList_New(0);
11584
0
            if (tmp == NULL) {
11585
0
                return -1;
11586
0
            }
11587
0
        }
11588
0
        {
11589
0
            int res;
11590
0
            Py_ssize_t len;
11591
0
            Py_ssize_t i;
11592
0
            if (!PyList_Check(tmp)) {
11593
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11594
0
                goto failed;
11595
0
            }
11596
0
            len = PyList_GET_SIZE(tmp);
11597
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11598
0
            if (type_params == NULL) goto failed;
11599
0
            for (i = 0; i < len; i++) {
11600
0
                type_param_ty val;
11601
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11602
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11603
0
                    goto failed;
11604
0
                }
11605
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11606
0
                _Py_LeaveRecursiveCall();
11607
0
                Py_DECREF(tmp2);
11608
0
                if (res != 0) goto failed;
11609
0
                if (len != PyList_GET_SIZE(tmp)) {
11610
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11611
0
                    goto failed;
11612
0
                }
11613
0
                asdl_seq_SET(type_params, i, val);
11614
0
            }
11615
0
            Py_CLEAR(tmp);
11616
0
        }
11617
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11618
0
                                       returns, type_comment, type_params,
11619
0
                                       lineno, col_offset, end_lineno,
11620
0
                                       end_col_offset, arena);
11621
0
        if (*out == NULL) goto failed;
11622
0
        return 0;
11623
0
    }
11624
0
    tp = state->ClassDef_type;
11625
0
    isinstance = PyObject_IsInstance(obj, tp);
11626
0
    if (isinstance == -1) {
11627
0
        return -1;
11628
0
    }
11629
0
    if (isinstance) {
11630
0
        identifier name;
11631
0
        asdl_expr_seq* bases;
11632
0
        asdl_keyword_seq* keywords;
11633
0
        asdl_stmt_seq* body;
11634
0
        asdl_expr_seq* decorator_list;
11635
0
        asdl_type_param_seq* type_params;
11636
11637
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11638
0
            return -1;
11639
0
        }
11640
0
        if (tmp == NULL) {
11641
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11642
0
            return -1;
11643
0
        }
11644
0
        else {
11645
0
            int res;
11646
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11647
0
                goto failed;
11648
0
            }
11649
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11650
0
            _Py_LeaveRecursiveCall();
11651
0
            if (res != 0) goto failed;
11652
0
            Py_CLEAR(tmp);
11653
0
        }
11654
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11655
0
            return -1;
11656
0
        }
11657
0
        if (tmp == NULL) {
11658
0
            tmp = PyList_New(0);
11659
0
            if (tmp == NULL) {
11660
0
                return -1;
11661
0
            }
11662
0
        }
11663
0
        {
11664
0
            int res;
11665
0
            Py_ssize_t len;
11666
0
            Py_ssize_t i;
11667
0
            if (!PyList_Check(tmp)) {
11668
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11669
0
                goto failed;
11670
0
            }
11671
0
            len = PyList_GET_SIZE(tmp);
11672
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11673
0
            if (bases == NULL) goto failed;
11674
0
            for (i = 0; i < len; i++) {
11675
0
                expr_ty val;
11676
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11677
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11678
0
                    goto failed;
11679
0
                }
11680
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11681
0
                _Py_LeaveRecursiveCall();
11682
0
                Py_DECREF(tmp2);
11683
0
                if (res != 0) goto failed;
11684
0
                if (len != PyList_GET_SIZE(tmp)) {
11685
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11686
0
                    goto failed;
11687
0
                }
11688
0
                asdl_seq_SET(bases, i, val);
11689
0
            }
11690
0
            Py_CLEAR(tmp);
11691
0
        }
11692
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11693
0
            return -1;
11694
0
        }
11695
0
        if (tmp == NULL) {
11696
0
            tmp = PyList_New(0);
11697
0
            if (tmp == NULL) {
11698
0
                return -1;
11699
0
            }
11700
0
        }
11701
0
        {
11702
0
            int res;
11703
0
            Py_ssize_t len;
11704
0
            Py_ssize_t i;
11705
0
            if (!PyList_Check(tmp)) {
11706
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11707
0
                goto failed;
11708
0
            }
11709
0
            len = PyList_GET_SIZE(tmp);
11710
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11711
0
            if (keywords == NULL) goto failed;
11712
0
            for (i = 0; i < len; i++) {
11713
0
                keyword_ty val;
11714
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11715
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11716
0
                    goto failed;
11717
0
                }
11718
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
11719
0
                _Py_LeaveRecursiveCall();
11720
0
                Py_DECREF(tmp2);
11721
0
                if (res != 0) goto failed;
11722
0
                if (len != PyList_GET_SIZE(tmp)) {
11723
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11724
0
                    goto failed;
11725
0
                }
11726
0
                asdl_seq_SET(keywords, i, val);
11727
0
            }
11728
0
            Py_CLEAR(tmp);
11729
0
        }
11730
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11731
0
            return -1;
11732
0
        }
11733
0
        if (tmp == NULL) {
11734
0
            tmp = PyList_New(0);
11735
0
            if (tmp == NULL) {
11736
0
                return -1;
11737
0
            }
11738
0
        }
11739
0
        {
11740
0
            int res;
11741
0
            Py_ssize_t len;
11742
0
            Py_ssize_t i;
11743
0
            if (!PyList_Check(tmp)) {
11744
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11745
0
                goto failed;
11746
0
            }
11747
0
            len = PyList_GET_SIZE(tmp);
11748
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11749
0
            if (body == NULL) goto failed;
11750
0
            for (i = 0; i < len; i++) {
11751
0
                stmt_ty val;
11752
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11753
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11754
0
                    goto failed;
11755
0
                }
11756
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11757
0
                _Py_LeaveRecursiveCall();
11758
0
                Py_DECREF(tmp2);
11759
0
                if (res != 0) goto failed;
11760
0
                if (len != PyList_GET_SIZE(tmp)) {
11761
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11762
0
                    goto failed;
11763
0
                }
11764
0
                asdl_seq_SET(body, i, val);
11765
0
            }
11766
0
            Py_CLEAR(tmp);
11767
0
        }
11768
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11769
0
            return -1;
11770
0
        }
11771
0
        if (tmp == NULL) {
11772
0
            tmp = PyList_New(0);
11773
0
            if (tmp == NULL) {
11774
0
                return -1;
11775
0
            }
11776
0
        }
11777
0
        {
11778
0
            int res;
11779
0
            Py_ssize_t len;
11780
0
            Py_ssize_t i;
11781
0
            if (!PyList_Check(tmp)) {
11782
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11783
0
                goto failed;
11784
0
            }
11785
0
            len = PyList_GET_SIZE(tmp);
11786
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11787
0
            if (decorator_list == NULL) goto failed;
11788
0
            for (i = 0; i < len; i++) {
11789
0
                expr_ty val;
11790
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11791
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11792
0
                    goto failed;
11793
0
                }
11794
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11795
0
                _Py_LeaveRecursiveCall();
11796
0
                Py_DECREF(tmp2);
11797
0
                if (res != 0) goto failed;
11798
0
                if (len != PyList_GET_SIZE(tmp)) {
11799
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11800
0
                    goto failed;
11801
0
                }
11802
0
                asdl_seq_SET(decorator_list, i, val);
11803
0
            }
11804
0
            Py_CLEAR(tmp);
11805
0
        }
11806
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11807
0
            return -1;
11808
0
        }
11809
0
        if (tmp == NULL) {
11810
0
            tmp = PyList_New(0);
11811
0
            if (tmp == NULL) {
11812
0
                return -1;
11813
0
            }
11814
0
        }
11815
0
        {
11816
0
            int res;
11817
0
            Py_ssize_t len;
11818
0
            Py_ssize_t i;
11819
0
            if (!PyList_Check(tmp)) {
11820
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11821
0
                goto failed;
11822
0
            }
11823
0
            len = PyList_GET_SIZE(tmp);
11824
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11825
0
            if (type_params == NULL) goto failed;
11826
0
            for (i = 0; i < len; i++) {
11827
0
                type_param_ty val;
11828
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11829
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11830
0
                    goto failed;
11831
0
                }
11832
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11833
0
                _Py_LeaveRecursiveCall();
11834
0
                Py_DECREF(tmp2);
11835
0
                if (res != 0) goto failed;
11836
0
                if (len != PyList_GET_SIZE(tmp)) {
11837
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11838
0
                    goto failed;
11839
0
                }
11840
0
                asdl_seq_SET(type_params, i, val);
11841
0
            }
11842
0
            Py_CLEAR(tmp);
11843
0
        }
11844
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11845
0
                               type_params, lineno, col_offset, end_lineno,
11846
0
                               end_col_offset, arena);
11847
0
        if (*out == NULL) goto failed;
11848
0
        return 0;
11849
0
    }
11850
0
    tp = state->Return_type;
11851
0
    isinstance = PyObject_IsInstance(obj, tp);
11852
0
    if (isinstance == -1) {
11853
0
        return -1;
11854
0
    }
11855
0
    if (isinstance) {
11856
0
        expr_ty value;
11857
11858
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11859
0
            return -1;
11860
0
        }
11861
0
        if (tmp == NULL || tmp == Py_None) {
11862
0
            Py_CLEAR(tmp);
11863
0
            value = NULL;
11864
0
        }
11865
0
        else {
11866
0
            int res;
11867
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11868
0
                goto failed;
11869
0
            }
11870
0
            res = obj2ast_expr(state, tmp, &value, arena);
11871
0
            _Py_LeaveRecursiveCall();
11872
0
            if (res != 0) goto failed;
11873
0
            Py_CLEAR(tmp);
11874
0
        }
11875
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11876
0
                             end_col_offset, arena);
11877
0
        if (*out == NULL) goto failed;
11878
0
        return 0;
11879
0
    }
11880
0
    tp = state->Delete_type;
11881
0
    isinstance = PyObject_IsInstance(obj, tp);
11882
0
    if (isinstance == -1) {
11883
0
        return -1;
11884
0
    }
11885
0
    if (isinstance) {
11886
0
        asdl_expr_seq* targets;
11887
11888
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11889
0
            return -1;
11890
0
        }
11891
0
        if (tmp == NULL) {
11892
0
            tmp = PyList_New(0);
11893
0
            if (tmp == NULL) {
11894
0
                return -1;
11895
0
            }
11896
0
        }
11897
0
        {
11898
0
            int res;
11899
0
            Py_ssize_t len;
11900
0
            Py_ssize_t i;
11901
0
            if (!PyList_Check(tmp)) {
11902
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11903
0
                goto failed;
11904
0
            }
11905
0
            len = PyList_GET_SIZE(tmp);
11906
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11907
0
            if (targets == NULL) goto failed;
11908
0
            for (i = 0; i < len; i++) {
11909
0
                expr_ty val;
11910
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11911
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11912
0
                    goto failed;
11913
0
                }
11914
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11915
0
                _Py_LeaveRecursiveCall();
11916
0
                Py_DECREF(tmp2);
11917
0
                if (res != 0) goto failed;
11918
0
                if (len != PyList_GET_SIZE(tmp)) {
11919
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11920
0
                    goto failed;
11921
0
                }
11922
0
                asdl_seq_SET(targets, i, val);
11923
0
            }
11924
0
            Py_CLEAR(tmp);
11925
0
        }
11926
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11927
0
                             end_col_offset, arena);
11928
0
        if (*out == NULL) goto failed;
11929
0
        return 0;
11930
0
    }
11931
0
    tp = state->Assign_type;
11932
0
    isinstance = PyObject_IsInstance(obj, tp);
11933
0
    if (isinstance == -1) {
11934
0
        return -1;
11935
0
    }
11936
0
    if (isinstance) {
11937
0
        asdl_expr_seq* targets;
11938
0
        expr_ty value;
11939
0
        string type_comment;
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, "Assign 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 'Assign' 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, "Assign 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
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11980
0
            return -1;
11981
0
        }
11982
0
        if (tmp == NULL) {
11983
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11984
0
            return -1;
11985
0
        }
11986
0
        else {
11987
0
            int res;
11988
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11989
0
                goto failed;
11990
0
            }
11991
0
            res = obj2ast_expr(state, tmp, &value, arena);
11992
0
            _Py_LeaveRecursiveCall();
11993
0
            if (res != 0) goto failed;
11994
0
            Py_CLEAR(tmp);
11995
0
        }
11996
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11997
0
            return -1;
11998
0
        }
11999
0
        if (tmp == NULL || tmp == Py_None) {
12000
0
            Py_CLEAR(tmp);
12001
0
            type_comment = NULL;
12002
0
        }
12003
0
        else {
12004
0
            int res;
12005
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12006
0
                goto failed;
12007
0
            }
12008
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12009
0
            _Py_LeaveRecursiveCall();
12010
0
            if (res != 0) goto failed;
12011
0
            Py_CLEAR(tmp);
12012
0
        }
12013
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
12014
0
                             end_lineno, end_col_offset, arena);
12015
0
        if (*out == NULL) goto failed;
12016
0
        return 0;
12017
0
    }
12018
0
    tp = state->TypeAlias_type;
12019
0
    isinstance = PyObject_IsInstance(obj, tp);
12020
0
    if (isinstance == -1) {
12021
0
        return -1;
12022
0
    }
12023
0
    if (isinstance) {
12024
0
        expr_ty name;
12025
0
        asdl_type_param_seq* type_params;
12026
0
        expr_ty value;
12027
12028
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12029
0
            return -1;
12030
0
        }
12031
0
        if (tmp == NULL) {
12032
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12033
0
            return -1;
12034
0
        }
12035
0
        else {
12036
0
            int res;
12037
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12038
0
                goto failed;
12039
0
            }
12040
0
            res = obj2ast_expr(state, tmp, &name, arena);
12041
0
            _Py_LeaveRecursiveCall();
12042
0
            if (res != 0) goto failed;
12043
0
            Py_CLEAR(tmp);
12044
0
        }
12045
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12046
0
            return -1;
12047
0
        }
12048
0
        if (tmp == NULL) {
12049
0
            tmp = PyList_New(0);
12050
0
            if (tmp == NULL) {
12051
0
                return -1;
12052
0
            }
12053
0
        }
12054
0
        {
12055
0
            int res;
12056
0
            Py_ssize_t len;
12057
0
            Py_ssize_t i;
12058
0
            if (!PyList_Check(tmp)) {
12059
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12060
0
                goto failed;
12061
0
            }
12062
0
            len = PyList_GET_SIZE(tmp);
12063
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12064
0
            if (type_params == NULL) goto failed;
12065
0
            for (i = 0; i < len; i++) {
12066
0
                type_param_ty val;
12067
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12068
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12069
0
                    goto failed;
12070
0
                }
12071
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
12072
0
                _Py_LeaveRecursiveCall();
12073
0
                Py_DECREF(tmp2);
12074
0
                if (res != 0) goto failed;
12075
0
                if (len != PyList_GET_SIZE(tmp)) {
12076
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12077
0
                    goto failed;
12078
0
                }
12079
0
                asdl_seq_SET(type_params, i, val);
12080
0
            }
12081
0
            Py_CLEAR(tmp);
12082
0
        }
12083
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12084
0
            return -1;
12085
0
        }
12086
0
        if (tmp == NULL) {
12087
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12088
0
            return -1;
12089
0
        }
12090
0
        else {
12091
0
            int res;
12092
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12093
0
                goto failed;
12094
0
            }
12095
0
            res = obj2ast_expr(state, tmp, &value, arena);
12096
0
            _Py_LeaveRecursiveCall();
12097
0
            if (res != 0) goto failed;
12098
0
            Py_CLEAR(tmp);
12099
0
        }
12100
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12101
0
                                end_lineno, end_col_offset, arena);
12102
0
        if (*out == NULL) goto failed;
12103
0
        return 0;
12104
0
    }
12105
0
    tp = state->AugAssign_type;
12106
0
    isinstance = PyObject_IsInstance(obj, tp);
12107
0
    if (isinstance == -1) {
12108
0
        return -1;
12109
0
    }
12110
0
    if (isinstance) {
12111
0
        expr_ty target;
12112
0
        operator_ty op;
12113
0
        expr_ty value;
12114
12115
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12116
0
            return -1;
12117
0
        }
12118
0
        if (tmp == NULL) {
12119
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12120
0
            return -1;
12121
0
        }
12122
0
        else {
12123
0
            int res;
12124
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12125
0
                goto failed;
12126
0
            }
12127
0
            res = obj2ast_expr(state, tmp, &target, arena);
12128
0
            _Py_LeaveRecursiveCall();
12129
0
            if (res != 0) goto failed;
12130
0
            Py_CLEAR(tmp);
12131
0
        }
12132
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12133
0
            return -1;
12134
0
        }
12135
0
        if (tmp == NULL) {
12136
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12137
0
            return -1;
12138
0
        }
12139
0
        else {
12140
0
            int res;
12141
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12142
0
                goto failed;
12143
0
            }
12144
0
            res = obj2ast_operator(state, tmp, &op, arena);
12145
0
            _Py_LeaveRecursiveCall();
12146
0
            if (res != 0) goto failed;
12147
0
            Py_CLEAR(tmp);
12148
0
        }
12149
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12150
0
            return -1;
12151
0
        }
12152
0
        if (tmp == NULL) {
12153
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12154
0
            return -1;
12155
0
        }
12156
0
        else {
12157
0
            int res;
12158
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12159
0
                goto failed;
12160
0
            }
12161
0
            res = obj2ast_expr(state, tmp, &value, arena);
12162
0
            _Py_LeaveRecursiveCall();
12163
0
            if (res != 0) goto failed;
12164
0
            Py_CLEAR(tmp);
12165
0
        }
12166
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12167
0
                                end_lineno, end_col_offset, arena);
12168
0
        if (*out == NULL) goto failed;
12169
0
        return 0;
12170
0
    }
12171
0
    tp = state->AnnAssign_type;
12172
0
    isinstance = PyObject_IsInstance(obj, tp);
12173
0
    if (isinstance == -1) {
12174
0
        return -1;
12175
0
    }
12176
0
    if (isinstance) {
12177
0
        expr_ty target;
12178
0
        expr_ty annotation;
12179
0
        expr_ty value;
12180
0
        int simple;
12181
12182
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12183
0
            return -1;
12184
0
        }
12185
0
        if (tmp == NULL) {
12186
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12187
0
            return -1;
12188
0
        }
12189
0
        else {
12190
0
            int res;
12191
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12192
0
                goto failed;
12193
0
            }
12194
0
            res = obj2ast_expr(state, tmp, &target, arena);
12195
0
            _Py_LeaveRecursiveCall();
12196
0
            if (res != 0) goto failed;
12197
0
            Py_CLEAR(tmp);
12198
0
        }
12199
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12200
0
            return -1;
12201
0
        }
12202
0
        if (tmp == NULL) {
12203
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12204
0
            return -1;
12205
0
        }
12206
0
        else {
12207
0
            int res;
12208
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12209
0
                goto failed;
12210
0
            }
12211
0
            res = obj2ast_expr(state, tmp, &annotation, arena);
12212
0
            _Py_LeaveRecursiveCall();
12213
0
            if (res != 0) goto failed;
12214
0
            Py_CLEAR(tmp);
12215
0
        }
12216
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12217
0
            return -1;
12218
0
        }
12219
0
        if (tmp == NULL || tmp == Py_None) {
12220
0
            Py_CLEAR(tmp);
12221
0
            value = NULL;
12222
0
        }
12223
0
        else {
12224
0
            int res;
12225
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12226
0
                goto failed;
12227
0
            }
12228
0
            res = obj2ast_expr(state, tmp, &value, arena);
12229
0
            _Py_LeaveRecursiveCall();
12230
0
            if (res != 0) goto failed;
12231
0
            Py_CLEAR(tmp);
12232
0
        }
12233
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
12234
0
            return -1;
12235
0
        }
12236
0
        if (tmp == NULL) {
12237
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12238
0
            return -1;
12239
0
        }
12240
0
        else {
12241
0
            int res;
12242
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12243
0
                goto failed;
12244
0
            }
12245
0
            res = obj2ast_int(state, tmp, &simple, arena);
12246
0
            _Py_LeaveRecursiveCall();
12247
0
            if (res != 0) goto failed;
12248
0
            Py_CLEAR(tmp);
12249
0
        }
12250
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12251
0
                                col_offset, end_lineno, end_col_offset, arena);
12252
0
        if (*out == NULL) goto failed;
12253
0
        return 0;
12254
0
    }
12255
0
    tp = state->For_type;
12256
0
    isinstance = PyObject_IsInstance(obj, tp);
12257
0
    if (isinstance == -1) {
12258
0
        return -1;
12259
0
    }
12260
0
    if (isinstance) {
12261
0
        expr_ty target;
12262
0
        expr_ty iter;
12263
0
        asdl_stmt_seq* body;
12264
0
        asdl_stmt_seq* orelse;
12265
0
        string type_comment;
12266
12267
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12268
0
            return -1;
12269
0
        }
12270
0
        if (tmp == NULL) {
12271
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12272
0
            return -1;
12273
0
        }
12274
0
        else {
12275
0
            int res;
12276
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12277
0
                goto failed;
12278
0
            }
12279
0
            res = obj2ast_expr(state, tmp, &target, arena);
12280
0
            _Py_LeaveRecursiveCall();
12281
0
            if (res != 0) goto failed;
12282
0
            Py_CLEAR(tmp);
12283
0
        }
12284
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12285
0
            return -1;
12286
0
        }
12287
0
        if (tmp == NULL) {
12288
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12289
0
            return -1;
12290
0
        }
12291
0
        else {
12292
0
            int res;
12293
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12294
0
                goto failed;
12295
0
            }
12296
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12297
0
            _Py_LeaveRecursiveCall();
12298
0
            if (res != 0) goto failed;
12299
0
            Py_CLEAR(tmp);
12300
0
        }
12301
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12302
0
            return -1;
12303
0
        }
12304
0
        if (tmp == NULL) {
12305
0
            tmp = PyList_New(0);
12306
0
            if (tmp == NULL) {
12307
0
                return -1;
12308
0
            }
12309
0
        }
12310
0
        {
12311
0
            int res;
12312
0
            Py_ssize_t len;
12313
0
            Py_ssize_t i;
12314
0
            if (!PyList_Check(tmp)) {
12315
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12316
0
                goto failed;
12317
0
            }
12318
0
            len = PyList_GET_SIZE(tmp);
12319
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12320
0
            if (body == NULL) goto failed;
12321
0
            for (i = 0; i < len; i++) {
12322
0
                stmt_ty val;
12323
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12324
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12325
0
                    goto failed;
12326
0
                }
12327
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12328
0
                _Py_LeaveRecursiveCall();
12329
0
                Py_DECREF(tmp2);
12330
0
                if (res != 0) goto failed;
12331
0
                if (len != PyList_GET_SIZE(tmp)) {
12332
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12333
0
                    goto failed;
12334
0
                }
12335
0
                asdl_seq_SET(body, i, val);
12336
0
            }
12337
0
            Py_CLEAR(tmp);
12338
0
        }
12339
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12340
0
            return -1;
12341
0
        }
12342
0
        if (tmp == NULL) {
12343
0
            tmp = PyList_New(0);
12344
0
            if (tmp == NULL) {
12345
0
                return -1;
12346
0
            }
12347
0
        }
12348
0
        {
12349
0
            int res;
12350
0
            Py_ssize_t len;
12351
0
            Py_ssize_t i;
12352
0
            if (!PyList_Check(tmp)) {
12353
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12354
0
                goto failed;
12355
0
            }
12356
0
            len = PyList_GET_SIZE(tmp);
12357
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12358
0
            if (orelse == NULL) goto failed;
12359
0
            for (i = 0; i < len; i++) {
12360
0
                stmt_ty val;
12361
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12362
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12363
0
                    goto failed;
12364
0
                }
12365
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12366
0
                _Py_LeaveRecursiveCall();
12367
0
                Py_DECREF(tmp2);
12368
0
                if (res != 0) goto failed;
12369
0
                if (len != PyList_GET_SIZE(tmp)) {
12370
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12371
0
                    goto failed;
12372
0
                }
12373
0
                asdl_seq_SET(orelse, i, val);
12374
0
            }
12375
0
            Py_CLEAR(tmp);
12376
0
        }
12377
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12378
0
            return -1;
12379
0
        }
12380
0
        if (tmp == NULL || tmp == Py_None) {
12381
0
            Py_CLEAR(tmp);
12382
0
            type_comment = NULL;
12383
0
        }
12384
0
        else {
12385
0
            int res;
12386
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12387
0
                goto failed;
12388
0
            }
12389
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12390
0
            _Py_LeaveRecursiveCall();
12391
0
            if (res != 0) goto failed;
12392
0
            Py_CLEAR(tmp);
12393
0
        }
12394
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12395
0
                          col_offset, end_lineno, end_col_offset, arena);
12396
0
        if (*out == NULL) goto failed;
12397
0
        return 0;
12398
0
    }
12399
0
    tp = state->AsyncFor_type;
12400
0
    isinstance = PyObject_IsInstance(obj, tp);
12401
0
    if (isinstance == -1) {
12402
0
        return -1;
12403
0
    }
12404
0
    if (isinstance) {
12405
0
        expr_ty target;
12406
0
        expr_ty iter;
12407
0
        asdl_stmt_seq* body;
12408
0
        asdl_stmt_seq* orelse;
12409
0
        string type_comment;
12410
12411
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12412
0
            return -1;
12413
0
        }
12414
0
        if (tmp == NULL) {
12415
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12416
0
            return -1;
12417
0
        }
12418
0
        else {
12419
0
            int res;
12420
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12421
0
                goto failed;
12422
0
            }
12423
0
            res = obj2ast_expr(state, tmp, &target, arena);
12424
0
            _Py_LeaveRecursiveCall();
12425
0
            if (res != 0) goto failed;
12426
0
            Py_CLEAR(tmp);
12427
0
        }
12428
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12429
0
            return -1;
12430
0
        }
12431
0
        if (tmp == NULL) {
12432
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12433
0
            return -1;
12434
0
        }
12435
0
        else {
12436
0
            int res;
12437
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12438
0
                goto failed;
12439
0
            }
12440
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12441
0
            _Py_LeaveRecursiveCall();
12442
0
            if (res != 0) goto failed;
12443
0
            Py_CLEAR(tmp);
12444
0
        }
12445
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12446
0
            return -1;
12447
0
        }
12448
0
        if (tmp == NULL) {
12449
0
            tmp = PyList_New(0);
12450
0
            if (tmp == NULL) {
12451
0
                return -1;
12452
0
            }
12453
0
        }
12454
0
        {
12455
0
            int res;
12456
0
            Py_ssize_t len;
12457
0
            Py_ssize_t i;
12458
0
            if (!PyList_Check(tmp)) {
12459
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12460
0
                goto failed;
12461
0
            }
12462
0
            len = PyList_GET_SIZE(tmp);
12463
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12464
0
            if (body == NULL) goto failed;
12465
0
            for (i = 0; i < len; i++) {
12466
0
                stmt_ty val;
12467
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12468
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12469
0
                    goto failed;
12470
0
                }
12471
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12472
0
                _Py_LeaveRecursiveCall();
12473
0
                Py_DECREF(tmp2);
12474
0
                if (res != 0) goto failed;
12475
0
                if (len != PyList_GET_SIZE(tmp)) {
12476
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12477
0
                    goto failed;
12478
0
                }
12479
0
                asdl_seq_SET(body, i, val);
12480
0
            }
12481
0
            Py_CLEAR(tmp);
12482
0
        }
12483
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12484
0
            return -1;
12485
0
        }
12486
0
        if (tmp == NULL) {
12487
0
            tmp = PyList_New(0);
12488
0
            if (tmp == NULL) {
12489
0
                return -1;
12490
0
            }
12491
0
        }
12492
0
        {
12493
0
            int res;
12494
0
            Py_ssize_t len;
12495
0
            Py_ssize_t i;
12496
0
            if (!PyList_Check(tmp)) {
12497
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12498
0
                goto failed;
12499
0
            }
12500
0
            len = PyList_GET_SIZE(tmp);
12501
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12502
0
            if (orelse == NULL) goto failed;
12503
0
            for (i = 0; i < len; i++) {
12504
0
                stmt_ty val;
12505
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12506
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12507
0
                    goto failed;
12508
0
                }
12509
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12510
0
                _Py_LeaveRecursiveCall();
12511
0
                Py_DECREF(tmp2);
12512
0
                if (res != 0) goto failed;
12513
0
                if (len != PyList_GET_SIZE(tmp)) {
12514
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12515
0
                    goto failed;
12516
0
                }
12517
0
                asdl_seq_SET(orelse, i, val);
12518
0
            }
12519
0
            Py_CLEAR(tmp);
12520
0
        }
12521
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12522
0
            return -1;
12523
0
        }
12524
0
        if (tmp == NULL || tmp == Py_None) {
12525
0
            Py_CLEAR(tmp);
12526
0
            type_comment = NULL;
12527
0
        }
12528
0
        else {
12529
0
            int res;
12530
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12531
0
                goto failed;
12532
0
            }
12533
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12534
0
            _Py_LeaveRecursiveCall();
12535
0
            if (res != 0) goto failed;
12536
0
            Py_CLEAR(tmp);
12537
0
        }
12538
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12539
0
                               lineno, col_offset, end_lineno, end_col_offset,
12540
0
                               arena);
12541
0
        if (*out == NULL) goto failed;
12542
0
        return 0;
12543
0
    }
12544
0
    tp = state->While_type;
12545
0
    isinstance = PyObject_IsInstance(obj, tp);
12546
0
    if (isinstance == -1) {
12547
0
        return -1;
12548
0
    }
12549
0
    if (isinstance) {
12550
0
        expr_ty test;
12551
0
        asdl_stmt_seq* body;
12552
0
        asdl_stmt_seq* orelse;
12553
12554
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12555
0
            return -1;
12556
0
        }
12557
0
        if (tmp == NULL) {
12558
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12559
0
            return -1;
12560
0
        }
12561
0
        else {
12562
0
            int res;
12563
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12564
0
                goto failed;
12565
0
            }
12566
0
            res = obj2ast_expr(state, tmp, &test, arena);
12567
0
            _Py_LeaveRecursiveCall();
12568
0
            if (res != 0) goto failed;
12569
0
            Py_CLEAR(tmp);
12570
0
        }
12571
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12572
0
            return -1;
12573
0
        }
12574
0
        if (tmp == NULL) {
12575
0
            tmp = PyList_New(0);
12576
0
            if (tmp == NULL) {
12577
0
                return -1;
12578
0
            }
12579
0
        }
12580
0
        {
12581
0
            int res;
12582
0
            Py_ssize_t len;
12583
0
            Py_ssize_t i;
12584
0
            if (!PyList_Check(tmp)) {
12585
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12586
0
                goto failed;
12587
0
            }
12588
0
            len = PyList_GET_SIZE(tmp);
12589
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12590
0
            if (body == NULL) goto failed;
12591
0
            for (i = 0; i < len; i++) {
12592
0
                stmt_ty val;
12593
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12594
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12595
0
                    goto failed;
12596
0
                }
12597
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12598
0
                _Py_LeaveRecursiveCall();
12599
0
                Py_DECREF(tmp2);
12600
0
                if (res != 0) goto failed;
12601
0
                if (len != PyList_GET_SIZE(tmp)) {
12602
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12603
0
                    goto failed;
12604
0
                }
12605
0
                asdl_seq_SET(body, i, val);
12606
0
            }
12607
0
            Py_CLEAR(tmp);
12608
0
        }
12609
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12610
0
            return -1;
12611
0
        }
12612
0
        if (tmp == NULL) {
12613
0
            tmp = PyList_New(0);
12614
0
            if (tmp == NULL) {
12615
0
                return -1;
12616
0
            }
12617
0
        }
12618
0
        {
12619
0
            int res;
12620
0
            Py_ssize_t len;
12621
0
            Py_ssize_t i;
12622
0
            if (!PyList_Check(tmp)) {
12623
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12624
0
                goto failed;
12625
0
            }
12626
0
            len = PyList_GET_SIZE(tmp);
12627
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12628
0
            if (orelse == NULL) goto failed;
12629
0
            for (i = 0; i < len; i++) {
12630
0
                stmt_ty val;
12631
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12632
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12633
0
                    goto failed;
12634
0
                }
12635
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12636
0
                _Py_LeaveRecursiveCall();
12637
0
                Py_DECREF(tmp2);
12638
0
                if (res != 0) goto failed;
12639
0
                if (len != PyList_GET_SIZE(tmp)) {
12640
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12641
0
                    goto failed;
12642
0
                }
12643
0
                asdl_seq_SET(orelse, i, val);
12644
0
            }
12645
0
            Py_CLEAR(tmp);
12646
0
        }
12647
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12648
0
                            end_col_offset, arena);
12649
0
        if (*out == NULL) goto failed;
12650
0
        return 0;
12651
0
    }
12652
0
    tp = state->If_type;
12653
0
    isinstance = PyObject_IsInstance(obj, tp);
12654
0
    if (isinstance == -1) {
12655
0
        return -1;
12656
0
    }
12657
0
    if (isinstance) {
12658
0
        expr_ty test;
12659
0
        asdl_stmt_seq* body;
12660
0
        asdl_stmt_seq* orelse;
12661
12662
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12663
0
            return -1;
12664
0
        }
12665
0
        if (tmp == NULL) {
12666
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12667
0
            return -1;
12668
0
        }
12669
0
        else {
12670
0
            int res;
12671
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12672
0
                goto failed;
12673
0
            }
12674
0
            res = obj2ast_expr(state, tmp, &test, arena);
12675
0
            _Py_LeaveRecursiveCall();
12676
0
            if (res != 0) goto failed;
12677
0
            Py_CLEAR(tmp);
12678
0
        }
12679
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12680
0
            return -1;
12681
0
        }
12682
0
        if (tmp == NULL) {
12683
0
            tmp = PyList_New(0);
12684
0
            if (tmp == NULL) {
12685
0
                return -1;
12686
0
            }
12687
0
        }
12688
0
        {
12689
0
            int res;
12690
0
            Py_ssize_t len;
12691
0
            Py_ssize_t i;
12692
0
            if (!PyList_Check(tmp)) {
12693
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12694
0
                goto failed;
12695
0
            }
12696
0
            len = PyList_GET_SIZE(tmp);
12697
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12698
0
            if (body == NULL) goto failed;
12699
0
            for (i = 0; i < len; i++) {
12700
0
                stmt_ty val;
12701
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12702
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12703
0
                    goto failed;
12704
0
                }
12705
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12706
0
                _Py_LeaveRecursiveCall();
12707
0
                Py_DECREF(tmp2);
12708
0
                if (res != 0) goto failed;
12709
0
                if (len != PyList_GET_SIZE(tmp)) {
12710
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12711
0
                    goto failed;
12712
0
                }
12713
0
                asdl_seq_SET(body, i, val);
12714
0
            }
12715
0
            Py_CLEAR(tmp);
12716
0
        }
12717
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12718
0
            return -1;
12719
0
        }
12720
0
        if (tmp == NULL) {
12721
0
            tmp = PyList_New(0);
12722
0
            if (tmp == NULL) {
12723
0
                return -1;
12724
0
            }
12725
0
        }
12726
0
        {
12727
0
            int res;
12728
0
            Py_ssize_t len;
12729
0
            Py_ssize_t i;
12730
0
            if (!PyList_Check(tmp)) {
12731
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12732
0
                goto failed;
12733
0
            }
12734
0
            len = PyList_GET_SIZE(tmp);
12735
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12736
0
            if (orelse == NULL) goto failed;
12737
0
            for (i = 0; i < len; i++) {
12738
0
                stmt_ty val;
12739
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12740
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12741
0
                    goto failed;
12742
0
                }
12743
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12744
0
                _Py_LeaveRecursiveCall();
12745
0
                Py_DECREF(tmp2);
12746
0
                if (res != 0) goto failed;
12747
0
                if (len != PyList_GET_SIZE(tmp)) {
12748
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12749
0
                    goto failed;
12750
0
                }
12751
0
                asdl_seq_SET(orelse, i, val);
12752
0
            }
12753
0
            Py_CLEAR(tmp);
12754
0
        }
12755
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12756
0
                         end_col_offset, arena);
12757
0
        if (*out == NULL) goto failed;
12758
0
        return 0;
12759
0
    }
12760
0
    tp = state->With_type;
12761
0
    isinstance = PyObject_IsInstance(obj, tp);
12762
0
    if (isinstance == -1) {
12763
0
        return -1;
12764
0
    }
12765
0
    if (isinstance) {
12766
0
        asdl_withitem_seq* items;
12767
0
        asdl_stmt_seq* body;
12768
0
        string type_comment;
12769
12770
0
        if (PyObject_GetOptionalAttr(obj, state->items, &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, "With field \"items\" 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
            items = _Py_asdl_withitem_seq_new(len, arena);
12789
0
            if (items == NULL) goto failed;
12790
0
            for (i = 0; i < len; i++) {
12791
0
                withitem_ty val;
12792
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12793
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12794
0
                    goto failed;
12795
0
                }
12796
0
                res = obj2ast_withitem(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, "With field \"items\" changed size during iteration");
12802
0
                    goto failed;
12803
0
                }
12804
0
                asdl_seq_SET(items, i, val);
12805
0
            }
12806
0
            Py_CLEAR(tmp);
12807
0
        }
12808
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12809
0
            return -1;
12810
0
        }
12811
0
        if (tmp == NULL) {
12812
0
            tmp = PyList_New(0);
12813
0
            if (tmp == NULL) {
12814
0
                return -1;
12815
0
            }
12816
0
        }
12817
0
        {
12818
0
            int res;
12819
0
            Py_ssize_t len;
12820
0
            Py_ssize_t i;
12821
0
            if (!PyList_Check(tmp)) {
12822
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12823
0
                goto failed;
12824
0
            }
12825
0
            len = PyList_GET_SIZE(tmp);
12826
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12827
0
            if (body == NULL) goto failed;
12828
0
            for (i = 0; i < len; i++) {
12829
0
                stmt_ty val;
12830
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12831
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12832
0
                    goto failed;
12833
0
                }
12834
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12835
0
                _Py_LeaveRecursiveCall();
12836
0
                Py_DECREF(tmp2);
12837
0
                if (res != 0) goto failed;
12838
0
                if (len != PyList_GET_SIZE(tmp)) {
12839
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12840
0
                    goto failed;
12841
0
                }
12842
0
                asdl_seq_SET(body, i, val);
12843
0
            }
12844
0
            Py_CLEAR(tmp);
12845
0
        }
12846
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12847
0
            return -1;
12848
0
        }
12849
0
        if (tmp == NULL || tmp == Py_None) {
12850
0
            Py_CLEAR(tmp);
12851
0
            type_comment = NULL;
12852
0
        }
12853
0
        else {
12854
0
            int res;
12855
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12856
0
                goto failed;
12857
0
            }
12858
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12859
0
            _Py_LeaveRecursiveCall();
12860
0
            if (res != 0) goto failed;
12861
0
            Py_CLEAR(tmp);
12862
0
        }
12863
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12864
0
                           end_lineno, end_col_offset, arena);
12865
0
        if (*out == NULL) goto failed;
12866
0
        return 0;
12867
0
    }
12868
0
    tp = state->AsyncWith_type;
12869
0
    isinstance = PyObject_IsInstance(obj, tp);
12870
0
    if (isinstance == -1) {
12871
0
        return -1;
12872
0
    }
12873
0
    if (isinstance) {
12874
0
        asdl_withitem_seq* items;
12875
0
        asdl_stmt_seq* body;
12876
0
        string type_comment;
12877
12878
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12879
0
            return -1;
12880
0
        }
12881
0
        if (tmp == NULL) {
12882
0
            tmp = PyList_New(0);
12883
0
            if (tmp == NULL) {
12884
0
                return -1;
12885
0
            }
12886
0
        }
12887
0
        {
12888
0
            int res;
12889
0
            Py_ssize_t len;
12890
0
            Py_ssize_t i;
12891
0
            if (!PyList_Check(tmp)) {
12892
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12893
0
                goto failed;
12894
0
            }
12895
0
            len = PyList_GET_SIZE(tmp);
12896
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12897
0
            if (items == NULL) goto failed;
12898
0
            for (i = 0; i < len; i++) {
12899
0
                withitem_ty val;
12900
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12901
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12902
0
                    goto failed;
12903
0
                }
12904
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12905
0
                _Py_LeaveRecursiveCall();
12906
0
                Py_DECREF(tmp2);
12907
0
                if (res != 0) goto failed;
12908
0
                if (len != PyList_GET_SIZE(tmp)) {
12909
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12910
0
                    goto failed;
12911
0
                }
12912
0
                asdl_seq_SET(items, i, val);
12913
0
            }
12914
0
            Py_CLEAR(tmp);
12915
0
        }
12916
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12917
0
            return -1;
12918
0
        }
12919
0
        if (tmp == NULL) {
12920
0
            tmp = PyList_New(0);
12921
0
            if (tmp == NULL) {
12922
0
                return -1;
12923
0
            }
12924
0
        }
12925
0
        {
12926
0
            int res;
12927
0
            Py_ssize_t len;
12928
0
            Py_ssize_t i;
12929
0
            if (!PyList_Check(tmp)) {
12930
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12931
0
                goto failed;
12932
0
            }
12933
0
            len = PyList_GET_SIZE(tmp);
12934
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12935
0
            if (body == NULL) goto failed;
12936
0
            for (i = 0; i < len; i++) {
12937
0
                stmt_ty val;
12938
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12939
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12940
0
                    goto failed;
12941
0
                }
12942
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12943
0
                _Py_LeaveRecursiveCall();
12944
0
                Py_DECREF(tmp2);
12945
0
                if (res != 0) goto failed;
12946
0
                if (len != PyList_GET_SIZE(tmp)) {
12947
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12948
0
                    goto failed;
12949
0
                }
12950
0
                asdl_seq_SET(body, i, val);
12951
0
            }
12952
0
            Py_CLEAR(tmp);
12953
0
        }
12954
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12955
0
            return -1;
12956
0
        }
12957
0
        if (tmp == NULL || tmp == Py_None) {
12958
0
            Py_CLEAR(tmp);
12959
0
            type_comment = NULL;
12960
0
        }
12961
0
        else {
12962
0
            int res;
12963
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12964
0
                goto failed;
12965
0
            }
12966
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12967
0
            _Py_LeaveRecursiveCall();
12968
0
            if (res != 0) goto failed;
12969
0
            Py_CLEAR(tmp);
12970
0
        }
12971
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12972
0
                                end_lineno, end_col_offset, arena);
12973
0
        if (*out == NULL) goto failed;
12974
0
        return 0;
12975
0
    }
12976
0
    tp = state->Match_type;
12977
0
    isinstance = PyObject_IsInstance(obj, tp);
12978
0
    if (isinstance == -1) {
12979
0
        return -1;
12980
0
    }
12981
0
    if (isinstance) {
12982
0
        expr_ty subject;
12983
0
        asdl_match_case_seq* cases;
12984
12985
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
12986
0
            return -1;
12987
0
        }
12988
0
        if (tmp == NULL) {
12989
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
12990
0
            return -1;
12991
0
        }
12992
0
        else {
12993
0
            int res;
12994
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
12995
0
                goto failed;
12996
0
            }
12997
0
            res = obj2ast_expr(state, tmp, &subject, arena);
12998
0
            _Py_LeaveRecursiveCall();
12999
0
            if (res != 0) goto failed;
13000
0
            Py_CLEAR(tmp);
13001
0
        }
13002
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
13003
0
            return -1;
13004
0
        }
13005
0
        if (tmp == NULL) {
13006
0
            tmp = PyList_New(0);
13007
0
            if (tmp == NULL) {
13008
0
                return -1;
13009
0
            }
13010
0
        }
13011
0
        {
13012
0
            int res;
13013
0
            Py_ssize_t len;
13014
0
            Py_ssize_t i;
13015
0
            if (!PyList_Check(tmp)) {
13016
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13017
0
                goto failed;
13018
0
            }
13019
0
            len = PyList_GET_SIZE(tmp);
13020
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13021
0
            if (cases == NULL) goto failed;
13022
0
            for (i = 0; i < len; i++) {
13023
0
                match_case_ty val;
13024
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13025
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13026
0
                    goto failed;
13027
0
                }
13028
0
                res = obj2ast_match_case(state, tmp2, &val, arena);
13029
0
                _Py_LeaveRecursiveCall();
13030
0
                Py_DECREF(tmp2);
13031
0
                if (res != 0) goto failed;
13032
0
                if (len != PyList_GET_SIZE(tmp)) {
13033
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13034
0
                    goto failed;
13035
0
                }
13036
0
                asdl_seq_SET(cases, i, val);
13037
0
            }
13038
0
            Py_CLEAR(tmp);
13039
0
        }
13040
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13041
0
                            end_col_offset, arena);
13042
0
        if (*out == NULL) goto failed;
13043
0
        return 0;
13044
0
    }
13045
0
    tp = state->Raise_type;
13046
0
    isinstance = PyObject_IsInstance(obj, tp);
13047
0
    if (isinstance == -1) {
13048
0
        return -1;
13049
0
    }
13050
0
    if (isinstance) {
13051
0
        expr_ty exc;
13052
0
        expr_ty cause;
13053
13054
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13055
0
            return -1;
13056
0
        }
13057
0
        if (tmp == NULL || tmp == Py_None) {
13058
0
            Py_CLEAR(tmp);
13059
0
            exc = NULL;
13060
0
        }
13061
0
        else {
13062
0
            int res;
13063
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13064
0
                goto failed;
13065
0
            }
13066
0
            res = obj2ast_expr(state, tmp, &exc, arena);
13067
0
            _Py_LeaveRecursiveCall();
13068
0
            if (res != 0) goto failed;
13069
0
            Py_CLEAR(tmp);
13070
0
        }
13071
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13072
0
            return -1;
13073
0
        }
13074
0
        if (tmp == NULL || tmp == Py_None) {
13075
0
            Py_CLEAR(tmp);
13076
0
            cause = NULL;
13077
0
        }
13078
0
        else {
13079
0
            int res;
13080
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13081
0
                goto failed;
13082
0
            }
13083
0
            res = obj2ast_expr(state, tmp, &cause, arena);
13084
0
            _Py_LeaveRecursiveCall();
13085
0
            if (res != 0) goto failed;
13086
0
            Py_CLEAR(tmp);
13087
0
        }
13088
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13089
0
                            end_col_offset, arena);
13090
0
        if (*out == NULL) goto failed;
13091
0
        return 0;
13092
0
    }
13093
0
    tp = state->Try_type;
13094
0
    isinstance = PyObject_IsInstance(obj, tp);
13095
0
    if (isinstance == -1) {
13096
0
        return -1;
13097
0
    }
13098
0
    if (isinstance) {
13099
0
        asdl_stmt_seq* body;
13100
0
        asdl_excepthandler_seq* handlers;
13101
0
        asdl_stmt_seq* orelse;
13102
0
        asdl_stmt_seq* finalbody;
13103
13104
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13105
0
            return -1;
13106
0
        }
13107
0
        if (tmp == NULL) {
13108
0
            tmp = PyList_New(0);
13109
0
            if (tmp == NULL) {
13110
0
                return -1;
13111
0
            }
13112
0
        }
13113
0
        {
13114
0
            int res;
13115
0
            Py_ssize_t len;
13116
0
            Py_ssize_t i;
13117
0
            if (!PyList_Check(tmp)) {
13118
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13119
0
                goto failed;
13120
0
            }
13121
0
            len = PyList_GET_SIZE(tmp);
13122
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13123
0
            if (body == NULL) goto failed;
13124
0
            for (i = 0; i < len; i++) {
13125
0
                stmt_ty val;
13126
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13127
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13128
0
                    goto failed;
13129
0
                }
13130
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13131
0
                _Py_LeaveRecursiveCall();
13132
0
                Py_DECREF(tmp2);
13133
0
                if (res != 0) goto failed;
13134
0
                if (len != PyList_GET_SIZE(tmp)) {
13135
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13136
0
                    goto failed;
13137
0
                }
13138
0
                asdl_seq_SET(body, i, val);
13139
0
            }
13140
0
            Py_CLEAR(tmp);
13141
0
        }
13142
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13143
0
            return -1;
13144
0
        }
13145
0
        if (tmp == NULL) {
13146
0
            tmp = PyList_New(0);
13147
0
            if (tmp == NULL) {
13148
0
                return -1;
13149
0
            }
13150
0
        }
13151
0
        {
13152
0
            int res;
13153
0
            Py_ssize_t len;
13154
0
            Py_ssize_t i;
13155
0
            if (!PyList_Check(tmp)) {
13156
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13157
0
                goto failed;
13158
0
            }
13159
0
            len = PyList_GET_SIZE(tmp);
13160
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13161
0
            if (handlers == NULL) goto failed;
13162
0
            for (i = 0; i < len; i++) {
13163
0
                excepthandler_ty val;
13164
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13165
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13166
0
                    goto failed;
13167
0
                }
13168
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13169
0
                _Py_LeaveRecursiveCall();
13170
0
                Py_DECREF(tmp2);
13171
0
                if (res != 0) goto failed;
13172
0
                if (len != PyList_GET_SIZE(tmp)) {
13173
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13174
0
                    goto failed;
13175
0
                }
13176
0
                asdl_seq_SET(handlers, i, val);
13177
0
            }
13178
0
            Py_CLEAR(tmp);
13179
0
        }
13180
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13181
0
            return -1;
13182
0
        }
13183
0
        if (tmp == NULL) {
13184
0
            tmp = PyList_New(0);
13185
0
            if (tmp == NULL) {
13186
0
                return -1;
13187
0
            }
13188
0
        }
13189
0
        {
13190
0
            int res;
13191
0
            Py_ssize_t len;
13192
0
            Py_ssize_t i;
13193
0
            if (!PyList_Check(tmp)) {
13194
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13195
0
                goto failed;
13196
0
            }
13197
0
            len = PyList_GET_SIZE(tmp);
13198
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13199
0
            if (orelse == NULL) goto failed;
13200
0
            for (i = 0; i < len; i++) {
13201
0
                stmt_ty val;
13202
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13203
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13204
0
                    goto failed;
13205
0
                }
13206
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13207
0
                _Py_LeaveRecursiveCall();
13208
0
                Py_DECREF(tmp2);
13209
0
                if (res != 0) goto failed;
13210
0
                if (len != PyList_GET_SIZE(tmp)) {
13211
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13212
0
                    goto failed;
13213
0
                }
13214
0
                asdl_seq_SET(orelse, i, val);
13215
0
            }
13216
0
            Py_CLEAR(tmp);
13217
0
        }
13218
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13219
0
            return -1;
13220
0
        }
13221
0
        if (tmp == NULL) {
13222
0
            tmp = PyList_New(0);
13223
0
            if (tmp == NULL) {
13224
0
                return -1;
13225
0
            }
13226
0
        }
13227
0
        {
13228
0
            int res;
13229
0
            Py_ssize_t len;
13230
0
            Py_ssize_t i;
13231
0
            if (!PyList_Check(tmp)) {
13232
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13233
0
                goto failed;
13234
0
            }
13235
0
            len = PyList_GET_SIZE(tmp);
13236
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13237
0
            if (finalbody == NULL) goto failed;
13238
0
            for (i = 0; i < len; i++) {
13239
0
                stmt_ty val;
13240
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13241
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13242
0
                    goto failed;
13243
0
                }
13244
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13245
0
                _Py_LeaveRecursiveCall();
13246
0
                Py_DECREF(tmp2);
13247
0
                if (res != 0) goto failed;
13248
0
                if (len != PyList_GET_SIZE(tmp)) {
13249
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13250
0
                    goto failed;
13251
0
                }
13252
0
                asdl_seq_SET(finalbody, i, val);
13253
0
            }
13254
0
            Py_CLEAR(tmp);
13255
0
        }
13256
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13257
0
                          col_offset, end_lineno, end_col_offset, arena);
13258
0
        if (*out == NULL) goto failed;
13259
0
        return 0;
13260
0
    }
13261
0
    tp = state->TryStar_type;
13262
0
    isinstance = PyObject_IsInstance(obj, tp);
13263
0
    if (isinstance == -1) {
13264
0
        return -1;
13265
0
    }
13266
0
    if (isinstance) {
13267
0
        asdl_stmt_seq* body;
13268
0
        asdl_excepthandler_seq* handlers;
13269
0
        asdl_stmt_seq* orelse;
13270
0
        asdl_stmt_seq* finalbody;
13271
13272
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13273
0
            return -1;
13274
0
        }
13275
0
        if (tmp == NULL) {
13276
0
            tmp = PyList_New(0);
13277
0
            if (tmp == NULL) {
13278
0
                return -1;
13279
0
            }
13280
0
        }
13281
0
        {
13282
0
            int res;
13283
0
            Py_ssize_t len;
13284
0
            Py_ssize_t i;
13285
0
            if (!PyList_Check(tmp)) {
13286
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13287
0
                goto failed;
13288
0
            }
13289
0
            len = PyList_GET_SIZE(tmp);
13290
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13291
0
            if (body == NULL) goto failed;
13292
0
            for (i = 0; i < len; i++) {
13293
0
                stmt_ty val;
13294
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13295
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13296
0
                    goto failed;
13297
0
                }
13298
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13299
0
                _Py_LeaveRecursiveCall();
13300
0
                Py_DECREF(tmp2);
13301
0
                if (res != 0) goto failed;
13302
0
                if (len != PyList_GET_SIZE(tmp)) {
13303
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13304
0
                    goto failed;
13305
0
                }
13306
0
                asdl_seq_SET(body, i, val);
13307
0
            }
13308
0
            Py_CLEAR(tmp);
13309
0
        }
13310
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13311
0
            return -1;
13312
0
        }
13313
0
        if (tmp == NULL) {
13314
0
            tmp = PyList_New(0);
13315
0
            if (tmp == NULL) {
13316
0
                return -1;
13317
0
            }
13318
0
        }
13319
0
        {
13320
0
            int res;
13321
0
            Py_ssize_t len;
13322
0
            Py_ssize_t i;
13323
0
            if (!PyList_Check(tmp)) {
13324
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13325
0
                goto failed;
13326
0
            }
13327
0
            len = PyList_GET_SIZE(tmp);
13328
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13329
0
            if (handlers == NULL) goto failed;
13330
0
            for (i = 0; i < len; i++) {
13331
0
                excepthandler_ty val;
13332
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13333
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13334
0
                    goto failed;
13335
0
                }
13336
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13337
0
                _Py_LeaveRecursiveCall();
13338
0
                Py_DECREF(tmp2);
13339
0
                if (res != 0) goto failed;
13340
0
                if (len != PyList_GET_SIZE(tmp)) {
13341
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13342
0
                    goto failed;
13343
0
                }
13344
0
                asdl_seq_SET(handlers, i, val);
13345
0
            }
13346
0
            Py_CLEAR(tmp);
13347
0
        }
13348
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13349
0
            return -1;
13350
0
        }
13351
0
        if (tmp == NULL) {
13352
0
            tmp = PyList_New(0);
13353
0
            if (tmp == NULL) {
13354
0
                return -1;
13355
0
            }
13356
0
        }
13357
0
        {
13358
0
            int res;
13359
0
            Py_ssize_t len;
13360
0
            Py_ssize_t i;
13361
0
            if (!PyList_Check(tmp)) {
13362
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13363
0
                goto failed;
13364
0
            }
13365
0
            len = PyList_GET_SIZE(tmp);
13366
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13367
0
            if (orelse == NULL) goto failed;
13368
0
            for (i = 0; i < len; i++) {
13369
0
                stmt_ty val;
13370
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13371
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13372
0
                    goto failed;
13373
0
                }
13374
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13375
0
                _Py_LeaveRecursiveCall();
13376
0
                Py_DECREF(tmp2);
13377
0
                if (res != 0) goto failed;
13378
0
                if (len != PyList_GET_SIZE(tmp)) {
13379
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13380
0
                    goto failed;
13381
0
                }
13382
0
                asdl_seq_SET(orelse, i, val);
13383
0
            }
13384
0
            Py_CLEAR(tmp);
13385
0
        }
13386
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13387
0
            return -1;
13388
0
        }
13389
0
        if (tmp == NULL) {
13390
0
            tmp = PyList_New(0);
13391
0
            if (tmp == NULL) {
13392
0
                return -1;
13393
0
            }
13394
0
        }
13395
0
        {
13396
0
            int res;
13397
0
            Py_ssize_t len;
13398
0
            Py_ssize_t i;
13399
0
            if (!PyList_Check(tmp)) {
13400
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13401
0
                goto failed;
13402
0
            }
13403
0
            len = PyList_GET_SIZE(tmp);
13404
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13405
0
            if (finalbody == NULL) goto failed;
13406
0
            for (i = 0; i < len; i++) {
13407
0
                stmt_ty val;
13408
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13409
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13410
0
                    goto failed;
13411
0
                }
13412
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13413
0
                _Py_LeaveRecursiveCall();
13414
0
                Py_DECREF(tmp2);
13415
0
                if (res != 0) goto failed;
13416
0
                if (len != PyList_GET_SIZE(tmp)) {
13417
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13418
0
                    goto failed;
13419
0
                }
13420
0
                asdl_seq_SET(finalbody, i, val);
13421
0
            }
13422
0
            Py_CLEAR(tmp);
13423
0
        }
13424
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13425
0
                              col_offset, end_lineno, end_col_offset, arena);
13426
0
        if (*out == NULL) goto failed;
13427
0
        return 0;
13428
0
    }
13429
0
    tp = state->Assert_type;
13430
0
    isinstance = PyObject_IsInstance(obj, tp);
13431
0
    if (isinstance == -1) {
13432
0
        return -1;
13433
0
    }
13434
0
    if (isinstance) {
13435
0
        expr_ty test;
13436
0
        expr_ty msg;
13437
13438
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13439
0
            return -1;
13440
0
        }
13441
0
        if (tmp == NULL) {
13442
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13443
0
            return -1;
13444
0
        }
13445
0
        else {
13446
0
            int res;
13447
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13448
0
                goto failed;
13449
0
            }
13450
0
            res = obj2ast_expr(state, tmp, &test, arena);
13451
0
            _Py_LeaveRecursiveCall();
13452
0
            if (res != 0) goto failed;
13453
0
            Py_CLEAR(tmp);
13454
0
        }
13455
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13456
0
            return -1;
13457
0
        }
13458
0
        if (tmp == NULL || tmp == Py_None) {
13459
0
            Py_CLEAR(tmp);
13460
0
            msg = NULL;
13461
0
        }
13462
0
        else {
13463
0
            int res;
13464
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13465
0
                goto failed;
13466
0
            }
13467
0
            res = obj2ast_expr(state, tmp, &msg, arena);
13468
0
            _Py_LeaveRecursiveCall();
13469
0
            if (res != 0) goto failed;
13470
0
            Py_CLEAR(tmp);
13471
0
        }
13472
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13473
0
                             end_col_offset, arena);
13474
0
        if (*out == NULL) goto failed;
13475
0
        return 0;
13476
0
    }
13477
0
    tp = state->Import_type;
13478
0
    isinstance = PyObject_IsInstance(obj, tp);
13479
0
    if (isinstance == -1) {
13480
0
        return -1;
13481
0
    }
13482
0
    if (isinstance) {
13483
0
        asdl_alias_seq* names;
13484
13485
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13486
0
            return -1;
13487
0
        }
13488
0
        if (tmp == NULL) {
13489
0
            tmp = PyList_New(0);
13490
0
            if (tmp == NULL) {
13491
0
                return -1;
13492
0
            }
13493
0
        }
13494
0
        {
13495
0
            int res;
13496
0
            Py_ssize_t len;
13497
0
            Py_ssize_t i;
13498
0
            if (!PyList_Check(tmp)) {
13499
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13500
0
                goto failed;
13501
0
            }
13502
0
            len = PyList_GET_SIZE(tmp);
13503
0
            names = _Py_asdl_alias_seq_new(len, arena);
13504
0
            if (names == NULL) goto failed;
13505
0
            for (i = 0; i < len; i++) {
13506
0
                alias_ty val;
13507
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13508
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13509
0
                    goto failed;
13510
0
                }
13511
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13512
0
                _Py_LeaveRecursiveCall();
13513
0
                Py_DECREF(tmp2);
13514
0
                if (res != 0) goto failed;
13515
0
                if (len != PyList_GET_SIZE(tmp)) {
13516
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13517
0
                    goto failed;
13518
0
                }
13519
0
                asdl_seq_SET(names, i, val);
13520
0
            }
13521
0
            Py_CLEAR(tmp);
13522
0
        }
13523
0
        *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
13524
0
                             end_col_offset, arena);
13525
0
        if (*out == NULL) goto failed;
13526
0
        return 0;
13527
0
    }
13528
0
    tp = state->ImportFrom_type;
13529
0
    isinstance = PyObject_IsInstance(obj, tp);
13530
0
    if (isinstance == -1) {
13531
0
        return -1;
13532
0
    }
13533
0
    if (isinstance) {
13534
0
        identifier module;
13535
0
        asdl_alias_seq* names;
13536
0
        int level;
13537
13538
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13539
0
            return -1;
13540
0
        }
13541
0
        if (tmp == NULL || tmp == Py_None) {
13542
0
            Py_CLEAR(tmp);
13543
0
            module = NULL;
13544
0
        }
13545
0
        else {
13546
0
            int res;
13547
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13548
0
                goto failed;
13549
0
            }
13550
0
            res = obj2ast_identifier(state, tmp, &module, arena);
13551
0
            _Py_LeaveRecursiveCall();
13552
0
            if (res != 0) goto failed;
13553
0
            Py_CLEAR(tmp);
13554
0
        }
13555
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13556
0
            return -1;
13557
0
        }
13558
0
        if (tmp == NULL) {
13559
0
            tmp = PyList_New(0);
13560
0
            if (tmp == NULL) {
13561
0
                return -1;
13562
0
            }
13563
0
        }
13564
0
        {
13565
0
            int res;
13566
0
            Py_ssize_t len;
13567
0
            Py_ssize_t i;
13568
0
            if (!PyList_Check(tmp)) {
13569
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13570
0
                goto failed;
13571
0
            }
13572
0
            len = PyList_GET_SIZE(tmp);
13573
0
            names = _Py_asdl_alias_seq_new(len, arena);
13574
0
            if (names == NULL) goto failed;
13575
0
            for (i = 0; i < len; i++) {
13576
0
                alias_ty val;
13577
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13578
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13579
0
                    goto failed;
13580
0
                }
13581
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13582
0
                _Py_LeaveRecursiveCall();
13583
0
                Py_DECREF(tmp2);
13584
0
                if (res != 0) goto failed;
13585
0
                if (len != PyList_GET_SIZE(tmp)) {
13586
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13587
0
                    goto failed;
13588
0
                }
13589
0
                asdl_seq_SET(names, i, val);
13590
0
            }
13591
0
            Py_CLEAR(tmp);
13592
0
        }
13593
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13594
0
            return -1;
13595
0
        }
13596
0
        if (tmp == NULL || tmp == Py_None) {
13597
0
            Py_CLEAR(tmp);
13598
0
            level = 0;
13599
0
        }
13600
0
        else {
13601
0
            int res;
13602
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13603
0
                goto failed;
13604
0
            }
13605
0
            res = obj2ast_int(state, tmp, &level, arena);
13606
0
            _Py_LeaveRecursiveCall();
13607
0
            if (res != 0) goto failed;
13608
0
            Py_CLEAR(tmp);
13609
0
        }
13610
0
        *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
13611
0
                                 end_lineno, end_col_offset, arena);
13612
0
        if (*out == NULL) goto failed;
13613
0
        return 0;
13614
0
    }
13615
0
    tp = state->Global_type;
13616
0
    isinstance = PyObject_IsInstance(obj, tp);
13617
0
    if (isinstance == -1) {
13618
0
        return -1;
13619
0
    }
13620
0
    if (isinstance) {
13621
0
        asdl_identifier_seq* names;
13622
13623
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13624
0
            return -1;
13625
0
        }
13626
0
        if (tmp == NULL) {
13627
0
            tmp = PyList_New(0);
13628
0
            if (tmp == NULL) {
13629
0
                return -1;
13630
0
            }
13631
0
        }
13632
0
        {
13633
0
            int res;
13634
0
            Py_ssize_t len;
13635
0
            Py_ssize_t i;
13636
0
            if (!PyList_Check(tmp)) {
13637
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13638
0
                goto failed;
13639
0
            }
13640
0
            len = PyList_GET_SIZE(tmp);
13641
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13642
0
            if (names == NULL) goto failed;
13643
0
            for (i = 0; i < len; i++) {
13644
0
                identifier val;
13645
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13646
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13647
0
                    goto failed;
13648
0
                }
13649
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13650
0
                _Py_LeaveRecursiveCall();
13651
0
                Py_DECREF(tmp2);
13652
0
                if (res != 0) goto failed;
13653
0
                if (len != PyList_GET_SIZE(tmp)) {
13654
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13655
0
                    goto failed;
13656
0
                }
13657
0
                asdl_seq_SET(names, i, val);
13658
0
            }
13659
0
            Py_CLEAR(tmp);
13660
0
        }
13661
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13662
0
                             end_col_offset, arena);
13663
0
        if (*out == NULL) goto failed;
13664
0
        return 0;
13665
0
    }
13666
0
    tp = state->Nonlocal_type;
13667
0
    isinstance = PyObject_IsInstance(obj, tp);
13668
0
    if (isinstance == -1) {
13669
0
        return -1;
13670
0
    }
13671
0
    if (isinstance) {
13672
0
        asdl_identifier_seq* names;
13673
13674
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13675
0
            return -1;
13676
0
        }
13677
0
        if (tmp == NULL) {
13678
0
            tmp = PyList_New(0);
13679
0
            if (tmp == NULL) {
13680
0
                return -1;
13681
0
            }
13682
0
        }
13683
0
        {
13684
0
            int res;
13685
0
            Py_ssize_t len;
13686
0
            Py_ssize_t i;
13687
0
            if (!PyList_Check(tmp)) {
13688
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13689
0
                goto failed;
13690
0
            }
13691
0
            len = PyList_GET_SIZE(tmp);
13692
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13693
0
            if (names == NULL) goto failed;
13694
0
            for (i = 0; i < len; i++) {
13695
0
                identifier val;
13696
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13697
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13698
0
                    goto failed;
13699
0
                }
13700
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13701
0
                _Py_LeaveRecursiveCall();
13702
0
                Py_DECREF(tmp2);
13703
0
                if (res != 0) goto failed;
13704
0
                if (len != PyList_GET_SIZE(tmp)) {
13705
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13706
0
                    goto failed;
13707
0
                }
13708
0
                asdl_seq_SET(names, i, val);
13709
0
            }
13710
0
            Py_CLEAR(tmp);
13711
0
        }
13712
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13713
0
                               end_col_offset, arena);
13714
0
        if (*out == NULL) goto failed;
13715
0
        return 0;
13716
0
    }
13717
0
    tp = state->Expr_type;
13718
0
    isinstance = PyObject_IsInstance(obj, tp);
13719
0
    if (isinstance == -1) {
13720
0
        return -1;
13721
0
    }
13722
0
    if (isinstance) {
13723
0
        expr_ty value;
13724
13725
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13726
0
            return -1;
13727
0
        }
13728
0
        if (tmp == NULL) {
13729
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13730
0
            return -1;
13731
0
        }
13732
0
        else {
13733
0
            int res;
13734
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13735
0
                goto failed;
13736
0
            }
13737
0
            res = obj2ast_expr(state, tmp, &value, arena);
13738
0
            _Py_LeaveRecursiveCall();
13739
0
            if (res != 0) goto failed;
13740
0
            Py_CLEAR(tmp);
13741
0
        }
13742
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13743
0
                           end_col_offset, arena);
13744
0
        if (*out == NULL) goto failed;
13745
0
        return 0;
13746
0
    }
13747
0
    tp = state->Pass_type;
13748
0
    isinstance = PyObject_IsInstance(obj, tp);
13749
0
    if (isinstance == -1) {
13750
0
        return -1;
13751
0
    }
13752
0
    if (isinstance) {
13753
13754
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13755
0
                           arena);
13756
0
        if (*out == NULL) goto failed;
13757
0
        return 0;
13758
0
    }
13759
0
    tp = state->Break_type;
13760
0
    isinstance = PyObject_IsInstance(obj, tp);
13761
0
    if (isinstance == -1) {
13762
0
        return -1;
13763
0
    }
13764
0
    if (isinstance) {
13765
13766
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13767
0
                            arena);
13768
0
        if (*out == NULL) goto failed;
13769
0
        return 0;
13770
0
    }
13771
0
    tp = state->Continue_type;
13772
0
    isinstance = PyObject_IsInstance(obj, tp);
13773
0
    if (isinstance == -1) {
13774
0
        return -1;
13775
0
    }
13776
0
    if (isinstance) {
13777
13778
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13779
0
                               arena);
13780
0
        if (*out == NULL) goto failed;
13781
0
        return 0;
13782
0
    }
13783
13784
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13785
0
    failed:
13786
0
    Py_XDECREF(tmp);
13787
0
    return -1;
13788
0
}
13789
13790
int
13791
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
13792
             arena)
13793
0
{
13794
0
    int isinstance;
13795
13796
0
    PyObject *tmp = NULL;
13797
0
    PyObject *tp;
13798
0
    int lineno;
13799
0
    int col_offset;
13800
0
    int end_lineno;
13801
0
    int end_col_offset;
13802
13803
0
    if (obj == Py_None) {
13804
0
        *out = NULL;
13805
0
        return 0;
13806
0
    }
13807
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13808
0
        return -1;
13809
0
    }
13810
0
    if (tmp == NULL) {
13811
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13812
0
        return -1;
13813
0
    }
13814
0
    else {
13815
0
        int res;
13816
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13817
0
            goto failed;
13818
0
        }
13819
0
        res = obj2ast_int(state, tmp, &lineno, arena);
13820
0
        _Py_LeaveRecursiveCall();
13821
0
        if (res != 0) goto failed;
13822
0
        Py_CLEAR(tmp);
13823
0
    }
13824
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13825
0
        return -1;
13826
0
    }
13827
0
    if (tmp == NULL) {
13828
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13829
0
        return -1;
13830
0
    }
13831
0
    else {
13832
0
        int res;
13833
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13834
0
            goto failed;
13835
0
        }
13836
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
13837
0
        _Py_LeaveRecursiveCall();
13838
0
        if (res != 0) goto failed;
13839
0
        Py_CLEAR(tmp);
13840
0
    }
13841
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13842
0
        return -1;
13843
0
    }
13844
0
    if (tmp == NULL || tmp == Py_None) {
13845
0
        Py_CLEAR(tmp);
13846
0
        end_lineno = lineno;
13847
0
    }
13848
0
    else {
13849
0
        int res;
13850
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13851
0
            goto failed;
13852
0
        }
13853
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
13854
0
        _Py_LeaveRecursiveCall();
13855
0
        if (res != 0) goto failed;
13856
0
        Py_CLEAR(tmp);
13857
0
    }
13858
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13859
0
        return -1;
13860
0
    }
13861
0
    if (tmp == NULL || tmp == Py_None) {
13862
0
        Py_CLEAR(tmp);
13863
0
        end_col_offset = col_offset;
13864
0
    }
13865
0
    else {
13866
0
        int res;
13867
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13868
0
            goto failed;
13869
0
        }
13870
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
13871
0
        _Py_LeaveRecursiveCall();
13872
0
        if (res != 0) goto failed;
13873
0
        Py_CLEAR(tmp);
13874
0
    }
13875
0
    tp = state->BoolOp_type;
13876
0
    isinstance = PyObject_IsInstance(obj, tp);
13877
0
    if (isinstance == -1) {
13878
0
        return -1;
13879
0
    }
13880
0
    if (isinstance) {
13881
0
        boolop_ty op;
13882
0
        asdl_expr_seq* values;
13883
13884
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13885
0
            return -1;
13886
0
        }
13887
0
        if (tmp == NULL) {
13888
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13889
0
            return -1;
13890
0
        }
13891
0
        else {
13892
0
            int res;
13893
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13894
0
                goto failed;
13895
0
            }
13896
0
            res = obj2ast_boolop(state, tmp, &op, arena);
13897
0
            _Py_LeaveRecursiveCall();
13898
0
            if (res != 0) goto failed;
13899
0
            Py_CLEAR(tmp);
13900
0
        }
13901
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13902
0
            return -1;
13903
0
        }
13904
0
        if (tmp == NULL) {
13905
0
            tmp = PyList_New(0);
13906
0
            if (tmp == NULL) {
13907
0
                return -1;
13908
0
            }
13909
0
        }
13910
0
        {
13911
0
            int res;
13912
0
            Py_ssize_t len;
13913
0
            Py_ssize_t i;
13914
0
            if (!PyList_Check(tmp)) {
13915
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13916
0
                goto failed;
13917
0
            }
13918
0
            len = PyList_GET_SIZE(tmp);
13919
0
            values = _Py_asdl_expr_seq_new(len, arena);
13920
0
            if (values == NULL) goto failed;
13921
0
            for (i = 0; i < len; i++) {
13922
0
                expr_ty val;
13923
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13924
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13925
0
                    goto failed;
13926
0
                }
13927
0
                res = obj2ast_expr(state, tmp2, &val, arena);
13928
0
                _Py_LeaveRecursiveCall();
13929
0
                Py_DECREF(tmp2);
13930
0
                if (res != 0) goto failed;
13931
0
                if (len != PyList_GET_SIZE(tmp)) {
13932
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13933
0
                    goto failed;
13934
0
                }
13935
0
                asdl_seq_SET(values, i, val);
13936
0
            }
13937
0
            Py_CLEAR(tmp);
13938
0
        }
13939
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
13940
0
                             end_col_offset, arena);
13941
0
        if (*out == NULL) goto failed;
13942
0
        return 0;
13943
0
    }
13944
0
    tp = state->NamedExpr_type;
13945
0
    isinstance = PyObject_IsInstance(obj, tp);
13946
0
    if (isinstance == -1) {
13947
0
        return -1;
13948
0
    }
13949
0
    if (isinstance) {
13950
0
        expr_ty target;
13951
0
        expr_ty value;
13952
13953
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
13954
0
            return -1;
13955
0
        }
13956
0
        if (tmp == NULL) {
13957
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
13958
0
            return -1;
13959
0
        }
13960
0
        else {
13961
0
            int res;
13962
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13963
0
                goto failed;
13964
0
            }
13965
0
            res = obj2ast_expr(state, tmp, &target, arena);
13966
0
            _Py_LeaveRecursiveCall();
13967
0
            if (res != 0) goto failed;
13968
0
            Py_CLEAR(tmp);
13969
0
        }
13970
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13971
0
            return -1;
13972
0
        }
13973
0
        if (tmp == NULL) {
13974
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
13975
0
            return -1;
13976
0
        }
13977
0
        else {
13978
0
            int res;
13979
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13980
0
                goto failed;
13981
0
            }
13982
0
            res = obj2ast_expr(state, tmp, &value, arena);
13983
0
            _Py_LeaveRecursiveCall();
13984
0
            if (res != 0) goto failed;
13985
0
            Py_CLEAR(tmp);
13986
0
        }
13987
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
13988
0
                                end_col_offset, arena);
13989
0
        if (*out == NULL) goto failed;
13990
0
        return 0;
13991
0
    }
13992
0
    tp = state->BinOp_type;
13993
0
    isinstance = PyObject_IsInstance(obj, tp);
13994
0
    if (isinstance == -1) {
13995
0
        return -1;
13996
0
    }
13997
0
    if (isinstance) {
13998
0
        expr_ty left;
13999
0
        operator_ty op;
14000
0
        expr_ty right;
14001
14002
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14003
0
            return -1;
14004
0
        }
14005
0
        if (tmp == NULL) {
14006
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14007
0
            return -1;
14008
0
        }
14009
0
        else {
14010
0
            int res;
14011
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14012
0
                goto failed;
14013
0
            }
14014
0
            res = obj2ast_expr(state, tmp, &left, arena);
14015
0
            _Py_LeaveRecursiveCall();
14016
0
            if (res != 0) goto failed;
14017
0
            Py_CLEAR(tmp);
14018
0
        }
14019
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14020
0
            return -1;
14021
0
        }
14022
0
        if (tmp == NULL) {
14023
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14024
0
            return -1;
14025
0
        }
14026
0
        else {
14027
0
            int res;
14028
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14029
0
                goto failed;
14030
0
            }
14031
0
            res = obj2ast_operator(state, tmp, &op, arena);
14032
0
            _Py_LeaveRecursiveCall();
14033
0
            if (res != 0) goto failed;
14034
0
            Py_CLEAR(tmp);
14035
0
        }
14036
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14037
0
            return -1;
14038
0
        }
14039
0
        if (tmp == NULL) {
14040
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14041
0
            return -1;
14042
0
        }
14043
0
        else {
14044
0
            int res;
14045
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14046
0
                goto failed;
14047
0
            }
14048
0
            res = obj2ast_expr(state, tmp, &right, arena);
14049
0
            _Py_LeaveRecursiveCall();
14050
0
            if (res != 0) goto failed;
14051
0
            Py_CLEAR(tmp);
14052
0
        }
14053
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14054
0
                            end_col_offset, arena);
14055
0
        if (*out == NULL) goto failed;
14056
0
        return 0;
14057
0
    }
14058
0
    tp = state->UnaryOp_type;
14059
0
    isinstance = PyObject_IsInstance(obj, tp);
14060
0
    if (isinstance == -1) {
14061
0
        return -1;
14062
0
    }
14063
0
    if (isinstance) {
14064
0
        unaryop_ty op;
14065
0
        expr_ty operand;
14066
14067
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14068
0
            return -1;
14069
0
        }
14070
0
        if (tmp == NULL) {
14071
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14072
0
            return -1;
14073
0
        }
14074
0
        else {
14075
0
            int res;
14076
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14077
0
                goto failed;
14078
0
            }
14079
0
            res = obj2ast_unaryop(state, tmp, &op, arena);
14080
0
            _Py_LeaveRecursiveCall();
14081
0
            if (res != 0) goto failed;
14082
0
            Py_CLEAR(tmp);
14083
0
        }
14084
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
14085
0
            return -1;
14086
0
        }
14087
0
        if (tmp == NULL) {
14088
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14089
0
            return -1;
14090
0
        }
14091
0
        else {
14092
0
            int res;
14093
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14094
0
                goto failed;
14095
0
            }
14096
0
            res = obj2ast_expr(state, tmp, &operand, arena);
14097
0
            _Py_LeaveRecursiveCall();
14098
0
            if (res != 0) goto failed;
14099
0
            Py_CLEAR(tmp);
14100
0
        }
14101
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14102
0
                              end_col_offset, arena);
14103
0
        if (*out == NULL) goto failed;
14104
0
        return 0;
14105
0
    }
14106
0
    tp = state->Lambda_type;
14107
0
    isinstance = PyObject_IsInstance(obj, tp);
14108
0
    if (isinstance == -1) {
14109
0
        return -1;
14110
0
    }
14111
0
    if (isinstance) {
14112
0
        arguments_ty args;
14113
0
        expr_ty body;
14114
14115
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14116
0
            return -1;
14117
0
        }
14118
0
        if (tmp == NULL) {
14119
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14120
0
            return -1;
14121
0
        }
14122
0
        else {
14123
0
            int res;
14124
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14125
0
                goto failed;
14126
0
            }
14127
0
            res = obj2ast_arguments(state, tmp, &args, arena);
14128
0
            _Py_LeaveRecursiveCall();
14129
0
            if (res != 0) goto failed;
14130
0
            Py_CLEAR(tmp);
14131
0
        }
14132
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14133
0
            return -1;
14134
0
        }
14135
0
        if (tmp == NULL) {
14136
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14137
0
            return -1;
14138
0
        }
14139
0
        else {
14140
0
            int res;
14141
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14142
0
                goto failed;
14143
0
            }
14144
0
            res = obj2ast_expr(state, tmp, &body, arena);
14145
0
            _Py_LeaveRecursiveCall();
14146
0
            if (res != 0) goto failed;
14147
0
            Py_CLEAR(tmp);
14148
0
        }
14149
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14150
0
                             end_col_offset, arena);
14151
0
        if (*out == NULL) goto failed;
14152
0
        return 0;
14153
0
    }
14154
0
    tp = state->IfExp_type;
14155
0
    isinstance = PyObject_IsInstance(obj, tp);
14156
0
    if (isinstance == -1) {
14157
0
        return -1;
14158
0
    }
14159
0
    if (isinstance) {
14160
0
        expr_ty test;
14161
0
        expr_ty body;
14162
0
        expr_ty orelse;
14163
14164
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14165
0
            return -1;
14166
0
        }
14167
0
        if (tmp == NULL) {
14168
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14169
0
            return -1;
14170
0
        }
14171
0
        else {
14172
0
            int res;
14173
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14174
0
                goto failed;
14175
0
            }
14176
0
            res = obj2ast_expr(state, tmp, &test, arena);
14177
0
            _Py_LeaveRecursiveCall();
14178
0
            if (res != 0) goto failed;
14179
0
            Py_CLEAR(tmp);
14180
0
        }
14181
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14182
0
            return -1;
14183
0
        }
14184
0
        if (tmp == NULL) {
14185
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14186
0
            return -1;
14187
0
        }
14188
0
        else {
14189
0
            int res;
14190
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14191
0
                goto failed;
14192
0
            }
14193
0
            res = obj2ast_expr(state, tmp, &body, arena);
14194
0
            _Py_LeaveRecursiveCall();
14195
0
            if (res != 0) goto failed;
14196
0
            Py_CLEAR(tmp);
14197
0
        }
14198
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14199
0
            return -1;
14200
0
        }
14201
0
        if (tmp == NULL) {
14202
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14203
0
            return -1;
14204
0
        }
14205
0
        else {
14206
0
            int res;
14207
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14208
0
                goto failed;
14209
0
            }
14210
0
            res = obj2ast_expr(state, tmp, &orelse, arena);
14211
0
            _Py_LeaveRecursiveCall();
14212
0
            if (res != 0) goto failed;
14213
0
            Py_CLEAR(tmp);
14214
0
        }
14215
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14216
0
                            end_col_offset, arena);
14217
0
        if (*out == NULL) goto failed;
14218
0
        return 0;
14219
0
    }
14220
0
    tp = state->Dict_type;
14221
0
    isinstance = PyObject_IsInstance(obj, tp);
14222
0
    if (isinstance == -1) {
14223
0
        return -1;
14224
0
    }
14225
0
    if (isinstance) {
14226
0
        asdl_expr_seq* keys;
14227
0
        asdl_expr_seq* values;
14228
14229
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14230
0
            return -1;
14231
0
        }
14232
0
        if (tmp == NULL) {
14233
0
            tmp = PyList_New(0);
14234
0
            if (tmp == NULL) {
14235
0
                return -1;
14236
0
            }
14237
0
        }
14238
0
        {
14239
0
            int res;
14240
0
            Py_ssize_t len;
14241
0
            Py_ssize_t i;
14242
0
            if (!PyList_Check(tmp)) {
14243
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14244
0
                goto failed;
14245
0
            }
14246
0
            len = PyList_GET_SIZE(tmp);
14247
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14248
0
            if (keys == NULL) goto failed;
14249
0
            for (i = 0; i < len; i++) {
14250
0
                expr_ty val;
14251
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14252
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14253
0
                    goto failed;
14254
0
                }
14255
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14256
0
                _Py_LeaveRecursiveCall();
14257
0
                Py_DECREF(tmp2);
14258
0
                if (res != 0) goto failed;
14259
0
                if (len != PyList_GET_SIZE(tmp)) {
14260
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14261
0
                    goto failed;
14262
0
                }
14263
0
                asdl_seq_SET(keys, i, val);
14264
0
            }
14265
0
            Py_CLEAR(tmp);
14266
0
        }
14267
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14268
0
            return -1;
14269
0
        }
14270
0
        if (tmp == NULL) {
14271
0
            tmp = PyList_New(0);
14272
0
            if (tmp == NULL) {
14273
0
                return -1;
14274
0
            }
14275
0
        }
14276
0
        {
14277
0
            int res;
14278
0
            Py_ssize_t len;
14279
0
            Py_ssize_t i;
14280
0
            if (!PyList_Check(tmp)) {
14281
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14282
0
                goto failed;
14283
0
            }
14284
0
            len = PyList_GET_SIZE(tmp);
14285
0
            values = _Py_asdl_expr_seq_new(len, arena);
14286
0
            if (values == NULL) goto failed;
14287
0
            for (i = 0; i < len; i++) {
14288
0
                expr_ty val;
14289
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14290
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14291
0
                    goto failed;
14292
0
                }
14293
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14294
0
                _Py_LeaveRecursiveCall();
14295
0
                Py_DECREF(tmp2);
14296
0
                if (res != 0) goto failed;
14297
0
                if (len != PyList_GET_SIZE(tmp)) {
14298
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14299
0
                    goto failed;
14300
0
                }
14301
0
                asdl_seq_SET(values, i, val);
14302
0
            }
14303
0
            Py_CLEAR(tmp);
14304
0
        }
14305
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14306
0
                           end_col_offset, arena);
14307
0
        if (*out == NULL) goto failed;
14308
0
        return 0;
14309
0
    }
14310
0
    tp = state->Set_type;
14311
0
    isinstance = PyObject_IsInstance(obj, tp);
14312
0
    if (isinstance == -1) {
14313
0
        return -1;
14314
0
    }
14315
0
    if (isinstance) {
14316
0
        asdl_expr_seq* elts;
14317
14318
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &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, "Set field \"elts\" 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
            elts = _Py_asdl_expr_seq_new(len, arena);
14337
0
            if (elts == 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 'Set' 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, "Set field \"elts\" changed size during iteration");
14350
0
                    goto failed;
14351
0
                }
14352
0
                asdl_seq_SET(elts, i, val);
14353
0
            }
14354
0
            Py_CLEAR(tmp);
14355
0
        }
14356
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14357
0
                          arena);
14358
0
        if (*out == NULL) goto failed;
14359
0
        return 0;
14360
0
    }
14361
0
    tp = state->ListComp_type;
14362
0
    isinstance = PyObject_IsInstance(obj, tp);
14363
0
    if (isinstance == -1) {
14364
0
        return -1;
14365
0
    }
14366
0
    if (isinstance) {
14367
0
        expr_ty elt;
14368
0
        asdl_comprehension_seq* generators;
14369
14370
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14371
0
            return -1;
14372
0
        }
14373
0
        if (tmp == NULL) {
14374
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14375
0
            return -1;
14376
0
        }
14377
0
        else {
14378
0
            int res;
14379
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14380
0
                goto failed;
14381
0
            }
14382
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14383
0
            _Py_LeaveRecursiveCall();
14384
0
            if (res != 0) goto failed;
14385
0
            Py_CLEAR(tmp);
14386
0
        }
14387
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14388
0
            return -1;
14389
0
        }
14390
0
        if (tmp == NULL) {
14391
0
            tmp = PyList_New(0);
14392
0
            if (tmp == NULL) {
14393
0
                return -1;
14394
0
            }
14395
0
        }
14396
0
        {
14397
0
            int res;
14398
0
            Py_ssize_t len;
14399
0
            Py_ssize_t i;
14400
0
            if (!PyList_Check(tmp)) {
14401
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14402
0
                goto failed;
14403
0
            }
14404
0
            len = PyList_GET_SIZE(tmp);
14405
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14406
0
            if (generators == NULL) goto failed;
14407
0
            for (i = 0; i < len; i++) {
14408
0
                comprehension_ty val;
14409
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14410
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14411
0
                    goto failed;
14412
0
                }
14413
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14414
0
                _Py_LeaveRecursiveCall();
14415
0
                Py_DECREF(tmp2);
14416
0
                if (res != 0) goto failed;
14417
0
                if (len != PyList_GET_SIZE(tmp)) {
14418
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14419
0
                    goto failed;
14420
0
                }
14421
0
                asdl_seq_SET(generators, i, val);
14422
0
            }
14423
0
            Py_CLEAR(tmp);
14424
0
        }
14425
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14426
0
                               end_col_offset, arena);
14427
0
        if (*out == NULL) goto failed;
14428
0
        return 0;
14429
0
    }
14430
0
    tp = state->SetComp_type;
14431
0
    isinstance = PyObject_IsInstance(obj, tp);
14432
0
    if (isinstance == -1) {
14433
0
        return -1;
14434
0
    }
14435
0
    if (isinstance) {
14436
0
        expr_ty elt;
14437
0
        asdl_comprehension_seq* generators;
14438
14439
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14440
0
            return -1;
14441
0
        }
14442
0
        if (tmp == NULL) {
14443
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14444
0
            return -1;
14445
0
        }
14446
0
        else {
14447
0
            int res;
14448
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14449
0
                goto failed;
14450
0
            }
14451
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14452
0
            _Py_LeaveRecursiveCall();
14453
0
            if (res != 0) goto failed;
14454
0
            Py_CLEAR(tmp);
14455
0
        }
14456
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14457
0
            return -1;
14458
0
        }
14459
0
        if (tmp == NULL) {
14460
0
            tmp = PyList_New(0);
14461
0
            if (tmp == NULL) {
14462
0
                return -1;
14463
0
            }
14464
0
        }
14465
0
        {
14466
0
            int res;
14467
0
            Py_ssize_t len;
14468
0
            Py_ssize_t i;
14469
0
            if (!PyList_Check(tmp)) {
14470
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14471
0
                goto failed;
14472
0
            }
14473
0
            len = PyList_GET_SIZE(tmp);
14474
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14475
0
            if (generators == NULL) goto failed;
14476
0
            for (i = 0; i < len; i++) {
14477
0
                comprehension_ty val;
14478
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14479
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14480
0
                    goto failed;
14481
0
                }
14482
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14483
0
                _Py_LeaveRecursiveCall();
14484
0
                Py_DECREF(tmp2);
14485
0
                if (res != 0) goto failed;
14486
0
                if (len != PyList_GET_SIZE(tmp)) {
14487
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14488
0
                    goto failed;
14489
0
                }
14490
0
                asdl_seq_SET(generators, i, val);
14491
0
            }
14492
0
            Py_CLEAR(tmp);
14493
0
        }
14494
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14495
0
                              end_col_offset, arena);
14496
0
        if (*out == NULL) goto failed;
14497
0
        return 0;
14498
0
    }
14499
0
    tp = state->DictComp_type;
14500
0
    isinstance = PyObject_IsInstance(obj, tp);
14501
0
    if (isinstance == -1) {
14502
0
        return -1;
14503
0
    }
14504
0
    if (isinstance) {
14505
0
        expr_ty key;
14506
0
        expr_ty value;
14507
0
        asdl_comprehension_seq* generators;
14508
14509
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14510
0
            return -1;
14511
0
        }
14512
0
        if (tmp == NULL) {
14513
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14514
0
            return -1;
14515
0
        }
14516
0
        else {
14517
0
            int res;
14518
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14519
0
                goto failed;
14520
0
            }
14521
0
            res = obj2ast_expr(state, tmp, &key, arena);
14522
0
            _Py_LeaveRecursiveCall();
14523
0
            if (res != 0) goto failed;
14524
0
            Py_CLEAR(tmp);
14525
0
        }
14526
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14527
0
            return -1;
14528
0
        }
14529
0
        if (tmp == NULL) {
14530
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
14531
0
            return -1;
14532
0
        }
14533
0
        else {
14534
0
            int res;
14535
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14536
0
                goto failed;
14537
0
            }
14538
0
            res = obj2ast_expr(state, tmp, &value, arena);
14539
0
            _Py_LeaveRecursiveCall();
14540
0
            if (res != 0) goto failed;
14541
0
            Py_CLEAR(tmp);
14542
0
        }
14543
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14544
0
            return -1;
14545
0
        }
14546
0
        if (tmp == NULL) {
14547
0
            tmp = PyList_New(0);
14548
0
            if (tmp == NULL) {
14549
0
                return -1;
14550
0
            }
14551
0
        }
14552
0
        {
14553
0
            int res;
14554
0
            Py_ssize_t len;
14555
0
            Py_ssize_t i;
14556
0
            if (!PyList_Check(tmp)) {
14557
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14558
0
                goto failed;
14559
0
            }
14560
0
            len = PyList_GET_SIZE(tmp);
14561
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14562
0
            if (generators == NULL) goto failed;
14563
0
            for (i = 0; i < len; i++) {
14564
0
                comprehension_ty val;
14565
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14566
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14567
0
                    goto failed;
14568
0
                }
14569
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14570
0
                _Py_LeaveRecursiveCall();
14571
0
                Py_DECREF(tmp2);
14572
0
                if (res != 0) goto failed;
14573
0
                if (len != PyList_GET_SIZE(tmp)) {
14574
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14575
0
                    goto failed;
14576
0
                }
14577
0
                asdl_seq_SET(generators, i, val);
14578
0
            }
14579
0
            Py_CLEAR(tmp);
14580
0
        }
14581
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14582
0
                               end_lineno, end_col_offset, arena);
14583
0
        if (*out == NULL) goto failed;
14584
0
        return 0;
14585
0
    }
14586
0
    tp = state->GeneratorExp_type;
14587
0
    isinstance = PyObject_IsInstance(obj, tp);
14588
0
    if (isinstance == -1) {
14589
0
        return -1;
14590
0
    }
14591
0
    if (isinstance) {
14592
0
        expr_ty elt;
14593
0
        asdl_comprehension_seq* generators;
14594
14595
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14596
0
            return -1;
14597
0
        }
14598
0
        if (tmp == NULL) {
14599
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14600
0
            return -1;
14601
0
        }
14602
0
        else {
14603
0
            int res;
14604
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14605
0
                goto failed;
14606
0
            }
14607
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14608
0
            _Py_LeaveRecursiveCall();
14609
0
            if (res != 0) goto failed;
14610
0
            Py_CLEAR(tmp);
14611
0
        }
14612
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14613
0
            return -1;
14614
0
        }
14615
0
        if (tmp == NULL) {
14616
0
            tmp = PyList_New(0);
14617
0
            if (tmp == NULL) {
14618
0
                return -1;
14619
0
            }
14620
0
        }
14621
0
        {
14622
0
            int res;
14623
0
            Py_ssize_t len;
14624
0
            Py_ssize_t i;
14625
0
            if (!PyList_Check(tmp)) {
14626
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14627
0
                goto failed;
14628
0
            }
14629
0
            len = PyList_GET_SIZE(tmp);
14630
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14631
0
            if (generators == NULL) goto failed;
14632
0
            for (i = 0; i < len; i++) {
14633
0
                comprehension_ty val;
14634
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14635
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14636
0
                    goto failed;
14637
0
                }
14638
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14639
0
                _Py_LeaveRecursiveCall();
14640
0
                Py_DECREF(tmp2);
14641
0
                if (res != 0) goto failed;
14642
0
                if (len != PyList_GET_SIZE(tmp)) {
14643
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14644
0
                    goto failed;
14645
0
                }
14646
0
                asdl_seq_SET(generators, i, val);
14647
0
            }
14648
0
            Py_CLEAR(tmp);
14649
0
        }
14650
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14651
0
                                   end_lineno, end_col_offset, arena);
14652
0
        if (*out == NULL) goto failed;
14653
0
        return 0;
14654
0
    }
14655
0
    tp = state->Await_type;
14656
0
    isinstance = PyObject_IsInstance(obj, tp);
14657
0
    if (isinstance == -1) {
14658
0
        return -1;
14659
0
    }
14660
0
    if (isinstance) {
14661
0
        expr_ty value;
14662
14663
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14664
0
            return -1;
14665
0
        }
14666
0
        if (tmp == NULL) {
14667
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14668
0
            return -1;
14669
0
        }
14670
0
        else {
14671
0
            int res;
14672
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14673
0
                goto failed;
14674
0
            }
14675
0
            res = obj2ast_expr(state, tmp, &value, arena);
14676
0
            _Py_LeaveRecursiveCall();
14677
0
            if (res != 0) goto failed;
14678
0
            Py_CLEAR(tmp);
14679
0
        }
14680
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14681
0
                            end_col_offset, arena);
14682
0
        if (*out == NULL) goto failed;
14683
0
        return 0;
14684
0
    }
14685
0
    tp = state->Yield_type;
14686
0
    isinstance = PyObject_IsInstance(obj, tp);
14687
0
    if (isinstance == -1) {
14688
0
        return -1;
14689
0
    }
14690
0
    if (isinstance) {
14691
0
        expr_ty value;
14692
14693
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14694
0
            return -1;
14695
0
        }
14696
0
        if (tmp == NULL || tmp == Py_None) {
14697
0
            Py_CLEAR(tmp);
14698
0
            value = NULL;
14699
0
        }
14700
0
        else {
14701
0
            int res;
14702
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14703
0
                goto failed;
14704
0
            }
14705
0
            res = obj2ast_expr(state, tmp, &value, arena);
14706
0
            _Py_LeaveRecursiveCall();
14707
0
            if (res != 0) goto failed;
14708
0
            Py_CLEAR(tmp);
14709
0
        }
14710
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14711
0
                            end_col_offset, arena);
14712
0
        if (*out == NULL) goto failed;
14713
0
        return 0;
14714
0
    }
14715
0
    tp = state->YieldFrom_type;
14716
0
    isinstance = PyObject_IsInstance(obj, tp);
14717
0
    if (isinstance == -1) {
14718
0
        return -1;
14719
0
    }
14720
0
    if (isinstance) {
14721
0
        expr_ty value;
14722
14723
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14724
0
            return -1;
14725
0
        }
14726
0
        if (tmp == NULL) {
14727
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14728
0
            return -1;
14729
0
        }
14730
0
        else {
14731
0
            int res;
14732
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14733
0
                goto failed;
14734
0
            }
14735
0
            res = obj2ast_expr(state, tmp, &value, arena);
14736
0
            _Py_LeaveRecursiveCall();
14737
0
            if (res != 0) goto failed;
14738
0
            Py_CLEAR(tmp);
14739
0
        }
14740
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14741
0
                                end_col_offset, arena);
14742
0
        if (*out == NULL) goto failed;
14743
0
        return 0;
14744
0
    }
14745
0
    tp = state->Compare_type;
14746
0
    isinstance = PyObject_IsInstance(obj, tp);
14747
0
    if (isinstance == -1) {
14748
0
        return -1;
14749
0
    }
14750
0
    if (isinstance) {
14751
0
        expr_ty left;
14752
0
        asdl_int_seq* ops;
14753
0
        asdl_expr_seq* comparators;
14754
14755
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14756
0
            return -1;
14757
0
        }
14758
0
        if (tmp == NULL) {
14759
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14760
0
            return -1;
14761
0
        }
14762
0
        else {
14763
0
            int res;
14764
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14765
0
                goto failed;
14766
0
            }
14767
0
            res = obj2ast_expr(state, tmp, &left, arena);
14768
0
            _Py_LeaveRecursiveCall();
14769
0
            if (res != 0) goto failed;
14770
0
            Py_CLEAR(tmp);
14771
0
        }
14772
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14773
0
            return -1;
14774
0
        }
14775
0
        if (tmp == NULL) {
14776
0
            tmp = PyList_New(0);
14777
0
            if (tmp == NULL) {
14778
0
                return -1;
14779
0
            }
14780
0
        }
14781
0
        {
14782
0
            int res;
14783
0
            Py_ssize_t len;
14784
0
            Py_ssize_t i;
14785
0
            if (!PyList_Check(tmp)) {
14786
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14787
0
                goto failed;
14788
0
            }
14789
0
            len = PyList_GET_SIZE(tmp);
14790
0
            ops = _Py_asdl_int_seq_new(len, arena);
14791
0
            if (ops == NULL) goto failed;
14792
0
            for (i = 0; i < len; i++) {
14793
0
                cmpop_ty val;
14794
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14795
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14796
0
                    goto failed;
14797
0
                }
14798
0
                res = obj2ast_cmpop(state, tmp2, &val, arena);
14799
0
                _Py_LeaveRecursiveCall();
14800
0
                Py_DECREF(tmp2);
14801
0
                if (res != 0) goto failed;
14802
0
                if (len != PyList_GET_SIZE(tmp)) {
14803
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14804
0
                    goto failed;
14805
0
                }
14806
0
                asdl_seq_SET(ops, i, val);
14807
0
            }
14808
0
            Py_CLEAR(tmp);
14809
0
        }
14810
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14811
0
            return -1;
14812
0
        }
14813
0
        if (tmp == NULL) {
14814
0
            tmp = PyList_New(0);
14815
0
            if (tmp == NULL) {
14816
0
                return -1;
14817
0
            }
14818
0
        }
14819
0
        {
14820
0
            int res;
14821
0
            Py_ssize_t len;
14822
0
            Py_ssize_t i;
14823
0
            if (!PyList_Check(tmp)) {
14824
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14825
0
                goto failed;
14826
0
            }
14827
0
            len = PyList_GET_SIZE(tmp);
14828
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14829
0
            if (comparators == NULL) goto failed;
14830
0
            for (i = 0; i < len; i++) {
14831
0
                expr_ty val;
14832
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14833
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14834
0
                    goto failed;
14835
0
                }
14836
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14837
0
                _Py_LeaveRecursiveCall();
14838
0
                Py_DECREF(tmp2);
14839
0
                if (res != 0) goto failed;
14840
0
                if (len != PyList_GET_SIZE(tmp)) {
14841
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14842
0
                    goto failed;
14843
0
                }
14844
0
                asdl_seq_SET(comparators, i, val);
14845
0
            }
14846
0
            Py_CLEAR(tmp);
14847
0
        }
14848
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14849
0
                              end_lineno, end_col_offset, arena);
14850
0
        if (*out == NULL) goto failed;
14851
0
        return 0;
14852
0
    }
14853
0
    tp = state->Call_type;
14854
0
    isinstance = PyObject_IsInstance(obj, tp);
14855
0
    if (isinstance == -1) {
14856
0
        return -1;
14857
0
    }
14858
0
    if (isinstance) {
14859
0
        expr_ty func;
14860
0
        asdl_expr_seq* args;
14861
0
        asdl_keyword_seq* keywords;
14862
14863
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14864
0
            return -1;
14865
0
        }
14866
0
        if (tmp == NULL) {
14867
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14868
0
            return -1;
14869
0
        }
14870
0
        else {
14871
0
            int res;
14872
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14873
0
                goto failed;
14874
0
            }
14875
0
            res = obj2ast_expr(state, tmp, &func, arena);
14876
0
            _Py_LeaveRecursiveCall();
14877
0
            if (res != 0) goto failed;
14878
0
            Py_CLEAR(tmp);
14879
0
        }
14880
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14881
0
            return -1;
14882
0
        }
14883
0
        if (tmp == NULL) {
14884
0
            tmp = PyList_New(0);
14885
0
            if (tmp == NULL) {
14886
0
                return -1;
14887
0
            }
14888
0
        }
14889
0
        {
14890
0
            int res;
14891
0
            Py_ssize_t len;
14892
0
            Py_ssize_t i;
14893
0
            if (!PyList_Check(tmp)) {
14894
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14895
0
                goto failed;
14896
0
            }
14897
0
            len = PyList_GET_SIZE(tmp);
14898
0
            args = _Py_asdl_expr_seq_new(len, arena);
14899
0
            if (args == NULL) goto failed;
14900
0
            for (i = 0; i < len; i++) {
14901
0
                expr_ty val;
14902
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14903
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14904
0
                    goto failed;
14905
0
                }
14906
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14907
0
                _Py_LeaveRecursiveCall();
14908
0
                Py_DECREF(tmp2);
14909
0
                if (res != 0) goto failed;
14910
0
                if (len != PyList_GET_SIZE(tmp)) {
14911
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14912
0
                    goto failed;
14913
0
                }
14914
0
                asdl_seq_SET(args, i, val);
14915
0
            }
14916
0
            Py_CLEAR(tmp);
14917
0
        }
14918
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14919
0
            return -1;
14920
0
        }
14921
0
        if (tmp == NULL) {
14922
0
            tmp = PyList_New(0);
14923
0
            if (tmp == NULL) {
14924
0
                return -1;
14925
0
            }
14926
0
        }
14927
0
        {
14928
0
            int res;
14929
0
            Py_ssize_t len;
14930
0
            Py_ssize_t i;
14931
0
            if (!PyList_Check(tmp)) {
14932
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14933
0
                goto failed;
14934
0
            }
14935
0
            len = PyList_GET_SIZE(tmp);
14936
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
14937
0
            if (keywords == NULL) goto failed;
14938
0
            for (i = 0; i < len; i++) {
14939
0
                keyword_ty val;
14940
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14941
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14942
0
                    goto failed;
14943
0
                }
14944
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
14945
0
                _Py_LeaveRecursiveCall();
14946
0
                Py_DECREF(tmp2);
14947
0
                if (res != 0) goto failed;
14948
0
                if (len != PyList_GET_SIZE(tmp)) {
14949
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
14950
0
                    goto failed;
14951
0
                }
14952
0
                asdl_seq_SET(keywords, i, val);
14953
0
            }
14954
0
            Py_CLEAR(tmp);
14955
0
        }
14956
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
14957
0
                           end_lineno, end_col_offset, arena);
14958
0
        if (*out == NULL) goto failed;
14959
0
        return 0;
14960
0
    }
14961
0
    tp = state->FormattedValue_type;
14962
0
    isinstance = PyObject_IsInstance(obj, tp);
14963
0
    if (isinstance == -1) {
14964
0
        return -1;
14965
0
    }
14966
0
    if (isinstance) {
14967
0
        expr_ty value;
14968
0
        int conversion;
14969
0
        expr_ty format_spec;
14970
14971
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14972
0
            return -1;
14973
0
        }
14974
0
        if (tmp == NULL) {
14975
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
14976
0
            return -1;
14977
0
        }
14978
0
        else {
14979
0
            int res;
14980
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14981
0
                goto failed;
14982
0
            }
14983
0
            res = obj2ast_expr(state, tmp, &value, arena);
14984
0
            _Py_LeaveRecursiveCall();
14985
0
            if (res != 0) goto failed;
14986
0
            Py_CLEAR(tmp);
14987
0
        }
14988
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
14989
0
            return -1;
14990
0
        }
14991
0
        if (tmp == NULL) {
14992
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
14993
0
            return -1;
14994
0
        }
14995
0
        else {
14996
0
            int res;
14997
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14998
0
                goto failed;
14999
0
            }
15000
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15001
0
            _Py_LeaveRecursiveCall();
15002
0
            if (res != 0) goto failed;
15003
0
            Py_CLEAR(tmp);
15004
0
        }
15005
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15006
0
            return -1;
15007
0
        }
15008
0
        if (tmp == NULL || tmp == Py_None) {
15009
0
            Py_CLEAR(tmp);
15010
0
            format_spec = NULL;
15011
0
        }
15012
0
        else {
15013
0
            int res;
15014
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15015
0
                goto failed;
15016
0
            }
15017
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15018
0
            _Py_LeaveRecursiveCall();
15019
0
            if (res != 0) goto failed;
15020
0
            Py_CLEAR(tmp);
15021
0
        }
15022
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15023
0
                                     col_offset, end_lineno, end_col_offset,
15024
0
                                     arena);
15025
0
        if (*out == NULL) goto failed;
15026
0
        return 0;
15027
0
    }
15028
0
    tp = state->Interpolation_type;
15029
0
    isinstance = PyObject_IsInstance(obj, tp);
15030
0
    if (isinstance == -1) {
15031
0
        return -1;
15032
0
    }
15033
0
    if (isinstance) {
15034
0
        expr_ty value;
15035
0
        constant str;
15036
0
        int conversion;
15037
0
        expr_ty format_spec;
15038
15039
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15040
0
            return -1;
15041
0
        }
15042
0
        if (tmp == NULL) {
15043
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15044
0
            return -1;
15045
0
        }
15046
0
        else {
15047
0
            int res;
15048
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15049
0
                goto failed;
15050
0
            }
15051
0
            res = obj2ast_expr(state, tmp, &value, arena);
15052
0
            _Py_LeaveRecursiveCall();
15053
0
            if (res != 0) goto failed;
15054
0
            Py_CLEAR(tmp);
15055
0
        }
15056
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15057
0
            return -1;
15058
0
        }
15059
0
        if (tmp == NULL) {
15060
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15061
0
            return -1;
15062
0
        }
15063
0
        else {
15064
0
            int res;
15065
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15066
0
                goto failed;
15067
0
            }
15068
0
            res = obj2ast_constant(state, tmp, &str, arena);
15069
0
            _Py_LeaveRecursiveCall();
15070
0
            if (res != 0) goto failed;
15071
0
            Py_CLEAR(tmp);
15072
0
        }
15073
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15074
0
            return -1;
15075
0
        }
15076
0
        if (tmp == NULL) {
15077
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15078
0
            return -1;
15079
0
        }
15080
0
        else {
15081
0
            int res;
15082
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15083
0
                goto failed;
15084
0
            }
15085
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15086
0
            _Py_LeaveRecursiveCall();
15087
0
            if (res != 0) goto failed;
15088
0
            Py_CLEAR(tmp);
15089
0
        }
15090
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15091
0
            return -1;
15092
0
        }
15093
0
        if (tmp == NULL || tmp == Py_None) {
15094
0
            Py_CLEAR(tmp);
15095
0
            format_spec = NULL;
15096
0
        }
15097
0
        else {
15098
0
            int res;
15099
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15100
0
                goto failed;
15101
0
            }
15102
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15103
0
            _Py_LeaveRecursiveCall();
15104
0
            if (res != 0) goto failed;
15105
0
            Py_CLEAR(tmp);
15106
0
        }
15107
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15108
0
                                    lineno, col_offset, end_lineno,
15109
0
                                    end_col_offset, arena);
15110
0
        if (*out == NULL) goto failed;
15111
0
        return 0;
15112
0
    }
15113
0
    tp = state->JoinedStr_type;
15114
0
    isinstance = PyObject_IsInstance(obj, tp);
15115
0
    if (isinstance == -1) {
15116
0
        return -1;
15117
0
    }
15118
0
    if (isinstance) {
15119
0
        asdl_expr_seq* values;
15120
15121
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15122
0
            return -1;
15123
0
        }
15124
0
        if (tmp == NULL) {
15125
0
            tmp = PyList_New(0);
15126
0
            if (tmp == NULL) {
15127
0
                return -1;
15128
0
            }
15129
0
        }
15130
0
        {
15131
0
            int res;
15132
0
            Py_ssize_t len;
15133
0
            Py_ssize_t i;
15134
0
            if (!PyList_Check(tmp)) {
15135
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15136
0
                goto failed;
15137
0
            }
15138
0
            len = PyList_GET_SIZE(tmp);
15139
0
            values = _Py_asdl_expr_seq_new(len, arena);
15140
0
            if (values == NULL) goto failed;
15141
0
            for (i = 0; i < len; i++) {
15142
0
                expr_ty val;
15143
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15144
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15145
0
                    goto failed;
15146
0
                }
15147
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15148
0
                _Py_LeaveRecursiveCall();
15149
0
                Py_DECREF(tmp2);
15150
0
                if (res != 0) goto failed;
15151
0
                if (len != PyList_GET_SIZE(tmp)) {
15152
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15153
0
                    goto failed;
15154
0
                }
15155
0
                asdl_seq_SET(values, i, val);
15156
0
            }
15157
0
            Py_CLEAR(tmp);
15158
0
        }
15159
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15160
0
                                end_col_offset, arena);
15161
0
        if (*out == NULL) goto failed;
15162
0
        return 0;
15163
0
    }
15164
0
    tp = state->TemplateStr_type;
15165
0
    isinstance = PyObject_IsInstance(obj, tp);
15166
0
    if (isinstance == -1) {
15167
0
        return -1;
15168
0
    }
15169
0
    if (isinstance) {
15170
0
        asdl_expr_seq* values;
15171
15172
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15173
0
            return -1;
15174
0
        }
15175
0
        if (tmp == NULL) {
15176
0
            tmp = PyList_New(0);
15177
0
            if (tmp == NULL) {
15178
0
                return -1;
15179
0
            }
15180
0
        }
15181
0
        {
15182
0
            int res;
15183
0
            Py_ssize_t len;
15184
0
            Py_ssize_t i;
15185
0
            if (!PyList_Check(tmp)) {
15186
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15187
0
                goto failed;
15188
0
            }
15189
0
            len = PyList_GET_SIZE(tmp);
15190
0
            values = _Py_asdl_expr_seq_new(len, arena);
15191
0
            if (values == NULL) goto failed;
15192
0
            for (i = 0; i < len; i++) {
15193
0
                expr_ty val;
15194
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15195
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15196
0
                    goto failed;
15197
0
                }
15198
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15199
0
                _Py_LeaveRecursiveCall();
15200
0
                Py_DECREF(tmp2);
15201
0
                if (res != 0) goto failed;
15202
0
                if (len != PyList_GET_SIZE(tmp)) {
15203
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15204
0
                    goto failed;
15205
0
                }
15206
0
                asdl_seq_SET(values, i, val);
15207
0
            }
15208
0
            Py_CLEAR(tmp);
15209
0
        }
15210
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15211
0
                                  end_col_offset, arena);
15212
0
        if (*out == NULL) goto failed;
15213
0
        return 0;
15214
0
    }
15215
0
    tp = state->Constant_type;
15216
0
    isinstance = PyObject_IsInstance(obj, tp);
15217
0
    if (isinstance == -1) {
15218
0
        return -1;
15219
0
    }
15220
0
    if (isinstance) {
15221
0
        constant value;
15222
0
        string kind;
15223
15224
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15225
0
            return -1;
15226
0
        }
15227
0
        if (tmp == NULL) {
15228
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15229
0
            return -1;
15230
0
        }
15231
0
        else {
15232
0
            int res;
15233
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15234
0
                goto failed;
15235
0
            }
15236
0
            res = obj2ast_constant(state, tmp, &value, arena);
15237
0
            _Py_LeaveRecursiveCall();
15238
0
            if (res != 0) goto failed;
15239
0
            Py_CLEAR(tmp);
15240
0
        }
15241
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15242
0
            return -1;
15243
0
        }
15244
0
        if (tmp == NULL || tmp == Py_None) {
15245
0
            Py_CLEAR(tmp);
15246
0
            kind = NULL;
15247
0
        }
15248
0
        else {
15249
0
            int res;
15250
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15251
0
                goto failed;
15252
0
            }
15253
0
            res = obj2ast_string(state, tmp, &kind, arena);
15254
0
            _Py_LeaveRecursiveCall();
15255
0
            if (res != 0) goto failed;
15256
0
            Py_CLEAR(tmp);
15257
0
        }
15258
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15259
0
                               end_col_offset, arena);
15260
0
        if (*out == NULL) goto failed;
15261
0
        return 0;
15262
0
    }
15263
0
    tp = state->Attribute_type;
15264
0
    isinstance = PyObject_IsInstance(obj, tp);
15265
0
    if (isinstance == -1) {
15266
0
        return -1;
15267
0
    }
15268
0
    if (isinstance) {
15269
0
        expr_ty value;
15270
0
        identifier attr;
15271
0
        expr_context_ty ctx;
15272
15273
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15274
0
            return -1;
15275
0
        }
15276
0
        if (tmp == NULL) {
15277
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15278
0
            return -1;
15279
0
        }
15280
0
        else {
15281
0
            int res;
15282
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15283
0
                goto failed;
15284
0
            }
15285
0
            res = obj2ast_expr(state, tmp, &value, arena);
15286
0
            _Py_LeaveRecursiveCall();
15287
0
            if (res != 0) goto failed;
15288
0
            Py_CLEAR(tmp);
15289
0
        }
15290
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15291
0
            return -1;
15292
0
        }
15293
0
        if (tmp == NULL) {
15294
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15295
0
            return -1;
15296
0
        }
15297
0
        else {
15298
0
            int res;
15299
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15300
0
                goto failed;
15301
0
            }
15302
0
            res = obj2ast_identifier(state, tmp, &attr, arena);
15303
0
            _Py_LeaveRecursiveCall();
15304
0
            if (res != 0) goto failed;
15305
0
            Py_CLEAR(tmp);
15306
0
        }
15307
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15308
0
            return -1;
15309
0
        }
15310
0
        if (tmp == NULL) {
15311
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15312
0
            return -1;
15313
0
        }
15314
0
        else {
15315
0
            int res;
15316
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15317
0
                goto failed;
15318
0
            }
15319
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15320
0
            _Py_LeaveRecursiveCall();
15321
0
            if (res != 0) goto failed;
15322
0
            Py_CLEAR(tmp);
15323
0
        }
15324
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15325
0
                                end_lineno, end_col_offset, arena);
15326
0
        if (*out == NULL) goto failed;
15327
0
        return 0;
15328
0
    }
15329
0
    tp = state->Subscript_type;
15330
0
    isinstance = PyObject_IsInstance(obj, tp);
15331
0
    if (isinstance == -1) {
15332
0
        return -1;
15333
0
    }
15334
0
    if (isinstance) {
15335
0
        expr_ty value;
15336
0
        expr_ty slice;
15337
0
        expr_context_ty ctx;
15338
15339
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15340
0
            return -1;
15341
0
        }
15342
0
        if (tmp == NULL) {
15343
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15344
0
            return -1;
15345
0
        }
15346
0
        else {
15347
0
            int res;
15348
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15349
0
                goto failed;
15350
0
            }
15351
0
            res = obj2ast_expr(state, tmp, &value, arena);
15352
0
            _Py_LeaveRecursiveCall();
15353
0
            if (res != 0) goto failed;
15354
0
            Py_CLEAR(tmp);
15355
0
        }
15356
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15357
0
            return -1;
15358
0
        }
15359
0
        if (tmp == NULL) {
15360
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15361
0
            return -1;
15362
0
        }
15363
0
        else {
15364
0
            int res;
15365
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15366
0
                goto failed;
15367
0
            }
15368
0
            res = obj2ast_expr(state, tmp, &slice, arena);
15369
0
            _Py_LeaveRecursiveCall();
15370
0
            if (res != 0) goto failed;
15371
0
            Py_CLEAR(tmp);
15372
0
        }
15373
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15374
0
            return -1;
15375
0
        }
15376
0
        if (tmp == NULL) {
15377
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15378
0
            return -1;
15379
0
        }
15380
0
        else {
15381
0
            int res;
15382
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15383
0
                goto failed;
15384
0
            }
15385
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15386
0
            _Py_LeaveRecursiveCall();
15387
0
            if (res != 0) goto failed;
15388
0
            Py_CLEAR(tmp);
15389
0
        }
15390
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15391
0
                                end_lineno, end_col_offset, arena);
15392
0
        if (*out == NULL) goto failed;
15393
0
        return 0;
15394
0
    }
15395
0
    tp = state->Starred_type;
15396
0
    isinstance = PyObject_IsInstance(obj, tp);
15397
0
    if (isinstance == -1) {
15398
0
        return -1;
15399
0
    }
15400
0
    if (isinstance) {
15401
0
        expr_ty value;
15402
0
        expr_context_ty ctx;
15403
15404
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15405
0
            return -1;
15406
0
        }
15407
0
        if (tmp == NULL) {
15408
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15409
0
            return -1;
15410
0
        }
15411
0
        else {
15412
0
            int res;
15413
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15414
0
                goto failed;
15415
0
            }
15416
0
            res = obj2ast_expr(state, tmp, &value, arena);
15417
0
            _Py_LeaveRecursiveCall();
15418
0
            if (res != 0) goto failed;
15419
0
            Py_CLEAR(tmp);
15420
0
        }
15421
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15422
0
            return -1;
15423
0
        }
15424
0
        if (tmp == NULL) {
15425
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15426
0
            return -1;
15427
0
        }
15428
0
        else {
15429
0
            int res;
15430
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15431
0
                goto failed;
15432
0
            }
15433
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15434
0
            _Py_LeaveRecursiveCall();
15435
0
            if (res != 0) goto failed;
15436
0
            Py_CLEAR(tmp);
15437
0
        }
15438
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15439
0
                              end_col_offset, arena);
15440
0
        if (*out == NULL) goto failed;
15441
0
        return 0;
15442
0
    }
15443
0
    tp = state->Name_type;
15444
0
    isinstance = PyObject_IsInstance(obj, tp);
15445
0
    if (isinstance == -1) {
15446
0
        return -1;
15447
0
    }
15448
0
    if (isinstance) {
15449
0
        identifier id;
15450
0
        expr_context_ty ctx;
15451
15452
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15453
0
            return -1;
15454
0
        }
15455
0
        if (tmp == NULL) {
15456
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15457
0
            return -1;
15458
0
        }
15459
0
        else {
15460
0
            int res;
15461
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15462
0
                goto failed;
15463
0
            }
15464
0
            res = obj2ast_identifier(state, tmp, &id, arena);
15465
0
            _Py_LeaveRecursiveCall();
15466
0
            if (res != 0) goto failed;
15467
0
            Py_CLEAR(tmp);
15468
0
        }
15469
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15470
0
            return -1;
15471
0
        }
15472
0
        if (tmp == NULL) {
15473
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15474
0
            return -1;
15475
0
        }
15476
0
        else {
15477
0
            int res;
15478
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15479
0
                goto failed;
15480
0
            }
15481
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15482
0
            _Py_LeaveRecursiveCall();
15483
0
            if (res != 0) goto failed;
15484
0
            Py_CLEAR(tmp);
15485
0
        }
15486
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15487
0
                           end_col_offset, arena);
15488
0
        if (*out == NULL) goto failed;
15489
0
        return 0;
15490
0
    }
15491
0
    tp = state->List_type;
15492
0
    isinstance = PyObject_IsInstance(obj, tp);
15493
0
    if (isinstance == -1) {
15494
0
        return -1;
15495
0
    }
15496
0
    if (isinstance) {
15497
0
        asdl_expr_seq* elts;
15498
0
        expr_context_ty ctx;
15499
15500
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15501
0
            return -1;
15502
0
        }
15503
0
        if (tmp == NULL) {
15504
0
            tmp = PyList_New(0);
15505
0
            if (tmp == NULL) {
15506
0
                return -1;
15507
0
            }
15508
0
        }
15509
0
        {
15510
0
            int res;
15511
0
            Py_ssize_t len;
15512
0
            Py_ssize_t i;
15513
0
            if (!PyList_Check(tmp)) {
15514
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15515
0
                goto failed;
15516
0
            }
15517
0
            len = PyList_GET_SIZE(tmp);
15518
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15519
0
            if (elts == NULL) goto failed;
15520
0
            for (i = 0; i < len; i++) {
15521
0
                expr_ty val;
15522
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15523
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15524
0
                    goto failed;
15525
0
                }
15526
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15527
0
                _Py_LeaveRecursiveCall();
15528
0
                Py_DECREF(tmp2);
15529
0
                if (res != 0) goto failed;
15530
0
                if (len != PyList_GET_SIZE(tmp)) {
15531
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15532
0
                    goto failed;
15533
0
                }
15534
0
                asdl_seq_SET(elts, i, val);
15535
0
            }
15536
0
            Py_CLEAR(tmp);
15537
0
        }
15538
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15539
0
            return -1;
15540
0
        }
15541
0
        if (tmp == NULL) {
15542
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15543
0
            return -1;
15544
0
        }
15545
0
        else {
15546
0
            int res;
15547
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15548
0
                goto failed;
15549
0
            }
15550
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15551
0
            _Py_LeaveRecursiveCall();
15552
0
            if (res != 0) goto failed;
15553
0
            Py_CLEAR(tmp);
15554
0
        }
15555
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15556
0
                           end_col_offset, arena);
15557
0
        if (*out == NULL) goto failed;
15558
0
        return 0;
15559
0
    }
15560
0
    tp = state->Tuple_type;
15561
0
    isinstance = PyObject_IsInstance(obj, tp);
15562
0
    if (isinstance == -1) {
15563
0
        return -1;
15564
0
    }
15565
0
    if (isinstance) {
15566
0
        asdl_expr_seq* elts;
15567
0
        expr_context_ty ctx;
15568
15569
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15570
0
            return -1;
15571
0
        }
15572
0
        if (tmp == NULL) {
15573
0
            tmp = PyList_New(0);
15574
0
            if (tmp == NULL) {
15575
0
                return -1;
15576
0
            }
15577
0
        }
15578
0
        {
15579
0
            int res;
15580
0
            Py_ssize_t len;
15581
0
            Py_ssize_t i;
15582
0
            if (!PyList_Check(tmp)) {
15583
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15584
0
                goto failed;
15585
0
            }
15586
0
            len = PyList_GET_SIZE(tmp);
15587
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15588
0
            if (elts == NULL) goto failed;
15589
0
            for (i = 0; i < len; i++) {
15590
0
                expr_ty val;
15591
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15592
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15593
0
                    goto failed;
15594
0
                }
15595
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15596
0
                _Py_LeaveRecursiveCall();
15597
0
                Py_DECREF(tmp2);
15598
0
                if (res != 0) goto failed;
15599
0
                if (len != PyList_GET_SIZE(tmp)) {
15600
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15601
0
                    goto failed;
15602
0
                }
15603
0
                asdl_seq_SET(elts, i, val);
15604
0
            }
15605
0
            Py_CLEAR(tmp);
15606
0
        }
15607
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15608
0
            return -1;
15609
0
        }
15610
0
        if (tmp == NULL) {
15611
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15612
0
            return -1;
15613
0
        }
15614
0
        else {
15615
0
            int res;
15616
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15617
0
                goto failed;
15618
0
            }
15619
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15620
0
            _Py_LeaveRecursiveCall();
15621
0
            if (res != 0) goto failed;
15622
0
            Py_CLEAR(tmp);
15623
0
        }
15624
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15625
0
                            end_col_offset, arena);
15626
0
        if (*out == NULL) goto failed;
15627
0
        return 0;
15628
0
    }
15629
0
    tp = state->Slice_type;
15630
0
    isinstance = PyObject_IsInstance(obj, tp);
15631
0
    if (isinstance == -1) {
15632
0
        return -1;
15633
0
    }
15634
0
    if (isinstance) {
15635
0
        expr_ty lower;
15636
0
        expr_ty upper;
15637
0
        expr_ty step;
15638
15639
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15640
0
            return -1;
15641
0
        }
15642
0
        if (tmp == NULL || tmp == Py_None) {
15643
0
            Py_CLEAR(tmp);
15644
0
            lower = NULL;
15645
0
        }
15646
0
        else {
15647
0
            int res;
15648
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15649
0
                goto failed;
15650
0
            }
15651
0
            res = obj2ast_expr(state, tmp, &lower, arena);
15652
0
            _Py_LeaveRecursiveCall();
15653
0
            if (res != 0) goto failed;
15654
0
            Py_CLEAR(tmp);
15655
0
        }
15656
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15657
0
            return -1;
15658
0
        }
15659
0
        if (tmp == NULL || tmp == Py_None) {
15660
0
            Py_CLEAR(tmp);
15661
0
            upper = NULL;
15662
0
        }
15663
0
        else {
15664
0
            int res;
15665
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15666
0
                goto failed;
15667
0
            }
15668
0
            res = obj2ast_expr(state, tmp, &upper, arena);
15669
0
            _Py_LeaveRecursiveCall();
15670
0
            if (res != 0) goto failed;
15671
0
            Py_CLEAR(tmp);
15672
0
        }
15673
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15674
0
            return -1;
15675
0
        }
15676
0
        if (tmp == NULL || tmp == Py_None) {
15677
0
            Py_CLEAR(tmp);
15678
0
            step = NULL;
15679
0
        }
15680
0
        else {
15681
0
            int res;
15682
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15683
0
                goto failed;
15684
0
            }
15685
0
            res = obj2ast_expr(state, tmp, &step, arena);
15686
0
            _Py_LeaveRecursiveCall();
15687
0
            if (res != 0) goto failed;
15688
0
            Py_CLEAR(tmp);
15689
0
        }
15690
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15691
0
                            end_col_offset, arena);
15692
0
        if (*out == NULL) goto failed;
15693
0
        return 0;
15694
0
    }
15695
15696
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15697
0
    failed:
15698
0
    Py_XDECREF(tmp);
15699
0
    return -1;
15700
0
}
15701
15702
int
15703
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15704
                     out, PyArena* arena)
15705
0
{
15706
0
    int isinstance;
15707
15708
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15709
0
    if (isinstance == -1) {
15710
0
        return -1;
15711
0
    }
15712
0
    if (isinstance) {
15713
0
        *out = Load;
15714
0
        return 0;
15715
0
    }
15716
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15717
0
    if (isinstance == -1) {
15718
0
        return -1;
15719
0
    }
15720
0
    if (isinstance) {
15721
0
        *out = Store;
15722
0
        return 0;
15723
0
    }
15724
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15725
0
    if (isinstance == -1) {
15726
0
        return -1;
15727
0
    }
15728
0
    if (isinstance) {
15729
0
        *out = Del;
15730
0
        return 0;
15731
0
    }
15732
15733
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15734
0
    return -1;
15735
0
}
15736
15737
int
15738
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
15739
               arena)
15740
0
{
15741
0
    int isinstance;
15742
15743
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15744
0
    if (isinstance == -1) {
15745
0
        return -1;
15746
0
    }
15747
0
    if (isinstance) {
15748
0
        *out = And;
15749
0
        return 0;
15750
0
    }
15751
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15752
0
    if (isinstance == -1) {
15753
0
        return -1;
15754
0
    }
15755
0
    if (isinstance) {
15756
0
        *out = Or;
15757
0
        return 0;
15758
0
    }
15759
15760
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15761
0
    return -1;
15762
0
}
15763
15764
int
15765
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15766
                 PyArena* arena)
15767
0
{
15768
0
    int isinstance;
15769
15770
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15771
0
    if (isinstance == -1) {
15772
0
        return -1;
15773
0
    }
15774
0
    if (isinstance) {
15775
0
        *out = Add;
15776
0
        return 0;
15777
0
    }
15778
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15779
0
    if (isinstance == -1) {
15780
0
        return -1;
15781
0
    }
15782
0
    if (isinstance) {
15783
0
        *out = Sub;
15784
0
        return 0;
15785
0
    }
15786
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15787
0
    if (isinstance == -1) {
15788
0
        return -1;
15789
0
    }
15790
0
    if (isinstance) {
15791
0
        *out = Mult;
15792
0
        return 0;
15793
0
    }
15794
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15795
0
    if (isinstance == -1) {
15796
0
        return -1;
15797
0
    }
15798
0
    if (isinstance) {
15799
0
        *out = MatMult;
15800
0
        return 0;
15801
0
    }
15802
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15803
0
    if (isinstance == -1) {
15804
0
        return -1;
15805
0
    }
15806
0
    if (isinstance) {
15807
0
        *out = Div;
15808
0
        return 0;
15809
0
    }
15810
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15811
0
    if (isinstance == -1) {
15812
0
        return -1;
15813
0
    }
15814
0
    if (isinstance) {
15815
0
        *out = Mod;
15816
0
        return 0;
15817
0
    }
15818
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15819
0
    if (isinstance == -1) {
15820
0
        return -1;
15821
0
    }
15822
0
    if (isinstance) {
15823
0
        *out = Pow;
15824
0
        return 0;
15825
0
    }
15826
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15827
0
    if (isinstance == -1) {
15828
0
        return -1;
15829
0
    }
15830
0
    if (isinstance) {
15831
0
        *out = LShift;
15832
0
        return 0;
15833
0
    }
15834
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15835
0
    if (isinstance == -1) {
15836
0
        return -1;
15837
0
    }
15838
0
    if (isinstance) {
15839
0
        *out = RShift;
15840
0
        return 0;
15841
0
    }
15842
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15843
0
    if (isinstance == -1) {
15844
0
        return -1;
15845
0
    }
15846
0
    if (isinstance) {
15847
0
        *out = BitOr;
15848
0
        return 0;
15849
0
    }
15850
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15851
0
    if (isinstance == -1) {
15852
0
        return -1;
15853
0
    }
15854
0
    if (isinstance) {
15855
0
        *out = BitXor;
15856
0
        return 0;
15857
0
    }
15858
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15859
0
    if (isinstance == -1) {
15860
0
        return -1;
15861
0
    }
15862
0
    if (isinstance) {
15863
0
        *out = BitAnd;
15864
0
        return 0;
15865
0
    }
15866
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15867
0
    if (isinstance == -1) {
15868
0
        return -1;
15869
0
    }
15870
0
    if (isinstance) {
15871
0
        *out = FloorDiv;
15872
0
        return 0;
15873
0
    }
15874
15875
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15876
0
    return -1;
15877
0
}
15878
15879
int
15880
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
15881
                PyArena* arena)
15882
0
{
15883
0
    int isinstance;
15884
15885
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15886
0
    if (isinstance == -1) {
15887
0
        return -1;
15888
0
    }
15889
0
    if (isinstance) {
15890
0
        *out = Invert;
15891
0
        return 0;
15892
0
    }
15893
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15894
0
    if (isinstance == -1) {
15895
0
        return -1;
15896
0
    }
15897
0
    if (isinstance) {
15898
0
        *out = Not;
15899
0
        return 0;
15900
0
    }
15901
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15902
0
    if (isinstance == -1) {
15903
0
        return -1;
15904
0
    }
15905
0
    if (isinstance) {
15906
0
        *out = UAdd;
15907
0
        return 0;
15908
0
    }
15909
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15910
0
    if (isinstance == -1) {
15911
0
        return -1;
15912
0
    }
15913
0
    if (isinstance) {
15914
0
        *out = USub;
15915
0
        return 0;
15916
0
    }
15917
15918
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15919
0
    return -1;
15920
0
}
15921
15922
int
15923
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
15924
              arena)
15925
0
{
15926
0
    int isinstance;
15927
15928
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15929
0
    if (isinstance == -1) {
15930
0
        return -1;
15931
0
    }
15932
0
    if (isinstance) {
15933
0
        *out = Eq;
15934
0
        return 0;
15935
0
    }
15936
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
15937
0
    if (isinstance == -1) {
15938
0
        return -1;
15939
0
    }
15940
0
    if (isinstance) {
15941
0
        *out = NotEq;
15942
0
        return 0;
15943
0
    }
15944
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
15945
0
    if (isinstance == -1) {
15946
0
        return -1;
15947
0
    }
15948
0
    if (isinstance) {
15949
0
        *out = Lt;
15950
0
        return 0;
15951
0
    }
15952
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
15953
0
    if (isinstance == -1) {
15954
0
        return -1;
15955
0
    }
15956
0
    if (isinstance) {
15957
0
        *out = LtE;
15958
0
        return 0;
15959
0
    }
15960
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
15961
0
    if (isinstance == -1) {
15962
0
        return -1;
15963
0
    }
15964
0
    if (isinstance) {
15965
0
        *out = Gt;
15966
0
        return 0;
15967
0
    }
15968
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
15969
0
    if (isinstance == -1) {
15970
0
        return -1;
15971
0
    }
15972
0
    if (isinstance) {
15973
0
        *out = GtE;
15974
0
        return 0;
15975
0
    }
15976
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
15977
0
    if (isinstance == -1) {
15978
0
        return -1;
15979
0
    }
15980
0
    if (isinstance) {
15981
0
        *out = Is;
15982
0
        return 0;
15983
0
    }
15984
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
15985
0
    if (isinstance == -1) {
15986
0
        return -1;
15987
0
    }
15988
0
    if (isinstance) {
15989
0
        *out = IsNot;
15990
0
        return 0;
15991
0
    }
15992
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
15993
0
    if (isinstance == -1) {
15994
0
        return -1;
15995
0
    }
15996
0
    if (isinstance) {
15997
0
        *out = In;
15998
0
        return 0;
15999
0
    }
16000
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16001
0
    if (isinstance == -1) {
16002
0
        return -1;
16003
0
    }
16004
0
    if (isinstance) {
16005
0
        *out = NotIn;
16006
0
        return 0;
16007
0
    }
16008
16009
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16010
0
    return -1;
16011
0
}
16012
16013
int
16014
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16015
                      out, PyArena* arena)
16016
0
{
16017
0
    PyObject* tmp = NULL;
16018
0
    expr_ty target;
16019
0
    expr_ty iter;
16020
0
    asdl_expr_seq* ifs;
16021
0
    int is_async;
16022
16023
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16024
0
        return -1;
16025
0
    }
16026
0
    if (tmp == NULL) {
16027
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16028
0
        return -1;
16029
0
    }
16030
0
    else {
16031
0
        int res;
16032
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16033
0
            goto failed;
16034
0
        }
16035
0
        res = obj2ast_expr(state, tmp, &target, arena);
16036
0
        _Py_LeaveRecursiveCall();
16037
0
        if (res != 0) goto failed;
16038
0
        Py_CLEAR(tmp);
16039
0
    }
16040
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16041
0
        return -1;
16042
0
    }
16043
0
    if (tmp == NULL) {
16044
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16045
0
        return -1;
16046
0
    }
16047
0
    else {
16048
0
        int res;
16049
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16050
0
            goto failed;
16051
0
        }
16052
0
        res = obj2ast_expr(state, tmp, &iter, arena);
16053
0
        _Py_LeaveRecursiveCall();
16054
0
        if (res != 0) goto failed;
16055
0
        Py_CLEAR(tmp);
16056
0
    }
16057
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16058
0
        return -1;
16059
0
    }
16060
0
    if (tmp == NULL) {
16061
0
        tmp = PyList_New(0);
16062
0
        if (tmp == NULL) {
16063
0
            return -1;
16064
0
        }
16065
0
    }
16066
0
    {
16067
0
        int res;
16068
0
        Py_ssize_t len;
16069
0
        Py_ssize_t i;
16070
0
        if (!PyList_Check(tmp)) {
16071
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16072
0
            goto failed;
16073
0
        }
16074
0
        len = PyList_GET_SIZE(tmp);
16075
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16076
0
        if (ifs == NULL) goto failed;
16077
0
        for (i = 0; i < len; i++) {
16078
0
            expr_ty val;
16079
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16080
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16081
0
                goto failed;
16082
0
            }
16083
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16084
0
            _Py_LeaveRecursiveCall();
16085
0
            Py_DECREF(tmp2);
16086
0
            if (res != 0) goto failed;
16087
0
            if (len != PyList_GET_SIZE(tmp)) {
16088
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16089
0
                goto failed;
16090
0
            }
16091
0
            asdl_seq_SET(ifs, i, val);
16092
0
        }
16093
0
        Py_CLEAR(tmp);
16094
0
    }
16095
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16096
0
        return -1;
16097
0
    }
16098
0
    if (tmp == NULL) {
16099
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16100
0
        return -1;
16101
0
    }
16102
0
    else {
16103
0
        int res;
16104
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16105
0
            goto failed;
16106
0
        }
16107
0
        res = obj2ast_int(state, tmp, &is_async, arena);
16108
0
        _Py_LeaveRecursiveCall();
16109
0
        if (res != 0) goto failed;
16110
0
        Py_CLEAR(tmp);
16111
0
    }
16112
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16113
0
    if (*out == NULL) goto failed;
16114
0
    return 0;
16115
0
failed:
16116
0
    Py_XDECREF(tmp);
16117
0
    return -1;
16118
0
}
16119
16120
int
16121
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16122
                      out, PyArena* arena)
16123
0
{
16124
0
    int isinstance;
16125
16126
0
    PyObject *tmp = NULL;
16127
0
    PyObject *tp;
16128
0
    int lineno;
16129
0
    int col_offset;
16130
0
    int end_lineno;
16131
0
    int end_col_offset;
16132
16133
0
    if (obj == Py_None) {
16134
0
        *out = NULL;
16135
0
        return 0;
16136
0
    }
16137
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16138
0
        return -1;
16139
0
    }
16140
0
    if (tmp == NULL) {
16141
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16142
0
        return -1;
16143
0
    }
16144
0
    else {
16145
0
        int res;
16146
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16147
0
            goto failed;
16148
0
        }
16149
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16150
0
        _Py_LeaveRecursiveCall();
16151
0
        if (res != 0) goto failed;
16152
0
        Py_CLEAR(tmp);
16153
0
    }
16154
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16155
0
        return -1;
16156
0
    }
16157
0
    if (tmp == NULL) {
16158
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16159
0
        return -1;
16160
0
    }
16161
0
    else {
16162
0
        int res;
16163
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16164
0
            goto failed;
16165
0
        }
16166
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16167
0
        _Py_LeaveRecursiveCall();
16168
0
        if (res != 0) goto failed;
16169
0
        Py_CLEAR(tmp);
16170
0
    }
16171
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16172
0
        return -1;
16173
0
    }
16174
0
    if (tmp == NULL || tmp == Py_None) {
16175
0
        Py_CLEAR(tmp);
16176
0
        end_lineno = lineno;
16177
0
    }
16178
0
    else {
16179
0
        int res;
16180
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16181
0
            goto failed;
16182
0
        }
16183
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16184
0
        _Py_LeaveRecursiveCall();
16185
0
        if (res != 0) goto failed;
16186
0
        Py_CLEAR(tmp);
16187
0
    }
16188
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16189
0
        return -1;
16190
0
    }
16191
0
    if (tmp == NULL || tmp == Py_None) {
16192
0
        Py_CLEAR(tmp);
16193
0
        end_col_offset = col_offset;
16194
0
    }
16195
0
    else {
16196
0
        int res;
16197
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16198
0
            goto failed;
16199
0
        }
16200
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16201
0
        _Py_LeaveRecursiveCall();
16202
0
        if (res != 0) goto failed;
16203
0
        Py_CLEAR(tmp);
16204
0
    }
16205
0
    tp = state->ExceptHandler_type;
16206
0
    isinstance = PyObject_IsInstance(obj, tp);
16207
0
    if (isinstance == -1) {
16208
0
        return -1;
16209
0
    }
16210
0
    if (isinstance) {
16211
0
        expr_ty type;
16212
0
        identifier name;
16213
0
        asdl_stmt_seq* body;
16214
16215
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16216
0
            return -1;
16217
0
        }
16218
0
        if (tmp == NULL || tmp == Py_None) {
16219
0
            Py_CLEAR(tmp);
16220
0
            type = NULL;
16221
0
        }
16222
0
        else {
16223
0
            int res;
16224
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16225
0
                goto failed;
16226
0
            }
16227
0
            res = obj2ast_expr(state, tmp, &type, arena);
16228
0
            _Py_LeaveRecursiveCall();
16229
0
            if (res != 0) goto failed;
16230
0
            Py_CLEAR(tmp);
16231
0
        }
16232
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16233
0
            return -1;
16234
0
        }
16235
0
        if (tmp == NULL || tmp == Py_None) {
16236
0
            Py_CLEAR(tmp);
16237
0
            name = NULL;
16238
0
        }
16239
0
        else {
16240
0
            int res;
16241
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16242
0
                goto failed;
16243
0
            }
16244
0
            res = obj2ast_identifier(state, tmp, &name, arena);
16245
0
            _Py_LeaveRecursiveCall();
16246
0
            if (res != 0) goto failed;
16247
0
            Py_CLEAR(tmp);
16248
0
        }
16249
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16250
0
            return -1;
16251
0
        }
16252
0
        if (tmp == NULL) {
16253
0
            tmp = PyList_New(0);
16254
0
            if (tmp == NULL) {
16255
0
                return -1;
16256
0
            }
16257
0
        }
16258
0
        {
16259
0
            int res;
16260
0
            Py_ssize_t len;
16261
0
            Py_ssize_t i;
16262
0
            if (!PyList_Check(tmp)) {
16263
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16264
0
                goto failed;
16265
0
            }
16266
0
            len = PyList_GET_SIZE(tmp);
16267
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16268
0
            if (body == NULL) goto failed;
16269
0
            for (i = 0; i < len; i++) {
16270
0
                stmt_ty val;
16271
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16272
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16273
0
                    goto failed;
16274
0
                }
16275
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
16276
0
                _Py_LeaveRecursiveCall();
16277
0
                Py_DECREF(tmp2);
16278
0
                if (res != 0) goto failed;
16279
0
                if (len != PyList_GET_SIZE(tmp)) {
16280
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16281
0
                    goto failed;
16282
0
                }
16283
0
                asdl_seq_SET(body, i, val);
16284
0
            }
16285
0
            Py_CLEAR(tmp);
16286
0
        }
16287
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16288
0
                                    end_lineno, end_col_offset, arena);
16289
0
        if (*out == NULL) goto failed;
16290
0
        return 0;
16291
0
    }
16292
16293
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16294
0
    failed:
16295
0
    Py_XDECREF(tmp);
16296
0
    return -1;
16297
0
}
16298
16299
int
16300
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16301
                  PyArena* arena)
16302
0
{
16303
0
    PyObject* tmp = NULL;
16304
0
    asdl_arg_seq* posonlyargs;
16305
0
    asdl_arg_seq* args;
16306
0
    arg_ty vararg;
16307
0
    asdl_arg_seq* kwonlyargs;
16308
0
    asdl_expr_seq* kw_defaults;
16309
0
    arg_ty kwarg;
16310
0
    asdl_expr_seq* defaults;
16311
16312
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16313
0
        return -1;
16314
0
    }
16315
0
    if (tmp == NULL) {
16316
0
        tmp = PyList_New(0);
16317
0
        if (tmp == NULL) {
16318
0
            return -1;
16319
0
        }
16320
0
    }
16321
0
    {
16322
0
        int res;
16323
0
        Py_ssize_t len;
16324
0
        Py_ssize_t i;
16325
0
        if (!PyList_Check(tmp)) {
16326
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16327
0
            goto failed;
16328
0
        }
16329
0
        len = PyList_GET_SIZE(tmp);
16330
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16331
0
        if (posonlyargs == NULL) goto failed;
16332
0
        for (i = 0; i < len; i++) {
16333
0
            arg_ty val;
16334
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16335
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16336
0
                goto failed;
16337
0
            }
16338
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16339
0
            _Py_LeaveRecursiveCall();
16340
0
            Py_DECREF(tmp2);
16341
0
            if (res != 0) goto failed;
16342
0
            if (len != PyList_GET_SIZE(tmp)) {
16343
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16344
0
                goto failed;
16345
0
            }
16346
0
            asdl_seq_SET(posonlyargs, i, val);
16347
0
        }
16348
0
        Py_CLEAR(tmp);
16349
0
    }
16350
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16351
0
        return -1;
16352
0
    }
16353
0
    if (tmp == NULL) {
16354
0
        tmp = PyList_New(0);
16355
0
        if (tmp == NULL) {
16356
0
            return -1;
16357
0
        }
16358
0
    }
16359
0
    {
16360
0
        int res;
16361
0
        Py_ssize_t len;
16362
0
        Py_ssize_t i;
16363
0
        if (!PyList_Check(tmp)) {
16364
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16365
0
            goto failed;
16366
0
        }
16367
0
        len = PyList_GET_SIZE(tmp);
16368
0
        args = _Py_asdl_arg_seq_new(len, arena);
16369
0
        if (args == NULL) goto failed;
16370
0
        for (i = 0; i < len; i++) {
16371
0
            arg_ty val;
16372
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16373
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16374
0
                goto failed;
16375
0
            }
16376
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16377
0
            _Py_LeaveRecursiveCall();
16378
0
            Py_DECREF(tmp2);
16379
0
            if (res != 0) goto failed;
16380
0
            if (len != PyList_GET_SIZE(tmp)) {
16381
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16382
0
                goto failed;
16383
0
            }
16384
0
            asdl_seq_SET(args, i, val);
16385
0
        }
16386
0
        Py_CLEAR(tmp);
16387
0
    }
16388
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16389
0
        return -1;
16390
0
    }
16391
0
    if (tmp == NULL || tmp == Py_None) {
16392
0
        Py_CLEAR(tmp);
16393
0
        vararg = NULL;
16394
0
    }
16395
0
    else {
16396
0
        int res;
16397
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16398
0
            goto failed;
16399
0
        }
16400
0
        res = obj2ast_arg(state, tmp, &vararg, arena);
16401
0
        _Py_LeaveRecursiveCall();
16402
0
        if (res != 0) goto failed;
16403
0
        Py_CLEAR(tmp);
16404
0
    }
16405
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16406
0
        return -1;
16407
0
    }
16408
0
    if (tmp == NULL) {
16409
0
        tmp = PyList_New(0);
16410
0
        if (tmp == NULL) {
16411
0
            return -1;
16412
0
        }
16413
0
    }
16414
0
    {
16415
0
        int res;
16416
0
        Py_ssize_t len;
16417
0
        Py_ssize_t i;
16418
0
        if (!PyList_Check(tmp)) {
16419
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16420
0
            goto failed;
16421
0
        }
16422
0
        len = PyList_GET_SIZE(tmp);
16423
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16424
0
        if (kwonlyargs == NULL) goto failed;
16425
0
        for (i = 0; i < len; i++) {
16426
0
            arg_ty val;
16427
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16428
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16429
0
                goto failed;
16430
0
            }
16431
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16432
0
            _Py_LeaveRecursiveCall();
16433
0
            Py_DECREF(tmp2);
16434
0
            if (res != 0) goto failed;
16435
0
            if (len != PyList_GET_SIZE(tmp)) {
16436
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16437
0
                goto failed;
16438
0
            }
16439
0
            asdl_seq_SET(kwonlyargs, i, val);
16440
0
        }
16441
0
        Py_CLEAR(tmp);
16442
0
    }
16443
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16444
0
        return -1;
16445
0
    }
16446
0
    if (tmp == NULL) {
16447
0
        tmp = PyList_New(0);
16448
0
        if (tmp == NULL) {
16449
0
            return -1;
16450
0
        }
16451
0
    }
16452
0
    {
16453
0
        int res;
16454
0
        Py_ssize_t len;
16455
0
        Py_ssize_t i;
16456
0
        if (!PyList_Check(tmp)) {
16457
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16458
0
            goto failed;
16459
0
        }
16460
0
        len = PyList_GET_SIZE(tmp);
16461
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16462
0
        if (kw_defaults == NULL) goto failed;
16463
0
        for (i = 0; i < len; i++) {
16464
0
            expr_ty val;
16465
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16466
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16467
0
                goto failed;
16468
0
            }
16469
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16470
0
            _Py_LeaveRecursiveCall();
16471
0
            Py_DECREF(tmp2);
16472
0
            if (res != 0) goto failed;
16473
0
            if (len != PyList_GET_SIZE(tmp)) {
16474
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16475
0
                goto failed;
16476
0
            }
16477
0
            asdl_seq_SET(kw_defaults, i, val);
16478
0
        }
16479
0
        Py_CLEAR(tmp);
16480
0
    }
16481
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16482
0
        return -1;
16483
0
    }
16484
0
    if (tmp == NULL || tmp == Py_None) {
16485
0
        Py_CLEAR(tmp);
16486
0
        kwarg = NULL;
16487
0
    }
16488
0
    else {
16489
0
        int res;
16490
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16491
0
            goto failed;
16492
0
        }
16493
0
        res = obj2ast_arg(state, tmp, &kwarg, arena);
16494
0
        _Py_LeaveRecursiveCall();
16495
0
        if (res != 0) goto failed;
16496
0
        Py_CLEAR(tmp);
16497
0
    }
16498
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16499
0
        return -1;
16500
0
    }
16501
0
    if (tmp == NULL) {
16502
0
        tmp = PyList_New(0);
16503
0
        if (tmp == NULL) {
16504
0
            return -1;
16505
0
        }
16506
0
    }
16507
0
    {
16508
0
        int res;
16509
0
        Py_ssize_t len;
16510
0
        Py_ssize_t i;
16511
0
        if (!PyList_Check(tmp)) {
16512
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16513
0
            goto failed;
16514
0
        }
16515
0
        len = PyList_GET_SIZE(tmp);
16516
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16517
0
        if (defaults == NULL) goto failed;
16518
0
        for (i = 0; i < len; i++) {
16519
0
            expr_ty val;
16520
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16521
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16522
0
                goto failed;
16523
0
            }
16524
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16525
0
            _Py_LeaveRecursiveCall();
16526
0
            Py_DECREF(tmp2);
16527
0
            if (res != 0) goto failed;
16528
0
            if (len != PyList_GET_SIZE(tmp)) {
16529
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16530
0
                goto failed;
16531
0
            }
16532
0
            asdl_seq_SET(defaults, i, val);
16533
0
        }
16534
0
        Py_CLEAR(tmp);
16535
0
    }
16536
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16537
0
                            kwarg, defaults, arena);
16538
0
    if (*out == NULL) goto failed;
16539
0
    return 0;
16540
0
failed:
16541
0
    Py_XDECREF(tmp);
16542
0
    return -1;
16543
0
}
16544
16545
int
16546
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
16547
0
{
16548
0
    PyObject* tmp = NULL;
16549
0
    identifier arg;
16550
0
    expr_ty annotation;
16551
0
    string type_comment;
16552
0
    int lineno;
16553
0
    int col_offset;
16554
0
    int end_lineno;
16555
0
    int end_col_offset;
16556
16557
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16558
0
        return -1;
16559
0
    }
16560
0
    if (tmp == NULL) {
16561
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16562
0
        return -1;
16563
0
    }
16564
0
    else {
16565
0
        int res;
16566
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16567
0
            goto failed;
16568
0
        }
16569
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16570
0
        _Py_LeaveRecursiveCall();
16571
0
        if (res != 0) goto failed;
16572
0
        Py_CLEAR(tmp);
16573
0
    }
16574
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16575
0
        return -1;
16576
0
    }
16577
0
    if (tmp == NULL || tmp == Py_None) {
16578
0
        Py_CLEAR(tmp);
16579
0
        annotation = NULL;
16580
0
    }
16581
0
    else {
16582
0
        int res;
16583
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16584
0
            goto failed;
16585
0
        }
16586
0
        res = obj2ast_expr(state, tmp, &annotation, arena);
16587
0
        _Py_LeaveRecursiveCall();
16588
0
        if (res != 0) goto failed;
16589
0
        Py_CLEAR(tmp);
16590
0
    }
16591
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16592
0
        return -1;
16593
0
    }
16594
0
    if (tmp == NULL || tmp == Py_None) {
16595
0
        Py_CLEAR(tmp);
16596
0
        type_comment = NULL;
16597
0
    }
16598
0
    else {
16599
0
        int res;
16600
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16601
0
            goto failed;
16602
0
        }
16603
0
        res = obj2ast_string(state, tmp, &type_comment, arena);
16604
0
        _Py_LeaveRecursiveCall();
16605
0
        if (res != 0) goto failed;
16606
0
        Py_CLEAR(tmp);
16607
0
    }
16608
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16609
0
        return -1;
16610
0
    }
16611
0
    if (tmp == NULL) {
16612
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16613
0
        return -1;
16614
0
    }
16615
0
    else {
16616
0
        int res;
16617
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16618
0
            goto failed;
16619
0
        }
16620
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16621
0
        _Py_LeaveRecursiveCall();
16622
0
        if (res != 0) goto failed;
16623
0
        Py_CLEAR(tmp);
16624
0
    }
16625
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16626
0
        return -1;
16627
0
    }
16628
0
    if (tmp == NULL) {
16629
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16630
0
        return -1;
16631
0
    }
16632
0
    else {
16633
0
        int res;
16634
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16635
0
            goto failed;
16636
0
        }
16637
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16638
0
        _Py_LeaveRecursiveCall();
16639
0
        if (res != 0) goto failed;
16640
0
        Py_CLEAR(tmp);
16641
0
    }
16642
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16643
0
        return -1;
16644
0
    }
16645
0
    if (tmp == NULL || tmp == Py_None) {
16646
0
        Py_CLEAR(tmp);
16647
0
        end_lineno = lineno;
16648
0
    }
16649
0
    else {
16650
0
        int res;
16651
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16652
0
            goto failed;
16653
0
        }
16654
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16655
0
        _Py_LeaveRecursiveCall();
16656
0
        if (res != 0) goto failed;
16657
0
        Py_CLEAR(tmp);
16658
0
    }
16659
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16660
0
        return -1;
16661
0
    }
16662
0
    if (tmp == NULL || tmp == Py_None) {
16663
0
        Py_CLEAR(tmp);
16664
0
        end_col_offset = col_offset;
16665
0
    }
16666
0
    else {
16667
0
        int res;
16668
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16669
0
            goto failed;
16670
0
        }
16671
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16672
0
        _Py_LeaveRecursiveCall();
16673
0
        if (res != 0) goto failed;
16674
0
        Py_CLEAR(tmp);
16675
0
    }
16676
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16677
0
                      end_lineno, end_col_offset, arena);
16678
0
    if (*out == NULL) goto failed;
16679
0
    return 0;
16680
0
failed:
16681
0
    Py_XDECREF(tmp);
16682
0
    return -1;
16683
0
}
16684
16685
int
16686
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
16687
                PyArena* arena)
16688
0
{
16689
0
    PyObject* tmp = NULL;
16690
0
    identifier arg;
16691
0
    expr_ty value;
16692
0
    int lineno;
16693
0
    int col_offset;
16694
0
    int end_lineno;
16695
0
    int end_col_offset;
16696
16697
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16698
0
        return -1;
16699
0
    }
16700
0
    if (tmp == NULL || tmp == Py_None) {
16701
0
        Py_CLEAR(tmp);
16702
0
        arg = NULL;
16703
0
    }
16704
0
    else {
16705
0
        int res;
16706
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16707
0
            goto failed;
16708
0
        }
16709
0
        res = obj2ast_identifier(state, tmp, &arg, 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->value, &tmp) < 0) {
16715
0
        return -1;
16716
0
    }
16717
0
    if (tmp == NULL) {
16718
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16719
0
        return -1;
16720
0
    }
16721
0
    else {
16722
0
        int res;
16723
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16724
0
            goto failed;
16725
0
        }
16726
0
        res = obj2ast_expr(state, tmp, &value, 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->lineno, &tmp) < 0) {
16732
0
        return -1;
16733
0
    }
16734
0
    if (tmp == NULL) {
16735
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16736
0
        return -1;
16737
0
    }
16738
0
    else {
16739
0
        int res;
16740
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16741
0
            goto failed;
16742
0
        }
16743
0
        res = obj2ast_int(state, tmp, &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->col_offset, &tmp) < 0) {
16749
0
        return -1;
16750
0
    }
16751
0
    if (tmp == NULL) {
16752
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16753
0
        return -1;
16754
0
    }
16755
0
    else {
16756
0
        int res;
16757
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16758
0
            goto failed;
16759
0
        }
16760
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16761
0
        _Py_LeaveRecursiveCall();
16762
0
        if (res != 0) goto failed;
16763
0
        Py_CLEAR(tmp);
16764
0
    }
16765
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16766
0
        return -1;
16767
0
    }
16768
0
    if (tmp == NULL || tmp == Py_None) {
16769
0
        Py_CLEAR(tmp);
16770
0
        end_lineno = lineno;
16771
0
    }
16772
0
    else {
16773
0
        int res;
16774
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16775
0
            goto failed;
16776
0
        }
16777
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16778
0
        _Py_LeaveRecursiveCall();
16779
0
        if (res != 0) goto failed;
16780
0
        Py_CLEAR(tmp);
16781
0
    }
16782
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16783
0
        return -1;
16784
0
    }
16785
0
    if (tmp == NULL || tmp == Py_None) {
16786
0
        Py_CLEAR(tmp);
16787
0
        end_col_offset = col_offset;
16788
0
    }
16789
0
    else {
16790
0
        int res;
16791
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16792
0
            goto failed;
16793
0
        }
16794
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16795
0
        _Py_LeaveRecursiveCall();
16796
0
        if (res != 0) goto failed;
16797
0
        Py_CLEAR(tmp);
16798
0
    }
16799
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16800
0
                          end_col_offset, arena);
16801
0
    if (*out == NULL) goto failed;
16802
0
    return 0;
16803
0
failed:
16804
0
    Py_XDECREF(tmp);
16805
0
    return -1;
16806
0
}
16807
16808
int
16809
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
16810
              arena)
16811
0
{
16812
0
    PyObject* tmp = NULL;
16813
0
    identifier name;
16814
0
    identifier asname;
16815
0
    int lineno;
16816
0
    int col_offset;
16817
0
    int end_lineno;
16818
0
    int end_col_offset;
16819
16820
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16821
0
        return -1;
16822
0
    }
16823
0
    if (tmp == NULL) {
16824
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16825
0
        return -1;
16826
0
    }
16827
0
    else {
16828
0
        int res;
16829
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16830
0
            goto failed;
16831
0
        }
16832
0
        res = obj2ast_identifier(state, tmp, &name, 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->asname, &tmp) < 0) {
16838
0
        return -1;
16839
0
    }
16840
0
    if (tmp == NULL || tmp == Py_None) {
16841
0
        Py_CLEAR(tmp);
16842
0
        asname = NULL;
16843
0
    }
16844
0
    else {
16845
0
        int res;
16846
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16847
0
            goto failed;
16848
0
        }
16849
0
        res = obj2ast_identifier(state, tmp, &asname, 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->lineno, &tmp) < 0) {
16855
0
        return -1;
16856
0
    }
16857
0
    if (tmp == NULL) {
16858
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16859
0
        return -1;
16860
0
    }
16861
0
    else {
16862
0
        int res;
16863
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16864
0
            goto failed;
16865
0
        }
16866
0
        res = obj2ast_int(state, tmp, &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->col_offset, &tmp) < 0) {
16872
0
        return -1;
16873
0
    }
16874
0
    if (tmp == NULL) {
16875
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16876
0
        return -1;
16877
0
    }
16878
0
    else {
16879
0
        int res;
16880
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16881
0
            goto failed;
16882
0
        }
16883
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16884
0
        _Py_LeaveRecursiveCall();
16885
0
        if (res != 0) goto failed;
16886
0
        Py_CLEAR(tmp);
16887
0
    }
16888
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16889
0
        return -1;
16890
0
    }
16891
0
    if (tmp == NULL || tmp == Py_None) {
16892
0
        Py_CLEAR(tmp);
16893
0
        end_lineno = lineno;
16894
0
    }
16895
0
    else {
16896
0
        int res;
16897
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16898
0
            goto failed;
16899
0
        }
16900
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16901
0
        _Py_LeaveRecursiveCall();
16902
0
        if (res != 0) goto failed;
16903
0
        Py_CLEAR(tmp);
16904
0
    }
16905
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16906
0
        return -1;
16907
0
    }
16908
0
    if (tmp == NULL || tmp == Py_None) {
16909
0
        Py_CLEAR(tmp);
16910
0
        end_col_offset = col_offset;
16911
0
    }
16912
0
    else {
16913
0
        int res;
16914
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16915
0
            goto failed;
16916
0
        }
16917
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16918
0
        _Py_LeaveRecursiveCall();
16919
0
        if (res != 0) goto failed;
16920
0
        Py_CLEAR(tmp);
16921
0
    }
16922
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16923
0
                        end_col_offset, arena);
16924
0
    if (*out == NULL) goto failed;
16925
0
    return 0;
16926
0
failed:
16927
0
    Py_XDECREF(tmp);
16928
0
    return -1;
16929
0
}
16930
16931
int
16932
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
16933
                 PyArena* arena)
16934
0
{
16935
0
    PyObject* tmp = NULL;
16936
0
    expr_ty context_expr;
16937
0
    expr_ty optional_vars;
16938
16939
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
16940
0
        return -1;
16941
0
    }
16942
0
    if (tmp == NULL) {
16943
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
16944
0
        return -1;
16945
0
    }
16946
0
    else {
16947
0
        int res;
16948
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16949
0
            goto failed;
16950
0
        }
16951
0
        res = obj2ast_expr(state, tmp, &context_expr, arena);
16952
0
        _Py_LeaveRecursiveCall();
16953
0
        if (res != 0) goto failed;
16954
0
        Py_CLEAR(tmp);
16955
0
    }
16956
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
16957
0
        return -1;
16958
0
    }
16959
0
    if (tmp == NULL || tmp == Py_None) {
16960
0
        Py_CLEAR(tmp);
16961
0
        optional_vars = NULL;
16962
0
    }
16963
0
    else {
16964
0
        int res;
16965
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16966
0
            goto failed;
16967
0
        }
16968
0
        res = obj2ast_expr(state, tmp, &optional_vars, arena);
16969
0
        _Py_LeaveRecursiveCall();
16970
0
        if (res != 0) goto failed;
16971
0
        Py_CLEAR(tmp);
16972
0
    }
16973
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
16974
0
    if (*out == NULL) goto failed;
16975
0
    return 0;
16976
0
failed:
16977
0
    Py_XDECREF(tmp);
16978
0
    return -1;
16979
0
}
16980
16981
int
16982
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
16983
                   PyArena* arena)
16984
0
{
16985
0
    PyObject* tmp = NULL;
16986
0
    pattern_ty pattern;
16987
0
    expr_ty guard;
16988
0
    asdl_stmt_seq* body;
16989
16990
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
16991
0
        return -1;
16992
0
    }
16993
0
    if (tmp == NULL) {
16994
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
16995
0
        return -1;
16996
0
    }
16997
0
    else {
16998
0
        int res;
16999
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17000
0
            goto failed;
17001
0
        }
17002
0
        res = obj2ast_pattern(state, tmp, &pattern, arena);
17003
0
        _Py_LeaveRecursiveCall();
17004
0
        if (res != 0) goto failed;
17005
0
        Py_CLEAR(tmp);
17006
0
    }
17007
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17008
0
        return -1;
17009
0
    }
17010
0
    if (tmp == NULL || tmp == Py_None) {
17011
0
        Py_CLEAR(tmp);
17012
0
        guard = NULL;
17013
0
    }
17014
0
    else {
17015
0
        int res;
17016
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17017
0
            goto failed;
17018
0
        }
17019
0
        res = obj2ast_expr(state, tmp, &guard, arena);
17020
0
        _Py_LeaveRecursiveCall();
17021
0
        if (res != 0) goto failed;
17022
0
        Py_CLEAR(tmp);
17023
0
    }
17024
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17025
0
        return -1;
17026
0
    }
17027
0
    if (tmp == NULL) {
17028
0
        tmp = PyList_New(0);
17029
0
        if (tmp == NULL) {
17030
0
            return -1;
17031
0
        }
17032
0
    }
17033
0
    {
17034
0
        int res;
17035
0
        Py_ssize_t len;
17036
0
        Py_ssize_t i;
17037
0
        if (!PyList_Check(tmp)) {
17038
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17039
0
            goto failed;
17040
0
        }
17041
0
        len = PyList_GET_SIZE(tmp);
17042
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17043
0
        if (body == NULL) goto failed;
17044
0
        for (i = 0; i < len; i++) {
17045
0
            stmt_ty val;
17046
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17047
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17048
0
                goto failed;
17049
0
            }
17050
0
            res = obj2ast_stmt(state, tmp2, &val, arena);
17051
0
            _Py_LeaveRecursiveCall();
17052
0
            Py_DECREF(tmp2);
17053
0
            if (res != 0) goto failed;
17054
0
            if (len != PyList_GET_SIZE(tmp)) {
17055
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17056
0
                goto failed;
17057
0
            }
17058
0
            asdl_seq_SET(body, i, val);
17059
0
        }
17060
0
        Py_CLEAR(tmp);
17061
0
    }
17062
0
    *out = _PyAST_match_case(pattern, guard, body, 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_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
17072
                PyArena* arena)
17073
0
{
17074
0
    int isinstance;
17075
17076
0
    PyObject *tmp = NULL;
17077
0
    PyObject *tp;
17078
0
    int lineno;
17079
0
    int col_offset;
17080
0
    int end_lineno;
17081
0
    int end_col_offset;
17082
17083
0
    if (obj == Py_None) {
17084
0
        *out = NULL;
17085
0
        return 0;
17086
0
    }
17087
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17088
0
        return -1;
17089
0
    }
17090
0
    if (tmp == NULL) {
17091
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17092
0
        return -1;
17093
0
    }
17094
0
    else {
17095
0
        int res;
17096
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17097
0
            goto failed;
17098
0
        }
17099
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17100
0
        _Py_LeaveRecursiveCall();
17101
0
        if (res != 0) goto failed;
17102
0
        Py_CLEAR(tmp);
17103
0
    }
17104
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17105
0
        return -1;
17106
0
    }
17107
0
    if (tmp == NULL) {
17108
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17109
0
        return -1;
17110
0
    }
17111
0
    else {
17112
0
        int res;
17113
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17114
0
            goto failed;
17115
0
        }
17116
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17117
0
        _Py_LeaveRecursiveCall();
17118
0
        if (res != 0) goto failed;
17119
0
        Py_CLEAR(tmp);
17120
0
    }
17121
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17122
0
        return -1;
17123
0
    }
17124
0
    if (tmp == NULL) {
17125
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17126
0
        return -1;
17127
0
    }
17128
0
    else {
17129
0
        int res;
17130
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17131
0
            goto failed;
17132
0
        }
17133
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17134
0
        _Py_LeaveRecursiveCall();
17135
0
        if (res != 0) goto failed;
17136
0
        Py_CLEAR(tmp);
17137
0
    }
17138
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17139
0
        return -1;
17140
0
    }
17141
0
    if (tmp == NULL) {
17142
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17143
0
        return -1;
17144
0
    }
17145
0
    else {
17146
0
        int res;
17147
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17148
0
            goto failed;
17149
0
        }
17150
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17151
0
        _Py_LeaveRecursiveCall();
17152
0
        if (res != 0) goto failed;
17153
0
        Py_CLEAR(tmp);
17154
0
    }
17155
0
    tp = state->MatchValue_type;
17156
0
    isinstance = PyObject_IsInstance(obj, tp);
17157
0
    if (isinstance == -1) {
17158
0
        return -1;
17159
0
    }
17160
0
    if (isinstance) {
17161
0
        expr_ty value;
17162
17163
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17164
0
            return -1;
17165
0
        }
17166
0
        if (tmp == NULL) {
17167
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17168
0
            return -1;
17169
0
        }
17170
0
        else {
17171
0
            int res;
17172
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17173
0
                goto failed;
17174
0
            }
17175
0
            res = obj2ast_expr(state, tmp, &value, arena);
17176
0
            _Py_LeaveRecursiveCall();
17177
0
            if (res != 0) goto failed;
17178
0
            Py_CLEAR(tmp);
17179
0
        }
17180
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17181
0
                                 end_col_offset, arena);
17182
0
        if (*out == NULL) goto failed;
17183
0
        return 0;
17184
0
    }
17185
0
    tp = state->MatchSingleton_type;
17186
0
    isinstance = PyObject_IsInstance(obj, tp);
17187
0
    if (isinstance == -1) {
17188
0
        return -1;
17189
0
    }
17190
0
    if (isinstance) {
17191
0
        constant value;
17192
17193
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17194
0
            return -1;
17195
0
        }
17196
0
        if (tmp == NULL) {
17197
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17198
0
            return -1;
17199
0
        }
17200
0
        else {
17201
0
            int res;
17202
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17203
0
                goto failed;
17204
0
            }
17205
0
            res = obj2ast_constant(state, tmp, &value, arena);
17206
0
            _Py_LeaveRecursiveCall();
17207
0
            if (res != 0) goto failed;
17208
0
            Py_CLEAR(tmp);
17209
0
        }
17210
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17211
0
                                     end_col_offset, arena);
17212
0
        if (*out == NULL) goto failed;
17213
0
        return 0;
17214
0
    }
17215
0
    tp = state->MatchSequence_type;
17216
0
    isinstance = PyObject_IsInstance(obj, tp);
17217
0
    if (isinstance == -1) {
17218
0
        return -1;
17219
0
    }
17220
0
    if (isinstance) {
17221
0
        asdl_pattern_seq* patterns;
17222
17223
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17224
0
            return -1;
17225
0
        }
17226
0
        if (tmp == NULL) {
17227
0
            tmp = PyList_New(0);
17228
0
            if (tmp == NULL) {
17229
0
                return -1;
17230
0
            }
17231
0
        }
17232
0
        {
17233
0
            int res;
17234
0
            Py_ssize_t len;
17235
0
            Py_ssize_t i;
17236
0
            if (!PyList_Check(tmp)) {
17237
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17238
0
                goto failed;
17239
0
            }
17240
0
            len = PyList_GET_SIZE(tmp);
17241
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17242
0
            if (patterns == NULL) goto failed;
17243
0
            for (i = 0; i < len; i++) {
17244
0
                pattern_ty val;
17245
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17246
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17247
0
                    goto failed;
17248
0
                }
17249
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17250
0
                _Py_LeaveRecursiveCall();
17251
0
                Py_DECREF(tmp2);
17252
0
                if (res != 0) goto failed;
17253
0
                if (len != PyList_GET_SIZE(tmp)) {
17254
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17255
0
                    goto failed;
17256
0
                }
17257
0
                asdl_seq_SET(patterns, i, val);
17258
0
            }
17259
0
            Py_CLEAR(tmp);
17260
0
        }
17261
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17262
0
                                    end_col_offset, arena);
17263
0
        if (*out == NULL) goto failed;
17264
0
        return 0;
17265
0
    }
17266
0
    tp = state->MatchMapping_type;
17267
0
    isinstance = PyObject_IsInstance(obj, tp);
17268
0
    if (isinstance == -1) {
17269
0
        return -1;
17270
0
    }
17271
0
    if (isinstance) {
17272
0
        asdl_expr_seq* keys;
17273
0
        asdl_pattern_seq* patterns;
17274
0
        identifier rest;
17275
17276
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17277
0
            return -1;
17278
0
        }
17279
0
        if (tmp == NULL) {
17280
0
            tmp = PyList_New(0);
17281
0
            if (tmp == NULL) {
17282
0
                return -1;
17283
0
            }
17284
0
        }
17285
0
        {
17286
0
            int res;
17287
0
            Py_ssize_t len;
17288
0
            Py_ssize_t i;
17289
0
            if (!PyList_Check(tmp)) {
17290
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17291
0
                goto failed;
17292
0
            }
17293
0
            len = PyList_GET_SIZE(tmp);
17294
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17295
0
            if (keys == NULL) goto failed;
17296
0
            for (i = 0; i < len; i++) {
17297
0
                expr_ty val;
17298
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17299
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17300
0
                    goto failed;
17301
0
                }
17302
0
                res = obj2ast_expr(state, tmp2, &val, arena);
17303
0
                _Py_LeaveRecursiveCall();
17304
0
                Py_DECREF(tmp2);
17305
0
                if (res != 0) goto failed;
17306
0
                if (len != PyList_GET_SIZE(tmp)) {
17307
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17308
0
                    goto failed;
17309
0
                }
17310
0
                asdl_seq_SET(keys, i, val);
17311
0
            }
17312
0
            Py_CLEAR(tmp);
17313
0
        }
17314
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17315
0
            return -1;
17316
0
        }
17317
0
        if (tmp == NULL) {
17318
0
            tmp = PyList_New(0);
17319
0
            if (tmp == NULL) {
17320
0
                return -1;
17321
0
            }
17322
0
        }
17323
0
        {
17324
0
            int res;
17325
0
            Py_ssize_t len;
17326
0
            Py_ssize_t i;
17327
0
            if (!PyList_Check(tmp)) {
17328
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17329
0
                goto failed;
17330
0
            }
17331
0
            len = PyList_GET_SIZE(tmp);
17332
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17333
0
            if (patterns == NULL) goto failed;
17334
0
            for (i = 0; i < len; i++) {
17335
0
                pattern_ty val;
17336
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17337
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17338
0
                    goto failed;
17339
0
                }
17340
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17341
0
                _Py_LeaveRecursiveCall();
17342
0
                Py_DECREF(tmp2);
17343
0
                if (res != 0) goto failed;
17344
0
                if (len != PyList_GET_SIZE(tmp)) {
17345
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17346
0
                    goto failed;
17347
0
                }
17348
0
                asdl_seq_SET(patterns, i, val);
17349
0
            }
17350
0
            Py_CLEAR(tmp);
17351
0
        }
17352
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17353
0
            return -1;
17354
0
        }
17355
0
        if (tmp == NULL || tmp == Py_None) {
17356
0
            Py_CLEAR(tmp);
17357
0
            rest = NULL;
17358
0
        }
17359
0
        else {
17360
0
            int res;
17361
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17362
0
                goto failed;
17363
0
            }
17364
0
            res = obj2ast_identifier(state, tmp, &rest, arena);
17365
0
            _Py_LeaveRecursiveCall();
17366
0
            if (res != 0) goto failed;
17367
0
            Py_CLEAR(tmp);
17368
0
        }
17369
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17370
0
                                   end_lineno, end_col_offset, arena);
17371
0
        if (*out == NULL) goto failed;
17372
0
        return 0;
17373
0
    }
17374
0
    tp = state->MatchClass_type;
17375
0
    isinstance = PyObject_IsInstance(obj, tp);
17376
0
    if (isinstance == -1) {
17377
0
        return -1;
17378
0
    }
17379
0
    if (isinstance) {
17380
0
        expr_ty cls;
17381
0
        asdl_pattern_seq* patterns;
17382
0
        asdl_identifier_seq* kwd_attrs;
17383
0
        asdl_pattern_seq* kwd_patterns;
17384
17385
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17386
0
            return -1;
17387
0
        }
17388
0
        if (tmp == NULL) {
17389
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17390
0
            return -1;
17391
0
        }
17392
0
        else {
17393
0
            int res;
17394
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17395
0
                goto failed;
17396
0
            }
17397
0
            res = obj2ast_expr(state, tmp, &cls, arena);
17398
0
            _Py_LeaveRecursiveCall();
17399
0
            if (res != 0) goto failed;
17400
0
            Py_CLEAR(tmp);
17401
0
        }
17402
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17403
0
            return -1;
17404
0
        }
17405
0
        if (tmp == NULL) {
17406
0
            tmp = PyList_New(0);
17407
0
            if (tmp == NULL) {
17408
0
                return -1;
17409
0
            }
17410
0
        }
17411
0
        {
17412
0
            int res;
17413
0
            Py_ssize_t len;
17414
0
            Py_ssize_t i;
17415
0
            if (!PyList_Check(tmp)) {
17416
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17417
0
                goto failed;
17418
0
            }
17419
0
            len = PyList_GET_SIZE(tmp);
17420
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17421
0
            if (patterns == NULL) goto failed;
17422
0
            for (i = 0; i < len; i++) {
17423
0
                pattern_ty val;
17424
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17425
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17426
0
                    goto failed;
17427
0
                }
17428
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17429
0
                _Py_LeaveRecursiveCall();
17430
0
                Py_DECREF(tmp2);
17431
0
                if (res != 0) goto failed;
17432
0
                if (len != PyList_GET_SIZE(tmp)) {
17433
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17434
0
                    goto failed;
17435
0
                }
17436
0
                asdl_seq_SET(patterns, i, val);
17437
0
            }
17438
0
            Py_CLEAR(tmp);
17439
0
        }
17440
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17441
0
            return -1;
17442
0
        }
17443
0
        if (tmp == NULL) {
17444
0
            tmp = PyList_New(0);
17445
0
            if (tmp == NULL) {
17446
0
                return -1;
17447
0
            }
17448
0
        }
17449
0
        {
17450
0
            int res;
17451
0
            Py_ssize_t len;
17452
0
            Py_ssize_t i;
17453
0
            if (!PyList_Check(tmp)) {
17454
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17455
0
                goto failed;
17456
0
            }
17457
0
            len = PyList_GET_SIZE(tmp);
17458
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17459
0
            if (kwd_attrs == NULL) goto failed;
17460
0
            for (i = 0; i < len; i++) {
17461
0
                identifier val;
17462
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17463
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17464
0
                    goto failed;
17465
0
                }
17466
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
17467
0
                _Py_LeaveRecursiveCall();
17468
0
                Py_DECREF(tmp2);
17469
0
                if (res != 0) goto failed;
17470
0
                if (len != PyList_GET_SIZE(tmp)) {
17471
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17472
0
                    goto failed;
17473
0
                }
17474
0
                asdl_seq_SET(kwd_attrs, i, val);
17475
0
            }
17476
0
            Py_CLEAR(tmp);
17477
0
        }
17478
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17479
0
            return -1;
17480
0
        }
17481
0
        if (tmp == NULL) {
17482
0
            tmp = PyList_New(0);
17483
0
            if (tmp == NULL) {
17484
0
                return -1;
17485
0
            }
17486
0
        }
17487
0
        {
17488
0
            int res;
17489
0
            Py_ssize_t len;
17490
0
            Py_ssize_t i;
17491
0
            if (!PyList_Check(tmp)) {
17492
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17493
0
                goto failed;
17494
0
            }
17495
0
            len = PyList_GET_SIZE(tmp);
17496
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17497
0
            if (kwd_patterns == NULL) goto failed;
17498
0
            for (i = 0; i < len; i++) {
17499
0
                pattern_ty val;
17500
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17501
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17502
0
                    goto failed;
17503
0
                }
17504
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17505
0
                _Py_LeaveRecursiveCall();
17506
0
                Py_DECREF(tmp2);
17507
0
                if (res != 0) goto failed;
17508
0
                if (len != PyList_GET_SIZE(tmp)) {
17509
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17510
0
                    goto failed;
17511
0
                }
17512
0
                asdl_seq_SET(kwd_patterns, i, val);
17513
0
            }
17514
0
            Py_CLEAR(tmp);
17515
0
        }
17516
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17517
0
                                 lineno, col_offset, end_lineno,
17518
0
                                 end_col_offset, arena);
17519
0
        if (*out == NULL) goto failed;
17520
0
        return 0;
17521
0
    }
17522
0
    tp = state->MatchStar_type;
17523
0
    isinstance = PyObject_IsInstance(obj, tp);
17524
0
    if (isinstance == -1) {
17525
0
        return -1;
17526
0
    }
17527
0
    if (isinstance) {
17528
0
        identifier name;
17529
17530
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17531
0
            return -1;
17532
0
        }
17533
0
        if (tmp == NULL || tmp == Py_None) {
17534
0
            Py_CLEAR(tmp);
17535
0
            name = NULL;
17536
0
        }
17537
0
        else {
17538
0
            int res;
17539
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17540
0
                goto failed;
17541
0
            }
17542
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17543
0
            _Py_LeaveRecursiveCall();
17544
0
            if (res != 0) goto failed;
17545
0
            Py_CLEAR(tmp);
17546
0
        }
17547
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17548
0
                                end_col_offset, arena);
17549
0
        if (*out == NULL) goto failed;
17550
0
        return 0;
17551
0
    }
17552
0
    tp = state->MatchAs_type;
17553
0
    isinstance = PyObject_IsInstance(obj, tp);
17554
0
    if (isinstance == -1) {
17555
0
        return -1;
17556
0
    }
17557
0
    if (isinstance) {
17558
0
        pattern_ty pattern;
17559
0
        identifier name;
17560
17561
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17562
0
            return -1;
17563
0
        }
17564
0
        if (tmp == NULL || tmp == Py_None) {
17565
0
            Py_CLEAR(tmp);
17566
0
            pattern = NULL;
17567
0
        }
17568
0
        else {
17569
0
            int res;
17570
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17571
0
                goto failed;
17572
0
            }
17573
0
            res = obj2ast_pattern(state, tmp, &pattern, arena);
17574
0
            _Py_LeaveRecursiveCall();
17575
0
            if (res != 0) goto failed;
17576
0
            Py_CLEAR(tmp);
17577
0
        }
17578
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17579
0
            return -1;
17580
0
        }
17581
0
        if (tmp == NULL || tmp == Py_None) {
17582
0
            Py_CLEAR(tmp);
17583
0
            name = NULL;
17584
0
        }
17585
0
        else {
17586
0
            int res;
17587
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17588
0
                goto failed;
17589
0
            }
17590
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17591
0
            _Py_LeaveRecursiveCall();
17592
0
            if (res != 0) goto failed;
17593
0
            Py_CLEAR(tmp);
17594
0
        }
17595
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17596
0
                              end_col_offset, arena);
17597
0
        if (*out == NULL) goto failed;
17598
0
        return 0;
17599
0
    }
17600
0
    tp = state->MatchOr_type;
17601
0
    isinstance = PyObject_IsInstance(obj, tp);
17602
0
    if (isinstance == -1) {
17603
0
        return -1;
17604
0
    }
17605
0
    if (isinstance) {
17606
0
        asdl_pattern_seq* patterns;
17607
17608
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17609
0
            return -1;
17610
0
        }
17611
0
        if (tmp == NULL) {
17612
0
            tmp = PyList_New(0);
17613
0
            if (tmp == NULL) {
17614
0
                return -1;
17615
0
            }
17616
0
        }
17617
0
        {
17618
0
            int res;
17619
0
            Py_ssize_t len;
17620
0
            Py_ssize_t i;
17621
0
            if (!PyList_Check(tmp)) {
17622
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17623
0
                goto failed;
17624
0
            }
17625
0
            len = PyList_GET_SIZE(tmp);
17626
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17627
0
            if (patterns == NULL) goto failed;
17628
0
            for (i = 0; i < len; i++) {
17629
0
                pattern_ty val;
17630
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17631
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17632
0
                    goto failed;
17633
0
                }
17634
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17635
0
                _Py_LeaveRecursiveCall();
17636
0
                Py_DECREF(tmp2);
17637
0
                if (res != 0) goto failed;
17638
0
                if (len != PyList_GET_SIZE(tmp)) {
17639
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17640
0
                    goto failed;
17641
0
                }
17642
0
                asdl_seq_SET(patterns, i, val);
17643
0
            }
17644
0
            Py_CLEAR(tmp);
17645
0
        }
17646
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17647
0
                              end_col_offset, arena);
17648
0
        if (*out == NULL) goto failed;
17649
0
        return 0;
17650
0
    }
17651
17652
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17653
0
    failed:
17654
0
    Py_XDECREF(tmp);
17655
0
    return -1;
17656
0
}
17657
17658
int
17659
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17660
                    out, PyArena* arena)
17661
0
{
17662
0
    int isinstance;
17663
17664
0
    PyObject *tmp = NULL;
17665
0
    PyObject *tp;
17666
17667
0
    if (obj == Py_None) {
17668
0
        *out = NULL;
17669
0
        return 0;
17670
0
    }
17671
0
    tp = state->TypeIgnore_type;
17672
0
    isinstance = PyObject_IsInstance(obj, tp);
17673
0
    if (isinstance == -1) {
17674
0
        return -1;
17675
0
    }
17676
0
    if (isinstance) {
17677
0
        int lineno;
17678
0
        string tag;
17679
17680
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17681
0
            return -1;
17682
0
        }
17683
0
        if (tmp == NULL) {
17684
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17685
0
            return -1;
17686
0
        }
17687
0
        else {
17688
0
            int res;
17689
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17690
0
                goto failed;
17691
0
            }
17692
0
            res = obj2ast_int(state, tmp, &lineno, arena);
17693
0
            _Py_LeaveRecursiveCall();
17694
0
            if (res != 0) goto failed;
17695
0
            Py_CLEAR(tmp);
17696
0
        }
17697
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17698
0
            return -1;
17699
0
        }
17700
0
        if (tmp == NULL) {
17701
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17702
0
            return -1;
17703
0
        }
17704
0
        else {
17705
0
            int res;
17706
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17707
0
                goto failed;
17708
0
            }
17709
0
            res = obj2ast_string(state, tmp, &tag, arena);
17710
0
            _Py_LeaveRecursiveCall();
17711
0
            if (res != 0) goto failed;
17712
0
            Py_CLEAR(tmp);
17713
0
        }
17714
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17715
0
        if (*out == NULL) goto failed;
17716
0
        return 0;
17717
0
    }
17718
17719
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17720
0
    failed:
17721
0
    Py_XDECREF(tmp);
17722
0
    return -1;
17723
0
}
17724
17725
int
17726
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17727
                   PyArena* arena)
17728
0
{
17729
0
    int isinstance;
17730
17731
0
    PyObject *tmp = NULL;
17732
0
    PyObject *tp;
17733
0
    int lineno;
17734
0
    int col_offset;
17735
0
    int end_lineno;
17736
0
    int end_col_offset;
17737
17738
0
    if (obj == Py_None) {
17739
0
        *out = NULL;
17740
0
        return 0;
17741
0
    }
17742
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17743
0
        return -1;
17744
0
    }
17745
0
    if (tmp == NULL) {
17746
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17747
0
        return -1;
17748
0
    }
17749
0
    else {
17750
0
        int res;
17751
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17752
0
            goto failed;
17753
0
        }
17754
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17755
0
        _Py_LeaveRecursiveCall();
17756
0
        if (res != 0) goto failed;
17757
0
        Py_CLEAR(tmp);
17758
0
    }
17759
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17760
0
        return -1;
17761
0
    }
17762
0
    if (tmp == NULL) {
17763
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17764
0
        return -1;
17765
0
    }
17766
0
    else {
17767
0
        int res;
17768
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17769
0
            goto failed;
17770
0
        }
17771
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17772
0
        _Py_LeaveRecursiveCall();
17773
0
        if (res != 0) goto failed;
17774
0
        Py_CLEAR(tmp);
17775
0
    }
17776
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17777
0
        return -1;
17778
0
    }
17779
0
    if (tmp == NULL) {
17780
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17781
0
        return -1;
17782
0
    }
17783
0
    else {
17784
0
        int res;
17785
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17786
0
            goto failed;
17787
0
        }
17788
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17789
0
        _Py_LeaveRecursiveCall();
17790
0
        if (res != 0) goto failed;
17791
0
        Py_CLEAR(tmp);
17792
0
    }
17793
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17794
0
        return -1;
17795
0
    }
17796
0
    if (tmp == NULL) {
17797
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17798
0
        return -1;
17799
0
    }
17800
0
    else {
17801
0
        int res;
17802
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17803
0
            goto failed;
17804
0
        }
17805
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17806
0
        _Py_LeaveRecursiveCall();
17807
0
        if (res != 0) goto failed;
17808
0
        Py_CLEAR(tmp);
17809
0
    }
17810
0
    tp = state->TypeVar_type;
17811
0
    isinstance = PyObject_IsInstance(obj, tp);
17812
0
    if (isinstance == -1) {
17813
0
        return -1;
17814
0
    }
17815
0
    if (isinstance) {
17816
0
        identifier name;
17817
0
        expr_ty bound;
17818
0
        expr_ty default_value;
17819
17820
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17821
0
            return -1;
17822
0
        }
17823
0
        if (tmp == NULL) {
17824
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17825
0
            return -1;
17826
0
        }
17827
0
        else {
17828
0
            int res;
17829
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17830
0
                goto failed;
17831
0
            }
17832
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17833
0
            _Py_LeaveRecursiveCall();
17834
0
            if (res != 0) goto failed;
17835
0
            Py_CLEAR(tmp);
17836
0
        }
17837
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17838
0
            return -1;
17839
0
        }
17840
0
        if (tmp == NULL || tmp == Py_None) {
17841
0
            Py_CLEAR(tmp);
17842
0
            bound = NULL;
17843
0
        }
17844
0
        else {
17845
0
            int res;
17846
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17847
0
                goto failed;
17848
0
            }
17849
0
            res = obj2ast_expr(state, tmp, &bound, arena);
17850
0
            _Py_LeaveRecursiveCall();
17851
0
            if (res != 0) goto failed;
17852
0
            Py_CLEAR(tmp);
17853
0
        }
17854
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17855
0
            return -1;
17856
0
        }
17857
0
        if (tmp == NULL || tmp == Py_None) {
17858
0
            Py_CLEAR(tmp);
17859
0
            default_value = NULL;
17860
0
        }
17861
0
        else {
17862
0
            int res;
17863
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17864
0
                goto failed;
17865
0
            }
17866
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17867
0
            _Py_LeaveRecursiveCall();
17868
0
            if (res != 0) goto failed;
17869
0
            Py_CLEAR(tmp);
17870
0
        }
17871
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17872
0
                              end_lineno, end_col_offset, arena);
17873
0
        if (*out == NULL) goto failed;
17874
0
        return 0;
17875
0
    }
17876
0
    tp = state->ParamSpec_type;
17877
0
    isinstance = PyObject_IsInstance(obj, tp);
17878
0
    if (isinstance == -1) {
17879
0
        return -1;
17880
0
    }
17881
0
    if (isinstance) {
17882
0
        identifier name;
17883
0
        expr_ty default_value;
17884
17885
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17886
0
            return -1;
17887
0
        }
17888
0
        if (tmp == NULL) {
17889
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17890
0
            return -1;
17891
0
        }
17892
0
        else {
17893
0
            int res;
17894
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17895
0
                goto failed;
17896
0
            }
17897
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17898
0
            _Py_LeaveRecursiveCall();
17899
0
            if (res != 0) goto failed;
17900
0
            Py_CLEAR(tmp);
17901
0
        }
17902
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17903
0
            return -1;
17904
0
        }
17905
0
        if (tmp == NULL || tmp == Py_None) {
17906
0
            Py_CLEAR(tmp);
17907
0
            default_value = NULL;
17908
0
        }
17909
0
        else {
17910
0
            int res;
17911
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17912
0
                goto failed;
17913
0
            }
17914
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17915
0
            _Py_LeaveRecursiveCall();
17916
0
            if (res != 0) goto failed;
17917
0
            Py_CLEAR(tmp);
17918
0
        }
17919
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
17920
0
                                end_lineno, end_col_offset, arena);
17921
0
        if (*out == NULL) goto failed;
17922
0
        return 0;
17923
0
    }
17924
0
    tp = state->TypeVarTuple_type;
17925
0
    isinstance = PyObject_IsInstance(obj, tp);
17926
0
    if (isinstance == -1) {
17927
0
        return -1;
17928
0
    }
17929
0
    if (isinstance) {
17930
0
        identifier name;
17931
0
        expr_ty default_value;
17932
17933
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17934
0
            return -1;
17935
0
        }
17936
0
        if (tmp == NULL) {
17937
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
17938
0
            return -1;
17939
0
        }
17940
0
        else {
17941
0
            int res;
17942
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17943
0
                goto failed;
17944
0
            }
17945
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17946
0
            _Py_LeaveRecursiveCall();
17947
0
            if (res != 0) goto failed;
17948
0
            Py_CLEAR(tmp);
17949
0
        }
17950
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17951
0
            return -1;
17952
0
        }
17953
0
        if (tmp == NULL || tmp == Py_None) {
17954
0
            Py_CLEAR(tmp);
17955
0
            default_value = NULL;
17956
0
        }
17957
0
        else {
17958
0
            int res;
17959
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17960
0
                goto failed;
17961
0
            }
17962
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17963
0
            _Py_LeaveRecursiveCall();
17964
0
            if (res != 0) goto failed;
17965
0
            Py_CLEAR(tmp);
17966
0
        }
17967
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
17968
0
                                   end_lineno, end_col_offset, arena);
17969
0
        if (*out == NULL) goto failed;
17970
0
        return 0;
17971
0
    }
17972
17973
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
17974
0
    failed:
17975
0
    Py_XDECREF(tmp);
17976
0
    return -1;
17977
0
}
17978
17979
17980
static int
17981
astmodule_exec(PyObject *m)
17982
2
{
17983
2
    struct ast_state *state = get_ast_state();
17984
2
    if (state == NULL) {
17985
0
        return -1;
17986
0
    }
17987
2
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
17988
0
        return -1;
17989
0
    }
17990
2
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
17991
0
        return -1;
17992
0
    }
17993
2
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
17994
0
        return -1;
17995
0
    }
17996
2
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
17997
0
        return -1;
17998
0
    }
17999
2
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18000
0
        return -1;
18001
0
    }
18002
2
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18003
0
        return -1;
18004
0
    }
18005
2
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18006
0
        return -1;
18007
0
    }
18008
2
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18009
0
        return -1;
18010
0
    }
18011
2
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18012
0
        return -1;
18013
0
    }
18014
2
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18015
0
        {
18016
0
        return -1;
18017
0
    }
18018
2
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18019
0
        return -1;
18020
0
    }
18021
2
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18022
0
        return -1;
18023
0
    }
18024
2
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18025
2
        state->AsyncFunctionDef_type) < 0) {
18026
0
        return -1;
18027
0
    }
18028
2
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18029
0
        return -1;
18030
0
    }
18031
2
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18032
0
        return -1;
18033
0
    }
18034
2
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18035
0
        return -1;
18036
0
    }
18037
2
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18038
0
        return -1;
18039
0
    }
18040
2
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18041
0
        return -1;
18042
0
    }
18043
2
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18044
0
        return -1;
18045
0
    }
18046
2
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18047
0
        return -1;
18048
0
    }
18049
2
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18050
0
        return -1;
18051
0
    }
18052
2
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18053
0
        return -1;
18054
0
    }
18055
2
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18056
0
        return -1;
18057
0
    }
18058
2
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18059
0
        return -1;
18060
0
    }
18061
2
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18062
0
        return -1;
18063
0
    }
18064
2
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18065
0
        return -1;
18066
0
    }
18067
2
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18068
0
        return -1;
18069
0
    }
18070
2
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18071
0
        return -1;
18072
0
    }
18073
2
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18074
0
        return -1;
18075
0
    }
18076
2
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18077
0
        return -1;
18078
0
    }
18079
2
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18080
0
        return -1;
18081
0
    }
18082
2
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18083
0
        return -1;
18084
0
    }
18085
2
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18086
0
        return -1;
18087
0
    }
18088
2
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18089
0
        return -1;
18090
0
    }
18091
2
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18092
0
        return -1;
18093
0
    }
18094
2
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18095
0
        return -1;
18096
0
    }
18097
2
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18098
0
        return -1;
18099
0
    }
18100
2
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18101
0
        return -1;
18102
0
    }
18103
2
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18104
0
        return -1;
18105
0
    }
18106
2
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18107
0
        return -1;
18108
0
    }
18109
2
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18110
0
        return -1;
18111
0
    }
18112
2
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18113
0
        return -1;
18114
0
    }
18115
2
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18116
0
        return -1;
18117
0
    }
18118
2
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18119
0
        return -1;
18120
0
    }
18121
2
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18122
0
        return -1;
18123
0
    }
18124
2
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18125
0
        return -1;
18126
0
    }
18127
2
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18128
0
        return -1;
18129
0
    }
18130
2
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18131
0
        return -1;
18132
0
    }
18133
2
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18134
0
        return -1;
18135
0
    }
18136
2
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18137
0
        return -1;
18138
0
    }
18139
2
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18140
0
        return -1;
18141
0
    }
18142
2
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18143
0
        {
18144
0
        return -1;
18145
0
    }
18146
2
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18147
0
        return -1;
18148
0
    }
18149
2
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18150
0
        return -1;
18151
0
    }
18152
2
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18153
0
        return -1;
18154
0
    }
18155
2
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18156
0
        return -1;
18157
0
    }
18158
2
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18159
0
        return -1;
18160
0
    }
18161
2
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18162
2
        < 0) {
18163
0
        return -1;
18164
0
    }
18165
2
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18166
2
        0) {
18167
0
        return -1;
18168
0
    }
18169
2
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18170
0
        return -1;
18171
0
    }
18172
2
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18173
0
        return -1;
18174
0
    }
18175
2
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18176
0
        return -1;
18177
0
    }
18178
2
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18179
0
        return -1;
18180
0
    }
18181
2
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18182
0
        return -1;
18183
0
    }
18184
2
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18185
0
        return -1;
18186
0
    }
18187
2
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18188
0
        return -1;
18189
0
    }
18190
2
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18191
0
        return -1;
18192
0
    }
18193
2
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18194
0
        return -1;
18195
0
    }
18196
2
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18197
0
        return -1;
18198
0
    }
18199
2
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18200
0
        {
18201
0
        return -1;
18202
0
    }
18203
2
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18204
0
        return -1;
18205
0
    }
18206
2
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18207
0
        return -1;
18208
0
    }
18209
2
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18210
0
        return -1;
18211
0
    }
18212
2
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18213
0
        return -1;
18214
0
    }
18215
2
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18216
0
        return -1;
18217
0
    }
18218
2
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18219
0
        return -1;
18220
0
    }
18221
2
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18222
0
        return -1;
18223
0
    }
18224
2
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18225
0
        return -1;
18226
0
    }
18227
2
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18228
0
        return -1;
18229
0
    }
18230
2
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18231
0
        return -1;
18232
0
    }
18233
2
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18234
0
        return -1;
18235
0
    }
18236
2
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18237
0
        return -1;
18238
0
    }
18239
2
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18240
0
        return -1;
18241
0
    }
18242
2
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18243
0
        return -1;
18244
0
    }
18245
2
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18246
0
        return -1;
18247
0
    }
18248
2
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18249
0
        return -1;
18250
0
    }
18251
2
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18252
0
        return -1;
18253
0
    }
18254
2
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18255
0
        return -1;
18256
0
    }
18257
2
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18258
0
        return -1;
18259
0
    }
18260
2
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18261
0
        return -1;
18262
0
    }
18263
2
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18264
0
        return -1;
18265
0
    }
18266
2
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18267
0
        return -1;
18268
0
    }
18269
2
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18270
0
        return -1;
18271
0
    }
18272
2
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18273
0
        return -1;
18274
0
    }
18275
2
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18276
0
        return -1;
18277
0
    }
18278
2
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18279
0
        return -1;
18280
0
    }
18281
2
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18282
0
        return -1;
18283
0
    }
18284
2
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18285
0
        return -1;
18286
0
    }
18287
2
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18288
0
        return -1;
18289
0
    }
18290
2
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18291
0
        return -1;
18292
0
    }
18293
2
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18294
0
        return -1;
18295
0
    }
18296
2
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18297
0
        return -1;
18298
0
    }
18299
2
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18300
0
        return -1;
18301
0
    }
18302
2
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18303
0
        return -1;
18304
0
    }
18305
2
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18306
0
        return -1;
18307
0
    }
18308
2
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18309
0
        return -1;
18310
0
    }
18311
2
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18312
2
        0) {
18313
0
        return -1;
18314
0
    }
18315
2
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18316
2
        0) {
18317
0
        return -1;
18318
0
    }
18319
2
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18320
2
        0) {
18321
0
        return -1;
18322
0
    }
18323
2
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18324
0
        return -1;
18325
0
    }
18326
2
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18327
0
        return -1;
18328
0
    }
18329
2
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18330
0
        return -1;
18331
0
    }
18332
2
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18333
0
        return -1;
18334
0
    }
18335
2
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18336
0
        return -1;
18337
0
    }
18338
2
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18339
0
        return -1;
18340
0
    }
18341
2
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18342
0
        return -1;
18343
0
    }
18344
2
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18345
0
        return -1;
18346
0
    }
18347
2
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18348
2
        < 0) {
18349
0
        return -1;
18350
0
    }
18351
2
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18352
2
        0) {
18353
0
        return -1;
18354
0
    }
18355
2
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18356
0
        {
18357
0
        return -1;
18358
0
    }
18359
2
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18360
0
        return -1;
18361
0
    }
18362
2
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18363
0
        return -1;
18364
0
    }
18365
2
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18366
0
        return -1;
18367
0
    }
18368
2
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18369
0
        return -1;
18370
0
    }
18371
2
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18372
0
        return -1;
18373
0
    }
18374
2
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18375
0
        return -1;
18376
0
    }
18377
2
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18378
0
        return -1;
18379
0
    }
18380
2
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18381
0
        return -1;
18382
0
    }
18383
2
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18384
0
        return -1;
18385
0
    }
18386
2
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18387
0
        {
18388
0
        return -1;
18389
0
    }
18390
2
    return 0;
18391
2
}
18392
18393
static PyModuleDef_Slot astmodule_slots[] = {
18394
    {Py_mod_exec, astmodule_exec},
18395
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18396
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18397
    {0, NULL}
18398
};
18399
18400
static struct PyModuleDef _astmodule = {
18401
    PyModuleDef_HEAD_INIT,
18402
    .m_name = "_ast",
18403
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18404
    .m_size = 0,
18405
    .m_slots = astmodule_slots,
18406
};
18407
18408
PyMODINIT_FUNC
18409
PyInit__ast(void)
18410
2
{
18411
2
    return PyModuleDef_Init(&_astmodule);
18412
2
}
18413
18414
18415
PyObject* PyAST_mod2obj(mod_ty t)
18416
7.57k
{
18417
7.57k
    struct ast_state *state = get_ast_state();
18418
7.57k
    if (state == NULL) {
18419
0
        return NULL;
18420
0
    }
18421
7.57k
    PyObject *result = ast2obj_mod(state, t);
18422
18423
7.57k
    return result;
18424
7.57k
}
18425
18426
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18427
int PyAst_CheckMode(PyObject *ast, int mode)
18428
0
{
18429
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18430
18431
0
    struct ast_state *state = get_ast_state();
18432
0
    if (state == NULL) {
18433
0
        return -1;
18434
0
    }
18435
18436
0
    PyObject *req_type[3];
18437
0
    req_type[0] = state->Module_type;
18438
0
    req_type[1] = state->Expression_type;
18439
0
    req_type[2] = state->Interactive_type;
18440
18441
0
    assert(0 <= mode && mode <= 2);
18442
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18443
0
    if (isinstance == -1) {
18444
0
        return -1;
18445
0
    }
18446
0
    if (!isinstance) {
18447
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18448
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18449
0
        return -1;
18450
0
    }
18451
0
    return 0;
18452
0
}
18453
18454
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18455
0
{
18456
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18457
0
        return NULL;
18458
0
    }
18459
18460
0
    struct ast_state *state = get_ast_state();
18461
0
    if (state == NULL) {
18462
0
        return NULL;
18463
0
    }
18464
18465
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18466
0
        return NULL;
18467
0
    }
18468
18469
0
    mod_ty res = NULL;
18470
0
    if (obj2ast_mod(state, ast, &res, arena) != 0)
18471
0
        return NULL;
18472
0
    else
18473
0
        return res;
18474
0
}
18475
18476
int PyAST_Check(PyObject* obj)
18477
23.3k
{
18478
23.3k
    struct ast_state *state = get_ast_state();
18479
23.3k
    if (state == NULL) {
18480
0
        return -1;
18481
0
    }
18482
23.3k
    return PyObject_IsInstance(obj, state->AST_type);
18483
23.3k
}
18484
18485