Coverage Report

Created: 2025-11-30 06:38

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