Coverage Report

Created: 2026-07-14 06:16

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
109k
{
23
109k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
109k
    struct ast_state *state = &interp->ast;
25
109k
    assert(!state->finalized);
26
109k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
109k
    return state;
30
109k
}
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->abstract_types);
182
0
    Py_CLEAR(state->alias_type);
183
0
    Py_CLEAR(state->annotation);
184
0
    Py_CLEAR(state->arg);
185
0
    Py_CLEAR(state->arg_type);
186
0
    Py_CLEAR(state->args);
187
0
    Py_CLEAR(state->argtypes);
188
0
    Py_CLEAR(state->arguments_type);
189
0
    Py_CLEAR(state->asname);
190
0
    Py_CLEAR(state->ast);
191
0
    Py_CLEAR(state->attr);
192
0
    Py_CLEAR(state->bases);
193
0
    Py_CLEAR(state->body);
194
0
    Py_CLEAR(state->boolop_type);
195
0
    Py_CLEAR(state->bound);
196
0
    Py_CLEAR(state->cases);
197
0
    Py_CLEAR(state->cause);
198
0
    Py_CLEAR(state->cls);
199
0
    Py_CLEAR(state->cmpop_type);
200
0
    Py_CLEAR(state->col_offset);
201
0
    Py_CLEAR(state->comparators);
202
0
    Py_CLEAR(state->comprehension_type);
203
0
    Py_CLEAR(state->context_expr);
204
0
    Py_CLEAR(state->conversion);
205
0
    Py_CLEAR(state->ctx);
206
0
    Py_CLEAR(state->decorator_list);
207
0
    Py_CLEAR(state->default_value);
208
0
    Py_CLEAR(state->defaults);
209
0
    Py_CLEAR(state->elt);
210
0
    Py_CLEAR(state->elts);
211
0
    Py_CLEAR(state->end_col_offset);
212
0
    Py_CLEAR(state->end_lineno);
213
0
    Py_CLEAR(state->exc);
214
0
    Py_CLEAR(state->excepthandler_type);
215
0
    Py_CLEAR(state->expr_context_type);
216
0
    Py_CLEAR(state->expr_type);
217
0
    Py_CLEAR(state->finalbody);
218
0
    Py_CLEAR(state->format_spec);
219
0
    Py_CLEAR(state->func);
220
0
    Py_CLEAR(state->generators);
221
0
    Py_CLEAR(state->guard);
222
0
    Py_CLEAR(state->handlers);
223
0
    Py_CLEAR(state->id);
224
0
    Py_CLEAR(state->ifs);
225
0
    Py_CLEAR(state->is_async);
226
0
    Py_CLEAR(state->is_lazy);
227
0
    Py_CLEAR(state->items);
228
0
    Py_CLEAR(state->iter);
229
0
    Py_CLEAR(state->key);
230
0
    Py_CLEAR(state->keys);
231
0
    Py_CLEAR(state->keyword_type);
232
0
    Py_CLEAR(state->keywords);
233
0
    Py_CLEAR(state->kind);
234
0
    Py_CLEAR(state->kw_defaults);
235
0
    Py_CLEAR(state->kwarg);
236
0
    Py_CLEAR(state->kwd_attrs);
237
0
    Py_CLEAR(state->kwd_patterns);
238
0
    Py_CLEAR(state->kwonlyargs);
239
0
    Py_CLEAR(state->left);
240
0
    Py_CLEAR(state->level);
241
0
    Py_CLEAR(state->lineno);
242
0
    Py_CLEAR(state->lower);
243
0
    Py_CLEAR(state->match_case_type);
244
0
    Py_CLEAR(state->mod_type);
245
0
    Py_CLEAR(state->module);
246
0
    Py_CLEAR(state->msg);
247
0
    Py_CLEAR(state->name);
248
0
    Py_CLEAR(state->names);
249
0
    Py_CLEAR(state->op);
250
0
    Py_CLEAR(state->operand);
251
0
    Py_CLEAR(state->operator_type);
252
0
    Py_CLEAR(state->ops);
253
0
    Py_CLEAR(state->optional_vars);
254
0
    Py_CLEAR(state->orelse);
255
0
    Py_CLEAR(state->pattern);
256
0
    Py_CLEAR(state->pattern_type);
257
0
    Py_CLEAR(state->patterns);
258
0
    Py_CLEAR(state->posonlyargs);
259
0
    Py_CLEAR(state->rest);
260
0
    Py_CLEAR(state->returns);
261
0
    Py_CLEAR(state->right);
262
0
    Py_CLEAR(state->simple);
263
0
    Py_CLEAR(state->slice);
264
0
    Py_CLEAR(state->step);
265
0
    Py_CLEAR(state->stmt_type);
266
0
    Py_CLEAR(state->str);
267
0
    Py_CLEAR(state->subject);
268
0
    Py_CLEAR(state->tag);
269
0
    Py_CLEAR(state->target);
270
0
    Py_CLEAR(state->targets);
271
0
    Py_CLEAR(state->test);
272
0
    Py_CLEAR(state->type);
273
0
    Py_CLEAR(state->type_comment);
274
0
    Py_CLEAR(state->type_ignore_type);
275
0
    Py_CLEAR(state->type_ignores);
276
0
    Py_CLEAR(state->type_param_type);
277
0
    Py_CLEAR(state->type_params);
278
0
    Py_CLEAR(state->unaryop_type);
279
0
    Py_CLEAR(state->upper);
280
0
    Py_CLEAR(state->value);
281
0
    Py_CLEAR(state->values);
282
0
    Py_CLEAR(state->vararg);
283
0
    Py_CLEAR(state->withitem_type);
284
285
0
    state->finalized = 1;
286
0
    state->once = (_PyOnceFlag){0};
287
0
}
288
289
static int init_identifiers(struct ast_state *state)
290
16
{
291
16
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
292
16
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
293
16
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
294
16
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
295
16
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
296
16
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
297
16
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
298
16
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
299
16
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
300
16
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
301
16
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
302
16
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
303
16
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
304
16
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
305
16
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
306
16
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
307
16
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
308
16
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
309
16
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
310
16
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
311
16
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
312
16
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
313
16
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
314
16
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
315
16
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
316
16
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
317
16
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
318
16
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
319
16
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
320
16
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
321
16
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
322
16
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
323
16
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
324
16
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
325
16
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
326
16
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
327
16
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
328
16
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
329
16
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
330
16
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
331
16
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
332
16
    if ((state->is_lazy = PyUnicode_InternFromString("is_lazy")) == NULL) return -1;
333
16
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
334
16
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
335
16
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
336
16
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
337
16
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
338
16
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
339
16
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
340
16
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
341
16
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
342
16
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
343
16
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
344
16
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
345
16
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
346
16
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
347
16
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
348
16
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
349
16
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
350
16
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
351
16
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
352
16
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
353
16
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
354
16
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
355
16
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
356
16
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
357
16
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
358
16
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
359
16
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
360
16
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
361
16
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
362
16
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
363
16
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
364
16
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
365
16
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
366
16
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
367
16
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
368
16
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
369
16
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
370
16
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
371
16
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
372
16
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
373
16
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
374
16
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
375
16
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
376
16
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
377
16
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
378
16
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
379
16
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
380
16
    return 0;
381
16
};
382
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
384
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
385
761k
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
386
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
387
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
388
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
389
1.01M
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
390
9.82k
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
391
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
392
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
393
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
394
1.48k
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
395
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
396
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
397
398
static PyObject* ast2obj_mod(struct ast_state *state, void*);
399
static const char * const Module_fields[]={
400
    "body",
401
    "type_ignores",
402
};
403
static const char * const Interactive_fields[]={
404
    "body",
405
};
406
static const char * const Expression_fields[]={
407
    "body",
408
};
409
static const char * const FunctionType_fields[]={
410
    "argtypes",
411
    "returns",
412
};
413
static const char * const stmt_attributes[] = {
414
    "lineno",
415
    "col_offset",
416
    "end_lineno",
417
    "end_col_offset",
418
};
419
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
420
static const char * const FunctionDef_fields[]={
421
    "name",
422
    "args",
423
    "body",
424
    "decorator_list",
425
    "returns",
426
    "type_comment",
427
    "type_params",
428
};
429
static const char * const AsyncFunctionDef_fields[]={
430
    "name",
431
    "args",
432
    "body",
433
    "decorator_list",
434
    "returns",
435
    "type_comment",
436
    "type_params",
437
};
438
static const char * const ClassDef_fields[]={
439
    "name",
440
    "bases",
441
    "keywords",
442
    "body",
443
    "decorator_list",
444
    "type_params",
445
};
446
static const char * const Return_fields[]={
447
    "value",
448
};
449
static const char * const Delete_fields[]={
450
    "targets",
451
};
452
static const char * const Assign_fields[]={
453
    "targets",
454
    "value",
455
    "type_comment",
456
};
457
static const char * const TypeAlias_fields[]={
458
    "name",
459
    "type_params",
460
    "value",
461
};
462
static const char * const AugAssign_fields[]={
463
    "target",
464
    "op",
465
    "value",
466
};
467
static const char * const AnnAssign_fields[]={
468
    "target",
469
    "annotation",
470
    "value",
471
    "simple",
472
};
473
static const char * const For_fields[]={
474
    "target",
475
    "iter",
476
    "body",
477
    "orelse",
478
    "type_comment",
479
};
480
static const char * const AsyncFor_fields[]={
481
    "target",
482
    "iter",
483
    "body",
484
    "orelse",
485
    "type_comment",
486
};
487
static const char * const While_fields[]={
488
    "test",
489
    "body",
490
    "orelse",
491
};
492
static const char * const If_fields[]={
493
    "test",
494
    "body",
495
    "orelse",
496
};
497
static const char * const With_fields[]={
498
    "items",
499
    "body",
500
    "type_comment",
501
};
502
static const char * const AsyncWith_fields[]={
503
    "items",
504
    "body",
505
    "type_comment",
506
};
507
static const char * const Match_fields[]={
508
    "subject",
509
    "cases",
510
};
511
static const char * const Raise_fields[]={
512
    "exc",
513
    "cause",
514
};
515
static const char * const Try_fields[]={
516
    "body",
517
    "handlers",
518
    "orelse",
519
    "finalbody",
520
};
521
static const char * const TryStar_fields[]={
522
    "body",
523
    "handlers",
524
    "orelse",
525
    "finalbody",
526
};
527
static const char * const Assert_fields[]={
528
    "test",
529
    "msg",
530
};
531
static const char * const Import_fields[]={
532
    "names",
533
    "is_lazy",
534
};
535
static const char * const ImportFrom_fields[]={
536
    "module",
537
    "names",
538
    "level",
539
    "is_lazy",
540
};
541
static const char * const Global_fields[]={
542
    "names",
543
};
544
static const char * const Nonlocal_fields[]={
545
    "names",
546
};
547
static const char * const Expr_fields[]={
548
    "value",
549
};
550
static const char * const expr_attributes[] = {
551
    "lineno",
552
    "col_offset",
553
    "end_lineno",
554
    "end_col_offset",
555
};
556
static PyObject* ast2obj_expr(struct ast_state *state, void*);
557
static const char * const BoolOp_fields[]={
558
    "op",
559
    "values",
560
};
561
static const char * const NamedExpr_fields[]={
562
    "target",
563
    "value",
564
};
565
static const char * const BinOp_fields[]={
566
    "left",
567
    "op",
568
    "right",
569
};
570
static const char * const UnaryOp_fields[]={
571
    "op",
572
    "operand",
573
};
574
static const char * const Lambda_fields[]={
575
    "args",
576
    "body",
577
};
578
static const char * const IfExp_fields[]={
579
    "test",
580
    "body",
581
    "orelse",
582
};
583
static const char * const Dict_fields[]={
584
    "keys",
585
    "values",
586
};
587
static const char * const Set_fields[]={
588
    "elts",
589
};
590
static const char * const ListComp_fields[]={
591
    "elt",
592
    "generators",
593
};
594
static const char * const SetComp_fields[]={
595
    "elt",
596
    "generators",
597
};
598
static const char * const DictComp_fields[]={
599
    "key",
600
    "value",
601
    "generators",
602
};
603
static const char * const GeneratorExp_fields[]={
604
    "elt",
605
    "generators",
606
};
607
static const char * const Await_fields[]={
608
    "value",
609
};
610
static const char * const Yield_fields[]={
611
    "value",
612
};
613
static const char * const YieldFrom_fields[]={
614
    "value",
615
};
616
static const char * const Compare_fields[]={
617
    "left",
618
    "ops",
619
    "comparators",
620
};
621
static const char * const Call_fields[]={
622
    "func",
623
    "args",
624
    "keywords",
625
};
626
static const char * const FormattedValue_fields[]={
627
    "value",
628
    "conversion",
629
    "format_spec",
630
};
631
static const char * const Interpolation_fields[]={
632
    "value",
633
    "str",
634
    "conversion",
635
    "format_spec",
636
};
637
static const char * const JoinedStr_fields[]={
638
    "values",
639
};
640
static const char * const TemplateStr_fields[]={
641
    "values",
642
};
643
static const char * const Constant_fields[]={
644
    "value",
645
    "kind",
646
};
647
static const char * const Attribute_fields[]={
648
    "value",
649
    "attr",
650
    "ctx",
651
};
652
static const char * const Subscript_fields[]={
653
    "value",
654
    "slice",
655
    "ctx",
656
};
657
static const char * const Starred_fields[]={
658
    "value",
659
    "ctx",
660
};
661
static const char * const Name_fields[]={
662
    "id",
663
    "ctx",
664
};
665
static const char * const List_fields[]={
666
    "elts",
667
    "ctx",
668
};
669
static const char * const Tuple_fields[]={
670
    "elts",
671
    "ctx",
672
};
673
static const char * const Slice_fields[]={
674
    "lower",
675
    "upper",
676
    "step",
677
};
678
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
679
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
680
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
681
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
682
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
683
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
684
static const char * const comprehension_fields[]={
685
    "target",
686
    "iter",
687
    "ifs",
688
    "is_async",
689
};
690
static const char * const excepthandler_attributes[] = {
691
    "lineno",
692
    "col_offset",
693
    "end_lineno",
694
    "end_col_offset",
695
};
696
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
697
static const char * const ExceptHandler_fields[]={
698
    "type",
699
    "name",
700
    "body",
701
};
702
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
703
static const char * const arguments_fields[]={
704
    "posonlyargs",
705
    "args",
706
    "vararg",
707
    "kwonlyargs",
708
    "kw_defaults",
709
    "kwarg",
710
    "defaults",
711
};
712
static PyObject* ast2obj_arg(struct ast_state *state, void*);
713
static const char * const arg_attributes[] = {
714
    "lineno",
715
    "col_offset",
716
    "end_lineno",
717
    "end_col_offset",
718
};
719
static const char * const arg_fields[]={
720
    "arg",
721
    "annotation",
722
    "type_comment",
723
};
724
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
725
static const char * const keyword_attributes[] = {
726
    "lineno",
727
    "col_offset",
728
    "end_lineno",
729
    "end_col_offset",
730
};
731
static const char * const keyword_fields[]={
732
    "arg",
733
    "value",
734
};
735
static PyObject* ast2obj_alias(struct ast_state *state, void*);
736
static const char * const alias_attributes[] = {
737
    "lineno",
738
    "col_offset",
739
    "end_lineno",
740
    "end_col_offset",
741
};
742
static const char * const alias_fields[]={
743
    "name",
744
    "asname",
745
};
746
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
747
static const char * const withitem_fields[]={
748
    "context_expr",
749
    "optional_vars",
750
};
751
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
752
static const char * const match_case_fields[]={
753
    "pattern",
754
    "guard",
755
    "body",
756
};
757
static const char * const pattern_attributes[] = {
758
    "lineno",
759
    "col_offset",
760
    "end_lineno",
761
    "end_col_offset",
762
};
763
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
764
static const char * const MatchValue_fields[]={
765
    "value",
766
};
767
static const char * const MatchSingleton_fields[]={
768
    "value",
769
};
770
static const char * const MatchSequence_fields[]={
771
    "patterns",
772
};
773
static const char * const MatchMapping_fields[]={
774
    "keys",
775
    "patterns",
776
    "rest",
777
};
778
static const char * const MatchClass_fields[]={
779
    "cls",
780
    "patterns",
781
    "kwd_attrs",
782
    "kwd_patterns",
783
};
784
static const char * const MatchStar_fields[]={
785
    "name",
786
};
787
static const char * const MatchAs_fields[]={
788
    "pattern",
789
    "name",
790
};
791
static const char * const MatchOr_fields[]={
792
    "patterns",
793
};
794
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
795
static const char * const TypeIgnore_fields[]={
796
    "lineno",
797
    "tag",
798
};
799
static const char * const type_param_attributes[] = {
800
    "lineno",
801
    "col_offset",
802
    "end_lineno",
803
    "end_col_offset",
804
};
805
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
806
static const char * const TypeVar_fields[]={
807
    "name",
808
    "bound",
809
    "default_value",
810
};
811
static const char * const ParamSpec_fields[]={
812
    "name",
813
    "default_value",
814
};
815
static const char * const TypeVarTuple_fields[]={
816
    "name",
817
    "default_value",
818
};
819
820
821
static int
822
add_ast_annotations(struct ast_state *state)
823
16
{
824
16
    bool cond;
825
16
    PyObject *Module_annotations = PyDict_New();
826
16
    if (!Module_annotations) return 0;
827
16
    {
828
16
        PyObject *type = state->stmt_type;
829
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
830
16
        cond = type != NULL;
831
16
        if (!cond) {
832
0
            Py_DECREF(Module_annotations);
833
0
            return 0;
834
0
        }
835
16
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
836
16
        Py_DECREF(type);
837
16
        if (!cond) {
838
0
            Py_DECREF(Module_annotations);
839
0
            return 0;
840
0
        }
841
16
    }
842
16
    {
843
16
        PyObject *type = state->type_ignore_type;
844
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
845
16
        cond = type != NULL;
846
16
        if (!cond) {
847
0
            Py_DECREF(Module_annotations);
848
0
            return 0;
849
0
        }
850
16
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
851
16
                                    == 0;
852
16
        Py_DECREF(type);
853
16
        if (!cond) {
854
0
            Py_DECREF(Module_annotations);
855
0
            return 0;
856
0
        }
857
16
    }
858
16
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
859
16
                                  Module_annotations) == 0;
860
16
    if (!cond) {
861
0
        Py_DECREF(Module_annotations);
862
0
        return 0;
863
0
    }
864
16
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
865
16
                                  Module_annotations) == 0;
866
16
    if (!cond) {
867
0
        Py_DECREF(Module_annotations);
868
0
        return 0;
869
0
    }
870
16
    Py_DECREF(Module_annotations);
871
16
    PyObject *Interactive_annotations = PyDict_New();
872
16
    if (!Interactive_annotations) return 0;
873
16
    {
874
16
        PyObject *type = state->stmt_type;
875
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
876
16
        cond = type != NULL;
877
16
        if (!cond) {
878
0
            Py_DECREF(Interactive_annotations);
879
0
            return 0;
880
0
        }
881
16
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
882
16
        Py_DECREF(type);
883
16
        if (!cond) {
884
0
            Py_DECREF(Interactive_annotations);
885
0
            return 0;
886
0
        }
887
16
    }
888
16
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
889
16
                                  Interactive_annotations) == 0;
890
16
    if (!cond) {
891
0
        Py_DECREF(Interactive_annotations);
892
0
        return 0;
893
0
    }
894
16
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
895
16
                                  Interactive_annotations) == 0;
896
16
    if (!cond) {
897
0
        Py_DECREF(Interactive_annotations);
898
0
        return 0;
899
0
    }
900
16
    Py_DECREF(Interactive_annotations);
901
16
    PyObject *Expression_annotations = PyDict_New();
902
16
    if (!Expression_annotations) return 0;
903
16
    {
904
16
        PyObject *type = state->expr_type;
905
16
        Py_INCREF(type);
906
16
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
907
16
        Py_DECREF(type);
908
16
        if (!cond) {
909
0
            Py_DECREF(Expression_annotations);
910
0
            return 0;
911
0
        }
912
16
    }
913
16
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
914
16
                                  Expression_annotations) == 0;
915
16
    if (!cond) {
916
0
        Py_DECREF(Expression_annotations);
917
0
        return 0;
918
0
    }
919
16
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
920
16
                                  Expression_annotations) == 0;
921
16
    if (!cond) {
922
0
        Py_DECREF(Expression_annotations);
923
0
        return 0;
924
0
    }
925
16
    Py_DECREF(Expression_annotations);
926
16
    PyObject *FunctionType_annotations = PyDict_New();
927
16
    if (!FunctionType_annotations) return 0;
928
16
    {
929
16
        PyObject *type = state->expr_type;
930
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
931
16
        cond = type != NULL;
932
16
        if (!cond) {
933
0
            Py_DECREF(FunctionType_annotations);
934
0
            return 0;
935
0
        }
936
16
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
937
16
                                    == 0;
938
16
        Py_DECREF(type);
939
16
        if (!cond) {
940
0
            Py_DECREF(FunctionType_annotations);
941
0
            return 0;
942
0
        }
943
16
    }
944
16
    {
945
16
        PyObject *type = state->expr_type;
946
16
        Py_INCREF(type);
947
16
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
948
16
                                    == 0;
949
16
        Py_DECREF(type);
950
16
        if (!cond) {
951
0
            Py_DECREF(FunctionType_annotations);
952
0
            return 0;
953
0
        }
954
16
    }
955
16
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
956
16
                                  FunctionType_annotations) == 0;
957
16
    if (!cond) {
958
0
        Py_DECREF(FunctionType_annotations);
959
0
        return 0;
960
0
    }
961
16
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
962
16
                                  FunctionType_annotations) == 0;
963
16
    if (!cond) {
964
0
        Py_DECREF(FunctionType_annotations);
965
0
        return 0;
966
0
    }
967
16
    Py_DECREF(FunctionType_annotations);
968
16
    PyObject *FunctionDef_annotations = PyDict_New();
969
16
    if (!FunctionDef_annotations) return 0;
970
16
    {
971
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
972
16
        Py_INCREF(type);
973
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
974
16
        Py_DECREF(type);
975
16
        if (!cond) {
976
0
            Py_DECREF(FunctionDef_annotations);
977
0
            return 0;
978
0
        }
979
16
    }
980
16
    {
981
16
        PyObject *type = state->arguments_type;
982
16
        Py_INCREF(type);
983
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
984
16
        Py_DECREF(type);
985
16
        if (!cond) {
986
0
            Py_DECREF(FunctionDef_annotations);
987
0
            return 0;
988
0
        }
989
16
    }
990
16
    {
991
16
        PyObject *type = state->stmt_type;
992
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
993
16
        cond = type != NULL;
994
16
        if (!cond) {
995
0
            Py_DECREF(FunctionDef_annotations);
996
0
            return 0;
997
0
        }
998
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
999
16
        Py_DECREF(type);
1000
16
        if (!cond) {
1001
0
            Py_DECREF(FunctionDef_annotations);
1002
0
            return 0;
1003
0
        }
1004
16
    }
1005
16
    {
1006
16
        PyObject *type = state->expr_type;
1007
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1008
16
        cond = type != NULL;
1009
16
        if (!cond) {
1010
0
            Py_DECREF(FunctionDef_annotations);
1011
0
            return 0;
1012
0
        }
1013
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1014
16
                                    type) == 0;
1015
16
        Py_DECREF(type);
1016
16
        if (!cond) {
1017
0
            Py_DECREF(FunctionDef_annotations);
1018
0
            return 0;
1019
0
        }
1020
16
    }
1021
16
    {
1022
16
        PyObject *type = state->expr_type;
1023
16
        type = _Py_union_type_or(type, Py_None);
1024
16
        cond = type != NULL;
1025
16
        if (!cond) {
1026
0
            Py_DECREF(FunctionDef_annotations);
1027
0
            return 0;
1028
0
        }
1029
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1030
16
                                    == 0;
1031
16
        Py_DECREF(type);
1032
16
        if (!cond) {
1033
0
            Py_DECREF(FunctionDef_annotations);
1034
0
            return 0;
1035
0
        }
1036
16
    }
1037
16
    {
1038
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1039
16
        type = _Py_union_type_or(type, Py_None);
1040
16
        cond = type != NULL;
1041
16
        if (!cond) {
1042
0
            Py_DECREF(FunctionDef_annotations);
1043
0
            return 0;
1044
0
        }
1045
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1046
16
                                    type) == 0;
1047
16
        Py_DECREF(type);
1048
16
        if (!cond) {
1049
0
            Py_DECREF(FunctionDef_annotations);
1050
0
            return 0;
1051
0
        }
1052
16
    }
1053
16
    {
1054
16
        PyObject *type = state->type_param_type;
1055
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1056
16
        cond = type != NULL;
1057
16
        if (!cond) {
1058
0
            Py_DECREF(FunctionDef_annotations);
1059
0
            return 0;
1060
0
        }
1061
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1062
16
                                    type) == 0;
1063
16
        Py_DECREF(type);
1064
16
        if (!cond) {
1065
0
            Py_DECREF(FunctionDef_annotations);
1066
0
            return 0;
1067
0
        }
1068
16
    }
1069
16
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1070
16
                                  FunctionDef_annotations) == 0;
1071
16
    if (!cond) {
1072
0
        Py_DECREF(FunctionDef_annotations);
1073
0
        return 0;
1074
0
    }
1075
16
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1076
16
                                  FunctionDef_annotations) == 0;
1077
16
    if (!cond) {
1078
0
        Py_DECREF(FunctionDef_annotations);
1079
0
        return 0;
1080
0
    }
1081
16
    Py_DECREF(FunctionDef_annotations);
1082
16
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1083
16
    if (!AsyncFunctionDef_annotations) return 0;
1084
16
    {
1085
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1086
16
        Py_INCREF(type);
1087
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1088
16
                                    == 0;
1089
16
        Py_DECREF(type);
1090
16
        if (!cond) {
1091
0
            Py_DECREF(AsyncFunctionDef_annotations);
1092
0
            return 0;
1093
0
        }
1094
16
    }
1095
16
    {
1096
16
        PyObject *type = state->arguments_type;
1097
16
        Py_INCREF(type);
1098
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1099
16
                                    == 0;
1100
16
        Py_DECREF(type);
1101
16
        if (!cond) {
1102
0
            Py_DECREF(AsyncFunctionDef_annotations);
1103
0
            return 0;
1104
0
        }
1105
16
    }
1106
16
    {
1107
16
        PyObject *type = state->stmt_type;
1108
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1109
16
        cond = type != NULL;
1110
16
        if (!cond) {
1111
0
            Py_DECREF(AsyncFunctionDef_annotations);
1112
0
            return 0;
1113
0
        }
1114
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1115
16
                                    == 0;
1116
16
        Py_DECREF(type);
1117
16
        if (!cond) {
1118
0
            Py_DECREF(AsyncFunctionDef_annotations);
1119
0
            return 0;
1120
0
        }
1121
16
    }
1122
16
    {
1123
16
        PyObject *type = state->expr_type;
1124
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1125
16
        cond = type != NULL;
1126
16
        if (!cond) {
1127
0
            Py_DECREF(AsyncFunctionDef_annotations);
1128
0
            return 0;
1129
0
        }
1130
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1131
16
                                    "decorator_list", type) == 0;
1132
16
        Py_DECREF(type);
1133
16
        if (!cond) {
1134
0
            Py_DECREF(AsyncFunctionDef_annotations);
1135
0
            return 0;
1136
0
        }
1137
16
    }
1138
16
    {
1139
16
        PyObject *type = state->expr_type;
1140
16
        type = _Py_union_type_or(type, Py_None);
1141
16
        cond = type != NULL;
1142
16
        if (!cond) {
1143
0
            Py_DECREF(AsyncFunctionDef_annotations);
1144
0
            return 0;
1145
0
        }
1146
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1147
16
                                    type) == 0;
1148
16
        Py_DECREF(type);
1149
16
        if (!cond) {
1150
0
            Py_DECREF(AsyncFunctionDef_annotations);
1151
0
            return 0;
1152
0
        }
1153
16
    }
1154
16
    {
1155
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1156
16
        type = _Py_union_type_or(type, Py_None);
1157
16
        cond = type != NULL;
1158
16
        if (!cond) {
1159
0
            Py_DECREF(AsyncFunctionDef_annotations);
1160
0
            return 0;
1161
0
        }
1162
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1163
16
                                    "type_comment", type) == 0;
1164
16
        Py_DECREF(type);
1165
16
        if (!cond) {
1166
0
            Py_DECREF(AsyncFunctionDef_annotations);
1167
0
            return 0;
1168
0
        }
1169
16
    }
1170
16
    {
1171
16
        PyObject *type = state->type_param_type;
1172
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1173
16
        cond = type != NULL;
1174
16
        if (!cond) {
1175
0
            Py_DECREF(AsyncFunctionDef_annotations);
1176
0
            return 0;
1177
0
        }
1178
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1179
16
                                    "type_params", type) == 0;
1180
16
        Py_DECREF(type);
1181
16
        if (!cond) {
1182
0
            Py_DECREF(AsyncFunctionDef_annotations);
1183
0
            return 0;
1184
0
        }
1185
16
    }
1186
16
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1187
16
                                  AsyncFunctionDef_annotations) == 0;
1188
16
    if (!cond) {
1189
0
        Py_DECREF(AsyncFunctionDef_annotations);
1190
0
        return 0;
1191
0
    }
1192
16
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1193
16
                                  "__annotations__",
1194
16
                                  AsyncFunctionDef_annotations) == 0;
1195
16
    if (!cond) {
1196
0
        Py_DECREF(AsyncFunctionDef_annotations);
1197
0
        return 0;
1198
0
    }
1199
16
    Py_DECREF(AsyncFunctionDef_annotations);
1200
16
    PyObject *ClassDef_annotations = PyDict_New();
1201
16
    if (!ClassDef_annotations) return 0;
1202
16
    {
1203
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1204
16
        Py_INCREF(type);
1205
16
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1206
16
        Py_DECREF(type);
1207
16
        if (!cond) {
1208
0
            Py_DECREF(ClassDef_annotations);
1209
0
            return 0;
1210
0
        }
1211
16
    }
1212
16
    {
1213
16
        PyObject *type = state->expr_type;
1214
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1215
16
        cond = type != NULL;
1216
16
        if (!cond) {
1217
0
            Py_DECREF(ClassDef_annotations);
1218
0
            return 0;
1219
0
        }
1220
16
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1221
16
        Py_DECREF(type);
1222
16
        if (!cond) {
1223
0
            Py_DECREF(ClassDef_annotations);
1224
0
            return 0;
1225
0
        }
1226
16
    }
1227
16
    {
1228
16
        PyObject *type = state->keyword_type;
1229
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1230
16
        cond = type != NULL;
1231
16
        if (!cond) {
1232
0
            Py_DECREF(ClassDef_annotations);
1233
0
            return 0;
1234
0
        }
1235
16
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1236
16
                                    0;
1237
16
        Py_DECREF(type);
1238
16
        if (!cond) {
1239
0
            Py_DECREF(ClassDef_annotations);
1240
0
            return 0;
1241
0
        }
1242
16
    }
1243
16
    {
1244
16
        PyObject *type = state->stmt_type;
1245
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1246
16
        cond = type != NULL;
1247
16
        if (!cond) {
1248
0
            Py_DECREF(ClassDef_annotations);
1249
0
            return 0;
1250
0
        }
1251
16
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1252
16
        Py_DECREF(type);
1253
16
        if (!cond) {
1254
0
            Py_DECREF(ClassDef_annotations);
1255
0
            return 0;
1256
0
        }
1257
16
    }
1258
16
    {
1259
16
        PyObject *type = state->expr_type;
1260
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1261
16
        cond = type != NULL;
1262
16
        if (!cond) {
1263
0
            Py_DECREF(ClassDef_annotations);
1264
0
            return 0;
1265
0
        }
1266
16
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1267
16
                                    type) == 0;
1268
16
        Py_DECREF(type);
1269
16
        if (!cond) {
1270
0
            Py_DECREF(ClassDef_annotations);
1271
0
            return 0;
1272
0
        }
1273
16
    }
1274
16
    {
1275
16
        PyObject *type = state->type_param_type;
1276
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1277
16
        cond = type != NULL;
1278
16
        if (!cond) {
1279
0
            Py_DECREF(ClassDef_annotations);
1280
0
            return 0;
1281
0
        }
1282
16
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1283
16
                                    == 0;
1284
16
        Py_DECREF(type);
1285
16
        if (!cond) {
1286
0
            Py_DECREF(ClassDef_annotations);
1287
0
            return 0;
1288
0
        }
1289
16
    }
1290
16
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1291
16
                                  ClassDef_annotations) == 0;
1292
16
    if (!cond) {
1293
0
        Py_DECREF(ClassDef_annotations);
1294
0
        return 0;
1295
0
    }
1296
16
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1297
16
                                  ClassDef_annotations) == 0;
1298
16
    if (!cond) {
1299
0
        Py_DECREF(ClassDef_annotations);
1300
0
        return 0;
1301
0
    }
1302
16
    Py_DECREF(ClassDef_annotations);
1303
16
    PyObject *Return_annotations = PyDict_New();
1304
16
    if (!Return_annotations) return 0;
1305
16
    {
1306
16
        PyObject *type = state->expr_type;
1307
16
        type = _Py_union_type_or(type, Py_None);
1308
16
        cond = type != NULL;
1309
16
        if (!cond) {
1310
0
            Py_DECREF(Return_annotations);
1311
0
            return 0;
1312
0
        }
1313
16
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1314
16
        Py_DECREF(type);
1315
16
        if (!cond) {
1316
0
            Py_DECREF(Return_annotations);
1317
0
            return 0;
1318
0
        }
1319
16
    }
1320
16
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1321
16
                                  Return_annotations) == 0;
1322
16
    if (!cond) {
1323
0
        Py_DECREF(Return_annotations);
1324
0
        return 0;
1325
0
    }
1326
16
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1327
16
                                  Return_annotations) == 0;
1328
16
    if (!cond) {
1329
0
        Py_DECREF(Return_annotations);
1330
0
        return 0;
1331
0
    }
1332
16
    Py_DECREF(Return_annotations);
1333
16
    PyObject *Delete_annotations = PyDict_New();
1334
16
    if (!Delete_annotations) return 0;
1335
16
    {
1336
16
        PyObject *type = state->expr_type;
1337
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1338
16
        cond = type != NULL;
1339
16
        if (!cond) {
1340
0
            Py_DECREF(Delete_annotations);
1341
0
            return 0;
1342
0
        }
1343
16
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1344
16
        Py_DECREF(type);
1345
16
        if (!cond) {
1346
0
            Py_DECREF(Delete_annotations);
1347
0
            return 0;
1348
0
        }
1349
16
    }
1350
16
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1351
16
                                  Delete_annotations) == 0;
1352
16
    if (!cond) {
1353
0
        Py_DECREF(Delete_annotations);
1354
0
        return 0;
1355
0
    }
1356
16
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1357
16
                                  Delete_annotations) == 0;
1358
16
    if (!cond) {
1359
0
        Py_DECREF(Delete_annotations);
1360
0
        return 0;
1361
0
    }
1362
16
    Py_DECREF(Delete_annotations);
1363
16
    PyObject *Assign_annotations = PyDict_New();
1364
16
    if (!Assign_annotations) return 0;
1365
16
    {
1366
16
        PyObject *type = state->expr_type;
1367
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1368
16
        cond = type != NULL;
1369
16
        if (!cond) {
1370
0
            Py_DECREF(Assign_annotations);
1371
0
            return 0;
1372
0
        }
1373
16
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1374
16
        Py_DECREF(type);
1375
16
        if (!cond) {
1376
0
            Py_DECREF(Assign_annotations);
1377
0
            return 0;
1378
0
        }
1379
16
    }
1380
16
    {
1381
16
        PyObject *type = state->expr_type;
1382
16
        Py_INCREF(type);
1383
16
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1384
16
        Py_DECREF(type);
1385
16
        if (!cond) {
1386
0
            Py_DECREF(Assign_annotations);
1387
0
            return 0;
1388
0
        }
1389
16
    }
1390
16
    {
1391
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1392
16
        type = _Py_union_type_or(type, Py_None);
1393
16
        cond = type != NULL;
1394
16
        if (!cond) {
1395
0
            Py_DECREF(Assign_annotations);
1396
0
            return 0;
1397
0
        }
1398
16
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1399
16
                                    == 0;
1400
16
        Py_DECREF(type);
1401
16
        if (!cond) {
1402
0
            Py_DECREF(Assign_annotations);
1403
0
            return 0;
1404
0
        }
1405
16
    }
1406
16
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1407
16
                                  Assign_annotations) == 0;
1408
16
    if (!cond) {
1409
0
        Py_DECREF(Assign_annotations);
1410
0
        return 0;
1411
0
    }
1412
16
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1413
16
                                  Assign_annotations) == 0;
1414
16
    if (!cond) {
1415
0
        Py_DECREF(Assign_annotations);
1416
0
        return 0;
1417
0
    }
1418
16
    Py_DECREF(Assign_annotations);
1419
16
    PyObject *TypeAlias_annotations = PyDict_New();
1420
16
    if (!TypeAlias_annotations) return 0;
1421
16
    {
1422
16
        PyObject *type = state->expr_type;
1423
16
        Py_INCREF(type);
1424
16
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1425
16
        Py_DECREF(type);
1426
16
        if (!cond) {
1427
0
            Py_DECREF(TypeAlias_annotations);
1428
0
            return 0;
1429
0
        }
1430
16
    }
1431
16
    {
1432
16
        PyObject *type = state->type_param_type;
1433
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1434
16
        cond = type != NULL;
1435
16
        if (!cond) {
1436
0
            Py_DECREF(TypeAlias_annotations);
1437
0
            return 0;
1438
0
        }
1439
16
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1440
16
                                    == 0;
1441
16
        Py_DECREF(type);
1442
16
        if (!cond) {
1443
0
            Py_DECREF(TypeAlias_annotations);
1444
0
            return 0;
1445
0
        }
1446
16
    }
1447
16
    {
1448
16
        PyObject *type = state->expr_type;
1449
16
        Py_INCREF(type);
1450
16
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1451
16
        Py_DECREF(type);
1452
16
        if (!cond) {
1453
0
            Py_DECREF(TypeAlias_annotations);
1454
0
            return 0;
1455
0
        }
1456
16
    }
1457
16
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1458
16
                                  TypeAlias_annotations) == 0;
1459
16
    if (!cond) {
1460
0
        Py_DECREF(TypeAlias_annotations);
1461
0
        return 0;
1462
0
    }
1463
16
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1464
16
                                  TypeAlias_annotations) == 0;
1465
16
    if (!cond) {
1466
0
        Py_DECREF(TypeAlias_annotations);
1467
0
        return 0;
1468
0
    }
1469
16
    Py_DECREF(TypeAlias_annotations);
1470
16
    PyObject *AugAssign_annotations = PyDict_New();
1471
16
    if (!AugAssign_annotations) return 0;
1472
16
    {
1473
16
        PyObject *type = state->expr_type;
1474
16
        Py_INCREF(type);
1475
16
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1476
16
        Py_DECREF(type);
1477
16
        if (!cond) {
1478
0
            Py_DECREF(AugAssign_annotations);
1479
0
            return 0;
1480
0
        }
1481
16
    }
1482
16
    {
1483
16
        PyObject *type = state->operator_type;
1484
16
        Py_INCREF(type);
1485
16
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1486
16
        Py_DECREF(type);
1487
16
        if (!cond) {
1488
0
            Py_DECREF(AugAssign_annotations);
1489
0
            return 0;
1490
0
        }
1491
16
    }
1492
16
    {
1493
16
        PyObject *type = state->expr_type;
1494
16
        Py_INCREF(type);
1495
16
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1496
16
        Py_DECREF(type);
1497
16
        if (!cond) {
1498
0
            Py_DECREF(AugAssign_annotations);
1499
0
            return 0;
1500
0
        }
1501
16
    }
1502
16
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1503
16
                                  AugAssign_annotations) == 0;
1504
16
    if (!cond) {
1505
0
        Py_DECREF(AugAssign_annotations);
1506
0
        return 0;
1507
0
    }
1508
16
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1509
16
                                  AugAssign_annotations) == 0;
1510
16
    if (!cond) {
1511
0
        Py_DECREF(AugAssign_annotations);
1512
0
        return 0;
1513
0
    }
1514
16
    Py_DECREF(AugAssign_annotations);
1515
16
    PyObject *AnnAssign_annotations = PyDict_New();
1516
16
    if (!AnnAssign_annotations) return 0;
1517
16
    {
1518
16
        PyObject *type = state->expr_type;
1519
16
        Py_INCREF(type);
1520
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1521
16
        Py_DECREF(type);
1522
16
        if (!cond) {
1523
0
            Py_DECREF(AnnAssign_annotations);
1524
0
            return 0;
1525
0
        }
1526
16
    }
1527
16
    {
1528
16
        PyObject *type = state->expr_type;
1529
16
        Py_INCREF(type);
1530
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1531
16
                                    == 0;
1532
16
        Py_DECREF(type);
1533
16
        if (!cond) {
1534
0
            Py_DECREF(AnnAssign_annotations);
1535
0
            return 0;
1536
0
        }
1537
16
    }
1538
16
    {
1539
16
        PyObject *type = state->expr_type;
1540
16
        type = _Py_union_type_or(type, Py_None);
1541
16
        cond = type != NULL;
1542
16
        if (!cond) {
1543
0
            Py_DECREF(AnnAssign_annotations);
1544
0
            return 0;
1545
0
        }
1546
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1547
16
        Py_DECREF(type);
1548
16
        if (!cond) {
1549
0
            Py_DECREF(AnnAssign_annotations);
1550
0
            return 0;
1551
0
        }
1552
16
    }
1553
16
    {
1554
16
        PyObject *type = (PyObject *)&PyLong_Type;
1555
16
        Py_INCREF(type);
1556
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1557
16
        Py_DECREF(type);
1558
16
        if (!cond) {
1559
0
            Py_DECREF(AnnAssign_annotations);
1560
0
            return 0;
1561
0
        }
1562
16
    }
1563
16
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1564
16
                                  AnnAssign_annotations) == 0;
1565
16
    if (!cond) {
1566
0
        Py_DECREF(AnnAssign_annotations);
1567
0
        return 0;
1568
0
    }
1569
16
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1570
16
                                  AnnAssign_annotations) == 0;
1571
16
    if (!cond) {
1572
0
        Py_DECREF(AnnAssign_annotations);
1573
0
        return 0;
1574
0
    }
1575
16
    Py_DECREF(AnnAssign_annotations);
1576
16
    PyObject *For_annotations = PyDict_New();
1577
16
    if (!For_annotations) return 0;
1578
16
    {
1579
16
        PyObject *type = state->expr_type;
1580
16
        Py_INCREF(type);
1581
16
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1582
16
        Py_DECREF(type);
1583
16
        if (!cond) {
1584
0
            Py_DECREF(For_annotations);
1585
0
            return 0;
1586
0
        }
1587
16
    }
1588
16
    {
1589
16
        PyObject *type = state->expr_type;
1590
16
        Py_INCREF(type);
1591
16
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1592
16
        Py_DECREF(type);
1593
16
        if (!cond) {
1594
0
            Py_DECREF(For_annotations);
1595
0
            return 0;
1596
0
        }
1597
16
    }
1598
16
    {
1599
16
        PyObject *type = state->stmt_type;
1600
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1601
16
        cond = type != NULL;
1602
16
        if (!cond) {
1603
0
            Py_DECREF(For_annotations);
1604
0
            return 0;
1605
0
        }
1606
16
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1607
16
        Py_DECREF(type);
1608
16
        if (!cond) {
1609
0
            Py_DECREF(For_annotations);
1610
0
            return 0;
1611
0
        }
1612
16
    }
1613
16
    {
1614
16
        PyObject *type = state->stmt_type;
1615
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1616
16
        cond = type != NULL;
1617
16
        if (!cond) {
1618
0
            Py_DECREF(For_annotations);
1619
0
            return 0;
1620
0
        }
1621
16
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1622
16
        Py_DECREF(type);
1623
16
        if (!cond) {
1624
0
            Py_DECREF(For_annotations);
1625
0
            return 0;
1626
0
        }
1627
16
    }
1628
16
    {
1629
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1630
16
        type = _Py_union_type_or(type, Py_None);
1631
16
        cond = type != NULL;
1632
16
        if (!cond) {
1633
0
            Py_DECREF(For_annotations);
1634
0
            return 0;
1635
0
        }
1636
16
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1637
16
        Py_DECREF(type);
1638
16
        if (!cond) {
1639
0
            Py_DECREF(For_annotations);
1640
0
            return 0;
1641
0
        }
1642
16
    }
1643
16
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1644
16
                                  For_annotations) == 0;
1645
16
    if (!cond) {
1646
0
        Py_DECREF(For_annotations);
1647
0
        return 0;
1648
0
    }
1649
16
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1650
16
                                  For_annotations) == 0;
1651
16
    if (!cond) {
1652
0
        Py_DECREF(For_annotations);
1653
0
        return 0;
1654
0
    }
1655
16
    Py_DECREF(For_annotations);
1656
16
    PyObject *AsyncFor_annotations = PyDict_New();
1657
16
    if (!AsyncFor_annotations) return 0;
1658
16
    {
1659
16
        PyObject *type = state->expr_type;
1660
16
        Py_INCREF(type);
1661
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1662
16
        Py_DECREF(type);
1663
16
        if (!cond) {
1664
0
            Py_DECREF(AsyncFor_annotations);
1665
0
            return 0;
1666
0
        }
1667
16
    }
1668
16
    {
1669
16
        PyObject *type = state->expr_type;
1670
16
        Py_INCREF(type);
1671
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1672
16
        Py_DECREF(type);
1673
16
        if (!cond) {
1674
0
            Py_DECREF(AsyncFor_annotations);
1675
0
            return 0;
1676
0
        }
1677
16
    }
1678
16
    {
1679
16
        PyObject *type = state->stmt_type;
1680
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1681
16
        cond = type != NULL;
1682
16
        if (!cond) {
1683
0
            Py_DECREF(AsyncFor_annotations);
1684
0
            return 0;
1685
0
        }
1686
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1687
16
        Py_DECREF(type);
1688
16
        if (!cond) {
1689
0
            Py_DECREF(AsyncFor_annotations);
1690
0
            return 0;
1691
0
        }
1692
16
    }
1693
16
    {
1694
16
        PyObject *type = state->stmt_type;
1695
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1696
16
        cond = type != NULL;
1697
16
        if (!cond) {
1698
0
            Py_DECREF(AsyncFor_annotations);
1699
0
            return 0;
1700
0
        }
1701
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1702
16
        Py_DECREF(type);
1703
16
        if (!cond) {
1704
0
            Py_DECREF(AsyncFor_annotations);
1705
0
            return 0;
1706
0
        }
1707
16
    }
1708
16
    {
1709
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1710
16
        type = _Py_union_type_or(type, Py_None);
1711
16
        cond = type != NULL;
1712
16
        if (!cond) {
1713
0
            Py_DECREF(AsyncFor_annotations);
1714
0
            return 0;
1715
0
        }
1716
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1717
16
                                    == 0;
1718
16
        Py_DECREF(type);
1719
16
        if (!cond) {
1720
0
            Py_DECREF(AsyncFor_annotations);
1721
0
            return 0;
1722
0
        }
1723
16
    }
1724
16
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1725
16
                                  AsyncFor_annotations) == 0;
1726
16
    if (!cond) {
1727
0
        Py_DECREF(AsyncFor_annotations);
1728
0
        return 0;
1729
0
    }
1730
16
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1731
16
                                  AsyncFor_annotations) == 0;
1732
16
    if (!cond) {
1733
0
        Py_DECREF(AsyncFor_annotations);
1734
0
        return 0;
1735
0
    }
1736
16
    Py_DECREF(AsyncFor_annotations);
1737
16
    PyObject *While_annotations = PyDict_New();
1738
16
    if (!While_annotations) return 0;
1739
16
    {
1740
16
        PyObject *type = state->expr_type;
1741
16
        Py_INCREF(type);
1742
16
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1743
16
        Py_DECREF(type);
1744
16
        if (!cond) {
1745
0
            Py_DECREF(While_annotations);
1746
0
            return 0;
1747
0
        }
1748
16
    }
1749
16
    {
1750
16
        PyObject *type = state->stmt_type;
1751
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1752
16
        cond = type != NULL;
1753
16
        if (!cond) {
1754
0
            Py_DECREF(While_annotations);
1755
0
            return 0;
1756
0
        }
1757
16
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1758
16
        Py_DECREF(type);
1759
16
        if (!cond) {
1760
0
            Py_DECREF(While_annotations);
1761
0
            return 0;
1762
0
        }
1763
16
    }
1764
16
    {
1765
16
        PyObject *type = state->stmt_type;
1766
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1767
16
        cond = type != NULL;
1768
16
        if (!cond) {
1769
0
            Py_DECREF(While_annotations);
1770
0
            return 0;
1771
0
        }
1772
16
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1773
16
        Py_DECREF(type);
1774
16
        if (!cond) {
1775
0
            Py_DECREF(While_annotations);
1776
0
            return 0;
1777
0
        }
1778
16
    }
1779
16
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1780
16
                                  While_annotations) == 0;
1781
16
    if (!cond) {
1782
0
        Py_DECREF(While_annotations);
1783
0
        return 0;
1784
0
    }
1785
16
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1786
16
                                  While_annotations) == 0;
1787
16
    if (!cond) {
1788
0
        Py_DECREF(While_annotations);
1789
0
        return 0;
1790
0
    }
1791
16
    Py_DECREF(While_annotations);
1792
16
    PyObject *If_annotations = PyDict_New();
1793
16
    if (!If_annotations) return 0;
1794
16
    {
1795
16
        PyObject *type = state->expr_type;
1796
16
        Py_INCREF(type);
1797
16
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1798
16
        Py_DECREF(type);
1799
16
        if (!cond) {
1800
0
            Py_DECREF(If_annotations);
1801
0
            return 0;
1802
0
        }
1803
16
    }
1804
16
    {
1805
16
        PyObject *type = state->stmt_type;
1806
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1807
16
        cond = type != NULL;
1808
16
        if (!cond) {
1809
0
            Py_DECREF(If_annotations);
1810
0
            return 0;
1811
0
        }
1812
16
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1813
16
        Py_DECREF(type);
1814
16
        if (!cond) {
1815
0
            Py_DECREF(If_annotations);
1816
0
            return 0;
1817
0
        }
1818
16
    }
1819
16
    {
1820
16
        PyObject *type = state->stmt_type;
1821
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1822
16
        cond = type != NULL;
1823
16
        if (!cond) {
1824
0
            Py_DECREF(If_annotations);
1825
0
            return 0;
1826
0
        }
1827
16
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1828
16
        Py_DECREF(type);
1829
16
        if (!cond) {
1830
0
            Py_DECREF(If_annotations);
1831
0
            return 0;
1832
0
        }
1833
16
    }
1834
16
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1835
16
                                  If_annotations) == 0;
1836
16
    if (!cond) {
1837
0
        Py_DECREF(If_annotations);
1838
0
        return 0;
1839
0
    }
1840
16
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1841
16
                                  If_annotations) == 0;
1842
16
    if (!cond) {
1843
0
        Py_DECREF(If_annotations);
1844
0
        return 0;
1845
0
    }
1846
16
    Py_DECREF(If_annotations);
1847
16
    PyObject *With_annotations = PyDict_New();
1848
16
    if (!With_annotations) return 0;
1849
16
    {
1850
16
        PyObject *type = state->withitem_type;
1851
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1852
16
        cond = type != NULL;
1853
16
        if (!cond) {
1854
0
            Py_DECREF(With_annotations);
1855
0
            return 0;
1856
0
        }
1857
16
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1858
16
        Py_DECREF(type);
1859
16
        if (!cond) {
1860
0
            Py_DECREF(With_annotations);
1861
0
            return 0;
1862
0
        }
1863
16
    }
1864
16
    {
1865
16
        PyObject *type = state->stmt_type;
1866
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1867
16
        cond = type != NULL;
1868
16
        if (!cond) {
1869
0
            Py_DECREF(With_annotations);
1870
0
            return 0;
1871
0
        }
1872
16
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1873
16
        Py_DECREF(type);
1874
16
        if (!cond) {
1875
0
            Py_DECREF(With_annotations);
1876
0
            return 0;
1877
0
        }
1878
16
    }
1879
16
    {
1880
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1881
16
        type = _Py_union_type_or(type, Py_None);
1882
16
        cond = type != NULL;
1883
16
        if (!cond) {
1884
0
            Py_DECREF(With_annotations);
1885
0
            return 0;
1886
0
        }
1887
16
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1888
16
                                    0;
1889
16
        Py_DECREF(type);
1890
16
        if (!cond) {
1891
0
            Py_DECREF(With_annotations);
1892
0
            return 0;
1893
0
        }
1894
16
    }
1895
16
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1896
16
                                  With_annotations) == 0;
1897
16
    if (!cond) {
1898
0
        Py_DECREF(With_annotations);
1899
0
        return 0;
1900
0
    }
1901
16
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1902
16
                                  With_annotations) == 0;
1903
16
    if (!cond) {
1904
0
        Py_DECREF(With_annotations);
1905
0
        return 0;
1906
0
    }
1907
16
    Py_DECREF(With_annotations);
1908
16
    PyObject *AsyncWith_annotations = PyDict_New();
1909
16
    if (!AsyncWith_annotations) return 0;
1910
16
    {
1911
16
        PyObject *type = state->withitem_type;
1912
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1913
16
        cond = type != NULL;
1914
16
        if (!cond) {
1915
0
            Py_DECREF(AsyncWith_annotations);
1916
0
            return 0;
1917
0
        }
1918
16
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1919
16
        Py_DECREF(type);
1920
16
        if (!cond) {
1921
0
            Py_DECREF(AsyncWith_annotations);
1922
0
            return 0;
1923
0
        }
1924
16
    }
1925
16
    {
1926
16
        PyObject *type = state->stmt_type;
1927
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1928
16
        cond = type != NULL;
1929
16
        if (!cond) {
1930
0
            Py_DECREF(AsyncWith_annotations);
1931
0
            return 0;
1932
0
        }
1933
16
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1934
16
        Py_DECREF(type);
1935
16
        if (!cond) {
1936
0
            Py_DECREF(AsyncWith_annotations);
1937
0
            return 0;
1938
0
        }
1939
16
    }
1940
16
    {
1941
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1942
16
        type = _Py_union_type_or(type, Py_None);
1943
16
        cond = type != NULL;
1944
16
        if (!cond) {
1945
0
            Py_DECREF(AsyncWith_annotations);
1946
0
            return 0;
1947
0
        }
1948
16
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1949
16
                                    type) == 0;
1950
16
        Py_DECREF(type);
1951
16
        if (!cond) {
1952
0
            Py_DECREF(AsyncWith_annotations);
1953
0
            return 0;
1954
0
        }
1955
16
    }
1956
16
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1957
16
                                  AsyncWith_annotations) == 0;
1958
16
    if (!cond) {
1959
0
        Py_DECREF(AsyncWith_annotations);
1960
0
        return 0;
1961
0
    }
1962
16
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1963
16
                                  AsyncWith_annotations) == 0;
1964
16
    if (!cond) {
1965
0
        Py_DECREF(AsyncWith_annotations);
1966
0
        return 0;
1967
0
    }
1968
16
    Py_DECREF(AsyncWith_annotations);
1969
16
    PyObject *Match_annotations = PyDict_New();
1970
16
    if (!Match_annotations) return 0;
1971
16
    {
1972
16
        PyObject *type = state->expr_type;
1973
16
        Py_INCREF(type);
1974
16
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1975
16
        Py_DECREF(type);
1976
16
        if (!cond) {
1977
0
            Py_DECREF(Match_annotations);
1978
0
            return 0;
1979
0
        }
1980
16
    }
1981
16
    {
1982
16
        PyObject *type = state->match_case_type;
1983
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1984
16
        cond = type != NULL;
1985
16
        if (!cond) {
1986
0
            Py_DECREF(Match_annotations);
1987
0
            return 0;
1988
0
        }
1989
16
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1990
16
        Py_DECREF(type);
1991
16
        if (!cond) {
1992
0
            Py_DECREF(Match_annotations);
1993
0
            return 0;
1994
0
        }
1995
16
    }
1996
16
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1997
16
                                  Match_annotations) == 0;
1998
16
    if (!cond) {
1999
0
        Py_DECREF(Match_annotations);
2000
0
        return 0;
2001
0
    }
2002
16
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
2003
16
                                  Match_annotations) == 0;
2004
16
    if (!cond) {
2005
0
        Py_DECREF(Match_annotations);
2006
0
        return 0;
2007
0
    }
2008
16
    Py_DECREF(Match_annotations);
2009
16
    PyObject *Raise_annotations = PyDict_New();
2010
16
    if (!Raise_annotations) return 0;
2011
16
    {
2012
16
        PyObject *type = state->expr_type;
2013
16
        type = _Py_union_type_or(type, Py_None);
2014
16
        cond = type != NULL;
2015
16
        if (!cond) {
2016
0
            Py_DECREF(Raise_annotations);
2017
0
            return 0;
2018
0
        }
2019
16
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2020
16
        Py_DECREF(type);
2021
16
        if (!cond) {
2022
0
            Py_DECREF(Raise_annotations);
2023
0
            return 0;
2024
0
        }
2025
16
    }
2026
16
    {
2027
16
        PyObject *type = state->expr_type;
2028
16
        type = _Py_union_type_or(type, Py_None);
2029
16
        cond = type != NULL;
2030
16
        if (!cond) {
2031
0
            Py_DECREF(Raise_annotations);
2032
0
            return 0;
2033
0
        }
2034
16
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2035
16
        Py_DECREF(type);
2036
16
        if (!cond) {
2037
0
            Py_DECREF(Raise_annotations);
2038
0
            return 0;
2039
0
        }
2040
16
    }
2041
16
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2042
16
                                  Raise_annotations) == 0;
2043
16
    if (!cond) {
2044
0
        Py_DECREF(Raise_annotations);
2045
0
        return 0;
2046
0
    }
2047
16
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2048
16
                                  Raise_annotations) == 0;
2049
16
    if (!cond) {
2050
0
        Py_DECREF(Raise_annotations);
2051
0
        return 0;
2052
0
    }
2053
16
    Py_DECREF(Raise_annotations);
2054
16
    PyObject *Try_annotations = PyDict_New();
2055
16
    if (!Try_annotations) return 0;
2056
16
    {
2057
16
        PyObject *type = state->stmt_type;
2058
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2059
16
        cond = type != NULL;
2060
16
        if (!cond) {
2061
0
            Py_DECREF(Try_annotations);
2062
0
            return 0;
2063
0
        }
2064
16
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2065
16
        Py_DECREF(type);
2066
16
        if (!cond) {
2067
0
            Py_DECREF(Try_annotations);
2068
0
            return 0;
2069
0
        }
2070
16
    }
2071
16
    {
2072
16
        PyObject *type = state->excepthandler_type;
2073
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2074
16
        cond = type != NULL;
2075
16
        if (!cond) {
2076
0
            Py_DECREF(Try_annotations);
2077
0
            return 0;
2078
0
        }
2079
16
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2080
16
        Py_DECREF(type);
2081
16
        if (!cond) {
2082
0
            Py_DECREF(Try_annotations);
2083
0
            return 0;
2084
0
        }
2085
16
    }
2086
16
    {
2087
16
        PyObject *type = state->stmt_type;
2088
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2089
16
        cond = type != NULL;
2090
16
        if (!cond) {
2091
0
            Py_DECREF(Try_annotations);
2092
0
            return 0;
2093
0
        }
2094
16
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2095
16
        Py_DECREF(type);
2096
16
        if (!cond) {
2097
0
            Py_DECREF(Try_annotations);
2098
0
            return 0;
2099
0
        }
2100
16
    }
2101
16
    {
2102
16
        PyObject *type = state->stmt_type;
2103
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2104
16
        cond = type != NULL;
2105
16
        if (!cond) {
2106
0
            Py_DECREF(Try_annotations);
2107
0
            return 0;
2108
0
        }
2109
16
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2110
16
        Py_DECREF(type);
2111
16
        if (!cond) {
2112
0
            Py_DECREF(Try_annotations);
2113
0
            return 0;
2114
0
        }
2115
16
    }
2116
16
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2117
16
                                  Try_annotations) == 0;
2118
16
    if (!cond) {
2119
0
        Py_DECREF(Try_annotations);
2120
0
        return 0;
2121
0
    }
2122
16
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2123
16
                                  Try_annotations) == 0;
2124
16
    if (!cond) {
2125
0
        Py_DECREF(Try_annotations);
2126
0
        return 0;
2127
0
    }
2128
16
    Py_DECREF(Try_annotations);
2129
16
    PyObject *TryStar_annotations = PyDict_New();
2130
16
    if (!TryStar_annotations) return 0;
2131
16
    {
2132
16
        PyObject *type = state->stmt_type;
2133
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2134
16
        cond = type != NULL;
2135
16
        if (!cond) {
2136
0
            Py_DECREF(TryStar_annotations);
2137
0
            return 0;
2138
0
        }
2139
16
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2140
16
        Py_DECREF(type);
2141
16
        if (!cond) {
2142
0
            Py_DECREF(TryStar_annotations);
2143
0
            return 0;
2144
0
        }
2145
16
    }
2146
16
    {
2147
16
        PyObject *type = state->excepthandler_type;
2148
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2149
16
        cond = type != NULL;
2150
16
        if (!cond) {
2151
0
            Py_DECREF(TryStar_annotations);
2152
0
            return 0;
2153
0
        }
2154
16
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2155
16
        Py_DECREF(type);
2156
16
        if (!cond) {
2157
0
            Py_DECREF(TryStar_annotations);
2158
0
            return 0;
2159
0
        }
2160
16
    }
2161
16
    {
2162
16
        PyObject *type = state->stmt_type;
2163
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2164
16
        cond = type != NULL;
2165
16
        if (!cond) {
2166
0
            Py_DECREF(TryStar_annotations);
2167
0
            return 0;
2168
0
        }
2169
16
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2170
16
        Py_DECREF(type);
2171
16
        if (!cond) {
2172
0
            Py_DECREF(TryStar_annotations);
2173
0
            return 0;
2174
0
        }
2175
16
    }
2176
16
    {
2177
16
        PyObject *type = state->stmt_type;
2178
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2179
16
        cond = type != NULL;
2180
16
        if (!cond) {
2181
0
            Py_DECREF(TryStar_annotations);
2182
0
            return 0;
2183
0
        }
2184
16
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2185
16
                                    0;
2186
16
        Py_DECREF(type);
2187
16
        if (!cond) {
2188
0
            Py_DECREF(TryStar_annotations);
2189
0
            return 0;
2190
0
        }
2191
16
    }
2192
16
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2193
16
                                  TryStar_annotations) == 0;
2194
16
    if (!cond) {
2195
0
        Py_DECREF(TryStar_annotations);
2196
0
        return 0;
2197
0
    }
2198
16
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2199
16
                                  TryStar_annotations) == 0;
2200
16
    if (!cond) {
2201
0
        Py_DECREF(TryStar_annotations);
2202
0
        return 0;
2203
0
    }
2204
16
    Py_DECREF(TryStar_annotations);
2205
16
    PyObject *Assert_annotations = PyDict_New();
2206
16
    if (!Assert_annotations) return 0;
2207
16
    {
2208
16
        PyObject *type = state->expr_type;
2209
16
        Py_INCREF(type);
2210
16
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2211
16
        Py_DECREF(type);
2212
16
        if (!cond) {
2213
0
            Py_DECREF(Assert_annotations);
2214
0
            return 0;
2215
0
        }
2216
16
    }
2217
16
    {
2218
16
        PyObject *type = state->expr_type;
2219
16
        type = _Py_union_type_or(type, Py_None);
2220
16
        cond = type != NULL;
2221
16
        if (!cond) {
2222
0
            Py_DECREF(Assert_annotations);
2223
0
            return 0;
2224
0
        }
2225
16
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2226
16
        Py_DECREF(type);
2227
16
        if (!cond) {
2228
0
            Py_DECREF(Assert_annotations);
2229
0
            return 0;
2230
0
        }
2231
16
    }
2232
16
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2233
16
                                  Assert_annotations) == 0;
2234
16
    if (!cond) {
2235
0
        Py_DECREF(Assert_annotations);
2236
0
        return 0;
2237
0
    }
2238
16
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2239
16
                                  Assert_annotations) == 0;
2240
16
    if (!cond) {
2241
0
        Py_DECREF(Assert_annotations);
2242
0
        return 0;
2243
0
    }
2244
16
    Py_DECREF(Assert_annotations);
2245
16
    PyObject *Import_annotations = PyDict_New();
2246
16
    if (!Import_annotations) return 0;
2247
16
    {
2248
16
        PyObject *type = state->alias_type;
2249
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2250
16
        cond = type != NULL;
2251
16
        if (!cond) {
2252
0
            Py_DECREF(Import_annotations);
2253
0
            return 0;
2254
0
        }
2255
16
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2256
16
        Py_DECREF(type);
2257
16
        if (!cond) {
2258
0
            Py_DECREF(Import_annotations);
2259
0
            return 0;
2260
0
        }
2261
16
    }
2262
16
    {
2263
16
        PyObject *type = (PyObject *)&PyLong_Type;
2264
16
        type = _Py_union_type_or(type, Py_None);
2265
16
        cond = type != NULL;
2266
16
        if (!cond) {
2267
0
            Py_DECREF(Import_annotations);
2268
0
            return 0;
2269
0
        }
2270
16
        cond = PyDict_SetItemString(Import_annotations, "is_lazy", type) == 0;
2271
16
        Py_DECREF(type);
2272
16
        if (!cond) {
2273
0
            Py_DECREF(Import_annotations);
2274
0
            return 0;
2275
0
        }
2276
16
    }
2277
16
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2278
16
                                  Import_annotations) == 0;
2279
16
    if (!cond) {
2280
0
        Py_DECREF(Import_annotations);
2281
0
        return 0;
2282
0
    }
2283
16
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2284
16
                                  Import_annotations) == 0;
2285
16
    if (!cond) {
2286
0
        Py_DECREF(Import_annotations);
2287
0
        return 0;
2288
0
    }
2289
16
    Py_DECREF(Import_annotations);
2290
16
    PyObject *ImportFrom_annotations = PyDict_New();
2291
16
    if (!ImportFrom_annotations) return 0;
2292
16
    {
2293
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
2294
16
        type = _Py_union_type_or(type, Py_None);
2295
16
        cond = type != NULL;
2296
16
        if (!cond) {
2297
0
            Py_DECREF(ImportFrom_annotations);
2298
0
            return 0;
2299
0
        }
2300
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2301
16
                                    0;
2302
16
        Py_DECREF(type);
2303
16
        if (!cond) {
2304
0
            Py_DECREF(ImportFrom_annotations);
2305
0
            return 0;
2306
0
        }
2307
16
    }
2308
16
    {
2309
16
        PyObject *type = state->alias_type;
2310
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2311
16
        cond = type != NULL;
2312
16
        if (!cond) {
2313
0
            Py_DECREF(ImportFrom_annotations);
2314
0
            return 0;
2315
0
        }
2316
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2317
16
        Py_DECREF(type);
2318
16
        if (!cond) {
2319
0
            Py_DECREF(ImportFrom_annotations);
2320
0
            return 0;
2321
0
        }
2322
16
    }
2323
16
    {
2324
16
        PyObject *type = (PyObject *)&PyLong_Type;
2325
16
        type = _Py_union_type_or(type, Py_None);
2326
16
        cond = type != NULL;
2327
16
        if (!cond) {
2328
0
            Py_DECREF(ImportFrom_annotations);
2329
0
            return 0;
2330
0
        }
2331
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2332
16
        Py_DECREF(type);
2333
16
        if (!cond) {
2334
0
            Py_DECREF(ImportFrom_annotations);
2335
0
            return 0;
2336
0
        }
2337
16
    }
2338
16
    {
2339
16
        PyObject *type = (PyObject *)&PyLong_Type;
2340
16
        type = _Py_union_type_or(type, Py_None);
2341
16
        cond = type != NULL;
2342
16
        if (!cond) {
2343
0
            Py_DECREF(ImportFrom_annotations);
2344
0
            return 0;
2345
0
        }
2346
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "is_lazy", type) ==
2347
16
                                    0;
2348
16
        Py_DECREF(type);
2349
16
        if (!cond) {
2350
0
            Py_DECREF(ImportFrom_annotations);
2351
0
            return 0;
2352
0
        }
2353
16
    }
2354
16
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2355
16
                                  ImportFrom_annotations) == 0;
2356
16
    if (!cond) {
2357
0
        Py_DECREF(ImportFrom_annotations);
2358
0
        return 0;
2359
0
    }
2360
16
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2361
16
                                  ImportFrom_annotations) == 0;
2362
16
    if (!cond) {
2363
0
        Py_DECREF(ImportFrom_annotations);
2364
0
        return 0;
2365
0
    }
2366
16
    Py_DECREF(ImportFrom_annotations);
2367
16
    PyObject *Global_annotations = PyDict_New();
2368
16
    if (!Global_annotations) return 0;
2369
16
    {
2370
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
2371
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2372
16
        cond = type != NULL;
2373
16
        if (!cond) {
2374
0
            Py_DECREF(Global_annotations);
2375
0
            return 0;
2376
0
        }
2377
16
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2378
16
        Py_DECREF(type);
2379
16
        if (!cond) {
2380
0
            Py_DECREF(Global_annotations);
2381
0
            return 0;
2382
0
        }
2383
16
    }
2384
16
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2385
16
                                  Global_annotations) == 0;
2386
16
    if (!cond) {
2387
0
        Py_DECREF(Global_annotations);
2388
0
        return 0;
2389
0
    }
2390
16
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2391
16
                                  Global_annotations) == 0;
2392
16
    if (!cond) {
2393
0
        Py_DECREF(Global_annotations);
2394
0
        return 0;
2395
0
    }
2396
16
    Py_DECREF(Global_annotations);
2397
16
    PyObject *Nonlocal_annotations = PyDict_New();
2398
16
    if (!Nonlocal_annotations) return 0;
2399
16
    {
2400
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
2401
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2402
16
        cond = type != NULL;
2403
16
        if (!cond) {
2404
0
            Py_DECREF(Nonlocal_annotations);
2405
0
            return 0;
2406
0
        }
2407
16
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2408
16
        Py_DECREF(type);
2409
16
        if (!cond) {
2410
0
            Py_DECREF(Nonlocal_annotations);
2411
0
            return 0;
2412
0
        }
2413
16
    }
2414
16
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2415
16
                                  Nonlocal_annotations) == 0;
2416
16
    if (!cond) {
2417
0
        Py_DECREF(Nonlocal_annotations);
2418
0
        return 0;
2419
0
    }
2420
16
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2421
16
                                  Nonlocal_annotations) == 0;
2422
16
    if (!cond) {
2423
0
        Py_DECREF(Nonlocal_annotations);
2424
0
        return 0;
2425
0
    }
2426
16
    Py_DECREF(Nonlocal_annotations);
2427
16
    PyObject *Expr_annotations = PyDict_New();
2428
16
    if (!Expr_annotations) return 0;
2429
16
    {
2430
16
        PyObject *type = state->expr_type;
2431
16
        Py_INCREF(type);
2432
16
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2433
16
        Py_DECREF(type);
2434
16
        if (!cond) {
2435
0
            Py_DECREF(Expr_annotations);
2436
0
            return 0;
2437
0
        }
2438
16
    }
2439
16
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2440
16
                                  Expr_annotations) == 0;
2441
16
    if (!cond) {
2442
0
        Py_DECREF(Expr_annotations);
2443
0
        return 0;
2444
0
    }
2445
16
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2446
16
                                  Expr_annotations) == 0;
2447
16
    if (!cond) {
2448
0
        Py_DECREF(Expr_annotations);
2449
0
        return 0;
2450
0
    }
2451
16
    Py_DECREF(Expr_annotations);
2452
16
    PyObject *Pass_annotations = PyDict_New();
2453
16
    if (!Pass_annotations) return 0;
2454
16
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2455
16
                                  Pass_annotations) == 0;
2456
16
    if (!cond) {
2457
0
        Py_DECREF(Pass_annotations);
2458
0
        return 0;
2459
0
    }
2460
16
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2461
16
                                  Pass_annotations) == 0;
2462
16
    if (!cond) {
2463
0
        Py_DECREF(Pass_annotations);
2464
0
        return 0;
2465
0
    }
2466
16
    Py_DECREF(Pass_annotations);
2467
16
    PyObject *Break_annotations = PyDict_New();
2468
16
    if (!Break_annotations) return 0;
2469
16
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2470
16
                                  Break_annotations) == 0;
2471
16
    if (!cond) {
2472
0
        Py_DECREF(Break_annotations);
2473
0
        return 0;
2474
0
    }
2475
16
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2476
16
                                  Break_annotations) == 0;
2477
16
    if (!cond) {
2478
0
        Py_DECREF(Break_annotations);
2479
0
        return 0;
2480
0
    }
2481
16
    Py_DECREF(Break_annotations);
2482
16
    PyObject *Continue_annotations = PyDict_New();
2483
16
    if (!Continue_annotations) return 0;
2484
16
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2485
16
                                  Continue_annotations) == 0;
2486
16
    if (!cond) {
2487
0
        Py_DECREF(Continue_annotations);
2488
0
        return 0;
2489
0
    }
2490
16
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2491
16
                                  Continue_annotations) == 0;
2492
16
    if (!cond) {
2493
0
        Py_DECREF(Continue_annotations);
2494
0
        return 0;
2495
0
    }
2496
16
    Py_DECREF(Continue_annotations);
2497
16
    PyObject *BoolOp_annotations = PyDict_New();
2498
16
    if (!BoolOp_annotations) return 0;
2499
16
    {
2500
16
        PyObject *type = state->boolop_type;
2501
16
        Py_INCREF(type);
2502
16
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2503
16
        Py_DECREF(type);
2504
16
        if (!cond) {
2505
0
            Py_DECREF(BoolOp_annotations);
2506
0
            return 0;
2507
0
        }
2508
16
    }
2509
16
    {
2510
16
        PyObject *type = state->expr_type;
2511
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2512
16
        cond = type != NULL;
2513
16
        if (!cond) {
2514
0
            Py_DECREF(BoolOp_annotations);
2515
0
            return 0;
2516
0
        }
2517
16
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2518
16
        Py_DECREF(type);
2519
16
        if (!cond) {
2520
0
            Py_DECREF(BoolOp_annotations);
2521
0
            return 0;
2522
0
        }
2523
16
    }
2524
16
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2525
16
                                  BoolOp_annotations) == 0;
2526
16
    if (!cond) {
2527
0
        Py_DECREF(BoolOp_annotations);
2528
0
        return 0;
2529
0
    }
2530
16
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2531
16
                                  BoolOp_annotations) == 0;
2532
16
    if (!cond) {
2533
0
        Py_DECREF(BoolOp_annotations);
2534
0
        return 0;
2535
0
    }
2536
16
    Py_DECREF(BoolOp_annotations);
2537
16
    PyObject *NamedExpr_annotations = PyDict_New();
2538
16
    if (!NamedExpr_annotations) return 0;
2539
16
    {
2540
16
        PyObject *type = state->expr_type;
2541
16
        Py_INCREF(type);
2542
16
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2543
16
        Py_DECREF(type);
2544
16
        if (!cond) {
2545
0
            Py_DECREF(NamedExpr_annotations);
2546
0
            return 0;
2547
0
        }
2548
16
    }
2549
16
    {
2550
16
        PyObject *type = state->expr_type;
2551
16
        Py_INCREF(type);
2552
16
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2553
16
        Py_DECREF(type);
2554
16
        if (!cond) {
2555
0
            Py_DECREF(NamedExpr_annotations);
2556
0
            return 0;
2557
0
        }
2558
16
    }
2559
16
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2560
16
                                  NamedExpr_annotations) == 0;
2561
16
    if (!cond) {
2562
0
        Py_DECREF(NamedExpr_annotations);
2563
0
        return 0;
2564
0
    }
2565
16
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2566
16
                                  NamedExpr_annotations) == 0;
2567
16
    if (!cond) {
2568
0
        Py_DECREF(NamedExpr_annotations);
2569
0
        return 0;
2570
0
    }
2571
16
    Py_DECREF(NamedExpr_annotations);
2572
16
    PyObject *BinOp_annotations = PyDict_New();
2573
16
    if (!BinOp_annotations) return 0;
2574
16
    {
2575
16
        PyObject *type = state->expr_type;
2576
16
        Py_INCREF(type);
2577
16
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2578
16
        Py_DECREF(type);
2579
16
        if (!cond) {
2580
0
            Py_DECREF(BinOp_annotations);
2581
0
            return 0;
2582
0
        }
2583
16
    }
2584
16
    {
2585
16
        PyObject *type = state->operator_type;
2586
16
        Py_INCREF(type);
2587
16
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2588
16
        Py_DECREF(type);
2589
16
        if (!cond) {
2590
0
            Py_DECREF(BinOp_annotations);
2591
0
            return 0;
2592
0
        }
2593
16
    }
2594
16
    {
2595
16
        PyObject *type = state->expr_type;
2596
16
        Py_INCREF(type);
2597
16
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2598
16
        Py_DECREF(type);
2599
16
        if (!cond) {
2600
0
            Py_DECREF(BinOp_annotations);
2601
0
            return 0;
2602
0
        }
2603
16
    }
2604
16
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2605
16
                                  BinOp_annotations) == 0;
2606
16
    if (!cond) {
2607
0
        Py_DECREF(BinOp_annotations);
2608
0
        return 0;
2609
0
    }
2610
16
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2611
16
                                  BinOp_annotations) == 0;
2612
16
    if (!cond) {
2613
0
        Py_DECREF(BinOp_annotations);
2614
0
        return 0;
2615
0
    }
2616
16
    Py_DECREF(BinOp_annotations);
2617
16
    PyObject *UnaryOp_annotations = PyDict_New();
2618
16
    if (!UnaryOp_annotations) return 0;
2619
16
    {
2620
16
        PyObject *type = state->unaryop_type;
2621
16
        Py_INCREF(type);
2622
16
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2623
16
        Py_DECREF(type);
2624
16
        if (!cond) {
2625
0
            Py_DECREF(UnaryOp_annotations);
2626
0
            return 0;
2627
0
        }
2628
16
    }
2629
16
    {
2630
16
        PyObject *type = state->expr_type;
2631
16
        Py_INCREF(type);
2632
16
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2633
16
        Py_DECREF(type);
2634
16
        if (!cond) {
2635
0
            Py_DECREF(UnaryOp_annotations);
2636
0
            return 0;
2637
0
        }
2638
16
    }
2639
16
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2640
16
                                  UnaryOp_annotations) == 0;
2641
16
    if (!cond) {
2642
0
        Py_DECREF(UnaryOp_annotations);
2643
0
        return 0;
2644
0
    }
2645
16
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2646
16
                                  UnaryOp_annotations) == 0;
2647
16
    if (!cond) {
2648
0
        Py_DECREF(UnaryOp_annotations);
2649
0
        return 0;
2650
0
    }
2651
16
    Py_DECREF(UnaryOp_annotations);
2652
16
    PyObject *Lambda_annotations = PyDict_New();
2653
16
    if (!Lambda_annotations) return 0;
2654
16
    {
2655
16
        PyObject *type = state->arguments_type;
2656
16
        Py_INCREF(type);
2657
16
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2658
16
        Py_DECREF(type);
2659
16
        if (!cond) {
2660
0
            Py_DECREF(Lambda_annotations);
2661
0
            return 0;
2662
0
        }
2663
16
    }
2664
16
    {
2665
16
        PyObject *type = state->expr_type;
2666
16
        Py_INCREF(type);
2667
16
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2668
16
        Py_DECREF(type);
2669
16
        if (!cond) {
2670
0
            Py_DECREF(Lambda_annotations);
2671
0
            return 0;
2672
0
        }
2673
16
    }
2674
16
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2675
16
                                  Lambda_annotations) == 0;
2676
16
    if (!cond) {
2677
0
        Py_DECREF(Lambda_annotations);
2678
0
        return 0;
2679
0
    }
2680
16
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2681
16
                                  Lambda_annotations) == 0;
2682
16
    if (!cond) {
2683
0
        Py_DECREF(Lambda_annotations);
2684
0
        return 0;
2685
0
    }
2686
16
    Py_DECREF(Lambda_annotations);
2687
16
    PyObject *IfExp_annotations = PyDict_New();
2688
16
    if (!IfExp_annotations) return 0;
2689
16
    {
2690
16
        PyObject *type = state->expr_type;
2691
16
        Py_INCREF(type);
2692
16
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2693
16
        Py_DECREF(type);
2694
16
        if (!cond) {
2695
0
            Py_DECREF(IfExp_annotations);
2696
0
            return 0;
2697
0
        }
2698
16
    }
2699
16
    {
2700
16
        PyObject *type = state->expr_type;
2701
16
        Py_INCREF(type);
2702
16
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2703
16
        Py_DECREF(type);
2704
16
        if (!cond) {
2705
0
            Py_DECREF(IfExp_annotations);
2706
0
            return 0;
2707
0
        }
2708
16
    }
2709
16
    {
2710
16
        PyObject *type = state->expr_type;
2711
16
        Py_INCREF(type);
2712
16
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2713
16
        Py_DECREF(type);
2714
16
        if (!cond) {
2715
0
            Py_DECREF(IfExp_annotations);
2716
0
            return 0;
2717
0
        }
2718
16
    }
2719
16
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2720
16
                                  IfExp_annotations) == 0;
2721
16
    if (!cond) {
2722
0
        Py_DECREF(IfExp_annotations);
2723
0
        return 0;
2724
0
    }
2725
16
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2726
16
                                  IfExp_annotations) == 0;
2727
16
    if (!cond) {
2728
0
        Py_DECREF(IfExp_annotations);
2729
0
        return 0;
2730
0
    }
2731
16
    Py_DECREF(IfExp_annotations);
2732
16
    PyObject *Dict_annotations = PyDict_New();
2733
16
    if (!Dict_annotations) return 0;
2734
16
    {
2735
16
        PyObject *type = state->expr_type;
2736
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2737
16
        cond = type != NULL;
2738
16
        if (!cond) {
2739
0
            Py_DECREF(Dict_annotations);
2740
0
            return 0;
2741
0
        }
2742
16
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2743
16
        Py_DECREF(type);
2744
16
        if (!cond) {
2745
0
            Py_DECREF(Dict_annotations);
2746
0
            return 0;
2747
0
        }
2748
16
    }
2749
16
    {
2750
16
        PyObject *type = state->expr_type;
2751
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2752
16
        cond = type != NULL;
2753
16
        if (!cond) {
2754
0
            Py_DECREF(Dict_annotations);
2755
0
            return 0;
2756
0
        }
2757
16
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2758
16
        Py_DECREF(type);
2759
16
        if (!cond) {
2760
0
            Py_DECREF(Dict_annotations);
2761
0
            return 0;
2762
0
        }
2763
16
    }
2764
16
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2765
16
                                  Dict_annotations) == 0;
2766
16
    if (!cond) {
2767
0
        Py_DECREF(Dict_annotations);
2768
0
        return 0;
2769
0
    }
2770
16
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2771
16
                                  Dict_annotations) == 0;
2772
16
    if (!cond) {
2773
0
        Py_DECREF(Dict_annotations);
2774
0
        return 0;
2775
0
    }
2776
16
    Py_DECREF(Dict_annotations);
2777
16
    PyObject *Set_annotations = PyDict_New();
2778
16
    if (!Set_annotations) return 0;
2779
16
    {
2780
16
        PyObject *type = state->expr_type;
2781
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2782
16
        cond = type != NULL;
2783
16
        if (!cond) {
2784
0
            Py_DECREF(Set_annotations);
2785
0
            return 0;
2786
0
        }
2787
16
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2788
16
        Py_DECREF(type);
2789
16
        if (!cond) {
2790
0
            Py_DECREF(Set_annotations);
2791
0
            return 0;
2792
0
        }
2793
16
    }
2794
16
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2795
16
                                  Set_annotations) == 0;
2796
16
    if (!cond) {
2797
0
        Py_DECREF(Set_annotations);
2798
0
        return 0;
2799
0
    }
2800
16
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2801
16
                                  Set_annotations) == 0;
2802
16
    if (!cond) {
2803
0
        Py_DECREF(Set_annotations);
2804
0
        return 0;
2805
0
    }
2806
16
    Py_DECREF(Set_annotations);
2807
16
    PyObject *ListComp_annotations = PyDict_New();
2808
16
    if (!ListComp_annotations) return 0;
2809
16
    {
2810
16
        PyObject *type = state->expr_type;
2811
16
        Py_INCREF(type);
2812
16
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2813
16
        Py_DECREF(type);
2814
16
        if (!cond) {
2815
0
            Py_DECREF(ListComp_annotations);
2816
0
            return 0;
2817
0
        }
2818
16
    }
2819
16
    {
2820
16
        PyObject *type = state->comprehension_type;
2821
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2822
16
        cond = type != NULL;
2823
16
        if (!cond) {
2824
0
            Py_DECREF(ListComp_annotations);
2825
0
            return 0;
2826
0
        }
2827
16
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2828
16
                                    == 0;
2829
16
        Py_DECREF(type);
2830
16
        if (!cond) {
2831
0
            Py_DECREF(ListComp_annotations);
2832
0
            return 0;
2833
0
        }
2834
16
    }
2835
16
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2836
16
                                  ListComp_annotations) == 0;
2837
16
    if (!cond) {
2838
0
        Py_DECREF(ListComp_annotations);
2839
0
        return 0;
2840
0
    }
2841
16
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2842
16
                                  ListComp_annotations) == 0;
2843
16
    if (!cond) {
2844
0
        Py_DECREF(ListComp_annotations);
2845
0
        return 0;
2846
0
    }
2847
16
    Py_DECREF(ListComp_annotations);
2848
16
    PyObject *SetComp_annotations = PyDict_New();
2849
16
    if (!SetComp_annotations) return 0;
2850
16
    {
2851
16
        PyObject *type = state->expr_type;
2852
16
        Py_INCREF(type);
2853
16
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2854
16
        Py_DECREF(type);
2855
16
        if (!cond) {
2856
0
            Py_DECREF(SetComp_annotations);
2857
0
            return 0;
2858
0
        }
2859
16
    }
2860
16
    {
2861
16
        PyObject *type = state->comprehension_type;
2862
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2863
16
        cond = type != NULL;
2864
16
        if (!cond) {
2865
0
            Py_DECREF(SetComp_annotations);
2866
0
            return 0;
2867
0
        }
2868
16
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2869
16
                                    0;
2870
16
        Py_DECREF(type);
2871
16
        if (!cond) {
2872
0
            Py_DECREF(SetComp_annotations);
2873
0
            return 0;
2874
0
        }
2875
16
    }
2876
16
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2877
16
                                  SetComp_annotations) == 0;
2878
16
    if (!cond) {
2879
0
        Py_DECREF(SetComp_annotations);
2880
0
        return 0;
2881
0
    }
2882
16
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2883
16
                                  SetComp_annotations) == 0;
2884
16
    if (!cond) {
2885
0
        Py_DECREF(SetComp_annotations);
2886
0
        return 0;
2887
0
    }
2888
16
    Py_DECREF(SetComp_annotations);
2889
16
    PyObject *DictComp_annotations = PyDict_New();
2890
16
    if (!DictComp_annotations) return 0;
2891
16
    {
2892
16
        PyObject *type = state->expr_type;
2893
16
        Py_INCREF(type);
2894
16
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2895
16
        Py_DECREF(type);
2896
16
        if (!cond) {
2897
0
            Py_DECREF(DictComp_annotations);
2898
0
            return 0;
2899
0
        }
2900
16
    }
2901
16
    {
2902
16
        PyObject *type = state->expr_type;
2903
16
        type = _Py_union_type_or(type, Py_None);
2904
16
        cond = type != NULL;
2905
16
        if (!cond) {
2906
0
            Py_DECREF(DictComp_annotations);
2907
0
            return 0;
2908
0
        }
2909
16
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2910
16
        Py_DECREF(type);
2911
16
        if (!cond) {
2912
0
            Py_DECREF(DictComp_annotations);
2913
0
            return 0;
2914
0
        }
2915
16
    }
2916
16
    {
2917
16
        PyObject *type = state->comprehension_type;
2918
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2919
16
        cond = type != NULL;
2920
16
        if (!cond) {
2921
0
            Py_DECREF(DictComp_annotations);
2922
0
            return 0;
2923
0
        }
2924
16
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2925
16
                                    == 0;
2926
16
        Py_DECREF(type);
2927
16
        if (!cond) {
2928
0
            Py_DECREF(DictComp_annotations);
2929
0
            return 0;
2930
0
        }
2931
16
    }
2932
16
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2933
16
                                  DictComp_annotations) == 0;
2934
16
    if (!cond) {
2935
0
        Py_DECREF(DictComp_annotations);
2936
0
        return 0;
2937
0
    }
2938
16
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2939
16
                                  DictComp_annotations) == 0;
2940
16
    if (!cond) {
2941
0
        Py_DECREF(DictComp_annotations);
2942
0
        return 0;
2943
0
    }
2944
16
    Py_DECREF(DictComp_annotations);
2945
16
    PyObject *GeneratorExp_annotations = PyDict_New();
2946
16
    if (!GeneratorExp_annotations) return 0;
2947
16
    {
2948
16
        PyObject *type = state->expr_type;
2949
16
        Py_INCREF(type);
2950
16
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2951
16
        Py_DECREF(type);
2952
16
        if (!cond) {
2953
0
            Py_DECREF(GeneratorExp_annotations);
2954
0
            return 0;
2955
0
        }
2956
16
    }
2957
16
    {
2958
16
        PyObject *type = state->comprehension_type;
2959
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2960
16
        cond = type != NULL;
2961
16
        if (!cond) {
2962
0
            Py_DECREF(GeneratorExp_annotations);
2963
0
            return 0;
2964
0
        }
2965
16
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2966
16
                                    type) == 0;
2967
16
        Py_DECREF(type);
2968
16
        if (!cond) {
2969
0
            Py_DECREF(GeneratorExp_annotations);
2970
0
            return 0;
2971
0
        }
2972
16
    }
2973
16
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2974
16
                                  GeneratorExp_annotations) == 0;
2975
16
    if (!cond) {
2976
0
        Py_DECREF(GeneratorExp_annotations);
2977
0
        return 0;
2978
0
    }
2979
16
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2980
16
                                  GeneratorExp_annotations) == 0;
2981
16
    if (!cond) {
2982
0
        Py_DECREF(GeneratorExp_annotations);
2983
0
        return 0;
2984
0
    }
2985
16
    Py_DECREF(GeneratorExp_annotations);
2986
16
    PyObject *Await_annotations = PyDict_New();
2987
16
    if (!Await_annotations) return 0;
2988
16
    {
2989
16
        PyObject *type = state->expr_type;
2990
16
        Py_INCREF(type);
2991
16
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2992
16
        Py_DECREF(type);
2993
16
        if (!cond) {
2994
0
            Py_DECREF(Await_annotations);
2995
0
            return 0;
2996
0
        }
2997
16
    }
2998
16
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2999
16
                                  Await_annotations) == 0;
3000
16
    if (!cond) {
3001
0
        Py_DECREF(Await_annotations);
3002
0
        return 0;
3003
0
    }
3004
16
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
3005
16
                                  Await_annotations) == 0;
3006
16
    if (!cond) {
3007
0
        Py_DECREF(Await_annotations);
3008
0
        return 0;
3009
0
    }
3010
16
    Py_DECREF(Await_annotations);
3011
16
    PyObject *Yield_annotations = PyDict_New();
3012
16
    if (!Yield_annotations) return 0;
3013
16
    {
3014
16
        PyObject *type = state->expr_type;
3015
16
        type = _Py_union_type_or(type, Py_None);
3016
16
        cond = type != NULL;
3017
16
        if (!cond) {
3018
0
            Py_DECREF(Yield_annotations);
3019
0
            return 0;
3020
0
        }
3021
16
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
3022
16
        Py_DECREF(type);
3023
16
        if (!cond) {
3024
0
            Py_DECREF(Yield_annotations);
3025
0
            return 0;
3026
0
        }
3027
16
    }
3028
16
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
3029
16
                                  Yield_annotations) == 0;
3030
16
    if (!cond) {
3031
0
        Py_DECREF(Yield_annotations);
3032
0
        return 0;
3033
0
    }
3034
16
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
3035
16
                                  Yield_annotations) == 0;
3036
16
    if (!cond) {
3037
0
        Py_DECREF(Yield_annotations);
3038
0
        return 0;
3039
0
    }
3040
16
    Py_DECREF(Yield_annotations);
3041
16
    PyObject *YieldFrom_annotations = PyDict_New();
3042
16
    if (!YieldFrom_annotations) return 0;
3043
16
    {
3044
16
        PyObject *type = state->expr_type;
3045
16
        Py_INCREF(type);
3046
16
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3047
16
        Py_DECREF(type);
3048
16
        if (!cond) {
3049
0
            Py_DECREF(YieldFrom_annotations);
3050
0
            return 0;
3051
0
        }
3052
16
    }
3053
16
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3054
16
                                  YieldFrom_annotations) == 0;
3055
16
    if (!cond) {
3056
0
        Py_DECREF(YieldFrom_annotations);
3057
0
        return 0;
3058
0
    }
3059
16
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3060
16
                                  YieldFrom_annotations) == 0;
3061
16
    if (!cond) {
3062
0
        Py_DECREF(YieldFrom_annotations);
3063
0
        return 0;
3064
0
    }
3065
16
    Py_DECREF(YieldFrom_annotations);
3066
16
    PyObject *Compare_annotations = PyDict_New();
3067
16
    if (!Compare_annotations) return 0;
3068
16
    {
3069
16
        PyObject *type = state->expr_type;
3070
16
        Py_INCREF(type);
3071
16
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3072
16
        Py_DECREF(type);
3073
16
        if (!cond) {
3074
0
            Py_DECREF(Compare_annotations);
3075
0
            return 0;
3076
0
        }
3077
16
    }
3078
16
    {
3079
16
        PyObject *type = state->cmpop_type;
3080
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3081
16
        cond = type != NULL;
3082
16
        if (!cond) {
3083
0
            Py_DECREF(Compare_annotations);
3084
0
            return 0;
3085
0
        }
3086
16
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3087
16
        Py_DECREF(type);
3088
16
        if (!cond) {
3089
0
            Py_DECREF(Compare_annotations);
3090
0
            return 0;
3091
0
        }
3092
16
    }
3093
16
    {
3094
16
        PyObject *type = state->expr_type;
3095
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3096
16
        cond = type != NULL;
3097
16
        if (!cond) {
3098
0
            Py_DECREF(Compare_annotations);
3099
0
            return 0;
3100
0
        }
3101
16
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3102
16
                                    == 0;
3103
16
        Py_DECREF(type);
3104
16
        if (!cond) {
3105
0
            Py_DECREF(Compare_annotations);
3106
0
            return 0;
3107
0
        }
3108
16
    }
3109
16
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3110
16
                                  Compare_annotations) == 0;
3111
16
    if (!cond) {
3112
0
        Py_DECREF(Compare_annotations);
3113
0
        return 0;
3114
0
    }
3115
16
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3116
16
                                  Compare_annotations) == 0;
3117
16
    if (!cond) {
3118
0
        Py_DECREF(Compare_annotations);
3119
0
        return 0;
3120
0
    }
3121
16
    Py_DECREF(Compare_annotations);
3122
16
    PyObject *Call_annotations = PyDict_New();
3123
16
    if (!Call_annotations) return 0;
3124
16
    {
3125
16
        PyObject *type = state->expr_type;
3126
16
        Py_INCREF(type);
3127
16
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3128
16
        Py_DECREF(type);
3129
16
        if (!cond) {
3130
0
            Py_DECREF(Call_annotations);
3131
0
            return 0;
3132
0
        }
3133
16
    }
3134
16
    {
3135
16
        PyObject *type = state->expr_type;
3136
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3137
16
        cond = type != NULL;
3138
16
        if (!cond) {
3139
0
            Py_DECREF(Call_annotations);
3140
0
            return 0;
3141
0
        }
3142
16
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3143
16
        Py_DECREF(type);
3144
16
        if (!cond) {
3145
0
            Py_DECREF(Call_annotations);
3146
0
            return 0;
3147
0
        }
3148
16
    }
3149
16
    {
3150
16
        PyObject *type = state->keyword_type;
3151
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3152
16
        cond = type != NULL;
3153
16
        if (!cond) {
3154
0
            Py_DECREF(Call_annotations);
3155
0
            return 0;
3156
0
        }
3157
16
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3158
16
        Py_DECREF(type);
3159
16
        if (!cond) {
3160
0
            Py_DECREF(Call_annotations);
3161
0
            return 0;
3162
0
        }
3163
16
    }
3164
16
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3165
16
                                  Call_annotations) == 0;
3166
16
    if (!cond) {
3167
0
        Py_DECREF(Call_annotations);
3168
0
        return 0;
3169
0
    }
3170
16
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3171
16
                                  Call_annotations) == 0;
3172
16
    if (!cond) {
3173
0
        Py_DECREF(Call_annotations);
3174
0
        return 0;
3175
0
    }
3176
16
    Py_DECREF(Call_annotations);
3177
16
    PyObject *FormattedValue_annotations = PyDict_New();
3178
16
    if (!FormattedValue_annotations) return 0;
3179
16
    {
3180
16
        PyObject *type = state->expr_type;
3181
16
        Py_INCREF(type);
3182
16
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3183
16
                                    == 0;
3184
16
        Py_DECREF(type);
3185
16
        if (!cond) {
3186
0
            Py_DECREF(FormattedValue_annotations);
3187
0
            return 0;
3188
0
        }
3189
16
    }
3190
16
    {
3191
16
        PyObject *type = (PyObject *)&PyLong_Type;
3192
16
        Py_INCREF(type);
3193
16
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3194
16
                                    type) == 0;
3195
16
        Py_DECREF(type);
3196
16
        if (!cond) {
3197
0
            Py_DECREF(FormattedValue_annotations);
3198
0
            return 0;
3199
0
        }
3200
16
    }
3201
16
    {
3202
16
        PyObject *type = state->expr_type;
3203
16
        type = _Py_union_type_or(type, Py_None);
3204
16
        cond = type != NULL;
3205
16
        if (!cond) {
3206
0
            Py_DECREF(FormattedValue_annotations);
3207
0
            return 0;
3208
0
        }
3209
16
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3210
16
                                    type) == 0;
3211
16
        Py_DECREF(type);
3212
16
        if (!cond) {
3213
0
            Py_DECREF(FormattedValue_annotations);
3214
0
            return 0;
3215
0
        }
3216
16
    }
3217
16
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3218
16
                                  FormattedValue_annotations) == 0;
3219
16
    if (!cond) {
3220
0
        Py_DECREF(FormattedValue_annotations);
3221
0
        return 0;
3222
0
    }
3223
16
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3224
16
                                  "__annotations__",
3225
16
                                  FormattedValue_annotations) == 0;
3226
16
    if (!cond) {
3227
0
        Py_DECREF(FormattedValue_annotations);
3228
0
        return 0;
3229
0
    }
3230
16
    Py_DECREF(FormattedValue_annotations);
3231
16
    PyObject *Interpolation_annotations = PyDict_New();
3232
16
    if (!Interpolation_annotations) return 0;
3233
16
    {
3234
16
        PyObject *type = state->expr_type;
3235
16
        Py_INCREF(type);
3236
16
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3237
16
                                    == 0;
3238
16
        Py_DECREF(type);
3239
16
        if (!cond) {
3240
0
            Py_DECREF(Interpolation_annotations);
3241
0
            return 0;
3242
0
        }
3243
16
    }
3244
16
    {
3245
16
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3246
16
        Py_INCREF(type);
3247
16
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3248
16
                                    0;
3249
16
        Py_DECREF(type);
3250
16
        if (!cond) {
3251
0
            Py_DECREF(Interpolation_annotations);
3252
0
            return 0;
3253
0
        }
3254
16
    }
3255
16
    {
3256
16
        PyObject *type = (PyObject *)&PyLong_Type;
3257
16
        Py_INCREF(type);
3258
16
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3259
16
                                    type) == 0;
3260
16
        Py_DECREF(type);
3261
16
        if (!cond) {
3262
0
            Py_DECREF(Interpolation_annotations);
3263
0
            return 0;
3264
0
        }
3265
16
    }
3266
16
    {
3267
16
        PyObject *type = state->expr_type;
3268
16
        type = _Py_union_type_or(type, Py_None);
3269
16
        cond = type != NULL;
3270
16
        if (!cond) {
3271
0
            Py_DECREF(Interpolation_annotations);
3272
0
            return 0;
3273
0
        }
3274
16
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3275
16
                                    type) == 0;
3276
16
        Py_DECREF(type);
3277
16
        if (!cond) {
3278
0
            Py_DECREF(Interpolation_annotations);
3279
0
            return 0;
3280
0
        }
3281
16
    }
3282
16
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3283
16
                                  Interpolation_annotations) == 0;
3284
16
    if (!cond) {
3285
0
        Py_DECREF(Interpolation_annotations);
3286
0
        return 0;
3287
0
    }
3288
16
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3289
16
                                  Interpolation_annotations) == 0;
3290
16
    if (!cond) {
3291
0
        Py_DECREF(Interpolation_annotations);
3292
0
        return 0;
3293
0
    }
3294
16
    Py_DECREF(Interpolation_annotations);
3295
16
    PyObject *JoinedStr_annotations = PyDict_New();
3296
16
    if (!JoinedStr_annotations) return 0;
3297
16
    {
3298
16
        PyObject *type = state->expr_type;
3299
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3300
16
        cond = type != NULL;
3301
16
        if (!cond) {
3302
0
            Py_DECREF(JoinedStr_annotations);
3303
0
            return 0;
3304
0
        }
3305
16
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3306
16
        Py_DECREF(type);
3307
16
        if (!cond) {
3308
0
            Py_DECREF(JoinedStr_annotations);
3309
0
            return 0;
3310
0
        }
3311
16
    }
3312
16
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3313
16
                                  JoinedStr_annotations) == 0;
3314
16
    if (!cond) {
3315
0
        Py_DECREF(JoinedStr_annotations);
3316
0
        return 0;
3317
0
    }
3318
16
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3319
16
                                  JoinedStr_annotations) == 0;
3320
16
    if (!cond) {
3321
0
        Py_DECREF(JoinedStr_annotations);
3322
0
        return 0;
3323
0
    }
3324
16
    Py_DECREF(JoinedStr_annotations);
3325
16
    PyObject *TemplateStr_annotations = PyDict_New();
3326
16
    if (!TemplateStr_annotations) return 0;
3327
16
    {
3328
16
        PyObject *type = state->expr_type;
3329
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3330
16
        cond = type != NULL;
3331
16
        if (!cond) {
3332
0
            Py_DECREF(TemplateStr_annotations);
3333
0
            return 0;
3334
0
        }
3335
16
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3336
16
                                    0;
3337
16
        Py_DECREF(type);
3338
16
        if (!cond) {
3339
0
            Py_DECREF(TemplateStr_annotations);
3340
0
            return 0;
3341
0
        }
3342
16
    }
3343
16
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3344
16
                                  TemplateStr_annotations) == 0;
3345
16
    if (!cond) {
3346
0
        Py_DECREF(TemplateStr_annotations);
3347
0
        return 0;
3348
0
    }
3349
16
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3350
16
                                  TemplateStr_annotations) == 0;
3351
16
    if (!cond) {
3352
0
        Py_DECREF(TemplateStr_annotations);
3353
0
        return 0;
3354
0
    }
3355
16
    Py_DECREF(TemplateStr_annotations);
3356
16
    PyObject *Constant_annotations = PyDict_New();
3357
16
    if (!Constant_annotations) return 0;
3358
16
    {
3359
16
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3360
16
        Py_INCREF(type);
3361
16
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3362
16
        Py_DECREF(type);
3363
16
        if (!cond) {
3364
0
            Py_DECREF(Constant_annotations);
3365
0
            return 0;
3366
0
        }
3367
16
    }
3368
16
    {
3369
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
3370
16
        type = _Py_union_type_or(type, Py_None);
3371
16
        cond = type != NULL;
3372
16
        if (!cond) {
3373
0
            Py_DECREF(Constant_annotations);
3374
0
            return 0;
3375
0
        }
3376
16
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3377
16
        Py_DECREF(type);
3378
16
        if (!cond) {
3379
0
            Py_DECREF(Constant_annotations);
3380
0
            return 0;
3381
0
        }
3382
16
    }
3383
16
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3384
16
                                  Constant_annotations) == 0;
3385
16
    if (!cond) {
3386
0
        Py_DECREF(Constant_annotations);
3387
0
        return 0;
3388
0
    }
3389
16
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3390
16
                                  Constant_annotations) == 0;
3391
16
    if (!cond) {
3392
0
        Py_DECREF(Constant_annotations);
3393
0
        return 0;
3394
0
    }
3395
16
    Py_DECREF(Constant_annotations);
3396
16
    PyObject *Attribute_annotations = PyDict_New();
3397
16
    if (!Attribute_annotations) return 0;
3398
16
    {
3399
16
        PyObject *type = state->expr_type;
3400
16
        Py_INCREF(type);
3401
16
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3402
16
        Py_DECREF(type);
3403
16
        if (!cond) {
3404
0
            Py_DECREF(Attribute_annotations);
3405
0
            return 0;
3406
0
        }
3407
16
    }
3408
16
    {
3409
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
3410
16
        Py_INCREF(type);
3411
16
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3412
16
        Py_DECREF(type);
3413
16
        if (!cond) {
3414
0
            Py_DECREF(Attribute_annotations);
3415
0
            return 0;
3416
0
        }
3417
16
    }
3418
16
    {
3419
16
        PyObject *type = state->expr_context_type;
3420
16
        Py_INCREF(type);
3421
16
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3422
16
        Py_DECREF(type);
3423
16
        if (!cond) {
3424
0
            Py_DECREF(Attribute_annotations);
3425
0
            return 0;
3426
0
        }
3427
16
    }
3428
16
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3429
16
                                  Attribute_annotations) == 0;
3430
16
    if (!cond) {
3431
0
        Py_DECREF(Attribute_annotations);
3432
0
        return 0;
3433
0
    }
3434
16
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3435
16
                                  Attribute_annotations) == 0;
3436
16
    if (!cond) {
3437
0
        Py_DECREF(Attribute_annotations);
3438
0
        return 0;
3439
0
    }
3440
16
    Py_DECREF(Attribute_annotations);
3441
16
    PyObject *Subscript_annotations = PyDict_New();
3442
16
    if (!Subscript_annotations) return 0;
3443
16
    {
3444
16
        PyObject *type = state->expr_type;
3445
16
        Py_INCREF(type);
3446
16
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3447
16
        Py_DECREF(type);
3448
16
        if (!cond) {
3449
0
            Py_DECREF(Subscript_annotations);
3450
0
            return 0;
3451
0
        }
3452
16
    }
3453
16
    {
3454
16
        PyObject *type = state->expr_type;
3455
16
        Py_INCREF(type);
3456
16
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3457
16
        Py_DECREF(type);
3458
16
        if (!cond) {
3459
0
            Py_DECREF(Subscript_annotations);
3460
0
            return 0;
3461
0
        }
3462
16
    }
3463
16
    {
3464
16
        PyObject *type = state->expr_context_type;
3465
16
        Py_INCREF(type);
3466
16
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3467
16
        Py_DECREF(type);
3468
16
        if (!cond) {
3469
0
            Py_DECREF(Subscript_annotations);
3470
0
            return 0;
3471
0
        }
3472
16
    }
3473
16
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3474
16
                                  Subscript_annotations) == 0;
3475
16
    if (!cond) {
3476
0
        Py_DECREF(Subscript_annotations);
3477
0
        return 0;
3478
0
    }
3479
16
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3480
16
                                  Subscript_annotations) == 0;
3481
16
    if (!cond) {
3482
0
        Py_DECREF(Subscript_annotations);
3483
0
        return 0;
3484
0
    }
3485
16
    Py_DECREF(Subscript_annotations);
3486
16
    PyObject *Starred_annotations = PyDict_New();
3487
16
    if (!Starred_annotations) return 0;
3488
16
    {
3489
16
        PyObject *type = state->expr_type;
3490
16
        Py_INCREF(type);
3491
16
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3492
16
        Py_DECREF(type);
3493
16
        if (!cond) {
3494
0
            Py_DECREF(Starred_annotations);
3495
0
            return 0;
3496
0
        }
3497
16
    }
3498
16
    {
3499
16
        PyObject *type = state->expr_context_type;
3500
16
        Py_INCREF(type);
3501
16
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3502
16
        Py_DECREF(type);
3503
16
        if (!cond) {
3504
0
            Py_DECREF(Starred_annotations);
3505
0
            return 0;
3506
0
        }
3507
16
    }
3508
16
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3509
16
                                  Starred_annotations) == 0;
3510
16
    if (!cond) {
3511
0
        Py_DECREF(Starred_annotations);
3512
0
        return 0;
3513
0
    }
3514
16
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3515
16
                                  Starred_annotations) == 0;
3516
16
    if (!cond) {
3517
0
        Py_DECREF(Starred_annotations);
3518
0
        return 0;
3519
0
    }
3520
16
    Py_DECREF(Starred_annotations);
3521
16
    PyObject *Name_annotations = PyDict_New();
3522
16
    if (!Name_annotations) return 0;
3523
16
    {
3524
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
3525
16
        Py_INCREF(type);
3526
16
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3527
16
        Py_DECREF(type);
3528
16
        if (!cond) {
3529
0
            Py_DECREF(Name_annotations);
3530
0
            return 0;
3531
0
        }
3532
16
    }
3533
16
    {
3534
16
        PyObject *type = state->expr_context_type;
3535
16
        Py_INCREF(type);
3536
16
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3537
16
        Py_DECREF(type);
3538
16
        if (!cond) {
3539
0
            Py_DECREF(Name_annotations);
3540
0
            return 0;
3541
0
        }
3542
16
    }
3543
16
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3544
16
                                  Name_annotations) == 0;
3545
16
    if (!cond) {
3546
0
        Py_DECREF(Name_annotations);
3547
0
        return 0;
3548
0
    }
3549
16
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3550
16
                                  Name_annotations) == 0;
3551
16
    if (!cond) {
3552
0
        Py_DECREF(Name_annotations);
3553
0
        return 0;
3554
0
    }
3555
16
    Py_DECREF(Name_annotations);
3556
16
    PyObject *List_annotations = PyDict_New();
3557
16
    if (!List_annotations) return 0;
3558
16
    {
3559
16
        PyObject *type = state->expr_type;
3560
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3561
16
        cond = type != NULL;
3562
16
        if (!cond) {
3563
0
            Py_DECREF(List_annotations);
3564
0
            return 0;
3565
0
        }
3566
16
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3567
16
        Py_DECREF(type);
3568
16
        if (!cond) {
3569
0
            Py_DECREF(List_annotations);
3570
0
            return 0;
3571
0
        }
3572
16
    }
3573
16
    {
3574
16
        PyObject *type = state->expr_context_type;
3575
16
        Py_INCREF(type);
3576
16
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3577
16
        Py_DECREF(type);
3578
16
        if (!cond) {
3579
0
            Py_DECREF(List_annotations);
3580
0
            return 0;
3581
0
        }
3582
16
    }
3583
16
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3584
16
                                  List_annotations) == 0;
3585
16
    if (!cond) {
3586
0
        Py_DECREF(List_annotations);
3587
0
        return 0;
3588
0
    }
3589
16
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3590
16
                                  List_annotations) == 0;
3591
16
    if (!cond) {
3592
0
        Py_DECREF(List_annotations);
3593
0
        return 0;
3594
0
    }
3595
16
    Py_DECREF(List_annotations);
3596
16
    PyObject *Tuple_annotations = PyDict_New();
3597
16
    if (!Tuple_annotations) return 0;
3598
16
    {
3599
16
        PyObject *type = state->expr_type;
3600
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3601
16
        cond = type != NULL;
3602
16
        if (!cond) {
3603
0
            Py_DECREF(Tuple_annotations);
3604
0
            return 0;
3605
0
        }
3606
16
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3607
16
        Py_DECREF(type);
3608
16
        if (!cond) {
3609
0
            Py_DECREF(Tuple_annotations);
3610
0
            return 0;
3611
0
        }
3612
16
    }
3613
16
    {
3614
16
        PyObject *type = state->expr_context_type;
3615
16
        Py_INCREF(type);
3616
16
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3617
16
        Py_DECREF(type);
3618
16
        if (!cond) {
3619
0
            Py_DECREF(Tuple_annotations);
3620
0
            return 0;
3621
0
        }
3622
16
    }
3623
16
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3624
16
                                  Tuple_annotations) == 0;
3625
16
    if (!cond) {
3626
0
        Py_DECREF(Tuple_annotations);
3627
0
        return 0;
3628
0
    }
3629
16
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3630
16
                                  Tuple_annotations) == 0;
3631
16
    if (!cond) {
3632
0
        Py_DECREF(Tuple_annotations);
3633
0
        return 0;
3634
0
    }
3635
16
    Py_DECREF(Tuple_annotations);
3636
16
    PyObject *Slice_annotations = PyDict_New();
3637
16
    if (!Slice_annotations) return 0;
3638
16
    {
3639
16
        PyObject *type = state->expr_type;
3640
16
        type = _Py_union_type_or(type, Py_None);
3641
16
        cond = type != NULL;
3642
16
        if (!cond) {
3643
0
            Py_DECREF(Slice_annotations);
3644
0
            return 0;
3645
0
        }
3646
16
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3647
16
        Py_DECREF(type);
3648
16
        if (!cond) {
3649
0
            Py_DECREF(Slice_annotations);
3650
0
            return 0;
3651
0
        }
3652
16
    }
3653
16
    {
3654
16
        PyObject *type = state->expr_type;
3655
16
        type = _Py_union_type_or(type, Py_None);
3656
16
        cond = type != NULL;
3657
16
        if (!cond) {
3658
0
            Py_DECREF(Slice_annotations);
3659
0
            return 0;
3660
0
        }
3661
16
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3662
16
        Py_DECREF(type);
3663
16
        if (!cond) {
3664
0
            Py_DECREF(Slice_annotations);
3665
0
            return 0;
3666
0
        }
3667
16
    }
3668
16
    {
3669
16
        PyObject *type = state->expr_type;
3670
16
        type = _Py_union_type_or(type, Py_None);
3671
16
        cond = type != NULL;
3672
16
        if (!cond) {
3673
0
            Py_DECREF(Slice_annotations);
3674
0
            return 0;
3675
0
        }
3676
16
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3677
16
        Py_DECREF(type);
3678
16
        if (!cond) {
3679
0
            Py_DECREF(Slice_annotations);
3680
0
            return 0;
3681
0
        }
3682
16
    }
3683
16
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3684
16
                                  Slice_annotations) == 0;
3685
16
    if (!cond) {
3686
0
        Py_DECREF(Slice_annotations);
3687
0
        return 0;
3688
0
    }
3689
16
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3690
16
                                  Slice_annotations) == 0;
3691
16
    if (!cond) {
3692
0
        Py_DECREF(Slice_annotations);
3693
0
        return 0;
3694
0
    }
3695
16
    Py_DECREF(Slice_annotations);
3696
16
    PyObject *Load_annotations = PyDict_New();
3697
16
    if (!Load_annotations) return 0;
3698
16
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3699
16
                                  Load_annotations) == 0;
3700
16
    if (!cond) {
3701
0
        Py_DECREF(Load_annotations);
3702
0
        return 0;
3703
0
    }
3704
16
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3705
16
                                  Load_annotations) == 0;
3706
16
    if (!cond) {
3707
0
        Py_DECREF(Load_annotations);
3708
0
        return 0;
3709
0
    }
3710
16
    Py_DECREF(Load_annotations);
3711
16
    PyObject *Store_annotations = PyDict_New();
3712
16
    if (!Store_annotations) return 0;
3713
16
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3714
16
                                  Store_annotations) == 0;
3715
16
    if (!cond) {
3716
0
        Py_DECREF(Store_annotations);
3717
0
        return 0;
3718
0
    }
3719
16
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3720
16
                                  Store_annotations) == 0;
3721
16
    if (!cond) {
3722
0
        Py_DECREF(Store_annotations);
3723
0
        return 0;
3724
0
    }
3725
16
    Py_DECREF(Store_annotations);
3726
16
    PyObject *Del_annotations = PyDict_New();
3727
16
    if (!Del_annotations) return 0;
3728
16
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3729
16
                                  Del_annotations) == 0;
3730
16
    if (!cond) {
3731
0
        Py_DECREF(Del_annotations);
3732
0
        return 0;
3733
0
    }
3734
16
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3735
16
                                  Del_annotations) == 0;
3736
16
    if (!cond) {
3737
0
        Py_DECREF(Del_annotations);
3738
0
        return 0;
3739
0
    }
3740
16
    Py_DECREF(Del_annotations);
3741
16
    PyObject *And_annotations = PyDict_New();
3742
16
    if (!And_annotations) return 0;
3743
16
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3744
16
                                  And_annotations) == 0;
3745
16
    if (!cond) {
3746
0
        Py_DECREF(And_annotations);
3747
0
        return 0;
3748
0
    }
3749
16
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3750
16
                                  And_annotations) == 0;
3751
16
    if (!cond) {
3752
0
        Py_DECREF(And_annotations);
3753
0
        return 0;
3754
0
    }
3755
16
    Py_DECREF(And_annotations);
3756
16
    PyObject *Or_annotations = PyDict_New();
3757
16
    if (!Or_annotations) return 0;
3758
16
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3759
16
                                  Or_annotations) == 0;
3760
16
    if (!cond) {
3761
0
        Py_DECREF(Or_annotations);
3762
0
        return 0;
3763
0
    }
3764
16
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3765
16
                                  Or_annotations) == 0;
3766
16
    if (!cond) {
3767
0
        Py_DECREF(Or_annotations);
3768
0
        return 0;
3769
0
    }
3770
16
    Py_DECREF(Or_annotations);
3771
16
    PyObject *Add_annotations = PyDict_New();
3772
16
    if (!Add_annotations) return 0;
3773
16
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3774
16
                                  Add_annotations) == 0;
3775
16
    if (!cond) {
3776
0
        Py_DECREF(Add_annotations);
3777
0
        return 0;
3778
0
    }
3779
16
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3780
16
                                  Add_annotations) == 0;
3781
16
    if (!cond) {
3782
0
        Py_DECREF(Add_annotations);
3783
0
        return 0;
3784
0
    }
3785
16
    Py_DECREF(Add_annotations);
3786
16
    PyObject *Sub_annotations = PyDict_New();
3787
16
    if (!Sub_annotations) return 0;
3788
16
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3789
16
                                  Sub_annotations) == 0;
3790
16
    if (!cond) {
3791
0
        Py_DECREF(Sub_annotations);
3792
0
        return 0;
3793
0
    }
3794
16
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3795
16
                                  Sub_annotations) == 0;
3796
16
    if (!cond) {
3797
0
        Py_DECREF(Sub_annotations);
3798
0
        return 0;
3799
0
    }
3800
16
    Py_DECREF(Sub_annotations);
3801
16
    PyObject *Mult_annotations = PyDict_New();
3802
16
    if (!Mult_annotations) return 0;
3803
16
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3804
16
                                  Mult_annotations) == 0;
3805
16
    if (!cond) {
3806
0
        Py_DECREF(Mult_annotations);
3807
0
        return 0;
3808
0
    }
3809
16
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3810
16
                                  Mult_annotations) == 0;
3811
16
    if (!cond) {
3812
0
        Py_DECREF(Mult_annotations);
3813
0
        return 0;
3814
0
    }
3815
16
    Py_DECREF(Mult_annotations);
3816
16
    PyObject *MatMult_annotations = PyDict_New();
3817
16
    if (!MatMult_annotations) return 0;
3818
16
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3819
16
                                  MatMult_annotations) == 0;
3820
16
    if (!cond) {
3821
0
        Py_DECREF(MatMult_annotations);
3822
0
        return 0;
3823
0
    }
3824
16
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3825
16
                                  MatMult_annotations) == 0;
3826
16
    if (!cond) {
3827
0
        Py_DECREF(MatMult_annotations);
3828
0
        return 0;
3829
0
    }
3830
16
    Py_DECREF(MatMult_annotations);
3831
16
    PyObject *Div_annotations = PyDict_New();
3832
16
    if (!Div_annotations) return 0;
3833
16
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3834
16
                                  Div_annotations) == 0;
3835
16
    if (!cond) {
3836
0
        Py_DECREF(Div_annotations);
3837
0
        return 0;
3838
0
    }
3839
16
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3840
16
                                  Div_annotations) == 0;
3841
16
    if (!cond) {
3842
0
        Py_DECREF(Div_annotations);
3843
0
        return 0;
3844
0
    }
3845
16
    Py_DECREF(Div_annotations);
3846
16
    PyObject *Mod_annotations = PyDict_New();
3847
16
    if (!Mod_annotations) return 0;
3848
16
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3849
16
                                  Mod_annotations) == 0;
3850
16
    if (!cond) {
3851
0
        Py_DECREF(Mod_annotations);
3852
0
        return 0;
3853
0
    }
3854
16
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3855
16
                                  Mod_annotations) == 0;
3856
16
    if (!cond) {
3857
0
        Py_DECREF(Mod_annotations);
3858
0
        return 0;
3859
0
    }
3860
16
    Py_DECREF(Mod_annotations);
3861
16
    PyObject *Pow_annotations = PyDict_New();
3862
16
    if (!Pow_annotations) return 0;
3863
16
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3864
16
                                  Pow_annotations) == 0;
3865
16
    if (!cond) {
3866
0
        Py_DECREF(Pow_annotations);
3867
0
        return 0;
3868
0
    }
3869
16
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3870
16
                                  Pow_annotations) == 0;
3871
16
    if (!cond) {
3872
0
        Py_DECREF(Pow_annotations);
3873
0
        return 0;
3874
0
    }
3875
16
    Py_DECREF(Pow_annotations);
3876
16
    PyObject *LShift_annotations = PyDict_New();
3877
16
    if (!LShift_annotations) return 0;
3878
16
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3879
16
                                  LShift_annotations) == 0;
3880
16
    if (!cond) {
3881
0
        Py_DECREF(LShift_annotations);
3882
0
        return 0;
3883
0
    }
3884
16
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3885
16
                                  LShift_annotations) == 0;
3886
16
    if (!cond) {
3887
0
        Py_DECREF(LShift_annotations);
3888
0
        return 0;
3889
0
    }
3890
16
    Py_DECREF(LShift_annotations);
3891
16
    PyObject *RShift_annotations = PyDict_New();
3892
16
    if (!RShift_annotations) return 0;
3893
16
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3894
16
                                  RShift_annotations) == 0;
3895
16
    if (!cond) {
3896
0
        Py_DECREF(RShift_annotations);
3897
0
        return 0;
3898
0
    }
3899
16
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3900
16
                                  RShift_annotations) == 0;
3901
16
    if (!cond) {
3902
0
        Py_DECREF(RShift_annotations);
3903
0
        return 0;
3904
0
    }
3905
16
    Py_DECREF(RShift_annotations);
3906
16
    PyObject *BitOr_annotations = PyDict_New();
3907
16
    if (!BitOr_annotations) return 0;
3908
16
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3909
16
                                  BitOr_annotations) == 0;
3910
16
    if (!cond) {
3911
0
        Py_DECREF(BitOr_annotations);
3912
0
        return 0;
3913
0
    }
3914
16
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3915
16
                                  BitOr_annotations) == 0;
3916
16
    if (!cond) {
3917
0
        Py_DECREF(BitOr_annotations);
3918
0
        return 0;
3919
0
    }
3920
16
    Py_DECREF(BitOr_annotations);
3921
16
    PyObject *BitXor_annotations = PyDict_New();
3922
16
    if (!BitXor_annotations) return 0;
3923
16
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3924
16
                                  BitXor_annotations) == 0;
3925
16
    if (!cond) {
3926
0
        Py_DECREF(BitXor_annotations);
3927
0
        return 0;
3928
0
    }
3929
16
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3930
16
                                  BitXor_annotations) == 0;
3931
16
    if (!cond) {
3932
0
        Py_DECREF(BitXor_annotations);
3933
0
        return 0;
3934
0
    }
3935
16
    Py_DECREF(BitXor_annotations);
3936
16
    PyObject *BitAnd_annotations = PyDict_New();
3937
16
    if (!BitAnd_annotations) return 0;
3938
16
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3939
16
                                  BitAnd_annotations) == 0;
3940
16
    if (!cond) {
3941
0
        Py_DECREF(BitAnd_annotations);
3942
0
        return 0;
3943
0
    }
3944
16
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3945
16
                                  BitAnd_annotations) == 0;
3946
16
    if (!cond) {
3947
0
        Py_DECREF(BitAnd_annotations);
3948
0
        return 0;
3949
0
    }
3950
16
    Py_DECREF(BitAnd_annotations);
3951
16
    PyObject *FloorDiv_annotations = PyDict_New();
3952
16
    if (!FloorDiv_annotations) return 0;
3953
16
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3954
16
                                  FloorDiv_annotations) == 0;
3955
16
    if (!cond) {
3956
0
        Py_DECREF(FloorDiv_annotations);
3957
0
        return 0;
3958
0
    }
3959
16
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3960
16
                                  FloorDiv_annotations) == 0;
3961
16
    if (!cond) {
3962
0
        Py_DECREF(FloorDiv_annotations);
3963
0
        return 0;
3964
0
    }
3965
16
    Py_DECREF(FloorDiv_annotations);
3966
16
    PyObject *Invert_annotations = PyDict_New();
3967
16
    if (!Invert_annotations) return 0;
3968
16
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3969
16
                                  Invert_annotations) == 0;
3970
16
    if (!cond) {
3971
0
        Py_DECREF(Invert_annotations);
3972
0
        return 0;
3973
0
    }
3974
16
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3975
16
                                  Invert_annotations) == 0;
3976
16
    if (!cond) {
3977
0
        Py_DECREF(Invert_annotations);
3978
0
        return 0;
3979
0
    }
3980
16
    Py_DECREF(Invert_annotations);
3981
16
    PyObject *Not_annotations = PyDict_New();
3982
16
    if (!Not_annotations) return 0;
3983
16
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3984
16
                                  Not_annotations) == 0;
3985
16
    if (!cond) {
3986
0
        Py_DECREF(Not_annotations);
3987
0
        return 0;
3988
0
    }
3989
16
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3990
16
                                  Not_annotations) == 0;
3991
16
    if (!cond) {
3992
0
        Py_DECREF(Not_annotations);
3993
0
        return 0;
3994
0
    }
3995
16
    Py_DECREF(Not_annotations);
3996
16
    PyObject *UAdd_annotations = PyDict_New();
3997
16
    if (!UAdd_annotations) return 0;
3998
16
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3999
16
                                  UAdd_annotations) == 0;
4000
16
    if (!cond) {
4001
0
        Py_DECREF(UAdd_annotations);
4002
0
        return 0;
4003
0
    }
4004
16
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
4005
16
                                  UAdd_annotations) == 0;
4006
16
    if (!cond) {
4007
0
        Py_DECREF(UAdd_annotations);
4008
0
        return 0;
4009
0
    }
4010
16
    Py_DECREF(UAdd_annotations);
4011
16
    PyObject *USub_annotations = PyDict_New();
4012
16
    if (!USub_annotations) return 0;
4013
16
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
4014
16
                                  USub_annotations) == 0;
4015
16
    if (!cond) {
4016
0
        Py_DECREF(USub_annotations);
4017
0
        return 0;
4018
0
    }
4019
16
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
4020
16
                                  USub_annotations) == 0;
4021
16
    if (!cond) {
4022
0
        Py_DECREF(USub_annotations);
4023
0
        return 0;
4024
0
    }
4025
16
    Py_DECREF(USub_annotations);
4026
16
    PyObject *Eq_annotations = PyDict_New();
4027
16
    if (!Eq_annotations) return 0;
4028
16
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
4029
16
                                  Eq_annotations) == 0;
4030
16
    if (!cond) {
4031
0
        Py_DECREF(Eq_annotations);
4032
0
        return 0;
4033
0
    }
4034
16
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
4035
16
                                  Eq_annotations) == 0;
4036
16
    if (!cond) {
4037
0
        Py_DECREF(Eq_annotations);
4038
0
        return 0;
4039
0
    }
4040
16
    Py_DECREF(Eq_annotations);
4041
16
    PyObject *NotEq_annotations = PyDict_New();
4042
16
    if (!NotEq_annotations) return 0;
4043
16
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4044
16
                                  NotEq_annotations) == 0;
4045
16
    if (!cond) {
4046
0
        Py_DECREF(NotEq_annotations);
4047
0
        return 0;
4048
0
    }
4049
16
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4050
16
                                  NotEq_annotations) == 0;
4051
16
    if (!cond) {
4052
0
        Py_DECREF(NotEq_annotations);
4053
0
        return 0;
4054
0
    }
4055
16
    Py_DECREF(NotEq_annotations);
4056
16
    PyObject *Lt_annotations = PyDict_New();
4057
16
    if (!Lt_annotations) return 0;
4058
16
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4059
16
                                  Lt_annotations) == 0;
4060
16
    if (!cond) {
4061
0
        Py_DECREF(Lt_annotations);
4062
0
        return 0;
4063
0
    }
4064
16
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4065
16
                                  Lt_annotations) == 0;
4066
16
    if (!cond) {
4067
0
        Py_DECREF(Lt_annotations);
4068
0
        return 0;
4069
0
    }
4070
16
    Py_DECREF(Lt_annotations);
4071
16
    PyObject *LtE_annotations = PyDict_New();
4072
16
    if (!LtE_annotations) return 0;
4073
16
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4074
16
                                  LtE_annotations) == 0;
4075
16
    if (!cond) {
4076
0
        Py_DECREF(LtE_annotations);
4077
0
        return 0;
4078
0
    }
4079
16
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4080
16
                                  LtE_annotations) == 0;
4081
16
    if (!cond) {
4082
0
        Py_DECREF(LtE_annotations);
4083
0
        return 0;
4084
0
    }
4085
16
    Py_DECREF(LtE_annotations);
4086
16
    PyObject *Gt_annotations = PyDict_New();
4087
16
    if (!Gt_annotations) return 0;
4088
16
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4089
16
                                  Gt_annotations) == 0;
4090
16
    if (!cond) {
4091
0
        Py_DECREF(Gt_annotations);
4092
0
        return 0;
4093
0
    }
4094
16
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4095
16
                                  Gt_annotations) == 0;
4096
16
    if (!cond) {
4097
0
        Py_DECREF(Gt_annotations);
4098
0
        return 0;
4099
0
    }
4100
16
    Py_DECREF(Gt_annotations);
4101
16
    PyObject *GtE_annotations = PyDict_New();
4102
16
    if (!GtE_annotations) return 0;
4103
16
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4104
16
                                  GtE_annotations) == 0;
4105
16
    if (!cond) {
4106
0
        Py_DECREF(GtE_annotations);
4107
0
        return 0;
4108
0
    }
4109
16
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4110
16
                                  GtE_annotations) == 0;
4111
16
    if (!cond) {
4112
0
        Py_DECREF(GtE_annotations);
4113
0
        return 0;
4114
0
    }
4115
16
    Py_DECREF(GtE_annotations);
4116
16
    PyObject *Is_annotations = PyDict_New();
4117
16
    if (!Is_annotations) return 0;
4118
16
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4119
16
                                  Is_annotations) == 0;
4120
16
    if (!cond) {
4121
0
        Py_DECREF(Is_annotations);
4122
0
        return 0;
4123
0
    }
4124
16
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4125
16
                                  Is_annotations) == 0;
4126
16
    if (!cond) {
4127
0
        Py_DECREF(Is_annotations);
4128
0
        return 0;
4129
0
    }
4130
16
    Py_DECREF(Is_annotations);
4131
16
    PyObject *IsNot_annotations = PyDict_New();
4132
16
    if (!IsNot_annotations) return 0;
4133
16
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4134
16
                                  IsNot_annotations) == 0;
4135
16
    if (!cond) {
4136
0
        Py_DECREF(IsNot_annotations);
4137
0
        return 0;
4138
0
    }
4139
16
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4140
16
                                  IsNot_annotations) == 0;
4141
16
    if (!cond) {
4142
0
        Py_DECREF(IsNot_annotations);
4143
0
        return 0;
4144
0
    }
4145
16
    Py_DECREF(IsNot_annotations);
4146
16
    PyObject *In_annotations = PyDict_New();
4147
16
    if (!In_annotations) return 0;
4148
16
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4149
16
                                  In_annotations) == 0;
4150
16
    if (!cond) {
4151
0
        Py_DECREF(In_annotations);
4152
0
        return 0;
4153
0
    }
4154
16
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4155
16
                                  In_annotations) == 0;
4156
16
    if (!cond) {
4157
0
        Py_DECREF(In_annotations);
4158
0
        return 0;
4159
0
    }
4160
16
    Py_DECREF(In_annotations);
4161
16
    PyObject *NotIn_annotations = PyDict_New();
4162
16
    if (!NotIn_annotations) return 0;
4163
16
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4164
16
                                  NotIn_annotations) == 0;
4165
16
    if (!cond) {
4166
0
        Py_DECREF(NotIn_annotations);
4167
0
        return 0;
4168
0
    }
4169
16
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4170
16
                                  NotIn_annotations) == 0;
4171
16
    if (!cond) {
4172
0
        Py_DECREF(NotIn_annotations);
4173
0
        return 0;
4174
0
    }
4175
16
    Py_DECREF(NotIn_annotations);
4176
16
    PyObject *comprehension_annotations = PyDict_New();
4177
16
    if (!comprehension_annotations) return 0;
4178
16
    {
4179
16
        PyObject *type = state->expr_type;
4180
16
        Py_INCREF(type);
4181
16
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4182
16
                                    == 0;
4183
16
        Py_DECREF(type);
4184
16
        if (!cond) {
4185
0
            Py_DECREF(comprehension_annotations);
4186
0
            return 0;
4187
0
        }
4188
16
    }
4189
16
    {
4190
16
        PyObject *type = state->expr_type;
4191
16
        Py_INCREF(type);
4192
16
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4193
16
                                    0;
4194
16
        Py_DECREF(type);
4195
16
        if (!cond) {
4196
0
            Py_DECREF(comprehension_annotations);
4197
0
            return 0;
4198
0
        }
4199
16
    }
4200
16
    {
4201
16
        PyObject *type = state->expr_type;
4202
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4203
16
        cond = type != NULL;
4204
16
        if (!cond) {
4205
0
            Py_DECREF(comprehension_annotations);
4206
0
            return 0;
4207
0
        }
4208
16
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4209
16
                                    0;
4210
16
        Py_DECREF(type);
4211
16
        if (!cond) {
4212
0
            Py_DECREF(comprehension_annotations);
4213
0
            return 0;
4214
0
        }
4215
16
    }
4216
16
    {
4217
16
        PyObject *type = (PyObject *)&PyLong_Type;
4218
16
        Py_INCREF(type);
4219
16
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4220
16
                                    type) == 0;
4221
16
        Py_DECREF(type);
4222
16
        if (!cond) {
4223
0
            Py_DECREF(comprehension_annotations);
4224
0
            return 0;
4225
0
        }
4226
16
    }
4227
16
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4228
16
                                  comprehension_annotations) == 0;
4229
16
    if (!cond) {
4230
0
        Py_DECREF(comprehension_annotations);
4231
0
        return 0;
4232
0
    }
4233
16
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4234
16
                                  comprehension_annotations) == 0;
4235
16
    if (!cond) {
4236
0
        Py_DECREF(comprehension_annotations);
4237
0
        return 0;
4238
0
    }
4239
16
    Py_DECREF(comprehension_annotations);
4240
16
    PyObject *ExceptHandler_annotations = PyDict_New();
4241
16
    if (!ExceptHandler_annotations) return 0;
4242
16
    {
4243
16
        PyObject *type = state->expr_type;
4244
16
        type = _Py_union_type_or(type, Py_None);
4245
16
        cond = type != NULL;
4246
16
        if (!cond) {
4247
0
            Py_DECREF(ExceptHandler_annotations);
4248
0
            return 0;
4249
0
        }
4250
16
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4251
16
                                    0;
4252
16
        Py_DECREF(type);
4253
16
        if (!cond) {
4254
0
            Py_DECREF(ExceptHandler_annotations);
4255
0
            return 0;
4256
0
        }
4257
16
    }
4258
16
    {
4259
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4260
16
        type = _Py_union_type_or(type, Py_None);
4261
16
        cond = type != NULL;
4262
16
        if (!cond) {
4263
0
            Py_DECREF(ExceptHandler_annotations);
4264
0
            return 0;
4265
0
        }
4266
16
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4267
16
                                    0;
4268
16
        Py_DECREF(type);
4269
16
        if (!cond) {
4270
0
            Py_DECREF(ExceptHandler_annotations);
4271
0
            return 0;
4272
0
        }
4273
16
    }
4274
16
    {
4275
16
        PyObject *type = state->stmt_type;
4276
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4277
16
        cond = type != NULL;
4278
16
        if (!cond) {
4279
0
            Py_DECREF(ExceptHandler_annotations);
4280
0
            return 0;
4281
0
        }
4282
16
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4283
16
                                    0;
4284
16
        Py_DECREF(type);
4285
16
        if (!cond) {
4286
0
            Py_DECREF(ExceptHandler_annotations);
4287
0
            return 0;
4288
0
        }
4289
16
    }
4290
16
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4291
16
                                  ExceptHandler_annotations) == 0;
4292
16
    if (!cond) {
4293
0
        Py_DECREF(ExceptHandler_annotations);
4294
0
        return 0;
4295
0
    }
4296
16
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4297
16
                                  ExceptHandler_annotations) == 0;
4298
16
    if (!cond) {
4299
0
        Py_DECREF(ExceptHandler_annotations);
4300
0
        return 0;
4301
0
    }
4302
16
    Py_DECREF(ExceptHandler_annotations);
4303
16
    PyObject *arguments_annotations = PyDict_New();
4304
16
    if (!arguments_annotations) return 0;
4305
16
    {
4306
16
        PyObject *type = state->arg_type;
4307
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4308
16
        cond = type != NULL;
4309
16
        if (!cond) {
4310
0
            Py_DECREF(arguments_annotations);
4311
0
            return 0;
4312
0
        }
4313
16
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4314
16
                                    == 0;
4315
16
        Py_DECREF(type);
4316
16
        if (!cond) {
4317
0
            Py_DECREF(arguments_annotations);
4318
0
            return 0;
4319
0
        }
4320
16
    }
4321
16
    {
4322
16
        PyObject *type = state->arg_type;
4323
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4324
16
        cond = type != NULL;
4325
16
        if (!cond) {
4326
0
            Py_DECREF(arguments_annotations);
4327
0
            return 0;
4328
0
        }
4329
16
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4330
16
        Py_DECREF(type);
4331
16
        if (!cond) {
4332
0
            Py_DECREF(arguments_annotations);
4333
0
            return 0;
4334
0
        }
4335
16
    }
4336
16
    {
4337
16
        PyObject *type = state->arg_type;
4338
16
        type = _Py_union_type_or(type, Py_None);
4339
16
        cond = type != NULL;
4340
16
        if (!cond) {
4341
0
            Py_DECREF(arguments_annotations);
4342
0
            return 0;
4343
0
        }
4344
16
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4345
16
        Py_DECREF(type);
4346
16
        if (!cond) {
4347
0
            Py_DECREF(arguments_annotations);
4348
0
            return 0;
4349
0
        }
4350
16
    }
4351
16
    {
4352
16
        PyObject *type = state->arg_type;
4353
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4354
16
        cond = type != NULL;
4355
16
        if (!cond) {
4356
0
            Py_DECREF(arguments_annotations);
4357
0
            return 0;
4358
0
        }
4359
16
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4360
16
                                    == 0;
4361
16
        Py_DECREF(type);
4362
16
        if (!cond) {
4363
0
            Py_DECREF(arguments_annotations);
4364
0
            return 0;
4365
0
        }
4366
16
    }
4367
16
    {
4368
16
        PyObject *type = state->expr_type;
4369
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4370
16
        cond = type != NULL;
4371
16
        if (!cond) {
4372
0
            Py_DECREF(arguments_annotations);
4373
0
            return 0;
4374
0
        }
4375
16
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4376
16
                                    == 0;
4377
16
        Py_DECREF(type);
4378
16
        if (!cond) {
4379
0
            Py_DECREF(arguments_annotations);
4380
0
            return 0;
4381
0
        }
4382
16
    }
4383
16
    {
4384
16
        PyObject *type = state->arg_type;
4385
16
        type = _Py_union_type_or(type, Py_None);
4386
16
        cond = type != NULL;
4387
16
        if (!cond) {
4388
0
            Py_DECREF(arguments_annotations);
4389
0
            return 0;
4390
0
        }
4391
16
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4392
16
        Py_DECREF(type);
4393
16
        if (!cond) {
4394
0
            Py_DECREF(arguments_annotations);
4395
0
            return 0;
4396
0
        }
4397
16
    }
4398
16
    {
4399
16
        PyObject *type = state->expr_type;
4400
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4401
16
        cond = type != NULL;
4402
16
        if (!cond) {
4403
0
            Py_DECREF(arguments_annotations);
4404
0
            return 0;
4405
0
        }
4406
16
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4407
16
                                    0;
4408
16
        Py_DECREF(type);
4409
16
        if (!cond) {
4410
0
            Py_DECREF(arguments_annotations);
4411
0
            return 0;
4412
0
        }
4413
16
    }
4414
16
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4415
16
                                  arguments_annotations) == 0;
4416
16
    if (!cond) {
4417
0
        Py_DECREF(arguments_annotations);
4418
0
        return 0;
4419
0
    }
4420
16
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4421
16
                                  arguments_annotations) == 0;
4422
16
    if (!cond) {
4423
0
        Py_DECREF(arguments_annotations);
4424
0
        return 0;
4425
0
    }
4426
16
    Py_DECREF(arguments_annotations);
4427
16
    PyObject *arg_annotations = PyDict_New();
4428
16
    if (!arg_annotations) return 0;
4429
16
    {
4430
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4431
16
        Py_INCREF(type);
4432
16
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4433
16
        Py_DECREF(type);
4434
16
        if (!cond) {
4435
0
            Py_DECREF(arg_annotations);
4436
0
            return 0;
4437
0
        }
4438
16
    }
4439
16
    {
4440
16
        PyObject *type = state->expr_type;
4441
16
        type = _Py_union_type_or(type, Py_None);
4442
16
        cond = type != NULL;
4443
16
        if (!cond) {
4444
0
            Py_DECREF(arg_annotations);
4445
0
            return 0;
4446
0
        }
4447
16
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4448
16
        Py_DECREF(type);
4449
16
        if (!cond) {
4450
0
            Py_DECREF(arg_annotations);
4451
0
            return 0;
4452
0
        }
4453
16
    }
4454
16
    {
4455
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4456
16
        type = _Py_union_type_or(type, Py_None);
4457
16
        cond = type != NULL;
4458
16
        if (!cond) {
4459
0
            Py_DECREF(arg_annotations);
4460
0
            return 0;
4461
0
        }
4462
16
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4463
16
        Py_DECREF(type);
4464
16
        if (!cond) {
4465
0
            Py_DECREF(arg_annotations);
4466
0
            return 0;
4467
0
        }
4468
16
    }
4469
16
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4470
16
                                  arg_annotations) == 0;
4471
16
    if (!cond) {
4472
0
        Py_DECREF(arg_annotations);
4473
0
        return 0;
4474
0
    }
4475
16
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4476
16
                                  arg_annotations) == 0;
4477
16
    if (!cond) {
4478
0
        Py_DECREF(arg_annotations);
4479
0
        return 0;
4480
0
    }
4481
16
    Py_DECREF(arg_annotations);
4482
16
    PyObject *keyword_annotations = PyDict_New();
4483
16
    if (!keyword_annotations) return 0;
4484
16
    {
4485
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4486
16
        type = _Py_union_type_or(type, Py_None);
4487
16
        cond = type != NULL;
4488
16
        if (!cond) {
4489
0
            Py_DECREF(keyword_annotations);
4490
0
            return 0;
4491
0
        }
4492
16
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4493
16
        Py_DECREF(type);
4494
16
        if (!cond) {
4495
0
            Py_DECREF(keyword_annotations);
4496
0
            return 0;
4497
0
        }
4498
16
    }
4499
16
    {
4500
16
        PyObject *type = state->expr_type;
4501
16
        Py_INCREF(type);
4502
16
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4503
16
        Py_DECREF(type);
4504
16
        if (!cond) {
4505
0
            Py_DECREF(keyword_annotations);
4506
0
            return 0;
4507
0
        }
4508
16
    }
4509
16
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4510
16
                                  keyword_annotations) == 0;
4511
16
    if (!cond) {
4512
0
        Py_DECREF(keyword_annotations);
4513
0
        return 0;
4514
0
    }
4515
16
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4516
16
                                  keyword_annotations) == 0;
4517
16
    if (!cond) {
4518
0
        Py_DECREF(keyword_annotations);
4519
0
        return 0;
4520
0
    }
4521
16
    Py_DECREF(keyword_annotations);
4522
16
    PyObject *alias_annotations = PyDict_New();
4523
16
    if (!alias_annotations) return 0;
4524
16
    {
4525
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4526
16
        Py_INCREF(type);
4527
16
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4528
16
        Py_DECREF(type);
4529
16
        if (!cond) {
4530
0
            Py_DECREF(alias_annotations);
4531
0
            return 0;
4532
0
        }
4533
16
    }
4534
16
    {
4535
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4536
16
        type = _Py_union_type_or(type, Py_None);
4537
16
        cond = type != NULL;
4538
16
        if (!cond) {
4539
0
            Py_DECREF(alias_annotations);
4540
0
            return 0;
4541
0
        }
4542
16
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4543
16
        Py_DECREF(type);
4544
16
        if (!cond) {
4545
0
            Py_DECREF(alias_annotations);
4546
0
            return 0;
4547
0
        }
4548
16
    }
4549
16
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4550
16
                                  alias_annotations) == 0;
4551
16
    if (!cond) {
4552
0
        Py_DECREF(alias_annotations);
4553
0
        return 0;
4554
0
    }
4555
16
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4556
16
                                  alias_annotations) == 0;
4557
16
    if (!cond) {
4558
0
        Py_DECREF(alias_annotations);
4559
0
        return 0;
4560
0
    }
4561
16
    Py_DECREF(alias_annotations);
4562
16
    PyObject *withitem_annotations = PyDict_New();
4563
16
    if (!withitem_annotations) return 0;
4564
16
    {
4565
16
        PyObject *type = state->expr_type;
4566
16
        Py_INCREF(type);
4567
16
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4568
16
                                    == 0;
4569
16
        Py_DECREF(type);
4570
16
        if (!cond) {
4571
0
            Py_DECREF(withitem_annotations);
4572
0
            return 0;
4573
0
        }
4574
16
    }
4575
16
    {
4576
16
        PyObject *type = state->expr_type;
4577
16
        type = _Py_union_type_or(type, Py_None);
4578
16
        cond = type != NULL;
4579
16
        if (!cond) {
4580
0
            Py_DECREF(withitem_annotations);
4581
0
            return 0;
4582
0
        }
4583
16
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4584
16
                                    type) == 0;
4585
16
        Py_DECREF(type);
4586
16
        if (!cond) {
4587
0
            Py_DECREF(withitem_annotations);
4588
0
            return 0;
4589
0
        }
4590
16
    }
4591
16
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4592
16
                                  withitem_annotations) == 0;
4593
16
    if (!cond) {
4594
0
        Py_DECREF(withitem_annotations);
4595
0
        return 0;
4596
0
    }
4597
16
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4598
16
                                  withitem_annotations) == 0;
4599
16
    if (!cond) {
4600
0
        Py_DECREF(withitem_annotations);
4601
0
        return 0;
4602
0
    }
4603
16
    Py_DECREF(withitem_annotations);
4604
16
    PyObject *match_case_annotations = PyDict_New();
4605
16
    if (!match_case_annotations) return 0;
4606
16
    {
4607
16
        PyObject *type = state->pattern_type;
4608
16
        Py_INCREF(type);
4609
16
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4610
16
                                    0;
4611
16
        Py_DECREF(type);
4612
16
        if (!cond) {
4613
0
            Py_DECREF(match_case_annotations);
4614
0
            return 0;
4615
0
        }
4616
16
    }
4617
16
    {
4618
16
        PyObject *type = state->expr_type;
4619
16
        type = _Py_union_type_or(type, Py_None);
4620
16
        cond = type != NULL;
4621
16
        if (!cond) {
4622
0
            Py_DECREF(match_case_annotations);
4623
0
            return 0;
4624
0
        }
4625
16
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4626
16
        Py_DECREF(type);
4627
16
        if (!cond) {
4628
0
            Py_DECREF(match_case_annotations);
4629
0
            return 0;
4630
0
        }
4631
16
    }
4632
16
    {
4633
16
        PyObject *type = state->stmt_type;
4634
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4635
16
        cond = type != NULL;
4636
16
        if (!cond) {
4637
0
            Py_DECREF(match_case_annotations);
4638
0
            return 0;
4639
0
        }
4640
16
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4641
16
        Py_DECREF(type);
4642
16
        if (!cond) {
4643
0
            Py_DECREF(match_case_annotations);
4644
0
            return 0;
4645
0
        }
4646
16
    }
4647
16
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4648
16
                                  match_case_annotations) == 0;
4649
16
    if (!cond) {
4650
0
        Py_DECREF(match_case_annotations);
4651
0
        return 0;
4652
0
    }
4653
16
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4654
16
                                  match_case_annotations) == 0;
4655
16
    if (!cond) {
4656
0
        Py_DECREF(match_case_annotations);
4657
0
        return 0;
4658
0
    }
4659
16
    Py_DECREF(match_case_annotations);
4660
16
    PyObject *MatchValue_annotations = PyDict_New();
4661
16
    if (!MatchValue_annotations) return 0;
4662
16
    {
4663
16
        PyObject *type = state->expr_type;
4664
16
        Py_INCREF(type);
4665
16
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4666
16
        Py_DECREF(type);
4667
16
        if (!cond) {
4668
0
            Py_DECREF(MatchValue_annotations);
4669
0
            return 0;
4670
0
        }
4671
16
    }
4672
16
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4673
16
                                  MatchValue_annotations) == 0;
4674
16
    if (!cond) {
4675
0
        Py_DECREF(MatchValue_annotations);
4676
0
        return 0;
4677
0
    }
4678
16
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4679
16
                                  MatchValue_annotations) == 0;
4680
16
    if (!cond) {
4681
0
        Py_DECREF(MatchValue_annotations);
4682
0
        return 0;
4683
0
    }
4684
16
    Py_DECREF(MatchValue_annotations);
4685
16
    PyObject *MatchSingleton_annotations = PyDict_New();
4686
16
    if (!MatchSingleton_annotations) return 0;
4687
16
    {
4688
16
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4689
16
        Py_INCREF(type);
4690
16
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4691
16
                                    == 0;
4692
16
        Py_DECREF(type);
4693
16
        if (!cond) {
4694
0
            Py_DECREF(MatchSingleton_annotations);
4695
0
            return 0;
4696
0
        }
4697
16
    }
4698
16
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4699
16
                                  MatchSingleton_annotations) == 0;
4700
16
    if (!cond) {
4701
0
        Py_DECREF(MatchSingleton_annotations);
4702
0
        return 0;
4703
0
    }
4704
16
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4705
16
                                  "__annotations__",
4706
16
                                  MatchSingleton_annotations) == 0;
4707
16
    if (!cond) {
4708
0
        Py_DECREF(MatchSingleton_annotations);
4709
0
        return 0;
4710
0
    }
4711
16
    Py_DECREF(MatchSingleton_annotations);
4712
16
    PyObject *MatchSequence_annotations = PyDict_New();
4713
16
    if (!MatchSequence_annotations) return 0;
4714
16
    {
4715
16
        PyObject *type = state->pattern_type;
4716
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4717
16
        cond = type != NULL;
4718
16
        if (!cond) {
4719
0
            Py_DECREF(MatchSequence_annotations);
4720
0
            return 0;
4721
0
        }
4722
16
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4723
16
                                    type) == 0;
4724
16
        Py_DECREF(type);
4725
16
        if (!cond) {
4726
0
            Py_DECREF(MatchSequence_annotations);
4727
0
            return 0;
4728
0
        }
4729
16
    }
4730
16
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4731
16
                                  MatchSequence_annotations) == 0;
4732
16
    if (!cond) {
4733
0
        Py_DECREF(MatchSequence_annotations);
4734
0
        return 0;
4735
0
    }
4736
16
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4737
16
                                  MatchSequence_annotations) == 0;
4738
16
    if (!cond) {
4739
0
        Py_DECREF(MatchSequence_annotations);
4740
0
        return 0;
4741
0
    }
4742
16
    Py_DECREF(MatchSequence_annotations);
4743
16
    PyObject *MatchMapping_annotations = PyDict_New();
4744
16
    if (!MatchMapping_annotations) return 0;
4745
16
    {
4746
16
        PyObject *type = state->expr_type;
4747
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4748
16
        cond = type != NULL;
4749
16
        if (!cond) {
4750
0
            Py_DECREF(MatchMapping_annotations);
4751
0
            return 0;
4752
0
        }
4753
16
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4754
16
                                    0;
4755
16
        Py_DECREF(type);
4756
16
        if (!cond) {
4757
0
            Py_DECREF(MatchMapping_annotations);
4758
0
            return 0;
4759
0
        }
4760
16
    }
4761
16
    {
4762
16
        PyObject *type = state->pattern_type;
4763
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4764
16
        cond = type != NULL;
4765
16
        if (!cond) {
4766
0
            Py_DECREF(MatchMapping_annotations);
4767
0
            return 0;
4768
0
        }
4769
16
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4770
16
                                    == 0;
4771
16
        Py_DECREF(type);
4772
16
        if (!cond) {
4773
0
            Py_DECREF(MatchMapping_annotations);
4774
0
            return 0;
4775
0
        }
4776
16
    }
4777
16
    {
4778
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4779
16
        type = _Py_union_type_or(type, Py_None);
4780
16
        cond = type != NULL;
4781
16
        if (!cond) {
4782
0
            Py_DECREF(MatchMapping_annotations);
4783
0
            return 0;
4784
0
        }
4785
16
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4786
16
                                    0;
4787
16
        Py_DECREF(type);
4788
16
        if (!cond) {
4789
0
            Py_DECREF(MatchMapping_annotations);
4790
0
            return 0;
4791
0
        }
4792
16
    }
4793
16
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4794
16
                                  MatchMapping_annotations) == 0;
4795
16
    if (!cond) {
4796
0
        Py_DECREF(MatchMapping_annotations);
4797
0
        return 0;
4798
0
    }
4799
16
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4800
16
                                  MatchMapping_annotations) == 0;
4801
16
    if (!cond) {
4802
0
        Py_DECREF(MatchMapping_annotations);
4803
0
        return 0;
4804
0
    }
4805
16
    Py_DECREF(MatchMapping_annotations);
4806
16
    PyObject *MatchClass_annotations = PyDict_New();
4807
16
    if (!MatchClass_annotations) return 0;
4808
16
    {
4809
16
        PyObject *type = state->expr_type;
4810
16
        Py_INCREF(type);
4811
16
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4812
16
        Py_DECREF(type);
4813
16
        if (!cond) {
4814
0
            Py_DECREF(MatchClass_annotations);
4815
0
            return 0;
4816
0
        }
4817
16
    }
4818
16
    {
4819
16
        PyObject *type = state->pattern_type;
4820
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4821
16
        cond = type != NULL;
4822
16
        if (!cond) {
4823
0
            Py_DECREF(MatchClass_annotations);
4824
0
            return 0;
4825
0
        }
4826
16
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4827
16
                                    == 0;
4828
16
        Py_DECREF(type);
4829
16
        if (!cond) {
4830
0
            Py_DECREF(MatchClass_annotations);
4831
0
            return 0;
4832
0
        }
4833
16
    }
4834
16
    {
4835
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4836
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4837
16
        cond = type != NULL;
4838
16
        if (!cond) {
4839
0
            Py_DECREF(MatchClass_annotations);
4840
0
            return 0;
4841
0
        }
4842
16
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4843
16
                                    == 0;
4844
16
        Py_DECREF(type);
4845
16
        if (!cond) {
4846
0
            Py_DECREF(MatchClass_annotations);
4847
0
            return 0;
4848
0
        }
4849
16
    }
4850
16
    {
4851
16
        PyObject *type = state->pattern_type;
4852
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4853
16
        cond = type != NULL;
4854
16
        if (!cond) {
4855
0
            Py_DECREF(MatchClass_annotations);
4856
0
            return 0;
4857
0
        }
4858
16
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4859
16
                                    type) == 0;
4860
16
        Py_DECREF(type);
4861
16
        if (!cond) {
4862
0
            Py_DECREF(MatchClass_annotations);
4863
0
            return 0;
4864
0
        }
4865
16
    }
4866
16
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4867
16
                                  MatchClass_annotations) == 0;
4868
16
    if (!cond) {
4869
0
        Py_DECREF(MatchClass_annotations);
4870
0
        return 0;
4871
0
    }
4872
16
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4873
16
                                  MatchClass_annotations) == 0;
4874
16
    if (!cond) {
4875
0
        Py_DECREF(MatchClass_annotations);
4876
0
        return 0;
4877
0
    }
4878
16
    Py_DECREF(MatchClass_annotations);
4879
16
    PyObject *MatchStar_annotations = PyDict_New();
4880
16
    if (!MatchStar_annotations) return 0;
4881
16
    {
4882
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4883
16
        type = _Py_union_type_or(type, Py_None);
4884
16
        cond = type != NULL;
4885
16
        if (!cond) {
4886
0
            Py_DECREF(MatchStar_annotations);
4887
0
            return 0;
4888
0
        }
4889
16
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4890
16
        Py_DECREF(type);
4891
16
        if (!cond) {
4892
0
            Py_DECREF(MatchStar_annotations);
4893
0
            return 0;
4894
0
        }
4895
16
    }
4896
16
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4897
16
                                  MatchStar_annotations) == 0;
4898
16
    if (!cond) {
4899
0
        Py_DECREF(MatchStar_annotations);
4900
0
        return 0;
4901
0
    }
4902
16
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4903
16
                                  MatchStar_annotations) == 0;
4904
16
    if (!cond) {
4905
0
        Py_DECREF(MatchStar_annotations);
4906
0
        return 0;
4907
0
    }
4908
16
    Py_DECREF(MatchStar_annotations);
4909
16
    PyObject *MatchAs_annotations = PyDict_New();
4910
16
    if (!MatchAs_annotations) return 0;
4911
16
    {
4912
16
        PyObject *type = state->pattern_type;
4913
16
        type = _Py_union_type_or(type, Py_None);
4914
16
        cond = type != NULL;
4915
16
        if (!cond) {
4916
0
            Py_DECREF(MatchAs_annotations);
4917
0
            return 0;
4918
0
        }
4919
16
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4920
16
        Py_DECREF(type);
4921
16
        if (!cond) {
4922
0
            Py_DECREF(MatchAs_annotations);
4923
0
            return 0;
4924
0
        }
4925
16
    }
4926
16
    {
4927
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4928
16
        type = _Py_union_type_or(type, Py_None);
4929
16
        cond = type != NULL;
4930
16
        if (!cond) {
4931
0
            Py_DECREF(MatchAs_annotations);
4932
0
            return 0;
4933
0
        }
4934
16
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4935
16
        Py_DECREF(type);
4936
16
        if (!cond) {
4937
0
            Py_DECREF(MatchAs_annotations);
4938
0
            return 0;
4939
0
        }
4940
16
    }
4941
16
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4942
16
                                  MatchAs_annotations) == 0;
4943
16
    if (!cond) {
4944
0
        Py_DECREF(MatchAs_annotations);
4945
0
        return 0;
4946
0
    }
4947
16
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4948
16
                                  MatchAs_annotations) == 0;
4949
16
    if (!cond) {
4950
0
        Py_DECREF(MatchAs_annotations);
4951
0
        return 0;
4952
0
    }
4953
16
    Py_DECREF(MatchAs_annotations);
4954
16
    PyObject *MatchOr_annotations = PyDict_New();
4955
16
    if (!MatchOr_annotations) return 0;
4956
16
    {
4957
16
        PyObject *type = state->pattern_type;
4958
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4959
16
        cond = type != NULL;
4960
16
        if (!cond) {
4961
0
            Py_DECREF(MatchOr_annotations);
4962
0
            return 0;
4963
0
        }
4964
16
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4965
16
        Py_DECREF(type);
4966
16
        if (!cond) {
4967
0
            Py_DECREF(MatchOr_annotations);
4968
0
            return 0;
4969
0
        }
4970
16
    }
4971
16
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4972
16
                                  MatchOr_annotations) == 0;
4973
16
    if (!cond) {
4974
0
        Py_DECREF(MatchOr_annotations);
4975
0
        return 0;
4976
0
    }
4977
16
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4978
16
                                  MatchOr_annotations) == 0;
4979
16
    if (!cond) {
4980
0
        Py_DECREF(MatchOr_annotations);
4981
0
        return 0;
4982
0
    }
4983
16
    Py_DECREF(MatchOr_annotations);
4984
16
    PyObject *TypeIgnore_annotations = PyDict_New();
4985
16
    if (!TypeIgnore_annotations) return 0;
4986
16
    {
4987
16
        PyObject *type = (PyObject *)&PyLong_Type;
4988
16
        Py_INCREF(type);
4989
16
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4990
16
                                    0;
4991
16
        Py_DECREF(type);
4992
16
        if (!cond) {
4993
0
            Py_DECREF(TypeIgnore_annotations);
4994
0
            return 0;
4995
0
        }
4996
16
    }
4997
16
    {
4998
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4999
16
        Py_INCREF(type);
5000
16
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
5001
16
        Py_DECREF(type);
5002
16
        if (!cond) {
5003
0
            Py_DECREF(TypeIgnore_annotations);
5004
0
            return 0;
5005
0
        }
5006
16
    }
5007
16
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
5008
16
                                  TypeIgnore_annotations) == 0;
5009
16
    if (!cond) {
5010
0
        Py_DECREF(TypeIgnore_annotations);
5011
0
        return 0;
5012
0
    }
5013
16
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
5014
16
                                  TypeIgnore_annotations) == 0;
5015
16
    if (!cond) {
5016
0
        Py_DECREF(TypeIgnore_annotations);
5017
0
        return 0;
5018
0
    }
5019
16
    Py_DECREF(TypeIgnore_annotations);
5020
16
    PyObject *TypeVar_annotations = PyDict_New();
5021
16
    if (!TypeVar_annotations) return 0;
5022
16
    {
5023
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
5024
16
        Py_INCREF(type);
5025
16
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
5026
16
        Py_DECREF(type);
5027
16
        if (!cond) {
5028
0
            Py_DECREF(TypeVar_annotations);
5029
0
            return 0;
5030
0
        }
5031
16
    }
5032
16
    {
5033
16
        PyObject *type = state->expr_type;
5034
16
        type = _Py_union_type_or(type, Py_None);
5035
16
        cond = type != NULL;
5036
16
        if (!cond) {
5037
0
            Py_DECREF(TypeVar_annotations);
5038
0
            return 0;
5039
0
        }
5040
16
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5041
16
        Py_DECREF(type);
5042
16
        if (!cond) {
5043
0
            Py_DECREF(TypeVar_annotations);
5044
0
            return 0;
5045
0
        }
5046
16
    }
5047
16
    {
5048
16
        PyObject *type = state->expr_type;
5049
16
        type = _Py_union_type_or(type, Py_None);
5050
16
        cond = type != NULL;
5051
16
        if (!cond) {
5052
0
            Py_DECREF(TypeVar_annotations);
5053
0
            return 0;
5054
0
        }
5055
16
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5056
16
                                    == 0;
5057
16
        Py_DECREF(type);
5058
16
        if (!cond) {
5059
0
            Py_DECREF(TypeVar_annotations);
5060
0
            return 0;
5061
0
        }
5062
16
    }
5063
16
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5064
16
                                  TypeVar_annotations) == 0;
5065
16
    if (!cond) {
5066
0
        Py_DECREF(TypeVar_annotations);
5067
0
        return 0;
5068
0
    }
5069
16
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5070
16
                                  TypeVar_annotations) == 0;
5071
16
    if (!cond) {
5072
0
        Py_DECREF(TypeVar_annotations);
5073
0
        return 0;
5074
0
    }
5075
16
    Py_DECREF(TypeVar_annotations);
5076
16
    PyObject *ParamSpec_annotations = PyDict_New();
5077
16
    if (!ParamSpec_annotations) return 0;
5078
16
    {
5079
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
5080
16
        Py_INCREF(type);
5081
16
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5082
16
        Py_DECREF(type);
5083
16
        if (!cond) {
5084
0
            Py_DECREF(ParamSpec_annotations);
5085
0
            return 0;
5086
0
        }
5087
16
    }
5088
16
    {
5089
16
        PyObject *type = state->expr_type;
5090
16
        type = _Py_union_type_or(type, Py_None);
5091
16
        cond = type != NULL;
5092
16
        if (!cond) {
5093
0
            Py_DECREF(ParamSpec_annotations);
5094
0
            return 0;
5095
0
        }
5096
16
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5097
16
                                    type) == 0;
5098
16
        Py_DECREF(type);
5099
16
        if (!cond) {
5100
0
            Py_DECREF(ParamSpec_annotations);
5101
0
            return 0;
5102
0
        }
5103
16
    }
5104
16
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5105
16
                                  ParamSpec_annotations) == 0;
5106
16
    if (!cond) {
5107
0
        Py_DECREF(ParamSpec_annotations);
5108
0
        return 0;
5109
0
    }
5110
16
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5111
16
                                  ParamSpec_annotations) == 0;
5112
16
    if (!cond) {
5113
0
        Py_DECREF(ParamSpec_annotations);
5114
0
        return 0;
5115
0
    }
5116
16
    Py_DECREF(ParamSpec_annotations);
5117
16
    PyObject *TypeVarTuple_annotations = PyDict_New();
5118
16
    if (!TypeVarTuple_annotations) return 0;
5119
16
    {
5120
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
5121
16
        Py_INCREF(type);
5122
16
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5123
16
                                    0;
5124
16
        Py_DECREF(type);
5125
16
        if (!cond) {
5126
0
            Py_DECREF(TypeVarTuple_annotations);
5127
0
            return 0;
5128
0
        }
5129
16
    }
5130
16
    {
5131
16
        PyObject *type = state->expr_type;
5132
16
        type = _Py_union_type_or(type, Py_None);
5133
16
        cond = type != NULL;
5134
16
        if (!cond) {
5135
0
            Py_DECREF(TypeVarTuple_annotations);
5136
0
            return 0;
5137
0
        }
5138
16
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5139
16
                                    type) == 0;
5140
16
        Py_DECREF(type);
5141
16
        if (!cond) {
5142
0
            Py_DECREF(TypeVarTuple_annotations);
5143
0
            return 0;
5144
0
        }
5145
16
    }
5146
16
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5147
16
                                  TypeVarTuple_annotations) == 0;
5148
16
    if (!cond) {
5149
0
        Py_DECREF(TypeVarTuple_annotations);
5150
0
        return 0;
5151
0
    }
5152
16
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5153
16
                                  TypeVarTuple_annotations) == 0;
5154
16
    if (!cond) {
5155
0
        Py_DECREF(TypeVarTuple_annotations);
5156
0
        return 0;
5157
0
    }
5158
16
    Py_DECREF(TypeVarTuple_annotations);
5159
5160
16
    return 1;
5161
16
}
5162
5163
5164
5165
typedef struct {
5166
    PyObject_HEAD
5167
    PyObject *dict;
5168
} AST_object;
5169
5170
static void
5171
ast_dealloc(PyObject *op)
5172
484k
{
5173
484k
    AST_object *self = (AST_object*)op;
5174
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5175
484k
    PyTypeObject *tp = Py_TYPE(self);
5176
484k
    PyObject_GC_UnTrack(self);
5177
484k
    Py_CLEAR(self->dict);
5178
484k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5179
484k
    assert(free_func != NULL);
5180
484k
    free_func(self);
5181
484k
    Py_DECREF(tp);
5182
484k
}
5183
5184
static int
5185
ast_traverse(PyObject *op, visitproc visit, void *arg)
5186
468k
{
5187
468k
    AST_object *self = (AST_object*)op;
5188
468k
    Py_VISIT(Py_TYPE(self));
5189
468k
    Py_VISIT(self->dict);
5190
468k
    return 0;
5191
468k
}
5192
5193
static int
5194
ast_clear(PyObject *op)
5195
0
{
5196
0
    AST_object *self = (AST_object*)op;
5197
0
    Py_CLEAR(self->dict);
5198
0
    return 0;
5199
0
}
5200
5201
/*
5202
 * Format the names in the set 'missing' into a natural language list,
5203
 * sorted in the order in which they appear in 'fields'.
5204
 *
5205
 * Similar to format_missing() from 'Python/ceval.c'.
5206
 *
5207
 * Parameters
5208
 *
5209
 *      missing     Set of missing field names to render.
5210
 *      fields      Sequence of AST node field names (self._fields).
5211
 */
5212
static PyObject *
5213
format_missing(PyObject *missing, PyObject *fields)
5214
0
{
5215
0
    Py_ssize_t num_fields, num_total, num_left;
5216
0
    num_fields = PySequence_Size(fields);
5217
0
    if (num_fields == -1) {
5218
0
        return NULL;
5219
0
    }
5220
0
    num_total = num_left = PySet_GET_SIZE(missing);
5221
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5222
0
    if (writer == NULL) {
5223
0
        goto error;
5224
0
    }
5225
    // Iterate all AST node fields in order so that the missing positional
5226
    // arguments are rendered in the order in which __init__ expects them.
5227
0
    for (Py_ssize_t i = 0; i < num_fields; i++) {
5228
0
        PyObject *name = PySequence_GetItem(fields, i);
5229
0
        if (name == NULL) {
5230
0
            goto error;
5231
0
        }
5232
0
        int contains = PySet_Contains(missing, name);
5233
0
        if (contains == -1) {
5234
0
            Py_DECREF(name);
5235
0
            goto error;
5236
0
        }
5237
0
        else if (contains == 1) {
5238
0
            const char* fmt = NULL;
5239
0
            if (num_left == 1) {
5240
0
                fmt = "'%U'";
5241
0
            }
5242
0
            else if (num_total == 2) {
5243
0
                fmt = "'%U' and ";
5244
0
            }
5245
0
            else if (num_left == 2) {
5246
0
                fmt = "'%U', and ";
5247
0
            }
5248
0
            else {
5249
0
                fmt = "'%U', ";
5250
0
            }
5251
0
            num_left--;
5252
0
            if (PyUnicodeWriter_Format(writer, fmt, name) < 0) {
5253
0
                Py_DECREF(name);
5254
0
                goto error;
5255
0
            }
5256
0
        }
5257
0
        Py_DECREF(name);
5258
0
    }
5259
0
    return PyUnicodeWriter_Finish(writer);
5260
0
error:
5261
0
    PyUnicodeWriter_Discard(writer);
5262
0
    return NULL;
5263
0
}
5264
5265
static int
5266
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
5267
245
{
5268
245
    struct ast_state *state = get_ast_state();
5269
245
    if (state == NULL) {
5270
0
        return -1;
5271
0
    }
5272
5273
245
    int contains = PySet_Contains(state->abstract_types, (PyObject *)Py_TYPE(self));
5274
245
    if (contains == -1) {
5275
0
        return -1;
5276
0
    }
5277
245
    else if (contains == 1) {
5278
0
        if (PyErr_WarnFormat(
5279
0
                PyExc_DeprecationWarning, 1,
5280
0
                "Instantiating abstract AST node class %T is deprecated. "
5281
0
                "This will become an error in Python 3.20", self) < 0) {
5282
0
            return -1;
5283
0
        }
5284
0
    }
5285
5286
245
    Py_ssize_t i, numfields = 0;
5287
245
    int res = -1;
5288
245
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5289
5290
245
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5291
245
    if (fields == NULL) {
5292
0
        goto cleanup;
5293
0
    }
5294
5295
245
    numfields = PySequence_Size(fields);
5296
245
    if (numfields == -1) {
5297
0
        goto cleanup;
5298
0
    }
5299
245
    remaining_fields = PySet_New(fields);
5300
245
    if (remaining_fields == NULL) {
5301
0
        goto cleanup;
5302
0
    }
5303
5304
245
    res = 0; /* if no error occurs, this stays 0 to the end */
5305
245
    if (numfields < PyTuple_GET_SIZE(args)) {
5306
0
        PyErr_Format(PyExc_TypeError, "%T constructor takes at most "
5307
0
                     "%zd positional argument%s",
5308
0
                     self, numfields, numfields == 1 ? "" : "s");
5309
0
        res = -1;
5310
0
        goto cleanup;
5311
0
    }
5312
245
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5313
        /* cannot be reached when fields is NULL */
5314
0
        PyObject *name = PySequence_GetItem(fields, i);
5315
0
        if (!name) {
5316
0
            res = -1;
5317
0
            goto cleanup;
5318
0
        }
5319
0
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5320
0
        if (PySet_Discard(remaining_fields, name) < 0) {
5321
0
            res = -1;
5322
0
            Py_DECREF(name);
5323
0
            goto cleanup;
5324
0
        }
5325
0
        Py_DECREF(name);
5326
0
        if (res < 0) {
5327
0
            goto cleanup;
5328
0
        }
5329
0
    }
5330
245
    if (kw) {
5331
0
        i = 0;  /* needed by PyDict_Next */
5332
0
        while (PyDict_Next(kw, &i, &key, &value)) {
5333
0
            int contains = PySequence_Contains(fields, key);
5334
0
            if (contains == -1) {
5335
0
                res = -1;
5336
0
                goto cleanup;
5337
0
            }
5338
0
            else if (contains == 1) {
5339
0
                int p = PySet_Discard(remaining_fields, key);
5340
0
                if (p == -1) {
5341
0
                    res = -1;
5342
0
                    goto cleanup;
5343
0
                }
5344
0
                if (p == 0) {
5345
0
                    PyErr_Format(PyExc_TypeError,
5346
0
                        "%T got multiple values for argument %R",
5347
0
                        self, key);
5348
0
                    res = -1;
5349
0
                    goto cleanup;
5350
0
                }
5351
0
            }
5352
0
            else {
5353
                // Lazily initialize "attributes"
5354
0
                if (attributes == NULL) {
5355
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5356
0
                    if (attributes == NULL) {
5357
0
                        res = -1;
5358
0
                        goto cleanup;
5359
0
                    }
5360
0
                }
5361
0
                int contains = PySequence_Contains(attributes, key);
5362
0
                if (contains == -1) {
5363
0
                    res = -1;
5364
0
                    goto cleanup;
5365
0
                }
5366
0
                else if (contains == 0) {
5367
0
                    PyErr_Format(PyExc_TypeError,
5368
0
                        "%T.__init__ got an unexpected keyword argument %R",
5369
0
                        self, key);
5370
0
                    res = -1;
5371
0
                    goto cleanup;
5372
0
                }
5373
0
            }
5374
0
            res = PyObject_SetAttr(self, key, value);
5375
0
            if (res < 0) {
5376
0
                goto cleanup;
5377
0
            }
5378
0
        }
5379
0
    }
5380
245
    Py_ssize_t size = PySet_Size(remaining_fields);
5381
245
    PyObject *field_types = NULL, *remaining_list = NULL, *missing_names = NULL;
5382
245
    if (size > 0) {
5383
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5384
0
                                     &field_types) < 0) {
5385
0
            res = -1;
5386
0
            goto cleanup;
5387
0
        }
5388
0
        if (field_types == NULL) {
5389
            // Probably a user-defined subclass of AST that lacks _field_types.
5390
            // This will continue to work as it did before 3.13; i.e., attributes
5391
            // that are not passed in simply do not exist on the instance.
5392
0
            goto cleanup;
5393
0
        }
5394
0
        remaining_list = PySequence_List(remaining_fields);
5395
0
        if (!remaining_list) {
5396
0
            goto set_remaining_cleanup;
5397
0
        }
5398
0
        missing_names = PySet_New(NULL);
5399
0
        if (!missing_names) {
5400
0
            goto set_remaining_cleanup;
5401
0
        }
5402
0
        for (Py_ssize_t i = 0; i < size; i++) {
5403
0
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5404
0
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5405
0
            if (!type) {
5406
0
                if (PyErr_Occurred()) {
5407
0
                    goto set_remaining_cleanup;
5408
0
                }
5409
0
                else {
5410
0
                    PyErr_Format(PyExc_TypeError,
5411
0
                        "Field %R is missing from %T._field_types",
5412
0
                        name, self);
5413
0
                    goto set_remaining_cleanup;
5414
0
                }
5415
0
            }
5416
0
            else if (_PyUnion_Check(type)) {
5417
                // optional field
5418
                // do nothing, we'll have set a None default on the class
5419
0
            }
5420
0
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5421
                // list field
5422
0
                PyObject *empty = PyList_New(0);
5423
0
                if (!empty) {
5424
0
                    goto set_remaining_cleanup;
5425
0
                }
5426
0
                res = PyObject_SetAttr(self, name, empty);
5427
0
                Py_DECREF(empty);
5428
0
                if (res < 0) {
5429
0
                    goto set_remaining_cleanup;
5430
0
                }
5431
0
            }
5432
0
            else if (type == state->expr_context_type) {
5433
                // special case for expr_context: default to Load()
5434
0
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5435
0
                if (res < 0) {
5436
0
                    goto set_remaining_cleanup;
5437
0
                }
5438
0
            }
5439
0
            else {
5440
                // simple field (e.g., identifier)
5441
0
                res = PySet_Add(missing_names, name);
5442
0
                if (res < 0) {
5443
0
                    goto set_remaining_cleanup;
5444
0
                }
5445
0
            }
5446
0
        }
5447
0
        Py_ssize_t num_missing = PySet_GET_SIZE(missing_names);
5448
0
        if (num_missing > 0) {
5449
0
            PyObject *name_str = format_missing(missing_names, fields);
5450
0
            if (!name_str) {
5451
0
                goto set_remaining_cleanup;
5452
0
            }
5453
0
            PyErr_Format(PyExc_TypeError,
5454
0
                "%T.__init__ missing %d required positional argument%s: %U",
5455
0
                self, num_missing, num_missing == 1 ? "" : "s", name_str);
5456
0
            Py_DECREF(name_str);
5457
0
            goto set_remaining_cleanup;
5458
0
        }
5459
0
        Py_DECREF(missing_names);
5460
0
        Py_DECREF(remaining_list);
5461
0
        Py_DECREF(field_types);
5462
0
    }
5463
245
  cleanup:
5464
245
    Py_XDECREF(attributes);
5465
245
    Py_XDECREF(fields);
5466
245
    Py_XDECREF(remaining_fields);
5467
245
    return res;
5468
0
  set_remaining_cleanup:
5469
0
    Py_XDECREF(missing_names);
5470
0
    Py_XDECREF(remaining_list);
5471
0
    Py_XDECREF(field_types);
5472
0
    res = -1;
5473
0
    goto cleanup;
5474
245
}
5475
5476
/* Pickling support */
5477
static PyObject *
5478
ast_type_reduce(PyObject *self, PyObject *unused)
5479
0
{
5480
0
    struct ast_state *state = get_ast_state();
5481
0
    if (state == NULL) {
5482
0
        return NULL;
5483
0
    }
5484
5485
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5486
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5487
0
        return NULL;
5488
0
    }
5489
0
    PyObject *result = NULL;
5490
0
    if (dict) {
5491
        // Unpickling (or copying) works as follows:
5492
        // - Construct the object with only positional arguments
5493
        // - Set the fields from the dict
5494
        // We have two constraints:
5495
        // - We must set all the required fields in the initial constructor call,
5496
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5497
        // - We must not include child nodes in the positional args, because
5498
        //   that may trigger runaway recursion during copying (gh-120108).
5499
        // To satisfy both constraints, we set all the fields to None in the
5500
        // initial list of positional args, and then set the fields from the dict.
5501
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5502
0
            goto cleanup;
5503
0
        }
5504
0
        if (fields) {
5505
0
            Py_ssize_t numfields = PySequence_Size(fields);
5506
0
            if (numfields == -1) {
5507
0
                Py_DECREF(dict);
5508
0
                goto cleanup;
5509
0
            }
5510
0
            positional_args = PyList_New(0);
5511
0
            if (!positional_args) {
5512
0
                goto cleanup;
5513
0
            }
5514
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5515
0
                PyObject *name = PySequence_GetItem(fields, i);
5516
0
                if (!name) {
5517
0
                    goto cleanup;
5518
0
                }
5519
0
                PyObject *value;
5520
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5521
0
                Py_DECREF(name);
5522
0
                if (rc < 0) {
5523
0
                    goto cleanup;
5524
0
                }
5525
0
                if (!value) {
5526
0
                    break;
5527
0
                }
5528
0
                rc = PyList_Append(positional_args, Py_None);
5529
0
                Py_DECREF(value);
5530
0
                if (rc < 0) {
5531
0
                    goto cleanup;
5532
0
                }
5533
0
            }
5534
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5535
0
            if (!args_tuple) {
5536
0
                goto cleanup;
5537
0
            }
5538
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5539
0
        }
5540
0
        else {
5541
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5542
0
        }
5543
0
    }
5544
0
    else {
5545
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5546
0
    }
5547
0
cleanup:
5548
0
    Py_XDECREF(fields);
5549
0
    Py_XDECREF(positional_args);
5550
0
    return result;
5551
0
}
5552
5553
/*
5554
 * Python equivalent:
5555
 *
5556
 *   for key in keys:
5557
 *       if hasattr(self, key):
5558
 *           payload[key] = getattr(self, key)
5559
 *
5560
 * The 'keys' argument is a sequence corresponding to
5561
 * the '_fields' or the '_attributes' of an AST node.
5562
 *
5563
 * This returns -1 if an error occurs and 0 otherwise.
5564
 *
5565
 * Parameters
5566
 *
5567
 *      payload   A dictionary to fill.
5568
 *      keys      A sequence of keys or NULL for an empty sequence.
5569
 *      dict      The AST node instance dictionary (must not be NULL).
5570
 */
5571
static inline int
5572
ast_type_replace_update_payload(PyObject *payload,
5573
                                PyObject *keys,
5574
                                PyObject *dict)
5575
0
{
5576
0
    assert(dict != NULL);
5577
0
    if (keys == NULL) {
5578
0
        return 0;
5579
0
    }
5580
0
    Py_ssize_t n = PySequence_Size(keys);
5581
0
    if (n == -1) {
5582
0
        return -1;
5583
0
    }
5584
0
    for (Py_ssize_t i = 0; i < n; i++) {
5585
0
        PyObject *key = PySequence_GetItem(keys, i);
5586
0
        if (key == NULL) {
5587
0
            return -1;
5588
0
        }
5589
0
        PyObject *value;
5590
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5591
0
            Py_DECREF(key);
5592
0
            return -1;
5593
0
        }
5594
0
        if (value == NULL) {
5595
0
            Py_DECREF(key);
5596
            // If a field or attribute is not present at runtime, it should
5597
            // be explicitly given in 'kwargs'. If not, the constructor will
5598
            // issue a warning (which becomes an error in 3.15).
5599
0
            continue;
5600
0
        }
5601
0
        int rc = PyDict_SetItem(payload, key, value);
5602
0
        Py_DECREF(key);
5603
0
        Py_DECREF(value);
5604
0
        if (rc < 0) {
5605
0
            return -1;
5606
0
        }
5607
0
    }
5608
0
    return 0;
5609
0
}
5610
5611
/* copy.replace() support (shallow copy) */
5612
static PyObject *
5613
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5614
0
{
5615
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5616
0
        return NULL;
5617
0
    }
5618
5619
0
    struct ast_state *state = get_ast_state();
5620
0
    if (state == NULL) {
5621
0
        return NULL;
5622
0
    }
5623
5624
0
    PyObject *result = NULL;
5625
    // known AST class fields and attributes
5626
0
    PyObject *fields = NULL, *attributes = NULL;
5627
    // current instance dictionary
5628
0
    PyObject *dict = NULL;
5629
    // constructor positional and keyword arguments
5630
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5631
5632
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5633
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5634
0
        goto cleanup;
5635
0
    }
5636
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5637
0
        goto cleanup;
5638
0
    }
5639
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5640
0
        goto cleanup;
5641
0
    }
5642
0
    empty_tuple = PyTuple_New(0);
5643
0
    if (empty_tuple == NULL) {
5644
0
        goto cleanup;
5645
0
    }
5646
0
    payload = PyDict_New();
5647
0
    if (payload == NULL) {
5648
0
        goto cleanup;
5649
0
    }
5650
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5651
        // copy the instance's fields (possibly NULL)
5652
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5653
0
            goto cleanup;
5654
0
        }
5655
        // copy the instance's attributes (possibly NULL)
5656
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5657
0
            goto cleanup;
5658
0
        }
5659
0
    }
5660
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5661
0
        goto cleanup;
5662
0
    }
5663
0
    result = PyObject_Call(type, empty_tuple, payload);
5664
0
cleanup:
5665
0
    Py_XDECREF(payload);
5666
0
    Py_XDECREF(empty_tuple);
5667
0
    Py_XDECREF(dict);
5668
0
    Py_XDECREF(attributes);
5669
0
    Py_XDECREF(fields);
5670
0
    return result;
5671
0
}
5672
5673
static PyMemberDef ast_type_members[] = {
5674
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5675
    {NULL}  /* Sentinel */
5676
};
5677
5678
static PyMethodDef ast_type_methods[] = {
5679
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5680
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5681
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5682
               "Return a copy of the AST node with new values "
5683
               "for the specified fields.")},
5684
    {NULL}
5685
};
5686
5687
static PyGetSetDef ast_type_getsets[] = {
5688
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5689
    {NULL}
5690
};
5691
5692
static PyObject *
5693
ast_repr_max_depth(AST_object *self, int depth);
5694
5695
/* Format list and tuple properties of AST nodes.
5696
   Note that, only the first and last elements are shown.
5697
   Anything in between is represented with an ellipsis ('...').
5698
   For example, the list [1, 2, 3] is formatted as
5699
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5700
static PyObject *
5701
ast_repr_list(PyObject *list, int depth)
5702
0
{
5703
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5704
5705
0
    struct ast_state *state = get_ast_state();
5706
0
    if (state == NULL) {
5707
0
        return NULL;
5708
0
    }
5709
5710
0
    Py_ssize_t length = PySequence_Size(list);
5711
0
    if (length < 0) {
5712
0
        return NULL;
5713
0
    }
5714
0
    else if (length == 0) {
5715
0
        return PyObject_Repr(list);
5716
0
    }
5717
5718
0
    PyObject *items[2] = {NULL, NULL};
5719
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5720
0
    if (writer == NULL) {
5721
0
        goto error;
5722
0
    }
5723
5724
0
    items[0] = PySequence_GetItem(list, 0);
5725
0
    if (!items[0]) {
5726
0
        goto error;
5727
0
    }
5728
0
    if (length > 1) {
5729
0
        items[1] = PySequence_GetItem(list, length - 1);
5730
0
        if (!items[1]) {
5731
0
            goto error;
5732
0
        }
5733
0
    }
5734
5735
0
    bool is_list = PyList_Check(list);
5736
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5737
0
        goto error;
5738
0
    }
5739
5740
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5741
0
        if (i > 0) {
5742
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5743
0
                goto error;
5744
0
            }
5745
0
        }
5746
5747
0
        PyObject *item = items[i];
5748
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5749
0
            PyObject *item_repr;
5750
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5751
0
            if (!item_repr) {
5752
0
                goto error;
5753
0
            }
5754
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5755
0
                Py_DECREF(item_repr);
5756
0
                goto error;
5757
0
            }
5758
0
            Py_DECREF(item_repr);
5759
0
        } else {
5760
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5761
0
                goto error;
5762
0
            }
5763
0
        }
5764
5765
0
        if (i == 0 && length > 2) {
5766
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5767
0
                goto error;
5768
0
            }
5769
0
        }
5770
0
    }
5771
5772
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5773
0
        goto error;
5774
0
    }
5775
5776
0
    Py_XDECREF(items[0]);
5777
0
    Py_XDECREF(items[1]);
5778
0
    return PyUnicodeWriter_Finish(writer);
5779
5780
0
error:
5781
0
    Py_XDECREF(items[0]);
5782
0
    Py_XDECREF(items[1]);
5783
0
    PyUnicodeWriter_Discard(writer);
5784
0
    return NULL;
5785
0
}
5786
5787
static PyObject *
5788
ast_repr_max_depth(AST_object *self, int depth)
5789
0
{
5790
0
    struct ast_state *state = get_ast_state();
5791
0
    if (state == NULL) {
5792
0
        return NULL;
5793
0
    }
5794
5795
0
    if (depth <= 0) {
5796
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5797
0
    }
5798
5799
0
    int status = Py_ReprEnter((PyObject *)self);
5800
0
    if (status != 0) {
5801
0
        if (status < 0) {
5802
0
            return NULL;
5803
0
        }
5804
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5805
0
    }
5806
5807
0
    PyObject *fields;
5808
0
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5809
0
        Py_ReprLeave((PyObject *)self);
5810
0
        return NULL;
5811
0
    }
5812
5813
0
    Py_ssize_t numfields = PySequence_Size(fields);
5814
0
    if (numfields < 0) {
5815
0
        Py_ReprLeave((PyObject *)self);
5816
0
        Py_DECREF(fields);
5817
0
        return NULL;
5818
0
    }
5819
5820
0
    if (numfields == 0) {
5821
0
        Py_ReprLeave((PyObject *)self);
5822
0
        Py_DECREF(fields);
5823
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5824
0
    }
5825
5826
0
    const char* tp_name = Py_TYPE(self)->tp_name;
5827
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5828
0
    if (writer == NULL) {
5829
0
        goto error;
5830
0
    }
5831
5832
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5833
0
        goto error;
5834
0
    }
5835
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5836
0
        goto error;
5837
0
    }
5838
5839
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
5840
0
        PyObject *name = PySequence_GetItem(fields, i);
5841
0
        if (!name) {
5842
0
            goto error;
5843
0
        }
5844
5845
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5846
0
        if (!value) {
5847
0
            Py_DECREF(name);
5848
0
            goto error;
5849
0
        }
5850
5851
0
        PyObject *value_repr;
5852
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
5853
0
            value_repr = ast_repr_list(value, depth);
5854
0
        }
5855
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5856
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5857
0
        }
5858
0
        else {
5859
0
            value_repr = PyObject_Repr(value);
5860
0
        }
5861
5862
0
        Py_DECREF(value);
5863
5864
0
        if (!value_repr) {
5865
0
            Py_DECREF(name);
5866
0
            goto error;
5867
0
        }
5868
5869
0
        if (i > 0) {
5870
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5871
0
                Py_DECREF(name);
5872
0
                Py_DECREF(value_repr);
5873
0
                goto error;
5874
0
            }
5875
0
        }
5876
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5877
0
            Py_DECREF(name);
5878
0
            Py_DECREF(value_repr);
5879
0
            goto error;
5880
0
        }
5881
5882
0
        Py_DECREF(name);
5883
5884
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5885
0
            Py_DECREF(value_repr);
5886
0
            goto error;
5887
0
        }
5888
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5889
0
            Py_DECREF(value_repr);
5890
0
            goto error;
5891
0
        }
5892
5893
0
        Py_DECREF(value_repr);
5894
0
    }
5895
5896
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5897
0
        goto error;
5898
0
    }
5899
0
    Py_ReprLeave((PyObject *)self);
5900
0
    Py_DECREF(fields);
5901
0
    return PyUnicodeWriter_Finish(writer);
5902
5903
0
error:
5904
0
    Py_ReprLeave((PyObject *)self);
5905
0
    Py_DECREF(fields);
5906
0
    PyUnicodeWriter_Discard(writer);
5907
0
    return NULL;
5908
0
}
5909
5910
static PyObject *
5911
ast_repr(PyObject *self)
5912
0
{
5913
0
    return ast_repr_max_depth((AST_object*)self, 3);
5914
0
}
5915
5916
static PyType_Slot AST_type_slots[] = {
5917
    {Py_tp_dealloc, ast_dealloc},
5918
    {Py_tp_repr, ast_repr},
5919
    {Py_tp_getattro, PyObject_GenericGetAttr},
5920
    {Py_tp_setattro, PyObject_GenericSetAttr},
5921
    {Py_tp_traverse, ast_traverse},
5922
    {Py_tp_clear, ast_clear},
5923
    {Py_tp_members, ast_type_members},
5924
    {Py_tp_methods, ast_type_methods},
5925
    {Py_tp_getset, ast_type_getsets},
5926
    {Py_tp_init, ast_type_init},
5927
    {Py_tp_alloc, PyType_GenericAlloc},
5928
    {Py_tp_new, PyType_GenericNew},
5929
    {Py_tp_free, PyObject_GC_Del},
5930
    {0, 0},
5931
};
5932
5933
static PyType_Spec AST_type_spec = {
5934
    "ast.AST",
5935
    sizeof(AST_object),
5936
    0,
5937
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
5938
    AST_type_slots
5939
};
5940
5941
static PyObject *
5942
make_type(struct ast_state *state, const char *type, PyObject* base,
5943
          const char* const* fields, int num_fields, const char *doc)
5944
2.00k
{
5945
2.00k
    PyObject *fnames, *result;
5946
2.00k
    int i;
5947
2.00k
    fnames = PyTuple_New(num_fields);
5948
2.00k
    if (!fnames) return NULL;
5949
5.16k
    for (i = 0; i < num_fields; i++) {
5950
3.16k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
5951
3.16k
        if (!field) {
5952
0
            Py_DECREF(fnames);
5953
0
            return NULL;
5954
0
        }
5955
3.16k
        PyTuple_SET_ITEM(fnames, i, field);
5956
3.16k
    }
5957
2.00k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
5958
2.00k
                    type, base,
5959
2.00k
                    state->_fields, fnames,
5960
2.00k
                    state->__match_args__, fnames,
5961
2.00k
                    state->__module__,
5962
2.00k
                    state->ast,
5963
2.00k
                    state->__doc__, doc);
5964
2.00k
    Py_DECREF(fnames);
5965
2.00k
    return result;
5966
2.00k
}
5967
5968
static int
5969
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
5970
304
{
5971
304
    int i, result;
5972
304
    PyObject *s, *l = PyTuple_New(num_fields);
5973
304
    if (!l)
5974
0
        return -1;
5975
816
    for (i = 0; i < num_fields; i++) {
5976
512
        s = PyUnicode_InternFromString(attrs[i]);
5977
512
        if (!s) {
5978
0
            Py_DECREF(l);
5979
0
            return -1;
5980
0
        }
5981
512
        PyTuple_SET_ITEM(l, i, s);
5982
512
    }
5983
304
    result = PyObject_SetAttr(type, state->_attributes, l);
5984
304
    Py_DECREF(l);
5985
304
    return result;
5986
304
}
5987
5988
/* Conversion AST -> Python */
5989
5990
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
5991
                              PyObject* (*func)(struct ast_state *state, void*))
5992
101k
{
5993
101k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
5994
101k
    PyObject *result = PyList_New(n);
5995
101k
    PyObject *value;
5996
101k
    if (!result)
5997
0
        return NULL;
5998
279k
    for (i = 0; i < n; i++) {
5999
177k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6000
177k
        if (!value) {
6001
0
            Py_DECREF(result);
6002
0
            return NULL;
6003
0
        }
6004
177k
        PyList_SET_ITEM(result, i, value);
6005
177k
    }
6006
101k
    return result;
6007
101k
}
6008
6009
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6010
274k
{
6011
274k
    PyObject *op = (PyObject*)o;
6012
274k
    if (!op) {
6013
93.2k
        op = Py_None;
6014
93.2k
    }
6015
274k
    return Py_NewRef(op);
6016
274k
}
6017
66.1k
#define ast2obj_constant ast2obj_object
6018
122k
#define ast2obj_identifier ast2obj_object
6019
83.7k
#define ast2obj_string ast2obj_object
6020
6021
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6022
1.90M
{
6023
1.90M
    return PyLong_FromLong(b);
6024
1.90M
}
6025
6026
/* Conversion Python -> AST */
6027
6028
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj,
6029
                          PyObject** out,
6030
                          const char* Py_UNUSED(field), PyArena* arena)
6031
0
{
6032
0
    if (obj == Py_None)
6033
0
        obj = NULL;
6034
0
    if (obj) {
6035
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6036
0
            *out = NULL;
6037
0
            return -1;
6038
0
        }
6039
0
        *out = Py_NewRef(obj);
6040
0
    }
6041
0
    else {
6042
0
        *out = NULL;
6043
0
    }
6044
0
    return 0;
6045
0
}
6046
6047
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj,
6048
                            PyObject** out,
6049
                            const char* Py_UNUSED(field), PyArena* arena)
6050
0
{
6051
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6052
0
        *out = NULL;
6053
0
        return -1;
6054
0
    }
6055
0
    *out = Py_NewRef(obj);
6056
0
    return 0;
6057
0
}
6058
6059
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, const char* field, PyArena* arena)
6060
0
{
6061
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6062
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting a string object, got %T", field, obj);
6063
0
        return -1;
6064
0
    }
6065
0
    return obj2ast_object(state, obj, out, field, arena);
6066
0
}
6067
6068
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, const char* field, PyArena* arena)
6069
0
{
6070
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6071
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting a string or bytes object, got %T", field, obj);
6072
0
        return -1;
6073
0
    }
6074
0
    return obj2ast_object(state, obj, out, field, arena);
6075
0
}
6076
6077
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, const char* field, PyArena* arena)
6078
0
{
6079
0
    int i;
6080
0
    if (!PyLong_Check(obj)) {
6081
0
        PyErr_Format(PyExc_ValueError, "field \"%s\" got an invalid integer value: %R", field, obj);
6082
0
        return -1;
6083
0
    }
6084
6085
0
    i = PyLong_AsInt(obj);
6086
0
    if (i == -1 && PyErr_Occurred())
6087
0
        return -1;
6088
0
    *out = i;
6089
0
    return 0;
6090
0
}
6091
6092
static int add_ast_fields(struct ast_state *state)
6093
16
{
6094
16
    PyObject *empty_tuple;
6095
16
    empty_tuple = PyTuple_New(0);
6096
16
    if (!empty_tuple ||
6097
16
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6098
16
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6099
16
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6100
0
        Py_XDECREF(empty_tuple);
6101
0
        return -1;
6102
0
    }
6103
16
    Py_DECREF(empty_tuple);
6104
16
    return 0;
6105
16
}
6106
6107
6108
6109
static int
6110
init_types(void *arg)
6111
16
{
6112
16
    struct ast_state *state = arg;
6113
16
    if (init_identifiers(state) < 0) {
6114
0
        return -1;
6115
0
    }
6116
16
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6117
16
    if (!state->AST_type) {
6118
0
        return -1;
6119
0
    }
6120
16
    state->abstract_types = PySet_New(NULL);
6121
16
    if (!state->abstract_types) {
6122
0
        return -1;
6123
0
    }
6124
16
    if (PySet_Add(state->abstract_types, state->AST_type) < 0) {
6125
0
        return -1;
6126
0
    }
6127
16
    if (add_ast_fields(state) < 0) {
6128
0
        return -1;
6129
0
    }
6130
16
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6131
16
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6132
16
        "    | Interactive(stmt* body)\n"
6133
16
        "    | Expression(expr body)\n"
6134
16
        "    | FunctionType(expr* argtypes, expr returns)");
6135
16
    if (!state->mod_type) return -1;
6136
16
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6137
16
    if (PySet_Add(state->abstract_types, state->mod_type) < 0) return -1;
6138
16
    state->Module_type = make_type(state, "Module", state->mod_type,
6139
16
                                   Module_fields, 2,
6140
16
        "Module(stmt* body, type_ignore* type_ignores)");
6141
16
    if (!state->Module_type) return -1;
6142
16
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6143
16
                                        Interactive_fields, 1,
6144
16
        "Interactive(stmt* body)");
6145
16
    if (!state->Interactive_type) return -1;
6146
16
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6147
16
                                       Expression_fields, 1,
6148
16
        "Expression(expr body)");
6149
16
    if (!state->Expression_type) return -1;
6150
16
    state->FunctionType_type = make_type(state, "FunctionType",
6151
16
                                         state->mod_type, FunctionType_fields,
6152
16
                                         2,
6153
16
        "FunctionType(expr* argtypes, expr returns)");
6154
16
    if (!state->FunctionType_type) return -1;
6155
16
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6156
16
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6157
16
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6158
16
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6159
16
        "     | Return(expr? value)\n"
6160
16
        "     | Delete(expr* targets)\n"
6161
16
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6162
16
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6163
16
        "     | AugAssign(expr target, operator op, expr value)\n"
6164
16
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6165
16
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6166
16
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6167
16
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6168
16
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6169
16
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6170
16
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6171
16
        "     | Match(expr subject, match_case* cases)\n"
6172
16
        "     | Raise(expr? exc, expr? cause)\n"
6173
16
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6174
16
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6175
16
        "     | Assert(expr test, expr? msg)\n"
6176
16
        "     | Import(alias* names, int? is_lazy)\n"
6177
16
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
6178
16
        "     | Global(identifier* names)\n"
6179
16
        "     | Nonlocal(identifier* names)\n"
6180
16
        "     | Expr(expr value)\n"
6181
16
        "     | Pass\n"
6182
16
        "     | Break\n"
6183
16
        "     | Continue");
6184
16
    if (!state->stmt_type) return -1;
6185
16
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6186
0
        -1;
6187
16
    if (PySet_Add(state->abstract_types, state->stmt_type) < 0) return -1;
6188
16
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6189
0
        return -1;
6190
16
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6191
16
        -1)
6192
0
        return -1;
6193
16
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6194
16
                                        FunctionDef_fields, 7,
6195
16
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6196
16
    if (!state->FunctionDef_type) return -1;
6197
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6198
16
        -1)
6199
0
        return -1;
6200
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6201
16
        == -1)
6202
0
        return -1;
6203
16
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6204
16
                                             state->stmt_type,
6205
16
                                             AsyncFunctionDef_fields, 7,
6206
16
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6207
16
    if (!state->AsyncFunctionDef_type) return -1;
6208
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6209
16
        == -1)
6210
0
        return -1;
6211
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6212
16
        Py_None) == -1)
6213
0
        return -1;
6214
16
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6215
16
                                     ClassDef_fields, 6,
6216
16
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6217
16
    if (!state->ClassDef_type) return -1;
6218
16
    state->Return_type = make_type(state, "Return", state->stmt_type,
6219
16
                                   Return_fields, 1,
6220
16
        "Return(expr? value)");
6221
16
    if (!state->Return_type) return -1;
6222
16
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6223
0
        return -1;
6224
16
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6225
16
                                   Delete_fields, 1,
6226
16
        "Delete(expr* targets)");
6227
16
    if (!state->Delete_type) return -1;
6228
16
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6229
16
                                   Assign_fields, 3,
6230
16
        "Assign(expr* targets, expr value, string? type_comment)");
6231
16
    if (!state->Assign_type) return -1;
6232
16
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6233
16
        -1)
6234
0
        return -1;
6235
16
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6236
16
                                      TypeAlias_fields, 3,
6237
16
        "TypeAlias(expr name, type_param* type_params, expr value)");
6238
16
    if (!state->TypeAlias_type) return -1;
6239
16
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6240
16
                                      AugAssign_fields, 3,
6241
16
        "AugAssign(expr target, operator op, expr value)");
6242
16
    if (!state->AugAssign_type) return -1;
6243
16
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6244
16
                                      AnnAssign_fields, 4,
6245
16
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6246
16
    if (!state->AnnAssign_type) return -1;
6247
16
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6248
0
        return -1;
6249
16
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6250
16
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6251
16
    if (!state->For_type) return -1;
6252
16
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6253
0
        return -1;
6254
16
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6255
16
                                     AsyncFor_fields, 5,
6256
16
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6257
16
    if (!state->AsyncFor_type) return -1;
6258
16
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6259
16
        -1)
6260
0
        return -1;
6261
16
    state->While_type = make_type(state, "While", state->stmt_type,
6262
16
                                  While_fields, 3,
6263
16
        "While(expr test, stmt* body, stmt* orelse)");
6264
16
    if (!state->While_type) return -1;
6265
16
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6266
16
        "If(expr test, stmt* body, stmt* orelse)");
6267
16
    if (!state->If_type) return -1;
6268
16
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6269
16
                                 3,
6270
16
        "With(withitem* items, stmt* body, string? type_comment)");
6271
16
    if (!state->With_type) return -1;
6272
16
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6273
0
        return -1;
6274
16
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6275
16
                                      AsyncWith_fields, 3,
6276
16
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6277
16
    if (!state->AsyncWith_type) return -1;
6278
16
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6279
16
        == -1)
6280
0
        return -1;
6281
16
    state->Match_type = make_type(state, "Match", state->stmt_type,
6282
16
                                  Match_fields, 2,
6283
16
        "Match(expr subject, match_case* cases)");
6284
16
    if (!state->Match_type) return -1;
6285
16
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6286
16
                                  Raise_fields, 2,
6287
16
        "Raise(expr? exc, expr? cause)");
6288
16
    if (!state->Raise_type) return -1;
6289
16
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6290
0
        return -1;
6291
16
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6292
0
        return -1;
6293
16
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6294
16
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6295
16
    if (!state->Try_type) return -1;
6296
16
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6297
16
                                    TryStar_fields, 4,
6298
16
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6299
16
    if (!state->TryStar_type) return -1;
6300
16
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6301
16
                                   Assert_fields, 2,
6302
16
        "Assert(expr test, expr? msg)");
6303
16
    if (!state->Assert_type) return -1;
6304
16
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6305
0
        return -1;
6306
16
    state->Import_type = make_type(state, "Import", state->stmt_type,
6307
16
                                   Import_fields, 2,
6308
16
        "Import(alias* names, int? is_lazy)");
6309
16
    if (!state->Import_type) return -1;
6310
16
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
6311
0
        return -1;
6312
16
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6313
16
                                       ImportFrom_fields, 4,
6314
16
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
6315
16
    if (!state->ImportFrom_type) return -1;
6316
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6317
0
        return -1;
6318
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6319
0
        return -1;
6320
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
6321
0
        return -1;
6322
16
    state->Global_type = make_type(state, "Global", state->stmt_type,
6323
16
                                   Global_fields, 1,
6324
16
        "Global(identifier* names)");
6325
16
    if (!state->Global_type) return -1;
6326
16
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6327
16
                                     Nonlocal_fields, 1,
6328
16
        "Nonlocal(identifier* names)");
6329
16
    if (!state->Nonlocal_type) return -1;
6330
16
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6331
16
                                 1,
6332
16
        "Expr(expr value)");
6333
16
    if (!state->Expr_type) return -1;
6334
16
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6335
16
        "Pass");
6336
16
    if (!state->Pass_type) return -1;
6337
16
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6338
16
        "Break");
6339
16
    if (!state->Break_type) return -1;
6340
16
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6341
16
                                     0,
6342
16
        "Continue");
6343
16
    if (!state->Continue_type) return -1;
6344
16
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6345
16
        "expr = BoolOp(boolop op, expr* values)\n"
6346
16
        "     | NamedExpr(expr target, expr value)\n"
6347
16
        "     | BinOp(expr left, operator op, expr right)\n"
6348
16
        "     | UnaryOp(unaryop op, expr operand)\n"
6349
16
        "     | Lambda(arguments args, expr body)\n"
6350
16
        "     | IfExp(expr test, expr body, expr orelse)\n"
6351
16
        "     | Dict(expr?* keys, expr* values)\n"
6352
16
        "     | Set(expr* elts)\n"
6353
16
        "     | ListComp(expr elt, comprehension* generators)\n"
6354
16
        "     | SetComp(expr elt, comprehension* generators)\n"
6355
16
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6356
16
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6357
16
        "     | Await(expr value)\n"
6358
16
        "     | Yield(expr? value)\n"
6359
16
        "     | YieldFrom(expr value)\n"
6360
16
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6361
16
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6362
16
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6363
16
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6364
16
        "     | JoinedStr(expr* values)\n"
6365
16
        "     | TemplateStr(expr* values)\n"
6366
16
        "     | Constant(constant value, string? kind)\n"
6367
16
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6368
16
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6369
16
        "     | Starred(expr value, expr_context ctx)\n"
6370
16
        "     | Name(identifier id, expr_context ctx)\n"
6371
16
        "     | List(expr* elts, expr_context ctx)\n"
6372
16
        "     | Tuple(expr* elts, expr_context ctx)\n"
6373
16
        "     | Slice(expr? lower, expr? upper, expr? step)");
6374
16
    if (!state->expr_type) return -1;
6375
16
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6376
0
        -1;
6377
16
    if (PySet_Add(state->abstract_types, state->expr_type) < 0) return -1;
6378
16
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6379
0
        return -1;
6380
16
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6381
16
        -1)
6382
0
        return -1;
6383
16
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6384
16
                                   BoolOp_fields, 2,
6385
16
        "BoolOp(boolop op, expr* values)");
6386
16
    if (!state->BoolOp_type) return -1;
6387
16
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6388
16
                                      NamedExpr_fields, 2,
6389
16
        "NamedExpr(expr target, expr value)");
6390
16
    if (!state->NamedExpr_type) return -1;
6391
16
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6392
16
                                  BinOp_fields, 3,
6393
16
        "BinOp(expr left, operator op, expr right)");
6394
16
    if (!state->BinOp_type) return -1;
6395
16
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6396
16
                                    UnaryOp_fields, 2,
6397
16
        "UnaryOp(unaryop op, expr operand)");
6398
16
    if (!state->UnaryOp_type) return -1;
6399
16
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6400
16
                                   Lambda_fields, 2,
6401
16
        "Lambda(arguments args, expr body)");
6402
16
    if (!state->Lambda_type) return -1;
6403
16
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6404
16
                                  IfExp_fields, 3,
6405
16
        "IfExp(expr test, expr body, expr orelse)");
6406
16
    if (!state->IfExp_type) return -1;
6407
16
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6408
16
                                 2,
6409
16
        "Dict(expr?* keys, expr* values)");
6410
16
    if (!state->Dict_type) return -1;
6411
16
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6412
16
        "Set(expr* elts)");
6413
16
    if (!state->Set_type) return -1;
6414
16
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6415
16
                                     ListComp_fields, 2,
6416
16
        "ListComp(expr elt, comprehension* generators)");
6417
16
    if (!state->ListComp_type) return -1;
6418
16
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6419
16
                                    SetComp_fields, 2,
6420
16
        "SetComp(expr elt, comprehension* generators)");
6421
16
    if (!state->SetComp_type) return -1;
6422
16
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6423
16
                                     DictComp_fields, 3,
6424
16
        "DictComp(expr key, expr? value, comprehension* generators)");
6425
16
    if (!state->DictComp_type) return -1;
6426
16
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6427
0
        return -1;
6428
16
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6429
16
                                         state->expr_type, GeneratorExp_fields,
6430
16
                                         2,
6431
16
        "GeneratorExp(expr elt, comprehension* generators)");
6432
16
    if (!state->GeneratorExp_type) return -1;
6433
16
    state->Await_type = make_type(state, "Await", state->expr_type,
6434
16
                                  Await_fields, 1,
6435
16
        "Await(expr value)");
6436
16
    if (!state->Await_type) return -1;
6437
16
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6438
16
                                  Yield_fields, 1,
6439
16
        "Yield(expr? value)");
6440
16
    if (!state->Yield_type) return -1;
6441
16
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6442
0
        return -1;
6443
16
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6444
16
                                      YieldFrom_fields, 1,
6445
16
        "YieldFrom(expr value)");
6446
16
    if (!state->YieldFrom_type) return -1;
6447
16
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6448
16
                                    Compare_fields, 3,
6449
16
        "Compare(expr left, cmpop* ops, expr* comparators)");
6450
16
    if (!state->Compare_type) return -1;
6451
16
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6452
16
                                 3,
6453
16
        "Call(expr func, expr* args, keyword* keywords)");
6454
16
    if (!state->Call_type) return -1;
6455
16
    state->FormattedValue_type = make_type(state, "FormattedValue",
6456
16
                                           state->expr_type,
6457
16
                                           FormattedValue_fields, 3,
6458
16
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6459
16
    if (!state->FormattedValue_type) return -1;
6460
16
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6461
16
        Py_None) == -1)
6462
0
        return -1;
6463
16
    state->Interpolation_type = make_type(state, "Interpolation",
6464
16
                                          state->expr_type,
6465
16
                                          Interpolation_fields, 4,
6466
16
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6467
16
    if (!state->Interpolation_type) return -1;
6468
16
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6469
16
        Py_None) == -1)
6470
0
        return -1;
6471
16
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6472
16
                                      JoinedStr_fields, 1,
6473
16
        "JoinedStr(expr* values)");
6474
16
    if (!state->JoinedStr_type) return -1;
6475
16
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6476
16
                                        TemplateStr_fields, 1,
6477
16
        "TemplateStr(expr* values)");
6478
16
    if (!state->TemplateStr_type) return -1;
6479
16
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6480
16
                                     Constant_fields, 2,
6481
16
        "Constant(constant value, string? kind)");
6482
16
    if (!state->Constant_type) return -1;
6483
16
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6484
0
        return -1;
6485
16
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6486
16
                                      Attribute_fields, 3,
6487
16
        "Attribute(expr value, identifier attr, expr_context ctx)");
6488
16
    if (!state->Attribute_type) return -1;
6489
16
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6490
16
                                      Subscript_fields, 3,
6491
16
        "Subscript(expr value, expr slice, expr_context ctx)");
6492
16
    if (!state->Subscript_type) return -1;
6493
16
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6494
16
                                    Starred_fields, 2,
6495
16
        "Starred(expr value, expr_context ctx)");
6496
16
    if (!state->Starred_type) return -1;
6497
16
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6498
16
                                 2,
6499
16
        "Name(identifier id, expr_context ctx)");
6500
16
    if (!state->Name_type) return -1;
6501
16
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6502
16
                                 2,
6503
16
        "List(expr* elts, expr_context ctx)");
6504
16
    if (!state->List_type) return -1;
6505
16
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6506
16
                                  Tuple_fields, 2,
6507
16
        "Tuple(expr* elts, expr_context ctx)");
6508
16
    if (!state->Tuple_type) return -1;
6509
16
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6510
16
                                  Slice_fields, 3,
6511
16
        "Slice(expr? lower, expr? upper, expr? step)");
6512
16
    if (!state->Slice_type) return -1;
6513
16
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6514
0
        return -1;
6515
16
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6516
0
        return -1;
6517
16
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6518
0
        return -1;
6519
16
    state->expr_context_type = make_type(state, "expr_context",
6520
16
                                         state->AST_type, NULL, 0,
6521
16
        "expr_context = Load | Store | Del");
6522
16
    if (!state->expr_context_type) return -1;
6523
16
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6524
16
    if (PySet_Add(state->abstract_types, state->expr_context_type) < 0) return
6525
0
        -1;
6526
16
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6527
16
                                 0,
6528
16
        "Load");
6529
16
    if (!state->Load_type) return -1;
6530
16
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6531
16
                                              NULL, NULL);
6532
16
    if (!state->Load_singleton) return -1;
6533
16
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6534
16
                                  NULL, 0,
6535
16
        "Store");
6536
16
    if (!state->Store_type) return -1;
6537
16
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6538
16
                                               *)state->Store_type, NULL, NULL);
6539
16
    if (!state->Store_singleton) return -1;
6540
16
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6541
16
        "Del");
6542
16
    if (!state->Del_type) return -1;
6543
16
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6544
16
                                             NULL, NULL);
6545
16
    if (!state->Del_singleton) return -1;
6546
16
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6547
16
        "boolop = And | Or");
6548
16
    if (!state->boolop_type) return -1;
6549
16
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6550
16
    if (PySet_Add(state->abstract_types, state->boolop_type) < 0) return -1;
6551
16
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6552
16
        "And");
6553
16
    if (!state->And_type) return -1;
6554
16
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6555
16
                                             NULL, NULL);
6556
16
    if (!state->And_singleton) return -1;
6557
16
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6558
16
        "Or");
6559
16
    if (!state->Or_type) return -1;
6560
16
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6561
16
                                            NULL, NULL);
6562
16
    if (!state->Or_singleton) return -1;
6563
16
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6564
16
                                     0,
6565
16
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6566
16
    if (!state->operator_type) return -1;
6567
16
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6568
16
    if (PySet_Add(state->abstract_types, state->operator_type) < 0) return -1;
6569
16
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6570
16
        "Add");
6571
16
    if (!state->Add_type) return -1;
6572
16
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6573
16
                                             NULL, NULL);
6574
16
    if (!state->Add_singleton) return -1;
6575
16
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6576
16
        "Sub");
6577
16
    if (!state->Sub_type) return -1;
6578
16
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6579
16
                                             NULL, NULL);
6580
16
    if (!state->Sub_singleton) return -1;
6581
16
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6582
16
        "Mult");
6583
16
    if (!state->Mult_type) return -1;
6584
16
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6585
16
                                              NULL, NULL);
6586
16
    if (!state->Mult_singleton) return -1;
6587
16
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6588
16
                                    NULL, 0,
6589
16
        "MatMult");
6590
16
    if (!state->MatMult_type) return -1;
6591
16
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6592
16
                                                 *)state->MatMult_type, NULL,
6593
16
                                                 NULL);
6594
16
    if (!state->MatMult_singleton) return -1;
6595
16
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6596
16
        "Div");
6597
16
    if (!state->Div_type) return -1;
6598
16
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6599
16
                                             NULL, NULL);
6600
16
    if (!state->Div_singleton) return -1;
6601
16
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6602
16
        "Mod");
6603
16
    if (!state->Mod_type) return -1;
6604
16
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6605
16
                                             NULL, NULL);
6606
16
    if (!state->Mod_singleton) return -1;
6607
16
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6608
16
        "Pow");
6609
16
    if (!state->Pow_type) return -1;
6610
16
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6611
16
                                             NULL, NULL);
6612
16
    if (!state->Pow_singleton) return -1;
6613
16
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6614
16
                                   0,
6615
16
        "LShift");
6616
16
    if (!state->LShift_type) return -1;
6617
16
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6618
16
                                                *)state->LShift_type, NULL,
6619
16
                                                NULL);
6620
16
    if (!state->LShift_singleton) return -1;
6621
16
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6622
16
                                   0,
6623
16
        "RShift");
6624
16
    if (!state->RShift_type) return -1;
6625
16
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6626
16
                                                *)state->RShift_type, NULL,
6627
16
                                                NULL);
6628
16
    if (!state->RShift_singleton) return -1;
6629
16
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6630
16
        "BitOr");
6631
16
    if (!state->BitOr_type) return -1;
6632
16
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6633
16
                                               *)state->BitOr_type, NULL, NULL);
6634
16
    if (!state->BitOr_singleton) return -1;
6635
16
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6636
16
                                   0,
6637
16
        "BitXor");
6638
16
    if (!state->BitXor_type) return -1;
6639
16
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6640
16
                                                *)state->BitXor_type, NULL,
6641
16
                                                NULL);
6642
16
    if (!state->BitXor_singleton) return -1;
6643
16
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6644
16
                                   0,
6645
16
        "BitAnd");
6646
16
    if (!state->BitAnd_type) return -1;
6647
16
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6648
16
                                                *)state->BitAnd_type, NULL,
6649
16
                                                NULL);
6650
16
    if (!state->BitAnd_singleton) return -1;
6651
16
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6652
16
                                     NULL, 0,
6653
16
        "FloorDiv");
6654
16
    if (!state->FloorDiv_type) return -1;
6655
16
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6656
16
                                                  *)state->FloorDiv_type, NULL,
6657
16
                                                  NULL);
6658
16
    if (!state->FloorDiv_singleton) return -1;
6659
16
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6660
16
        "unaryop = Invert | Not | UAdd | USub");
6661
16
    if (!state->unaryop_type) return -1;
6662
16
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6663
16
    if (PySet_Add(state->abstract_types, state->unaryop_type) < 0) return -1;
6664
16
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6665
16
                                   0,
6666
16
        "Invert");
6667
16
    if (!state->Invert_type) return -1;
6668
16
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6669
16
                                                *)state->Invert_type, NULL,
6670
16
                                                NULL);
6671
16
    if (!state->Invert_singleton) return -1;
6672
16
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6673
16
        "Not");
6674
16
    if (!state->Not_type) return -1;
6675
16
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6676
16
                                             NULL, NULL);
6677
16
    if (!state->Not_singleton) return -1;
6678
16
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6679
16
        "UAdd");
6680
16
    if (!state->UAdd_type) return -1;
6681
16
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6682
16
                                              NULL, NULL);
6683
16
    if (!state->UAdd_singleton) return -1;
6684
16
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6685
16
        "USub");
6686
16
    if (!state->USub_type) return -1;
6687
16
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6688
16
                                              NULL, NULL);
6689
16
    if (!state->USub_singleton) return -1;
6690
16
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6691
16
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6692
16
    if (!state->cmpop_type) return -1;
6693
16
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6694
16
    if (PySet_Add(state->abstract_types, state->cmpop_type) < 0) return -1;
6695
16
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6696
16
        "Eq");
6697
16
    if (!state->Eq_type) return -1;
6698
16
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6699
16
                                            NULL, NULL);
6700
16
    if (!state->Eq_singleton) return -1;
6701
16
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6702
16
        "NotEq");
6703
16
    if (!state->NotEq_type) return -1;
6704
16
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6705
16
                                               *)state->NotEq_type, NULL, NULL);
6706
16
    if (!state->NotEq_singleton) return -1;
6707
16
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6708
16
        "Lt");
6709
16
    if (!state->Lt_type) return -1;
6710
16
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6711
16
                                            NULL, NULL);
6712
16
    if (!state->Lt_singleton) return -1;
6713
16
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6714
16
        "LtE");
6715
16
    if (!state->LtE_type) return -1;
6716
16
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6717
16
                                             NULL, NULL);
6718
16
    if (!state->LtE_singleton) return -1;
6719
16
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6720
16
        "Gt");
6721
16
    if (!state->Gt_type) return -1;
6722
16
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6723
16
                                            NULL, NULL);
6724
16
    if (!state->Gt_singleton) return -1;
6725
16
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6726
16
        "GtE");
6727
16
    if (!state->GtE_type) return -1;
6728
16
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6729
16
                                             NULL, NULL);
6730
16
    if (!state->GtE_singleton) return -1;
6731
16
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6732
16
        "Is");
6733
16
    if (!state->Is_type) return -1;
6734
16
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6735
16
                                            NULL, NULL);
6736
16
    if (!state->Is_singleton) return -1;
6737
16
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6738
16
        "IsNot");
6739
16
    if (!state->IsNot_type) return -1;
6740
16
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6741
16
                                               *)state->IsNot_type, NULL, NULL);
6742
16
    if (!state->IsNot_singleton) return -1;
6743
16
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6744
16
        "In");
6745
16
    if (!state->In_type) return -1;
6746
16
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6747
16
                                            NULL, NULL);
6748
16
    if (!state->In_singleton) return -1;
6749
16
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6750
16
        "NotIn");
6751
16
    if (!state->NotIn_type) return -1;
6752
16
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6753
16
                                               *)state->NotIn_type, NULL, NULL);
6754
16
    if (!state->NotIn_singleton) return -1;
6755
16
    state->comprehension_type = make_type(state, "comprehension",
6756
16
                                          state->AST_type,
6757
16
                                          comprehension_fields, 4,
6758
16
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6759
16
    if (!state->comprehension_type) return -1;
6760
16
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6761
0
        -1;
6762
16
    state->excepthandler_type = make_type(state, "excepthandler",
6763
16
                                          state->AST_type, NULL, 0,
6764
16
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6765
16
    if (!state->excepthandler_type) return -1;
6766
16
    if (add_attributes(state, state->excepthandler_type,
6767
16
        excepthandler_attributes, 4) < 0) return -1;
6768
16
    if (PySet_Add(state->abstract_types, state->excepthandler_type) < 0) return
6769
0
        -1;
6770
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6771
16
        == -1)
6772
0
        return -1;
6773
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6774
16
        Py_None) == -1)
6775
0
        return -1;
6776
16
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6777
16
                                          state->excepthandler_type,
6778
16
                                          ExceptHandler_fields, 3,
6779
16
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6780
16
    if (!state->ExceptHandler_type) return -1;
6781
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6782
0
        return -1;
6783
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6784
0
        return -1;
6785
16
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6786
16
                                      arguments_fields, 7,
6787
16
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6788
16
    if (!state->arguments_type) return -1;
6789
16
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6790
16
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6791
0
        return -1;
6792
16
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6793
0
        return -1;
6794
16
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6795
16
        "arg(identifier arg, expr? annotation, string? type_comment)");
6796
16
    if (!state->arg_type) return -1;
6797
16
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6798
0
        -1;
6799
16
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6800
0
        return -1;
6801
16
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6802
0
        return -1;
6803
16
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6804
0
        return -1;
6805
16
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6806
0
        return -1;
6807
16
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6808
16
                                    keyword_fields, 2,
6809
16
        "keyword(identifier? arg, expr value)");
6810
16
    if (!state->keyword_type) return -1;
6811
16
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6812
0
        return -1;
6813
16
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6814
0
        return -1;
6815
16
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6816
0
        return -1;
6817
16
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6818
16
        == -1)
6819
0
        return -1;
6820
16
    state->alias_type = make_type(state, "alias", state->AST_type,
6821
16
                                  alias_fields, 2,
6822
16
        "alias(identifier name, identifier? asname)");
6823
16
    if (!state->alias_type) return -1;
6824
16
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6825
0
        return -1;
6826
16
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6827
0
        return -1;
6828
16
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6829
0
        return -1;
6830
16
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6831
16
        -1)
6832
0
        return -1;
6833
16
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6834
16
                                     withitem_fields, 2,
6835
16
        "withitem(expr context_expr, expr? optional_vars)");
6836
16
    if (!state->withitem_type) return -1;
6837
16
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6838
16
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6839
16
        == -1)
6840
0
        return -1;
6841
16
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6842
16
                                       match_case_fields, 3,
6843
16
        "match_case(pattern pattern, expr? guard, stmt* body)");
6844
16
    if (!state->match_case_type) return -1;
6845
16
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6846
16
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6847
0
        return -1;
6848
16
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6849
16
        "pattern = MatchValue(expr value)\n"
6850
16
        "        | MatchSingleton(constant value)\n"
6851
16
        "        | MatchSequence(pattern* patterns)\n"
6852
16
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6853
16
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6854
16
        "        | MatchStar(identifier? name)\n"
6855
16
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6856
16
        "        | MatchOr(pattern* patterns)");
6857
16
    if (!state->pattern_type) return -1;
6858
16
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6859
0
        return -1;
6860
16
    if (PySet_Add(state->abstract_types, state->pattern_type) < 0) return -1;
6861
16
    state->MatchValue_type = make_type(state, "MatchValue",
6862
16
                                       state->pattern_type, MatchValue_fields,
6863
16
                                       1,
6864
16
        "MatchValue(expr value)");
6865
16
    if (!state->MatchValue_type) return -1;
6866
16
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6867
16
                                           state->pattern_type,
6868
16
                                           MatchSingleton_fields, 1,
6869
16
        "MatchSingleton(constant value)");
6870
16
    if (!state->MatchSingleton_type) return -1;
6871
16
    state->MatchSequence_type = make_type(state, "MatchSequence",
6872
16
                                          state->pattern_type,
6873
16
                                          MatchSequence_fields, 1,
6874
16
        "MatchSequence(pattern* patterns)");
6875
16
    if (!state->MatchSequence_type) return -1;
6876
16
    state->MatchMapping_type = make_type(state, "MatchMapping",
6877
16
                                         state->pattern_type,
6878
16
                                         MatchMapping_fields, 3,
6879
16
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6880
16
    if (!state->MatchMapping_type) return -1;
6881
16
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6882
0
        return -1;
6883
16
    state->MatchClass_type = make_type(state, "MatchClass",
6884
16
                                       state->pattern_type, MatchClass_fields,
6885
16
                                       4,
6886
16
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6887
16
    if (!state->MatchClass_type) return -1;
6888
16
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6889
16
                                      MatchStar_fields, 1,
6890
16
        "MatchStar(identifier? name)");
6891
16
    if (!state->MatchStar_type) return -1;
6892
16
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6893
0
        return -1;
6894
16
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6895
16
                                    MatchAs_fields, 2,
6896
16
        "MatchAs(pattern? pattern, identifier? name)");
6897
16
    if (!state->MatchAs_type) return -1;
6898
16
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6899
0
        return -1;
6900
16
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6901
0
        return -1;
6902
16
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6903
16
                                    MatchOr_fields, 1,
6904
16
        "MatchOr(pattern* patterns)");
6905
16
    if (!state->MatchOr_type) return -1;
6906
16
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6907
16
                                        NULL, 0,
6908
16
        "type_ignore = TypeIgnore(int lineno, string tag)");
6909
16
    if (!state->type_ignore_type) return -1;
6910
16
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6911
16
    if (PySet_Add(state->abstract_types, state->type_ignore_type) < 0) return
6912
0
        -1;
6913
16
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6914
16
                                       state->type_ignore_type,
6915
16
                                       TypeIgnore_fields, 2,
6916
16
        "TypeIgnore(int lineno, string tag)");
6917
16
    if (!state->TypeIgnore_type) return -1;
6918
16
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6919
16
                                       NULL, 0,
6920
16
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6921
16
        "           | ParamSpec(identifier name, expr? default_value)\n"
6922
16
        "           | TypeVarTuple(identifier name, expr? default_value)");
6923
16
    if (!state->type_param_type) return -1;
6924
16
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6925
16
        < 0) return -1;
6926
16
    if (PySet_Add(state->abstract_types, state->type_param_type) < 0) return -1;
6927
16
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6928
16
                                    TypeVar_fields, 3,
6929
16
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6930
16
    if (!state->TypeVar_type) return -1;
6931
16
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6932
0
        return -1;
6933
16
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6934
16
        -1)
6935
0
        return -1;
6936
16
    state->ParamSpec_type = make_type(state, "ParamSpec",
6937
16
                                      state->type_param_type, ParamSpec_fields,
6938
16
                                      2,
6939
16
        "ParamSpec(identifier name, expr? default_value)");
6940
16
    if (!state->ParamSpec_type) return -1;
6941
16
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6942
16
        == -1)
6943
0
        return -1;
6944
16
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6945
16
                                         state->type_param_type,
6946
16
                                         TypeVarTuple_fields, 2,
6947
16
        "TypeVarTuple(identifier name, expr? default_value)");
6948
16
    if (!state->TypeVarTuple_type) return -1;
6949
16
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6950
16
        Py_None) == -1)
6951
0
        return -1;
6952
6953
16
    if (!add_ast_annotations(state)) {
6954
0
        return -1;
6955
0
    }
6956
16
    return 0;
6957
16
}
6958
6959
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6960
                       const char* field, PyArena* arena);
6961
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6962
                        const char* field, PyArena* arena);
6963
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6964
                        const char* field, PyArena* arena);
6965
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6966
                                expr_context_ty* out, const char* field,
6967
                                PyArena* arena);
6968
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
6969
                          out, const char* field, PyArena* arena);
6970
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
6971
                            operator_ty* out, const char* field, PyArena*
6972
                            arena);
6973
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
6974
                           out, const char* field, PyArena* arena);
6975
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
6976
                         const char* field, PyArena* arena);
6977
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
6978
                                 comprehension_ty* out, const char* field,
6979
                                 PyArena* arena);
6980
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
6981
                                 excepthandler_ty* out, const char* field,
6982
                                 PyArena* arena);
6983
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
6984
                             arguments_ty* out, const char* field, PyArena*
6985
                             arena);
6986
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
6987
                       const char* field, PyArena* arena);
6988
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
6989
                           out, const char* field, PyArena* arena);
6990
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
6991
                         const char* field, PyArena* arena);
6992
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
6993
                            withitem_ty* out, const char* field, PyArena*
6994
                            arena);
6995
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
6996
                              match_case_ty* out, const char* field, PyArena*
6997
                              arena);
6998
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
6999
                           out, const char* field, PyArena* arena);
7000
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
7001
                               type_ignore_ty* out, const char* field, PyArena*
7002
                               arena);
7003
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
7004
                              type_param_ty* out, const char* field, PyArena*
7005
                              arena);
7006
7007
mod_ty
7008
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
7009
              PyArena *arena)
7010
7.56k
{
7011
7.56k
    mod_ty p;
7012
7.56k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7013
7.56k
    if (!p)
7014
0
        return NULL;
7015
7.56k
    p->kind = Module_kind;
7016
7.56k
    p->v.Module.body = body;
7017
7.56k
    p->v.Module.type_ignores = type_ignores;
7018
7.56k
    return p;
7019
7.56k
}
7020
7021
mod_ty
7022
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7023
0
{
7024
0
    mod_ty p;
7025
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7026
0
    if (!p)
7027
0
        return NULL;
7028
0
    p->kind = Interactive_kind;
7029
0
    p->v.Interactive.body = body;
7030
0
    return p;
7031
0
}
7032
7033
mod_ty
7034
_PyAST_Expression(expr_ty body, PyArena *arena)
7035
223
{
7036
223
    mod_ty p;
7037
223
    if (!body) {
7038
0
        PyErr_SetString(PyExc_ValueError,
7039
0
                        "field 'body' is required for Expression");
7040
0
        return NULL;
7041
0
    }
7042
223
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7043
223
    if (!p)
7044
0
        return NULL;
7045
223
    p->kind = Expression_kind;
7046
223
    p->v.Expression.body = body;
7047
223
    return p;
7048
223
}
7049
7050
mod_ty
7051
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7052
0
{
7053
0
    mod_ty p;
7054
0
    if (!returns) {
7055
0
        PyErr_SetString(PyExc_ValueError,
7056
0
                        "field 'returns' is required for FunctionType");
7057
0
        return NULL;
7058
0
    }
7059
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7060
0
    if (!p)
7061
0
        return NULL;
7062
0
    p->kind = FunctionType_kind;
7063
0
    p->v.FunctionType.argtypes = argtypes;
7064
0
    p->v.FunctionType.returns = returns;
7065
0
    return p;
7066
0
}
7067
7068
stmt_ty
7069
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7070
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7071
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7072
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7073
                   *arena)
7074
6.01k
{
7075
6.01k
    stmt_ty p;
7076
6.01k
    if (!name) {
7077
0
        PyErr_SetString(PyExc_ValueError,
7078
0
                        "field 'name' is required for FunctionDef");
7079
0
        return NULL;
7080
0
    }
7081
6.01k
    if (!args) {
7082
0
        PyErr_SetString(PyExc_ValueError,
7083
0
                        "field 'args' is required for FunctionDef");
7084
0
        return NULL;
7085
0
    }
7086
6.01k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7087
6.01k
    if (!p)
7088
0
        return NULL;
7089
6.01k
    p->kind = FunctionDef_kind;
7090
6.01k
    p->v.FunctionDef.name = name;
7091
6.01k
    p->v.FunctionDef.args = args;
7092
6.01k
    p->v.FunctionDef.body = body;
7093
6.01k
    p->v.FunctionDef.decorator_list = decorator_list;
7094
6.01k
    p->v.FunctionDef.returns = returns;
7095
6.01k
    p->v.FunctionDef.type_comment = type_comment;
7096
6.01k
    p->v.FunctionDef.type_params = type_params;
7097
6.01k
    p->lineno = lineno;
7098
6.01k
    p->col_offset = col_offset;
7099
6.01k
    p->end_lineno = end_lineno;
7100
6.01k
    p->end_col_offset = end_col_offset;
7101
6.01k
    return p;
7102
6.01k
}
7103
7104
stmt_ty
7105
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7106
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7107
                        string type_comment, asdl_type_param_seq * type_params,
7108
                        int lineno, int col_offset, int end_lineno, int
7109
                        end_col_offset, PyArena *arena)
7110
552
{
7111
552
    stmt_ty p;
7112
552
    if (!name) {
7113
0
        PyErr_SetString(PyExc_ValueError,
7114
0
                        "field 'name' is required for AsyncFunctionDef");
7115
0
        return NULL;
7116
0
    }
7117
552
    if (!args) {
7118
0
        PyErr_SetString(PyExc_ValueError,
7119
0
                        "field 'args' is required for AsyncFunctionDef");
7120
0
        return NULL;
7121
0
    }
7122
552
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7123
552
    if (!p)
7124
0
        return NULL;
7125
552
    p->kind = AsyncFunctionDef_kind;
7126
552
    p->v.AsyncFunctionDef.name = name;
7127
552
    p->v.AsyncFunctionDef.args = args;
7128
552
    p->v.AsyncFunctionDef.body = body;
7129
552
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7130
552
    p->v.AsyncFunctionDef.returns = returns;
7131
552
    p->v.AsyncFunctionDef.type_comment = type_comment;
7132
552
    p->v.AsyncFunctionDef.type_params = type_params;
7133
552
    p->lineno = lineno;
7134
552
    p->col_offset = col_offset;
7135
552
    p->end_lineno = end_lineno;
7136
552
    p->end_col_offset = end_col_offset;
7137
552
    return p;
7138
552
}
7139
7140
stmt_ty
7141
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7142
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7143
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7144
                int end_lineno, int end_col_offset, PyArena *arena)
7145
2.63k
{
7146
2.63k
    stmt_ty p;
7147
2.63k
    if (!name) {
7148
0
        PyErr_SetString(PyExc_ValueError,
7149
0
                        "field 'name' is required for ClassDef");
7150
0
        return NULL;
7151
0
    }
7152
2.63k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7153
2.63k
    if (!p)
7154
0
        return NULL;
7155
2.63k
    p->kind = ClassDef_kind;
7156
2.63k
    p->v.ClassDef.name = name;
7157
2.63k
    p->v.ClassDef.bases = bases;
7158
2.63k
    p->v.ClassDef.keywords = keywords;
7159
2.63k
    p->v.ClassDef.body = body;
7160
2.63k
    p->v.ClassDef.decorator_list = decorator_list;
7161
2.63k
    p->v.ClassDef.type_params = type_params;
7162
2.63k
    p->lineno = lineno;
7163
2.63k
    p->col_offset = col_offset;
7164
2.63k
    p->end_lineno = end_lineno;
7165
2.63k
    p->end_col_offset = end_col_offset;
7166
2.63k
    return p;
7167
2.63k
}
7168
7169
stmt_ty
7170
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7171
              end_col_offset, PyArena *arena)
7172
2.64k
{
7173
2.64k
    stmt_ty p;
7174
2.64k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7175
2.64k
    if (!p)
7176
0
        return NULL;
7177
2.64k
    p->kind = Return_kind;
7178
2.64k
    p->v.Return.value = value;
7179
2.64k
    p->lineno = lineno;
7180
2.64k
    p->col_offset = col_offset;
7181
2.64k
    p->end_lineno = end_lineno;
7182
2.64k
    p->end_col_offset = end_col_offset;
7183
2.64k
    return p;
7184
2.64k
}
7185
7186
stmt_ty
7187
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7188
              end_lineno, int end_col_offset, PyArena *arena)
7189
489
{
7190
489
    stmt_ty p;
7191
489
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7192
489
    if (!p)
7193
0
        return NULL;
7194
489
    p->kind = Delete_kind;
7195
489
    p->v.Delete.targets = targets;
7196
489
    p->lineno = lineno;
7197
489
    p->col_offset = col_offset;
7198
489
    p->end_lineno = end_lineno;
7199
489
    p->end_col_offset = end_col_offset;
7200
489
    return p;
7201
489
}
7202
7203
stmt_ty
7204
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7205
              lineno, int col_offset, int end_lineno, int end_col_offset,
7206
              PyArena *arena)
7207
4.71k
{
7208
4.71k
    stmt_ty p;
7209
4.71k
    if (!value) {
7210
0
        PyErr_SetString(PyExc_ValueError,
7211
0
                        "field 'value' is required for Assign");
7212
0
        return NULL;
7213
0
    }
7214
4.71k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7215
4.71k
    if (!p)
7216
0
        return NULL;
7217
4.71k
    p->kind = Assign_kind;
7218
4.71k
    p->v.Assign.targets = targets;
7219
4.71k
    p->v.Assign.value = value;
7220
4.71k
    p->v.Assign.type_comment = type_comment;
7221
4.71k
    p->lineno = lineno;
7222
4.71k
    p->col_offset = col_offset;
7223
4.71k
    p->end_lineno = end_lineno;
7224
4.71k
    p->end_col_offset = end_col_offset;
7225
4.71k
    return p;
7226
4.71k
}
7227
7228
stmt_ty
7229
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7230
                 value, int lineno, int col_offset, int end_lineno, int
7231
                 end_col_offset, PyArena *arena)
7232
268
{
7233
268
    stmt_ty p;
7234
268
    if (!name) {
7235
0
        PyErr_SetString(PyExc_ValueError,
7236
0
                        "field 'name' is required for TypeAlias");
7237
0
        return NULL;
7238
0
    }
7239
268
    if (!value) {
7240
0
        PyErr_SetString(PyExc_ValueError,
7241
0
                        "field 'value' is required for TypeAlias");
7242
0
        return NULL;
7243
0
    }
7244
268
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7245
268
    if (!p)
7246
0
        return NULL;
7247
268
    p->kind = TypeAlias_kind;
7248
268
    p->v.TypeAlias.name = name;
7249
268
    p->v.TypeAlias.type_params = type_params;
7250
268
    p->v.TypeAlias.value = value;
7251
268
    p->lineno = lineno;
7252
268
    p->col_offset = col_offset;
7253
268
    p->end_lineno = end_lineno;
7254
268
    p->end_col_offset = end_col_offset;
7255
268
    return p;
7256
268
}
7257
7258
stmt_ty
7259
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7260
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7261
2.30k
{
7262
2.30k
    stmt_ty p;
7263
2.30k
    if (!target) {
7264
0
        PyErr_SetString(PyExc_ValueError,
7265
0
                        "field 'target' is required for AugAssign");
7266
0
        return NULL;
7267
0
    }
7268
2.30k
    if (!op) {
7269
0
        PyErr_SetString(PyExc_ValueError,
7270
0
                        "field 'op' is required for AugAssign");
7271
0
        return NULL;
7272
0
    }
7273
2.30k
    if (!value) {
7274
0
        PyErr_SetString(PyExc_ValueError,
7275
0
                        "field 'value' is required for AugAssign");
7276
0
        return NULL;
7277
0
    }
7278
2.30k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7279
2.30k
    if (!p)
7280
0
        return NULL;
7281
2.30k
    p->kind = AugAssign_kind;
7282
2.30k
    p->v.AugAssign.target = target;
7283
2.30k
    p->v.AugAssign.op = op;
7284
2.30k
    p->v.AugAssign.value = value;
7285
2.30k
    p->lineno = lineno;
7286
2.30k
    p->col_offset = col_offset;
7287
2.30k
    p->end_lineno = end_lineno;
7288
2.30k
    p->end_col_offset = end_col_offset;
7289
2.30k
    return p;
7290
2.30k
}
7291
7292
stmt_ty
7293
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7294
                 int lineno, int col_offset, int end_lineno, int
7295
                 end_col_offset, PyArena *arena)
7296
2.77k
{
7297
2.77k
    stmt_ty p;
7298
2.77k
    if (!target) {
7299
0
        PyErr_SetString(PyExc_ValueError,
7300
0
                        "field 'target' is required for AnnAssign");
7301
0
        return NULL;
7302
0
    }
7303
2.77k
    if (!annotation) {
7304
0
        PyErr_SetString(PyExc_ValueError,
7305
0
                        "field 'annotation' is required for AnnAssign");
7306
0
        return NULL;
7307
0
    }
7308
2.77k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7309
2.77k
    if (!p)
7310
0
        return NULL;
7311
2.77k
    p->kind = AnnAssign_kind;
7312
2.77k
    p->v.AnnAssign.target = target;
7313
2.77k
    p->v.AnnAssign.annotation = annotation;
7314
2.77k
    p->v.AnnAssign.value = value;
7315
2.77k
    p->v.AnnAssign.simple = simple;
7316
2.77k
    p->lineno = lineno;
7317
2.77k
    p->col_offset = col_offset;
7318
2.77k
    p->end_lineno = end_lineno;
7319
2.77k
    p->end_col_offset = end_col_offset;
7320
2.77k
    return p;
7321
2.77k
}
7322
7323
stmt_ty
7324
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7325
           orelse, string type_comment, int lineno, int col_offset, int
7326
           end_lineno, int end_col_offset, PyArena *arena)
7327
1.28k
{
7328
1.28k
    stmt_ty p;
7329
1.28k
    if (!target) {
7330
0
        PyErr_SetString(PyExc_ValueError,
7331
0
                        "field 'target' is required for For");
7332
0
        return NULL;
7333
0
    }
7334
1.28k
    if (!iter) {
7335
0
        PyErr_SetString(PyExc_ValueError,
7336
0
                        "field 'iter' is required for For");
7337
0
        return NULL;
7338
0
    }
7339
1.28k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7340
1.28k
    if (!p)
7341
0
        return NULL;
7342
1.28k
    p->kind = For_kind;
7343
1.28k
    p->v.For.target = target;
7344
1.28k
    p->v.For.iter = iter;
7345
1.28k
    p->v.For.body = body;
7346
1.28k
    p->v.For.orelse = orelse;
7347
1.28k
    p->v.For.type_comment = type_comment;
7348
1.28k
    p->lineno = lineno;
7349
1.28k
    p->col_offset = col_offset;
7350
1.28k
    p->end_lineno = end_lineno;
7351
1.28k
    p->end_col_offset = end_col_offset;
7352
1.28k
    return p;
7353
1.28k
}
7354
7355
stmt_ty
7356
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7357
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7358
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7359
609
{
7360
609
    stmt_ty p;
7361
609
    if (!target) {
7362
0
        PyErr_SetString(PyExc_ValueError,
7363
0
                        "field 'target' is required for AsyncFor");
7364
0
        return NULL;
7365
0
    }
7366
609
    if (!iter) {
7367
0
        PyErr_SetString(PyExc_ValueError,
7368
0
                        "field 'iter' is required for AsyncFor");
7369
0
        return NULL;
7370
0
    }
7371
609
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7372
609
    if (!p)
7373
0
        return NULL;
7374
609
    p->kind = AsyncFor_kind;
7375
609
    p->v.AsyncFor.target = target;
7376
609
    p->v.AsyncFor.iter = iter;
7377
609
    p->v.AsyncFor.body = body;
7378
609
    p->v.AsyncFor.orelse = orelse;
7379
609
    p->v.AsyncFor.type_comment = type_comment;
7380
609
    p->lineno = lineno;
7381
609
    p->col_offset = col_offset;
7382
609
    p->end_lineno = end_lineno;
7383
609
    p->end_col_offset = end_col_offset;
7384
609
    return p;
7385
609
}
7386
7387
stmt_ty
7388
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7389
             lineno, int col_offset, int end_lineno, int end_col_offset,
7390
             PyArena *arena)
7391
832
{
7392
832
    stmt_ty p;
7393
832
    if (!test) {
7394
0
        PyErr_SetString(PyExc_ValueError,
7395
0
                        "field 'test' is required for While");
7396
0
        return NULL;
7397
0
    }
7398
832
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7399
832
    if (!p)
7400
0
        return NULL;
7401
832
    p->kind = While_kind;
7402
832
    p->v.While.test = test;
7403
832
    p->v.While.body = body;
7404
832
    p->v.While.orelse = orelse;
7405
832
    p->lineno = lineno;
7406
832
    p->col_offset = col_offset;
7407
832
    p->end_lineno = end_lineno;
7408
832
    p->end_col_offset = end_col_offset;
7409
832
    return p;
7410
832
}
7411
7412
stmt_ty
7413
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7414
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7415
          *arena)
7416
4.15k
{
7417
4.15k
    stmt_ty p;
7418
4.15k
    if (!test) {
7419
0
        PyErr_SetString(PyExc_ValueError,
7420
0
                        "field 'test' is required for If");
7421
0
        return NULL;
7422
0
    }
7423
4.15k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7424
4.15k
    if (!p)
7425
0
        return NULL;
7426
4.15k
    p->kind = If_kind;
7427
4.15k
    p->v.If.test = test;
7428
4.15k
    p->v.If.body = body;
7429
4.15k
    p->v.If.orelse = orelse;
7430
4.15k
    p->lineno = lineno;
7431
4.15k
    p->col_offset = col_offset;
7432
4.15k
    p->end_lineno = end_lineno;
7433
4.15k
    p->end_col_offset = end_col_offset;
7434
4.15k
    return p;
7435
4.15k
}
7436
7437
stmt_ty
7438
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7439
            type_comment, int lineno, int col_offset, int end_lineno, int
7440
            end_col_offset, PyArena *arena)
7441
2.69k
{
7442
2.69k
    stmt_ty p;
7443
2.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7444
2.69k
    if (!p)
7445
0
        return NULL;
7446
2.69k
    p->kind = With_kind;
7447
2.69k
    p->v.With.items = items;
7448
2.69k
    p->v.With.body = body;
7449
2.69k
    p->v.With.type_comment = type_comment;
7450
2.69k
    p->lineno = lineno;
7451
2.69k
    p->col_offset = col_offset;
7452
2.69k
    p->end_lineno = end_lineno;
7453
2.69k
    p->end_col_offset = end_col_offset;
7454
2.69k
    return p;
7455
2.69k
}
7456
7457
stmt_ty
7458
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7459
                 type_comment, int lineno, int col_offset, int end_lineno, int
7460
                 end_col_offset, PyArena *arena)
7461
669
{
7462
669
    stmt_ty p;
7463
669
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7464
669
    if (!p)
7465
0
        return NULL;
7466
669
    p->kind = AsyncWith_kind;
7467
669
    p->v.AsyncWith.items = items;
7468
669
    p->v.AsyncWith.body = body;
7469
669
    p->v.AsyncWith.type_comment = type_comment;
7470
669
    p->lineno = lineno;
7471
669
    p->col_offset = col_offset;
7472
669
    p->end_lineno = end_lineno;
7473
669
    p->end_col_offset = end_col_offset;
7474
669
    return p;
7475
669
}
7476
7477
stmt_ty
7478
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7479
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7480
985
{
7481
985
    stmt_ty p;
7482
985
    if (!subject) {
7483
0
        PyErr_SetString(PyExc_ValueError,
7484
0
                        "field 'subject' is required for Match");
7485
0
        return NULL;
7486
0
    }
7487
985
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7488
985
    if (!p)
7489
0
        return NULL;
7490
985
    p->kind = Match_kind;
7491
985
    p->v.Match.subject = subject;
7492
985
    p->v.Match.cases = cases;
7493
985
    p->lineno = lineno;
7494
985
    p->col_offset = col_offset;
7495
985
    p->end_lineno = end_lineno;
7496
985
    p->end_col_offset = end_col_offset;
7497
985
    return p;
7498
985
}
7499
7500
stmt_ty
7501
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7502
             end_lineno, int end_col_offset, PyArena *arena)
7503
1.90k
{
7504
1.90k
    stmt_ty p;
7505
1.90k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7506
1.90k
    if (!p)
7507
0
        return NULL;
7508
1.90k
    p->kind = Raise_kind;
7509
1.90k
    p->v.Raise.exc = exc;
7510
1.90k
    p->v.Raise.cause = cause;
7511
1.90k
    p->lineno = lineno;
7512
1.90k
    p->col_offset = col_offset;
7513
1.90k
    p->end_lineno = end_lineno;
7514
1.90k
    p->end_col_offset = end_col_offset;
7515
1.90k
    return p;
7516
1.90k
}
7517
7518
stmt_ty
7519
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7520
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7521
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7522
2.71k
{
7523
2.71k
    stmt_ty p;
7524
2.71k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7525
2.71k
    if (!p)
7526
0
        return NULL;
7527
2.71k
    p->kind = Try_kind;
7528
2.71k
    p->v.Try.body = body;
7529
2.71k
    p->v.Try.handlers = handlers;
7530
2.71k
    p->v.Try.orelse = orelse;
7531
2.71k
    p->v.Try.finalbody = finalbody;
7532
2.71k
    p->lineno = lineno;
7533
2.71k
    p->col_offset = col_offset;
7534
2.71k
    p->end_lineno = end_lineno;
7535
2.71k
    p->end_col_offset = end_col_offset;
7536
2.71k
    return p;
7537
2.71k
}
7538
7539
stmt_ty
7540
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7541
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7542
               int col_offset, int end_lineno, int end_col_offset, PyArena
7543
               *arena)
7544
1.24k
{
7545
1.24k
    stmt_ty p;
7546
1.24k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7547
1.24k
    if (!p)
7548
0
        return NULL;
7549
1.24k
    p->kind = TryStar_kind;
7550
1.24k
    p->v.TryStar.body = body;
7551
1.24k
    p->v.TryStar.handlers = handlers;
7552
1.24k
    p->v.TryStar.orelse = orelse;
7553
1.24k
    p->v.TryStar.finalbody = finalbody;
7554
1.24k
    p->lineno = lineno;
7555
1.24k
    p->col_offset = col_offset;
7556
1.24k
    p->end_lineno = end_lineno;
7557
1.24k
    p->end_col_offset = end_col_offset;
7558
1.24k
    return p;
7559
1.24k
}
7560
7561
stmt_ty
7562
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7563
              end_lineno, int end_col_offset, PyArena *arena)
7564
1.11k
{
7565
1.11k
    stmt_ty p;
7566
1.11k
    if (!test) {
7567
0
        PyErr_SetString(PyExc_ValueError,
7568
0
                        "field 'test' is required for Assert");
7569
0
        return NULL;
7570
0
    }
7571
1.11k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7572
1.11k
    if (!p)
7573
0
        return NULL;
7574
1.11k
    p->kind = Assert_kind;
7575
1.11k
    p->v.Assert.test = test;
7576
1.11k
    p->v.Assert.msg = msg;
7577
1.11k
    p->lineno = lineno;
7578
1.11k
    p->col_offset = col_offset;
7579
1.11k
    p->end_lineno = end_lineno;
7580
1.11k
    p->end_col_offset = end_col_offset;
7581
1.11k
    return p;
7582
1.11k
}
7583
7584
stmt_ty
7585
_PyAST_Import(asdl_alias_seq * names, int is_lazy, int lineno, int col_offset,
7586
              int end_lineno, int end_col_offset, PyArena *arena)
7587
2.34k
{
7588
2.34k
    stmt_ty p;
7589
2.34k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7590
2.34k
    if (!p)
7591
0
        return NULL;
7592
2.34k
    p->kind = Import_kind;
7593
2.34k
    p->v.Import.names = names;
7594
2.34k
    p->v.Import.is_lazy = is_lazy;
7595
2.34k
    p->lineno = lineno;
7596
2.34k
    p->col_offset = col_offset;
7597
2.34k
    p->end_lineno = end_lineno;
7598
2.34k
    p->end_col_offset = end_col_offset;
7599
2.34k
    return p;
7600
2.34k
}
7601
7602
stmt_ty
7603
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7604
                  is_lazy, int lineno, int col_offset, int end_lineno, int
7605
                  end_col_offset, PyArena *arena)
7606
3.52k
{
7607
3.52k
    stmt_ty p;
7608
3.52k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7609
3.52k
    if (!p)
7610
0
        return NULL;
7611
3.52k
    p->kind = ImportFrom_kind;
7612
3.52k
    p->v.ImportFrom.module = module;
7613
3.52k
    p->v.ImportFrom.names = names;
7614
3.52k
    p->v.ImportFrom.level = level;
7615
3.52k
    p->v.ImportFrom.is_lazy = is_lazy;
7616
3.52k
    p->lineno = lineno;
7617
3.52k
    p->col_offset = col_offset;
7618
3.52k
    p->end_lineno = end_lineno;
7619
3.52k
    p->end_col_offset = end_col_offset;
7620
3.52k
    return p;
7621
3.52k
}
7622
7623
stmt_ty
7624
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7625
              end_lineno, int end_col_offset, PyArena *arena)
7626
763
{
7627
763
    stmt_ty p;
7628
763
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7629
763
    if (!p)
7630
0
        return NULL;
7631
763
    p->kind = Global_kind;
7632
763
    p->v.Global.names = names;
7633
763
    p->lineno = lineno;
7634
763
    p->col_offset = col_offset;
7635
763
    p->end_lineno = end_lineno;
7636
763
    p->end_col_offset = end_col_offset;
7637
763
    return p;
7638
763
}
7639
7640
stmt_ty
7641
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7642
                end_lineno, int end_col_offset, PyArena *arena)
7643
273
{
7644
273
    stmt_ty p;
7645
273
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7646
273
    if (!p)
7647
0
        return NULL;
7648
273
    p->kind = Nonlocal_kind;
7649
273
    p->v.Nonlocal.names = names;
7650
273
    p->lineno = lineno;
7651
273
    p->col_offset = col_offset;
7652
273
    p->end_lineno = end_lineno;
7653
273
    p->end_col_offset = end_col_offset;
7654
273
    return p;
7655
273
}
7656
7657
stmt_ty
7658
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7659
            end_col_offset, PyArena *arena)
7660
96.0k
{
7661
96.0k
    stmt_ty p;
7662
96.0k
    if (!value) {
7663
0
        PyErr_SetString(PyExc_ValueError,
7664
0
                        "field 'value' is required for Expr");
7665
0
        return NULL;
7666
0
    }
7667
96.0k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7668
96.0k
    if (!p)
7669
0
        return NULL;
7670
96.0k
    p->kind = Expr_kind;
7671
96.0k
    p->v.Expr.value = value;
7672
96.0k
    p->lineno = lineno;
7673
96.0k
    p->col_offset = col_offset;
7674
96.0k
    p->end_lineno = end_lineno;
7675
96.0k
    p->end_col_offset = end_col_offset;
7676
96.0k
    return p;
7677
96.0k
}
7678
7679
stmt_ty
7680
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7681
            PyArena *arena)
7682
1.39k
{
7683
1.39k
    stmt_ty p;
7684
1.39k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7685
1.39k
    if (!p)
7686
0
        return NULL;
7687
1.39k
    p->kind = Pass_kind;
7688
1.39k
    p->lineno = lineno;
7689
1.39k
    p->col_offset = col_offset;
7690
1.39k
    p->end_lineno = end_lineno;
7691
1.39k
    p->end_col_offset = end_col_offset;
7692
1.39k
    return p;
7693
1.39k
}
7694
7695
stmt_ty
7696
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7697
             PyArena *arena)
7698
1.56k
{
7699
1.56k
    stmt_ty p;
7700
1.56k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7701
1.56k
    if (!p)
7702
0
        return NULL;
7703
1.56k
    p->kind = Break_kind;
7704
1.56k
    p->lineno = lineno;
7705
1.56k
    p->col_offset = col_offset;
7706
1.56k
    p->end_lineno = end_lineno;
7707
1.56k
    p->end_col_offset = end_col_offset;
7708
1.56k
    return p;
7709
1.56k
}
7710
7711
stmt_ty
7712
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7713
                PyArena *arena)
7714
3.74k
{
7715
3.74k
    stmt_ty p;
7716
3.74k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7717
3.74k
    if (!p)
7718
0
        return NULL;
7719
3.74k
    p->kind = Continue_kind;
7720
3.74k
    p->lineno = lineno;
7721
3.74k
    p->col_offset = col_offset;
7722
3.74k
    p->end_lineno = end_lineno;
7723
3.74k
    p->end_col_offset = end_col_offset;
7724
3.74k
    return p;
7725
3.74k
}
7726
7727
expr_ty
7728
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7729
              int end_lineno, int end_col_offset, PyArena *arena)
7730
1.93k
{
7731
1.93k
    expr_ty p;
7732
1.93k
    if (!op) {
7733
0
        PyErr_SetString(PyExc_ValueError,
7734
0
                        "field 'op' is required for BoolOp");
7735
0
        return NULL;
7736
0
    }
7737
1.93k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7738
1.93k
    if (!p)
7739
0
        return NULL;
7740
1.93k
    p->kind = BoolOp_kind;
7741
1.93k
    p->v.BoolOp.op = op;
7742
1.93k
    p->v.BoolOp.values = values;
7743
1.93k
    p->lineno = lineno;
7744
1.93k
    p->col_offset = col_offset;
7745
1.93k
    p->end_lineno = end_lineno;
7746
1.93k
    p->end_col_offset = end_col_offset;
7747
1.93k
    return p;
7748
1.93k
}
7749
7750
expr_ty
7751
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7752
                 end_lineno, int end_col_offset, PyArena *arena)
7753
1.67k
{
7754
1.67k
    expr_ty p;
7755
1.67k
    if (!target) {
7756
0
        PyErr_SetString(PyExc_ValueError,
7757
0
                        "field 'target' is required for NamedExpr");
7758
0
        return NULL;
7759
0
    }
7760
1.67k
    if (!value) {
7761
0
        PyErr_SetString(PyExc_ValueError,
7762
0
                        "field 'value' is required for NamedExpr");
7763
0
        return NULL;
7764
0
    }
7765
1.67k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7766
1.67k
    if (!p)
7767
0
        return NULL;
7768
1.67k
    p->kind = NamedExpr_kind;
7769
1.67k
    p->v.NamedExpr.target = target;
7770
1.67k
    p->v.NamedExpr.value = value;
7771
1.67k
    p->lineno = lineno;
7772
1.67k
    p->col_offset = col_offset;
7773
1.67k
    p->end_lineno = end_lineno;
7774
1.67k
    p->end_col_offset = end_col_offset;
7775
1.67k
    return p;
7776
1.67k
}
7777
7778
expr_ty
7779
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7780
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7781
49.3k
{
7782
49.3k
    expr_ty p;
7783
49.3k
    if (!left) {
7784
0
        PyErr_SetString(PyExc_ValueError,
7785
0
                        "field 'left' is required for BinOp");
7786
0
        return NULL;
7787
0
    }
7788
49.3k
    if (!op) {
7789
0
        PyErr_SetString(PyExc_ValueError,
7790
0
                        "field 'op' is required for BinOp");
7791
0
        return NULL;
7792
0
    }
7793
49.3k
    if (!right) {
7794
0
        PyErr_SetString(PyExc_ValueError,
7795
0
                        "field 'right' is required for BinOp");
7796
0
        return NULL;
7797
0
    }
7798
49.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7799
49.3k
    if (!p)
7800
0
        return NULL;
7801
49.3k
    p->kind = BinOp_kind;
7802
49.3k
    p->v.BinOp.left = left;
7803
49.3k
    p->v.BinOp.op = op;
7804
49.3k
    p->v.BinOp.right = right;
7805
49.3k
    p->lineno = lineno;
7806
49.3k
    p->col_offset = col_offset;
7807
49.3k
    p->end_lineno = end_lineno;
7808
49.3k
    p->end_col_offset = end_col_offset;
7809
49.3k
    return p;
7810
49.3k
}
7811
7812
expr_ty
7813
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7814
               end_lineno, int end_col_offset, PyArena *arena)
7815
171k
{
7816
171k
    expr_ty p;
7817
171k
    if (!op) {
7818
0
        PyErr_SetString(PyExc_ValueError,
7819
0
                        "field 'op' is required for UnaryOp");
7820
0
        return NULL;
7821
0
    }
7822
171k
    if (!operand) {
7823
0
        PyErr_SetString(PyExc_ValueError,
7824
0
                        "field 'operand' is required for UnaryOp");
7825
0
        return NULL;
7826
0
    }
7827
171k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7828
171k
    if (!p)
7829
0
        return NULL;
7830
171k
    p->kind = UnaryOp_kind;
7831
171k
    p->v.UnaryOp.op = op;
7832
171k
    p->v.UnaryOp.operand = operand;
7833
171k
    p->lineno = lineno;
7834
171k
    p->col_offset = col_offset;
7835
171k
    p->end_lineno = end_lineno;
7836
171k
    p->end_col_offset = end_col_offset;
7837
171k
    return p;
7838
171k
}
7839
7840
expr_ty
7841
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7842
              end_lineno, int end_col_offset, PyArena *arena)
7843
2.84k
{
7844
2.84k
    expr_ty p;
7845
2.84k
    if (!args) {
7846
0
        PyErr_SetString(PyExc_ValueError,
7847
0
                        "field 'args' is required for Lambda");
7848
0
        return NULL;
7849
0
    }
7850
2.84k
    if (!body) {
7851
0
        PyErr_SetString(PyExc_ValueError,
7852
0
                        "field 'body' is required for Lambda");
7853
0
        return NULL;
7854
0
    }
7855
2.84k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7856
2.84k
    if (!p)
7857
0
        return NULL;
7858
2.84k
    p->kind = Lambda_kind;
7859
2.84k
    p->v.Lambda.args = args;
7860
2.84k
    p->v.Lambda.body = body;
7861
2.84k
    p->lineno = lineno;
7862
2.84k
    p->col_offset = col_offset;
7863
2.84k
    p->end_lineno = end_lineno;
7864
2.84k
    p->end_col_offset = end_col_offset;
7865
2.84k
    return p;
7866
2.84k
}
7867
7868
expr_ty
7869
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7870
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7871
954
{
7872
954
    expr_ty p;
7873
954
    if (!test) {
7874
0
        PyErr_SetString(PyExc_ValueError,
7875
0
                        "field 'test' is required for IfExp");
7876
0
        return NULL;
7877
0
    }
7878
954
    if (!body) {
7879
0
        PyErr_SetString(PyExc_ValueError,
7880
0
                        "field 'body' is required for IfExp");
7881
0
        return NULL;
7882
0
    }
7883
954
    if (!orelse) {
7884
0
        PyErr_SetString(PyExc_ValueError,
7885
0
                        "field 'orelse' is required for IfExp");
7886
0
        return NULL;
7887
0
    }
7888
954
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7889
954
    if (!p)
7890
0
        return NULL;
7891
954
    p->kind = IfExp_kind;
7892
954
    p->v.IfExp.test = test;
7893
954
    p->v.IfExp.body = body;
7894
954
    p->v.IfExp.orelse = orelse;
7895
954
    p->lineno = lineno;
7896
954
    p->col_offset = col_offset;
7897
954
    p->end_lineno = end_lineno;
7898
954
    p->end_col_offset = end_col_offset;
7899
954
    return p;
7900
954
}
7901
7902
expr_ty
7903
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7904
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7905
4.38k
{
7906
4.38k
    expr_ty p;
7907
4.38k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7908
4.38k
    if (!p)
7909
0
        return NULL;
7910
4.38k
    p->kind = Dict_kind;
7911
4.38k
    p->v.Dict.keys = keys;
7912
4.38k
    p->v.Dict.values = values;
7913
4.38k
    p->lineno = lineno;
7914
4.38k
    p->col_offset = col_offset;
7915
4.38k
    p->end_lineno = end_lineno;
7916
4.38k
    p->end_col_offset = end_col_offset;
7917
4.38k
    return p;
7918
4.38k
}
7919
7920
expr_ty
7921
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7922
           int end_col_offset, PyArena *arena)
7923
1.48k
{
7924
1.48k
    expr_ty p;
7925
1.48k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7926
1.48k
    if (!p)
7927
0
        return NULL;
7928
1.48k
    p->kind = Set_kind;
7929
1.48k
    p->v.Set.elts = elts;
7930
1.48k
    p->lineno = lineno;
7931
1.48k
    p->col_offset = col_offset;
7932
1.48k
    p->end_lineno = end_lineno;
7933
1.48k
    p->end_col_offset = end_col_offset;
7934
1.48k
    return p;
7935
1.48k
}
7936
7937
expr_ty
7938
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7939
                int col_offset, int end_lineno, int end_col_offset, PyArena
7940
                *arena)
7941
673
{
7942
673
    expr_ty p;
7943
673
    if (!elt) {
7944
0
        PyErr_SetString(PyExc_ValueError,
7945
0
                        "field 'elt' is required for ListComp");
7946
0
        return NULL;
7947
0
    }
7948
673
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7949
673
    if (!p)
7950
0
        return NULL;
7951
673
    p->kind = ListComp_kind;
7952
673
    p->v.ListComp.elt = elt;
7953
673
    p->v.ListComp.generators = generators;
7954
673
    p->lineno = lineno;
7955
673
    p->col_offset = col_offset;
7956
673
    p->end_lineno = end_lineno;
7957
673
    p->end_col_offset = end_col_offset;
7958
673
    return p;
7959
673
}
7960
7961
expr_ty
7962
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7963
               int col_offset, int end_lineno, int end_col_offset, PyArena
7964
               *arena)
7965
886
{
7966
886
    expr_ty p;
7967
886
    if (!elt) {
7968
0
        PyErr_SetString(PyExc_ValueError,
7969
0
                        "field 'elt' is required for SetComp");
7970
0
        return NULL;
7971
0
    }
7972
886
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7973
886
    if (!p)
7974
0
        return NULL;
7975
886
    p->kind = SetComp_kind;
7976
886
    p->v.SetComp.elt = elt;
7977
886
    p->v.SetComp.generators = generators;
7978
886
    p->lineno = lineno;
7979
886
    p->col_offset = col_offset;
7980
886
    p->end_lineno = end_lineno;
7981
886
    p->end_col_offset = end_col_offset;
7982
886
    return p;
7983
886
}
7984
7985
expr_ty
7986
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
7987
                generators, int lineno, int col_offset, int end_lineno, int
7988
                end_col_offset, PyArena *arena)
7989
1.28k
{
7990
1.28k
    expr_ty p;
7991
1.28k
    if (!key) {
7992
0
        PyErr_SetString(PyExc_ValueError,
7993
0
                        "field 'key' is required for DictComp");
7994
0
        return NULL;
7995
0
    }
7996
1.28k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7997
1.28k
    if (!p)
7998
0
        return NULL;
7999
1.28k
    p->kind = DictComp_kind;
8000
1.28k
    p->v.DictComp.key = key;
8001
1.28k
    p->v.DictComp.value = value;
8002
1.28k
    p->v.DictComp.generators = generators;
8003
1.28k
    p->lineno = lineno;
8004
1.28k
    p->col_offset = col_offset;
8005
1.28k
    p->end_lineno = end_lineno;
8006
1.28k
    p->end_col_offset = end_col_offset;
8007
1.28k
    return p;
8008
1.28k
}
8009
8010
expr_ty
8011
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8012
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8013
                    PyArena *arena)
8014
4.04k
{
8015
4.04k
    expr_ty p;
8016
4.04k
    if (!elt) {
8017
0
        PyErr_SetString(PyExc_ValueError,
8018
0
                        "field 'elt' is required for GeneratorExp");
8019
0
        return NULL;
8020
0
    }
8021
4.04k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8022
4.04k
    if (!p)
8023
0
        return NULL;
8024
4.04k
    p->kind = GeneratorExp_kind;
8025
4.04k
    p->v.GeneratorExp.elt = elt;
8026
4.04k
    p->v.GeneratorExp.generators = generators;
8027
4.04k
    p->lineno = lineno;
8028
4.04k
    p->col_offset = col_offset;
8029
4.04k
    p->end_lineno = end_lineno;
8030
4.04k
    p->end_col_offset = end_col_offset;
8031
4.04k
    return p;
8032
4.04k
}
8033
8034
expr_ty
8035
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8036
             end_col_offset, PyArena *arena)
8037
264
{
8038
264
    expr_ty p;
8039
264
    if (!value) {
8040
0
        PyErr_SetString(PyExc_ValueError,
8041
0
                        "field 'value' is required for Await");
8042
0
        return NULL;
8043
0
    }
8044
264
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8045
264
    if (!p)
8046
0
        return NULL;
8047
264
    p->kind = Await_kind;
8048
264
    p->v.Await.value = value;
8049
264
    p->lineno = lineno;
8050
264
    p->col_offset = col_offset;
8051
264
    p->end_lineno = end_lineno;
8052
264
    p->end_col_offset = end_col_offset;
8053
264
    return p;
8054
264
}
8055
8056
expr_ty
8057
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8058
             end_col_offset, PyArena *arena)
8059
2.83k
{
8060
2.83k
    expr_ty p;
8061
2.83k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8062
2.83k
    if (!p)
8063
0
        return NULL;
8064
2.83k
    p->kind = Yield_kind;
8065
2.83k
    p->v.Yield.value = value;
8066
2.83k
    p->lineno = lineno;
8067
2.83k
    p->col_offset = col_offset;
8068
2.83k
    p->end_lineno = end_lineno;
8069
2.83k
    p->end_col_offset = end_col_offset;
8070
2.83k
    return p;
8071
2.83k
}
8072
8073
expr_ty
8074
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8075
                 end_col_offset, PyArena *arena)
8076
291
{
8077
291
    expr_ty p;
8078
291
    if (!value) {
8079
0
        PyErr_SetString(PyExc_ValueError,
8080
0
                        "field 'value' is required for YieldFrom");
8081
0
        return NULL;
8082
0
    }
8083
291
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8084
291
    if (!p)
8085
0
        return NULL;
8086
291
    p->kind = YieldFrom_kind;
8087
291
    p->v.YieldFrom.value = value;
8088
291
    p->lineno = lineno;
8089
291
    p->col_offset = col_offset;
8090
291
    p->end_lineno = end_lineno;
8091
291
    p->end_col_offset = end_col_offset;
8092
291
    return p;
8093
291
}
8094
8095
expr_ty
8096
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8097
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8098
               PyArena *arena)
8099
5.40k
{
8100
5.40k
    expr_ty p;
8101
5.40k
    if (!left) {
8102
0
        PyErr_SetString(PyExc_ValueError,
8103
0
                        "field 'left' is required for Compare");
8104
0
        return NULL;
8105
0
    }
8106
5.40k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8107
5.40k
    if (!p)
8108
0
        return NULL;
8109
5.40k
    p->kind = Compare_kind;
8110
5.40k
    p->v.Compare.left = left;
8111
5.40k
    p->v.Compare.ops = ops;
8112
5.40k
    p->v.Compare.comparators = comparators;
8113
5.40k
    p->lineno = lineno;
8114
5.40k
    p->col_offset = col_offset;
8115
5.40k
    p->end_lineno = end_lineno;
8116
5.40k
    p->end_col_offset = end_col_offset;
8117
5.40k
    return p;
8118
5.40k
}
8119
8120
expr_ty
8121
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8122
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8123
            PyArena *arena)
8124
54.8k
{
8125
54.8k
    expr_ty p;
8126
54.8k
    if (!func) {
8127
0
        PyErr_SetString(PyExc_ValueError,
8128
0
                        "field 'func' is required for Call");
8129
0
        return NULL;
8130
0
    }
8131
54.8k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8132
54.8k
    if (!p)
8133
0
        return NULL;
8134
54.8k
    p->kind = Call_kind;
8135
54.8k
    p->v.Call.func = func;
8136
54.8k
    p->v.Call.args = args;
8137
54.8k
    p->v.Call.keywords = keywords;
8138
54.8k
    p->lineno = lineno;
8139
54.8k
    p->col_offset = col_offset;
8140
54.8k
    p->end_lineno = end_lineno;
8141
54.8k
    p->end_col_offset = end_col_offset;
8142
54.8k
    return p;
8143
54.8k
}
8144
8145
expr_ty
8146
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8147
                      lineno, int col_offset, int end_lineno, int
8148
                      end_col_offset, PyArena *arena)
8149
20.7k
{
8150
20.7k
    expr_ty p;
8151
20.7k
    if (!value) {
8152
0
        PyErr_SetString(PyExc_ValueError,
8153
0
                        "field 'value' is required for FormattedValue");
8154
0
        return NULL;
8155
0
    }
8156
20.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8157
20.7k
    if (!p)
8158
0
        return NULL;
8159
20.7k
    p->kind = FormattedValue_kind;
8160
20.7k
    p->v.FormattedValue.value = value;
8161
20.7k
    p->v.FormattedValue.conversion = conversion;
8162
20.7k
    p->v.FormattedValue.format_spec = format_spec;
8163
20.7k
    p->lineno = lineno;
8164
20.7k
    p->col_offset = col_offset;
8165
20.7k
    p->end_lineno = end_lineno;
8166
20.7k
    p->end_col_offset = end_col_offset;
8167
20.7k
    return p;
8168
20.7k
}
8169
8170
expr_ty
8171
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8172
                     format_spec, int lineno, int col_offset, int end_lineno,
8173
                     int end_col_offset, PyArena *arena)
8174
7.48k
{
8175
7.48k
    expr_ty p;
8176
7.48k
    if (!value) {
8177
0
        PyErr_SetString(PyExc_ValueError,
8178
0
                        "field 'value' is required for Interpolation");
8179
0
        return NULL;
8180
0
    }
8181
7.48k
    if (!str) {
8182
0
        PyErr_SetString(PyExc_ValueError,
8183
0
                        "field 'str' is required for Interpolation");
8184
0
        return NULL;
8185
0
    }
8186
7.48k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8187
7.48k
    if (!p)
8188
0
        return NULL;
8189
7.48k
    p->kind = Interpolation_kind;
8190
7.48k
    p->v.Interpolation.value = value;
8191
7.48k
    p->v.Interpolation.str = str;
8192
7.48k
    p->v.Interpolation.conversion = conversion;
8193
7.48k
    p->v.Interpolation.format_spec = format_spec;
8194
7.48k
    p->lineno = lineno;
8195
7.48k
    p->col_offset = col_offset;
8196
7.48k
    p->end_lineno = end_lineno;
8197
7.48k
    p->end_col_offset = end_col_offset;
8198
7.48k
    return p;
8199
7.48k
}
8200
8201
expr_ty
8202
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8203
                 end_lineno, int end_col_offset, PyArena *arena)
8204
40.2k
{
8205
40.2k
    expr_ty p;
8206
40.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8207
40.2k
    if (!p)
8208
0
        return NULL;
8209
40.2k
    p->kind = JoinedStr_kind;
8210
40.2k
    p->v.JoinedStr.values = values;
8211
40.2k
    p->lineno = lineno;
8212
40.2k
    p->col_offset = col_offset;
8213
40.2k
    p->end_lineno = end_lineno;
8214
40.2k
    p->end_col_offset = end_col_offset;
8215
40.2k
    return p;
8216
40.2k
}
8217
8218
expr_ty
8219
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8220
                   end_lineno, int end_col_offset, PyArena *arena)
8221
9.47k
{
8222
9.47k
    expr_ty p;
8223
9.47k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8224
9.47k
    if (!p)
8225
0
        return NULL;
8226
9.47k
    p->kind = TemplateStr_kind;
8227
9.47k
    p->v.TemplateStr.values = values;
8228
9.47k
    p->lineno = lineno;
8229
9.47k
    p->col_offset = col_offset;
8230
9.47k
    p->end_lineno = end_lineno;
8231
9.47k
    p->end_col_offset = end_col_offset;
8232
9.47k
    return p;
8233
9.47k
}
8234
8235
expr_ty
8236
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8237
                end_lineno, int end_col_offset, PyArena *arena)
8238
391k
{
8239
391k
    expr_ty p;
8240
391k
    if (!value) {
8241
3
        PyErr_SetString(PyExc_ValueError,
8242
3
                        "field 'value' is required for Constant");
8243
3
        return NULL;
8244
3
    }
8245
391k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8246
391k
    if (!p)
8247
0
        return NULL;
8248
391k
    p->kind = Constant_kind;
8249
391k
    p->v.Constant.value = value;
8250
391k
    p->v.Constant.kind = kind;
8251
391k
    p->lineno = lineno;
8252
391k
    p->col_offset = col_offset;
8253
391k
    p->end_lineno = end_lineno;
8254
391k
    p->end_col_offset = end_col_offset;
8255
391k
    return p;
8256
391k
}
8257
8258
expr_ty
8259
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8260
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8261
                 PyArena *arena)
8262
26.1k
{
8263
26.1k
    expr_ty p;
8264
26.1k
    if (!value) {
8265
0
        PyErr_SetString(PyExc_ValueError,
8266
0
                        "field 'value' is required for Attribute");
8267
0
        return NULL;
8268
0
    }
8269
26.1k
    if (!attr) {
8270
0
        PyErr_SetString(PyExc_ValueError,
8271
0
                        "field 'attr' is required for Attribute");
8272
0
        return NULL;
8273
0
    }
8274
26.1k
    if (!ctx) {
8275
0
        PyErr_SetString(PyExc_ValueError,
8276
0
                        "field 'ctx' is required for Attribute");
8277
0
        return NULL;
8278
0
    }
8279
26.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8280
26.1k
    if (!p)
8281
0
        return NULL;
8282
26.1k
    p->kind = Attribute_kind;
8283
26.1k
    p->v.Attribute.value = value;
8284
26.1k
    p->v.Attribute.attr = attr;
8285
26.1k
    p->v.Attribute.ctx = ctx;
8286
26.1k
    p->lineno = lineno;
8287
26.1k
    p->col_offset = col_offset;
8288
26.1k
    p->end_lineno = end_lineno;
8289
26.1k
    p->end_col_offset = end_col_offset;
8290
26.1k
    return p;
8291
26.1k
}
8292
8293
expr_ty
8294
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8295
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8296
                 *arena)
8297
6.79k
{
8298
6.79k
    expr_ty p;
8299
6.79k
    if (!value) {
8300
0
        PyErr_SetString(PyExc_ValueError,
8301
0
                        "field 'value' is required for Subscript");
8302
0
        return NULL;
8303
0
    }
8304
6.79k
    if (!slice) {
8305
0
        PyErr_SetString(PyExc_ValueError,
8306
0
                        "field 'slice' is required for Subscript");
8307
0
        return NULL;
8308
0
    }
8309
6.79k
    if (!ctx) {
8310
0
        PyErr_SetString(PyExc_ValueError,
8311
0
                        "field 'ctx' is required for Subscript");
8312
0
        return NULL;
8313
0
    }
8314
6.79k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8315
6.79k
    if (!p)
8316
0
        return NULL;
8317
6.79k
    p->kind = Subscript_kind;
8318
6.79k
    p->v.Subscript.value = value;
8319
6.79k
    p->v.Subscript.slice = slice;
8320
6.79k
    p->v.Subscript.ctx = ctx;
8321
6.79k
    p->lineno = lineno;
8322
6.79k
    p->col_offset = col_offset;
8323
6.79k
    p->end_lineno = end_lineno;
8324
6.79k
    p->end_col_offset = end_col_offset;
8325
6.79k
    return p;
8326
6.79k
}
8327
8328
expr_ty
8329
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8330
               int end_lineno, int end_col_offset, PyArena *arena)
8331
24.5k
{
8332
24.5k
    expr_ty p;
8333
24.5k
    if (!value) {
8334
0
        PyErr_SetString(PyExc_ValueError,
8335
0
                        "field 'value' is required for Starred");
8336
0
        return NULL;
8337
0
    }
8338
24.5k
    if (!ctx) {
8339
0
        PyErr_SetString(PyExc_ValueError,
8340
0
                        "field 'ctx' is required for Starred");
8341
0
        return NULL;
8342
0
    }
8343
24.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8344
24.5k
    if (!p)
8345
0
        return NULL;
8346
24.5k
    p->kind = Starred_kind;
8347
24.5k
    p->v.Starred.value = value;
8348
24.5k
    p->v.Starred.ctx = ctx;
8349
24.5k
    p->lineno = lineno;
8350
24.5k
    p->col_offset = col_offset;
8351
24.5k
    p->end_lineno = end_lineno;
8352
24.5k
    p->end_col_offset = end_col_offset;
8353
24.5k
    return p;
8354
24.5k
}
8355
8356
expr_ty
8357
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8358
            end_lineno, int end_col_offset, PyArena *arena)
8359
12.3M
{
8360
12.3M
    expr_ty p;
8361
12.3M
    if (!id) {
8362
0
        PyErr_SetString(PyExc_ValueError,
8363
0
                        "field 'id' is required for Name");
8364
0
        return NULL;
8365
0
    }
8366
12.3M
    if (!ctx) {
8367
0
        PyErr_SetString(PyExc_ValueError,
8368
0
                        "field 'ctx' is required for Name");
8369
0
        return NULL;
8370
0
    }
8371
12.3M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8372
12.3M
    if (!p)
8373
0
        return NULL;
8374
12.3M
    p->kind = Name_kind;
8375
12.3M
    p->v.Name.id = id;
8376
12.3M
    p->v.Name.ctx = ctx;
8377
12.3M
    p->lineno = lineno;
8378
12.3M
    p->col_offset = col_offset;
8379
12.3M
    p->end_lineno = end_lineno;
8380
12.3M
    p->end_col_offset = end_col_offset;
8381
12.3M
    return p;
8382
12.3M
}
8383
8384
expr_ty
8385
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8386
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8387
15.4k
{
8388
15.4k
    expr_ty p;
8389
15.4k
    if (!ctx) {
8390
0
        PyErr_SetString(PyExc_ValueError,
8391
0
                        "field 'ctx' is required for List");
8392
0
        return NULL;
8393
0
    }
8394
15.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8395
15.4k
    if (!p)
8396
0
        return NULL;
8397
15.4k
    p->kind = List_kind;
8398
15.4k
    p->v.List.elts = elts;
8399
15.4k
    p->v.List.ctx = ctx;
8400
15.4k
    p->lineno = lineno;
8401
15.4k
    p->col_offset = col_offset;
8402
15.4k
    p->end_lineno = end_lineno;
8403
15.4k
    p->end_col_offset = end_col_offset;
8404
15.4k
    return p;
8405
15.4k
}
8406
8407
expr_ty
8408
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8409
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8410
93.2k
{
8411
93.2k
    expr_ty p;
8412
93.2k
    if (!ctx) {
8413
0
        PyErr_SetString(PyExc_ValueError,
8414
0
                        "field 'ctx' is required for Tuple");
8415
0
        return NULL;
8416
0
    }
8417
93.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8418
93.2k
    if (!p)
8419
0
        return NULL;
8420
93.2k
    p->kind = Tuple_kind;
8421
93.2k
    p->v.Tuple.elts = elts;
8422
93.2k
    p->v.Tuple.ctx = ctx;
8423
93.2k
    p->lineno = lineno;
8424
93.2k
    p->col_offset = col_offset;
8425
93.2k
    p->end_lineno = end_lineno;
8426
93.2k
    p->end_col_offset = end_col_offset;
8427
93.2k
    return p;
8428
93.2k
}
8429
8430
expr_ty
8431
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8432
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8433
17.1k
{
8434
17.1k
    expr_ty p;
8435
17.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8436
17.1k
    if (!p)
8437
0
        return NULL;
8438
17.1k
    p->kind = Slice_kind;
8439
17.1k
    p->v.Slice.lower = lower;
8440
17.1k
    p->v.Slice.upper = upper;
8441
17.1k
    p->v.Slice.step = step;
8442
17.1k
    p->lineno = lineno;
8443
17.1k
    p->col_offset = col_offset;
8444
17.1k
    p->end_lineno = end_lineno;
8445
17.1k
    p->end_col_offset = end_col_offset;
8446
17.1k
    return p;
8447
17.1k
}
8448
8449
comprehension_ty
8450
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8451
                     is_async, PyArena *arena)
8452
9.21k
{
8453
9.21k
    comprehension_ty p;
8454
9.21k
    if (!target) {
8455
0
        PyErr_SetString(PyExc_ValueError,
8456
0
                        "field 'target' is required for comprehension");
8457
0
        return NULL;
8458
0
    }
8459
9.21k
    if (!iter) {
8460
0
        PyErr_SetString(PyExc_ValueError,
8461
0
                        "field 'iter' is required for comprehension");
8462
0
        return NULL;
8463
0
    }
8464
9.21k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8465
9.21k
    if (!p)
8466
0
        return NULL;
8467
9.21k
    p->target = target;
8468
9.21k
    p->iter = iter;
8469
9.21k
    p->ifs = ifs;
8470
9.21k
    p->is_async = is_async;
8471
9.21k
    return p;
8472
9.21k
}
8473
8474
excepthandler_ty
8475
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8476
                     lineno, int col_offset, int end_lineno, int
8477
                     end_col_offset, PyArena *arena)
8478
8.34k
{
8479
8.34k
    excepthandler_ty p;
8480
8.34k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8481
8.34k
    if (!p)
8482
0
        return NULL;
8483
8.34k
    p->kind = ExceptHandler_kind;
8484
8.34k
    p->v.ExceptHandler.type = type;
8485
8.34k
    p->v.ExceptHandler.name = name;
8486
8.34k
    p->v.ExceptHandler.body = body;
8487
8.34k
    p->lineno = lineno;
8488
8.34k
    p->col_offset = col_offset;
8489
8.34k
    p->end_lineno = end_lineno;
8490
8.34k
    p->end_col_offset = end_col_offset;
8491
8.34k
    return p;
8492
8.34k
}
8493
8494
arguments_ty
8495
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8496
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8497
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8498
                 *arena)
8499
339k
{
8500
339k
    arguments_ty p;
8501
339k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8502
339k
    if (!p)
8503
0
        return NULL;
8504
339k
    p->posonlyargs = posonlyargs;
8505
339k
    p->args = args;
8506
339k
    p->vararg = vararg;
8507
339k
    p->kwonlyargs = kwonlyargs;
8508
339k
    p->kw_defaults = kw_defaults;
8509
339k
    p->kwarg = kwarg;
8510
339k
    p->defaults = defaults;
8511
339k
    return p;
8512
339k
}
8513
8514
arg_ty
8515
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8516
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8517
10.4M
{
8518
10.4M
    arg_ty p;
8519
10.4M
    if (!arg) {
8520
0
        PyErr_SetString(PyExc_ValueError,
8521
0
                        "field 'arg' is required for arg");
8522
0
        return NULL;
8523
0
    }
8524
10.4M
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8525
10.4M
    if (!p)
8526
0
        return NULL;
8527
10.4M
    p->arg = arg;
8528
10.4M
    p->annotation = annotation;
8529
10.4M
    p->type_comment = type_comment;
8530
10.4M
    p->lineno = lineno;
8531
10.4M
    p->col_offset = col_offset;
8532
10.4M
    p->end_lineno = end_lineno;
8533
10.4M
    p->end_col_offset = end_col_offset;
8534
10.4M
    return p;
8535
10.4M
}
8536
8537
keyword_ty
8538
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8539
               end_lineno, int end_col_offset, PyArena *arena)
8540
35.1k
{
8541
35.1k
    keyword_ty p;
8542
35.1k
    if (!value) {
8543
0
        PyErr_SetString(PyExc_ValueError,
8544
0
                        "field 'value' is required for keyword");
8545
0
        return NULL;
8546
0
    }
8547
35.1k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8548
35.1k
    if (!p)
8549
0
        return NULL;
8550
35.1k
    p->arg = arg;
8551
35.1k
    p->value = value;
8552
35.1k
    p->lineno = lineno;
8553
35.1k
    p->col_offset = col_offset;
8554
35.1k
    p->end_lineno = end_lineno;
8555
35.1k
    p->end_col_offset = end_col_offset;
8556
35.1k
    return p;
8557
35.1k
}
8558
8559
alias_ty
8560
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8561
             int end_lineno, int end_col_offset, PyArena *arena)
8562
12.8k
{
8563
12.8k
    alias_ty p;
8564
12.8k
    if (!name) {
8565
0
        PyErr_SetString(PyExc_ValueError,
8566
0
                        "field 'name' is required for alias");
8567
0
        return NULL;
8568
0
    }
8569
12.8k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8570
12.8k
    if (!p)
8571
0
        return NULL;
8572
12.8k
    p->name = name;
8573
12.8k
    p->asname = asname;
8574
12.8k
    p->lineno = lineno;
8575
12.8k
    p->col_offset = col_offset;
8576
12.8k
    p->end_lineno = end_lineno;
8577
12.8k
    p->end_col_offset = end_col_offset;
8578
12.8k
    return p;
8579
12.8k
}
8580
8581
withitem_ty
8582
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8583
11.3k
{
8584
11.3k
    withitem_ty p;
8585
11.3k
    if (!context_expr) {
8586
0
        PyErr_SetString(PyExc_ValueError,
8587
0
                        "field 'context_expr' is required for withitem");
8588
0
        return NULL;
8589
0
    }
8590
11.3k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8591
11.3k
    if (!p)
8592
0
        return NULL;
8593
11.3k
    p->context_expr = context_expr;
8594
11.3k
    p->optional_vars = optional_vars;
8595
11.3k
    return p;
8596
11.3k
}
8597
8598
match_case_ty
8599
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8600
                  PyArena *arena)
8601
3.01k
{
8602
3.01k
    match_case_ty p;
8603
3.01k
    if (!pattern) {
8604
0
        PyErr_SetString(PyExc_ValueError,
8605
0
                        "field 'pattern' is required for match_case");
8606
0
        return NULL;
8607
0
    }
8608
3.01k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8609
3.01k
    if (!p)
8610
0
        return NULL;
8611
3.01k
    p->pattern = pattern;
8612
3.01k
    p->guard = guard;
8613
3.01k
    p->body = body;
8614
3.01k
    return p;
8615
3.01k
}
8616
8617
pattern_ty
8618
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8619
                  int end_col_offset, PyArena *arena)
8620
6.10k
{
8621
6.10k
    pattern_ty p;
8622
6.10k
    if (!value) {
8623
0
        PyErr_SetString(PyExc_ValueError,
8624
0
                        "field 'value' is required for MatchValue");
8625
0
        return NULL;
8626
0
    }
8627
6.10k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8628
6.10k
    if (!p)
8629
0
        return NULL;
8630
6.10k
    p->kind = MatchValue_kind;
8631
6.10k
    p->v.MatchValue.value = value;
8632
6.10k
    p->lineno = lineno;
8633
6.10k
    p->col_offset = col_offset;
8634
6.10k
    p->end_lineno = end_lineno;
8635
6.10k
    p->end_col_offset = end_col_offset;
8636
6.10k
    return p;
8637
6.10k
}
8638
8639
pattern_ty
8640
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8641
                      end_lineno, int end_col_offset, PyArena *arena)
8642
1.24k
{
8643
1.24k
    pattern_ty p;
8644
1.24k
    if (!value) {
8645
0
        PyErr_SetString(PyExc_ValueError,
8646
0
                        "field 'value' is required for MatchSingleton");
8647
0
        return NULL;
8648
0
    }
8649
1.24k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8650
1.24k
    if (!p)
8651
0
        return NULL;
8652
1.24k
    p->kind = MatchSingleton_kind;
8653
1.24k
    p->v.MatchSingleton.value = value;
8654
1.24k
    p->lineno = lineno;
8655
1.24k
    p->col_offset = col_offset;
8656
1.24k
    p->end_lineno = end_lineno;
8657
1.24k
    p->end_col_offset = end_col_offset;
8658
1.24k
    return p;
8659
1.24k
}
8660
8661
pattern_ty
8662
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8663
                     int end_lineno, int end_col_offset, PyArena *arena)
8664
3.81k
{
8665
3.81k
    pattern_ty p;
8666
3.81k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8667
3.81k
    if (!p)
8668
0
        return NULL;
8669
3.81k
    p->kind = MatchSequence_kind;
8670
3.81k
    p->v.MatchSequence.patterns = patterns;
8671
3.81k
    p->lineno = lineno;
8672
3.81k
    p->col_offset = col_offset;
8673
3.81k
    p->end_lineno = end_lineno;
8674
3.81k
    p->end_col_offset = end_col_offset;
8675
3.81k
    return p;
8676
3.81k
}
8677
8678
pattern_ty
8679
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8680
                    identifier rest, int lineno, int col_offset, int
8681
                    end_lineno, int end_col_offset, PyArena *arena)
8682
1.15k
{
8683
1.15k
    pattern_ty p;
8684
1.15k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8685
1.15k
    if (!p)
8686
0
        return NULL;
8687
1.15k
    p->kind = MatchMapping_kind;
8688
1.15k
    p->v.MatchMapping.keys = keys;
8689
1.15k
    p->v.MatchMapping.patterns = patterns;
8690
1.15k
    p->v.MatchMapping.rest = rest;
8691
1.15k
    p->lineno = lineno;
8692
1.15k
    p->col_offset = col_offset;
8693
1.15k
    p->end_lineno = end_lineno;
8694
1.15k
    p->end_col_offset = end_col_offset;
8695
1.15k
    return p;
8696
1.15k
}
8697
8698
pattern_ty
8699
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8700
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8701
                  col_offset, int end_lineno, int end_col_offset, PyArena
8702
                  *arena)
8703
2.33k
{
8704
2.33k
    pattern_ty p;
8705
2.33k
    if (!cls) {
8706
0
        PyErr_SetString(PyExc_ValueError,
8707
0
                        "field 'cls' is required for MatchClass");
8708
0
        return NULL;
8709
0
    }
8710
2.33k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8711
2.33k
    if (!p)
8712
0
        return NULL;
8713
2.33k
    p->kind = MatchClass_kind;
8714
2.33k
    p->v.MatchClass.cls = cls;
8715
2.33k
    p->v.MatchClass.patterns = patterns;
8716
2.33k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8717
2.33k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8718
2.33k
    p->lineno = lineno;
8719
2.33k
    p->col_offset = col_offset;
8720
2.33k
    p->end_lineno = end_lineno;
8721
2.33k
    p->end_col_offset = end_col_offset;
8722
2.33k
    return p;
8723
2.33k
}
8724
8725
pattern_ty
8726
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8727
                 int end_col_offset, PyArena *arena)
8728
1.86k
{
8729
1.86k
    pattern_ty p;
8730
1.86k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8731
1.86k
    if (!p)
8732
0
        return NULL;
8733
1.86k
    p->kind = MatchStar_kind;
8734
1.86k
    p->v.MatchStar.name = name;
8735
1.86k
    p->lineno = lineno;
8736
1.86k
    p->col_offset = col_offset;
8737
1.86k
    p->end_lineno = end_lineno;
8738
1.86k
    p->end_col_offset = end_col_offset;
8739
1.86k
    return p;
8740
1.86k
}
8741
8742
pattern_ty
8743
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8744
               int end_lineno, int end_col_offset, PyArena *arena)
8745
22.0k
{
8746
22.0k
    pattern_ty p;
8747
22.0k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8748
22.0k
    if (!p)
8749
0
        return NULL;
8750
22.0k
    p->kind = MatchAs_kind;
8751
22.0k
    p->v.MatchAs.pattern = pattern;
8752
22.0k
    p->v.MatchAs.name = name;
8753
22.0k
    p->lineno = lineno;
8754
22.0k
    p->col_offset = col_offset;
8755
22.0k
    p->end_lineno = end_lineno;
8756
22.0k
    p->end_col_offset = end_col_offset;
8757
22.0k
    return p;
8758
22.0k
}
8759
8760
pattern_ty
8761
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8762
               end_lineno, int end_col_offset, PyArena *arena)
8763
9.70k
{
8764
9.70k
    pattern_ty p;
8765
9.70k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8766
9.70k
    if (!p)
8767
0
        return NULL;
8768
9.70k
    p->kind = MatchOr_kind;
8769
9.70k
    p->v.MatchOr.patterns = patterns;
8770
9.70k
    p->lineno = lineno;
8771
9.70k
    p->col_offset = col_offset;
8772
9.70k
    p->end_lineno = end_lineno;
8773
9.70k
    p->end_col_offset = end_col_offset;
8774
9.70k
    return p;
8775
9.70k
}
8776
8777
type_ignore_ty
8778
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8779
0
{
8780
0
    type_ignore_ty p;
8781
0
    if (!tag) {
8782
0
        PyErr_SetString(PyExc_ValueError,
8783
0
                        "field 'tag' is required for TypeIgnore");
8784
0
        return NULL;
8785
0
    }
8786
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8787
0
    if (!p)
8788
0
        return NULL;
8789
0
    p->kind = TypeIgnore_kind;
8790
0
    p->v.TypeIgnore.lineno = lineno;
8791
0
    p->v.TypeIgnore.tag = tag;
8792
0
    return p;
8793
0
}
8794
8795
type_param_ty
8796
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8797
               lineno, int col_offset, int end_lineno, int end_col_offset,
8798
               PyArena *arena)
8799
8.40k
{
8800
8.40k
    type_param_ty p;
8801
8.40k
    if (!name) {
8802
0
        PyErr_SetString(PyExc_ValueError,
8803
0
                        "field 'name' is required for TypeVar");
8804
0
        return NULL;
8805
0
    }
8806
8.40k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8807
8.40k
    if (!p)
8808
0
        return NULL;
8809
8.40k
    p->kind = TypeVar_kind;
8810
8.40k
    p->v.TypeVar.name = name;
8811
8.40k
    p->v.TypeVar.bound = bound;
8812
8.40k
    p->v.TypeVar.default_value = default_value;
8813
8.40k
    p->lineno = lineno;
8814
8.40k
    p->col_offset = col_offset;
8815
8.40k
    p->end_lineno = end_lineno;
8816
8.40k
    p->end_col_offset = end_col_offset;
8817
8.40k
    return p;
8818
8.40k
}
8819
8820
type_param_ty
8821
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8822
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8823
1.38k
{
8824
1.38k
    type_param_ty p;
8825
1.38k
    if (!name) {
8826
0
        PyErr_SetString(PyExc_ValueError,
8827
0
                        "field 'name' is required for ParamSpec");
8828
0
        return NULL;
8829
0
    }
8830
1.38k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8831
1.38k
    if (!p)
8832
0
        return NULL;
8833
1.38k
    p->kind = ParamSpec_kind;
8834
1.38k
    p->v.ParamSpec.name = name;
8835
1.38k
    p->v.ParamSpec.default_value = default_value;
8836
1.38k
    p->lineno = lineno;
8837
1.38k
    p->col_offset = col_offset;
8838
1.38k
    p->end_lineno = end_lineno;
8839
1.38k
    p->end_col_offset = end_col_offset;
8840
1.38k
    return p;
8841
1.38k
}
8842
8843
type_param_ty
8844
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8845
                    col_offset, int end_lineno, int end_col_offset, PyArena
8846
                    *arena)
8847
2.11k
{
8848
2.11k
    type_param_ty p;
8849
2.11k
    if (!name) {
8850
0
        PyErr_SetString(PyExc_ValueError,
8851
0
                        "field 'name' is required for TypeVarTuple");
8852
0
        return NULL;
8853
0
    }
8854
2.11k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8855
2.11k
    if (!p)
8856
0
        return NULL;
8857
2.11k
    p->kind = TypeVarTuple_kind;
8858
2.11k
    p->v.TypeVarTuple.name = name;
8859
2.11k
    p->v.TypeVarTuple.default_value = default_value;
8860
2.11k
    p->lineno = lineno;
8861
2.11k
    p->col_offset = col_offset;
8862
2.11k
    p->end_lineno = end_lineno;
8863
2.11k
    p->end_col_offset = end_col_offset;
8864
2.11k
    return p;
8865
2.11k
}
8866
8867
8868
PyObject*
8869
ast2obj_mod(struct ast_state *state, void* _o)
8870
7.01k
{
8871
7.01k
    mod_ty o = (mod_ty)_o;
8872
7.01k
    PyObject *result = NULL, *value = NULL;
8873
7.01k
    PyTypeObject *tp;
8874
7.01k
    if (!o) {
8875
0
        Py_RETURN_NONE;
8876
0
    }
8877
7.01k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8878
0
        return NULL;
8879
0
    }
8880
7.01k
    switch (o->kind) {
8881
7.01k
    case Module_kind:
8882
7.01k
        tp = (PyTypeObject *)state->Module_type;
8883
7.01k
        result = PyType_GenericNew(tp, NULL, NULL);
8884
7.01k
        if (!result) goto failed;
8885
7.01k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8886
7.01k
        if (!value) goto failed;
8887
7.01k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8888
0
            goto failed;
8889
7.01k
        Py_DECREF(value);
8890
7.01k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8891
7.01k
                             ast2obj_type_ignore);
8892
7.01k
        if (!value) goto failed;
8893
7.01k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8894
0
            goto failed;
8895
7.01k
        Py_DECREF(value);
8896
7.01k
        break;
8897
0
    case Interactive_kind:
8898
0
        tp = (PyTypeObject *)state->Interactive_type;
8899
0
        result = PyType_GenericNew(tp, NULL, NULL);
8900
0
        if (!result) goto failed;
8901
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8902
0
                             ast2obj_stmt);
8903
0
        if (!value) goto failed;
8904
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8905
0
            goto failed;
8906
0
        Py_DECREF(value);
8907
0
        break;
8908
0
    case Expression_kind:
8909
0
        tp = (PyTypeObject *)state->Expression_type;
8910
0
        result = PyType_GenericNew(tp, NULL, NULL);
8911
0
        if (!result) goto failed;
8912
0
        value = ast2obj_expr(state, o->v.Expression.body);
8913
0
        if (!value) goto failed;
8914
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8915
0
            goto failed;
8916
0
        Py_DECREF(value);
8917
0
        break;
8918
0
    case FunctionType_kind:
8919
0
        tp = (PyTypeObject *)state->FunctionType_type;
8920
0
        result = PyType_GenericNew(tp, NULL, NULL);
8921
0
        if (!result) goto failed;
8922
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8923
0
                             ast2obj_expr);
8924
0
        if (!value) goto failed;
8925
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8926
0
            goto failed;
8927
0
        Py_DECREF(value);
8928
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8929
0
        if (!value) goto failed;
8930
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8931
0
            goto failed;
8932
0
        Py_DECREF(value);
8933
0
        break;
8934
7.01k
    }
8935
7.01k
    Py_LeaveRecursiveCall();
8936
7.01k
    return result;
8937
0
failed:
8938
0
    Py_LeaveRecursiveCall();
8939
0
    Py_XDECREF(value);
8940
0
    Py_XDECREF(result);
8941
0
    return NULL;
8942
7.01k
}
8943
8944
PyObject*
8945
ast2obj_stmt(struct ast_state *state, void* _o)
8946
49.4k
{
8947
49.4k
    stmt_ty o = (stmt_ty)_o;
8948
49.4k
    PyObject *result = NULL, *value = NULL;
8949
49.4k
    PyTypeObject *tp;
8950
49.4k
    if (!o) {
8951
0
        Py_RETURN_NONE;
8952
0
    }
8953
49.4k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8954
0
        return NULL;
8955
0
    }
8956
49.4k
    switch (o->kind) {
8957
1.56k
    case FunctionDef_kind:
8958
1.56k
        tp = (PyTypeObject *)state->FunctionDef_type;
8959
1.56k
        result = PyType_GenericNew(tp, NULL, NULL);
8960
1.56k
        if (!result) goto failed;
8961
1.56k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8962
1.56k
        if (!value) goto failed;
8963
1.56k
        if (PyObject_SetAttr(result, state->name, value) == -1)
8964
0
            goto failed;
8965
1.56k
        Py_DECREF(value);
8966
1.56k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8967
1.56k
        if (!value) goto failed;
8968
1.56k
        if (PyObject_SetAttr(result, state->args, value) == -1)
8969
0
            goto failed;
8970
1.56k
        Py_DECREF(value);
8971
1.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8972
1.56k
                             ast2obj_stmt);
8973
1.56k
        if (!value) goto failed;
8974
1.56k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8975
0
            goto failed;
8976
1.56k
        Py_DECREF(value);
8977
1.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8978
1.56k
                             ast2obj_expr);
8979
1.56k
        if (!value) goto failed;
8980
1.56k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
8981
0
            goto failed;
8982
1.56k
        Py_DECREF(value);
8983
1.56k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
8984
1.56k
        if (!value) goto failed;
8985
1.56k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8986
0
            goto failed;
8987
1.56k
        Py_DECREF(value);
8988
1.56k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
8989
1.56k
        if (!value) goto failed;
8990
1.56k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
8991
0
            goto failed;
8992
1.56k
        Py_DECREF(value);
8993
1.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
8994
1.56k
                             ast2obj_type_param);
8995
1.56k
        if (!value) goto failed;
8996
1.56k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
8997
0
            goto failed;
8998
1.56k
        Py_DECREF(value);
8999
1.56k
        break;
9000
278
    case AsyncFunctionDef_kind:
9001
278
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9002
278
        result = PyType_GenericNew(tp, NULL, NULL);
9003
278
        if (!result) goto failed;
9004
278
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9005
278
        if (!value) goto failed;
9006
278
        if (PyObject_SetAttr(result, state->name, value) == -1)
9007
0
            goto failed;
9008
278
        Py_DECREF(value);
9009
278
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9010
278
        if (!value) goto failed;
9011
278
        if (PyObject_SetAttr(result, state->args, value) == -1)
9012
0
            goto failed;
9013
278
        Py_DECREF(value);
9014
278
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9015
278
                             ast2obj_stmt);
9016
278
        if (!value) goto failed;
9017
278
        if (PyObject_SetAttr(result, state->body, value) == -1)
9018
0
            goto failed;
9019
278
        Py_DECREF(value);
9020
278
        value = ast2obj_list(state,
9021
278
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9022
278
                             ast2obj_expr);
9023
278
        if (!value) goto failed;
9024
278
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9025
0
            goto failed;
9026
278
        Py_DECREF(value);
9027
278
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9028
278
        if (!value) goto failed;
9029
278
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9030
0
            goto failed;
9031
278
        Py_DECREF(value);
9032
278
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9033
278
        if (!value) goto failed;
9034
278
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9035
0
            goto failed;
9036
278
        Py_DECREF(value);
9037
278
        value = ast2obj_list(state,
9038
278
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9039
278
                             ast2obj_type_param);
9040
278
        if (!value) goto failed;
9041
278
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9042
0
            goto failed;
9043
278
        Py_DECREF(value);
9044
278
        break;
9045
407
    case ClassDef_kind:
9046
407
        tp = (PyTypeObject *)state->ClassDef_type;
9047
407
        result = PyType_GenericNew(tp, NULL, NULL);
9048
407
        if (!result) goto failed;
9049
407
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9050
407
        if (!value) goto failed;
9051
407
        if (PyObject_SetAttr(result, state->name, value) == -1)
9052
0
            goto failed;
9053
407
        Py_DECREF(value);
9054
407
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9055
407
                             ast2obj_expr);
9056
407
        if (!value) goto failed;
9057
407
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9058
0
            goto failed;
9059
407
        Py_DECREF(value);
9060
407
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9061
407
                             ast2obj_keyword);
9062
407
        if (!value) goto failed;
9063
407
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9064
0
            goto failed;
9065
407
        Py_DECREF(value);
9066
407
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9067
407
                             ast2obj_stmt);
9068
407
        if (!value) goto failed;
9069
407
        if (PyObject_SetAttr(result, state->body, value) == -1)
9070
0
            goto failed;
9071
407
        Py_DECREF(value);
9072
407
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9073
407
                             ast2obj_expr);
9074
407
        if (!value) goto failed;
9075
407
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9076
0
            goto failed;
9077
407
        Py_DECREF(value);
9078
407
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9079
407
                             ast2obj_type_param);
9080
407
        if (!value) goto failed;
9081
407
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9082
0
            goto failed;
9083
407
        Py_DECREF(value);
9084
407
        break;
9085
195
    case Return_kind:
9086
195
        tp = (PyTypeObject *)state->Return_type;
9087
195
        result = PyType_GenericNew(tp, NULL, NULL);
9088
195
        if (!result) goto failed;
9089
195
        value = ast2obj_expr(state, o->v.Return.value);
9090
195
        if (!value) goto failed;
9091
195
        if (PyObject_SetAttr(result, state->value, value) == -1)
9092
0
            goto failed;
9093
195
        Py_DECREF(value);
9094
195
        break;
9095
225
    case Delete_kind:
9096
225
        tp = (PyTypeObject *)state->Delete_type;
9097
225
        result = PyType_GenericNew(tp, NULL, NULL);
9098
225
        if (!result) goto failed;
9099
225
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9100
225
                             ast2obj_expr);
9101
225
        if (!value) goto failed;
9102
225
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9103
0
            goto failed;
9104
225
        Py_DECREF(value);
9105
225
        break;
9106
833
    case Assign_kind:
9107
833
        tp = (PyTypeObject *)state->Assign_type;
9108
833
        result = PyType_GenericNew(tp, NULL, NULL);
9109
833
        if (!result) goto failed;
9110
833
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9111
833
                             ast2obj_expr);
9112
833
        if (!value) goto failed;
9113
833
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9114
0
            goto failed;
9115
833
        Py_DECREF(value);
9116
833
        value = ast2obj_expr(state, o->v.Assign.value);
9117
833
        if (!value) goto failed;
9118
833
        if (PyObject_SetAttr(result, state->value, value) == -1)
9119
0
            goto failed;
9120
833
        Py_DECREF(value);
9121
833
        value = ast2obj_string(state, o->v.Assign.type_comment);
9122
833
        if (!value) goto failed;
9123
833
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9124
0
            goto failed;
9125
833
        Py_DECREF(value);
9126
833
        break;
9127
81
    case TypeAlias_kind:
9128
81
        tp = (PyTypeObject *)state->TypeAlias_type;
9129
81
        result = PyType_GenericNew(tp, NULL, NULL);
9130
81
        if (!result) goto failed;
9131
81
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9132
81
        if (!value) goto failed;
9133
81
        if (PyObject_SetAttr(result, state->name, value) == -1)
9134
0
            goto failed;
9135
81
        Py_DECREF(value);
9136
81
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9137
81
                             ast2obj_type_param);
9138
81
        if (!value) goto failed;
9139
81
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9140
0
            goto failed;
9141
81
        Py_DECREF(value);
9142
81
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9143
81
        if (!value) goto failed;
9144
81
        if (PyObject_SetAttr(result, state->value, value) == -1)
9145
0
            goto failed;
9146
81
        Py_DECREF(value);
9147
81
        break;
9148
252
    case AugAssign_kind:
9149
252
        tp = (PyTypeObject *)state->AugAssign_type;
9150
252
        result = PyType_GenericNew(tp, NULL, NULL);
9151
252
        if (!result) goto failed;
9152
252
        value = ast2obj_expr(state, o->v.AugAssign.target);
9153
252
        if (!value) goto failed;
9154
252
        if (PyObject_SetAttr(result, state->target, value) == -1)
9155
0
            goto failed;
9156
252
        Py_DECREF(value);
9157
252
        value = ast2obj_operator(state, o->v.AugAssign.op);
9158
252
        if (!value) goto failed;
9159
252
        if (PyObject_SetAttr(result, state->op, value) == -1)
9160
0
            goto failed;
9161
252
        Py_DECREF(value);
9162
252
        value = ast2obj_expr(state, o->v.AugAssign.value);
9163
252
        if (!value) goto failed;
9164
252
        if (PyObject_SetAttr(result, state->value, value) == -1)
9165
0
            goto failed;
9166
252
        Py_DECREF(value);
9167
252
        break;
9168
879
    case AnnAssign_kind:
9169
879
        tp = (PyTypeObject *)state->AnnAssign_type;
9170
879
        result = PyType_GenericNew(tp, NULL, NULL);
9171
879
        if (!result) goto failed;
9172
879
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9173
879
        if (!value) goto failed;
9174
879
        if (PyObject_SetAttr(result, state->target, value) == -1)
9175
0
            goto failed;
9176
879
        Py_DECREF(value);
9177
879
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9178
879
        if (!value) goto failed;
9179
879
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9180
0
            goto failed;
9181
879
        Py_DECREF(value);
9182
879
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9183
879
        if (!value) goto failed;
9184
879
        if (PyObject_SetAttr(result, state->value, value) == -1)
9185
0
            goto failed;
9186
879
        Py_DECREF(value);
9187
879
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9188
879
        if (!value) goto failed;
9189
879
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9190
0
            goto failed;
9191
879
        Py_DECREF(value);
9192
879
        break;
9193
345
    case For_kind:
9194
345
        tp = (PyTypeObject *)state->For_type;
9195
345
        result = PyType_GenericNew(tp, NULL, NULL);
9196
345
        if (!result) goto failed;
9197
345
        value = ast2obj_expr(state, o->v.For.target);
9198
345
        if (!value) goto failed;
9199
345
        if (PyObject_SetAttr(result, state->target, value) == -1)
9200
0
            goto failed;
9201
345
        Py_DECREF(value);
9202
345
        value = ast2obj_expr(state, o->v.For.iter);
9203
345
        if (!value) goto failed;
9204
345
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9205
0
            goto failed;
9206
345
        Py_DECREF(value);
9207
345
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9208
345
        if (!value) goto failed;
9209
345
        if (PyObject_SetAttr(result, state->body, value) == -1)
9210
0
            goto failed;
9211
345
        Py_DECREF(value);
9212
345
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9213
345
        if (!value) goto failed;
9214
345
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9215
0
            goto failed;
9216
345
        Py_DECREF(value);
9217
345
        value = ast2obj_string(state, o->v.For.type_comment);
9218
345
        if (!value) goto failed;
9219
345
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9220
0
            goto failed;
9221
345
        Py_DECREF(value);
9222
345
        break;
9223
81
    case AsyncFor_kind:
9224
81
        tp = (PyTypeObject *)state->AsyncFor_type;
9225
81
        result = PyType_GenericNew(tp, NULL, NULL);
9226
81
        if (!result) goto failed;
9227
81
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9228
81
        if (!value) goto failed;
9229
81
        if (PyObject_SetAttr(result, state->target, value) == -1)
9230
0
            goto failed;
9231
81
        Py_DECREF(value);
9232
81
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9233
81
        if (!value) goto failed;
9234
81
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9235
0
            goto failed;
9236
81
        Py_DECREF(value);
9237
81
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9238
81
                             ast2obj_stmt);
9239
81
        if (!value) goto failed;
9240
81
        if (PyObject_SetAttr(result, state->body, value) == -1)
9241
0
            goto failed;
9242
81
        Py_DECREF(value);
9243
81
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9244
81
                             ast2obj_stmt);
9245
81
        if (!value) goto failed;
9246
81
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9247
0
            goto failed;
9248
81
        Py_DECREF(value);
9249
81
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9250
81
        if (!value) goto failed;
9251
81
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9252
0
            goto failed;
9253
81
        Py_DECREF(value);
9254
81
        break;
9255
223
    case While_kind:
9256
223
        tp = (PyTypeObject *)state->While_type;
9257
223
        result = PyType_GenericNew(tp, NULL, NULL);
9258
223
        if (!result) goto failed;
9259
223
        value = ast2obj_expr(state, o->v.While.test);
9260
223
        if (!value) goto failed;
9261
223
        if (PyObject_SetAttr(result, state->test, value) == -1)
9262
0
            goto failed;
9263
223
        Py_DECREF(value);
9264
223
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9265
223
        if (!value) goto failed;
9266
223
        if (PyObject_SetAttr(result, state->body, value) == -1)
9267
0
            goto failed;
9268
223
        Py_DECREF(value);
9269
223
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9270
223
        if (!value) goto failed;
9271
223
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9272
0
            goto failed;
9273
223
        Py_DECREF(value);
9274
223
        break;
9275
479
    case If_kind:
9276
479
        tp = (PyTypeObject *)state->If_type;
9277
479
        result = PyType_GenericNew(tp, NULL, NULL);
9278
479
        if (!result) goto failed;
9279
479
        value = ast2obj_expr(state, o->v.If.test);
9280
479
        if (!value) goto failed;
9281
479
        if (PyObject_SetAttr(result, state->test, value) == -1)
9282
0
            goto failed;
9283
479
        Py_DECREF(value);
9284
479
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9285
479
        if (!value) goto failed;
9286
479
        if (PyObject_SetAttr(result, state->body, value) == -1)
9287
0
            goto failed;
9288
479
        Py_DECREF(value);
9289
479
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9290
479
        if (!value) goto failed;
9291
479
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9292
0
            goto failed;
9293
479
        Py_DECREF(value);
9294
479
        break;
9295
297
    case With_kind:
9296
297
        tp = (PyTypeObject *)state->With_type;
9297
297
        result = PyType_GenericNew(tp, NULL, NULL);
9298
297
        if (!result) goto failed;
9299
297
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9300
297
                             ast2obj_withitem);
9301
297
        if (!value) goto failed;
9302
297
        if (PyObject_SetAttr(result, state->items, value) == -1)
9303
0
            goto failed;
9304
297
        Py_DECREF(value);
9305
297
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9306
297
        if (!value) goto failed;
9307
297
        if (PyObject_SetAttr(result, state->body, value) == -1)
9308
0
            goto failed;
9309
297
        Py_DECREF(value);
9310
297
        value = ast2obj_string(state, o->v.With.type_comment);
9311
297
        if (!value) goto failed;
9312
297
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9313
0
            goto failed;
9314
297
        Py_DECREF(value);
9315
297
        break;
9316
121
    case AsyncWith_kind:
9317
121
        tp = (PyTypeObject *)state->AsyncWith_type;
9318
121
        result = PyType_GenericNew(tp, NULL, NULL);
9319
121
        if (!result) goto failed;
9320
121
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9321
121
                             ast2obj_withitem);
9322
121
        if (!value) goto failed;
9323
121
        if (PyObject_SetAttr(result, state->items, value) == -1)
9324
0
            goto failed;
9325
121
        Py_DECREF(value);
9326
121
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9327
121
                             ast2obj_stmt);
9328
121
        if (!value) goto failed;
9329
121
        if (PyObject_SetAttr(result, state->body, value) == -1)
9330
0
            goto failed;
9331
121
        Py_DECREF(value);
9332
121
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9333
121
        if (!value) goto failed;
9334
121
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9335
0
            goto failed;
9336
121
        Py_DECREF(value);
9337
121
        break;
9338
281
    case Match_kind:
9339
281
        tp = (PyTypeObject *)state->Match_type;
9340
281
        result = PyType_GenericNew(tp, NULL, NULL);
9341
281
        if (!result) goto failed;
9342
281
        value = ast2obj_expr(state, o->v.Match.subject);
9343
281
        if (!value) goto failed;
9344
281
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9345
0
            goto failed;
9346
281
        Py_DECREF(value);
9347
281
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9348
281
                             ast2obj_match_case);
9349
281
        if (!value) goto failed;
9350
281
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9351
0
            goto failed;
9352
281
        Py_DECREF(value);
9353
281
        break;
9354
467
    case Raise_kind:
9355
467
        tp = (PyTypeObject *)state->Raise_type;
9356
467
        result = PyType_GenericNew(tp, NULL, NULL);
9357
467
        if (!result) goto failed;
9358
467
        value = ast2obj_expr(state, o->v.Raise.exc);
9359
467
        if (!value) goto failed;
9360
467
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9361
0
            goto failed;
9362
467
        Py_DECREF(value);
9363
467
        value = ast2obj_expr(state, o->v.Raise.cause);
9364
467
        if (!value) goto failed;
9365
467
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9366
0
            goto failed;
9367
467
        Py_DECREF(value);
9368
467
        break;
9369
441
    case Try_kind:
9370
441
        tp = (PyTypeObject *)state->Try_type;
9371
441
        result = PyType_GenericNew(tp, NULL, NULL);
9372
441
        if (!result) goto failed;
9373
441
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9374
441
        if (!value) goto failed;
9375
441
        if (PyObject_SetAttr(result, state->body, value) == -1)
9376
0
            goto failed;
9377
441
        Py_DECREF(value);
9378
441
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9379
441
                             ast2obj_excepthandler);
9380
441
        if (!value) goto failed;
9381
441
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9382
0
            goto failed;
9383
441
        Py_DECREF(value);
9384
441
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9385
441
        if (!value) goto failed;
9386
441
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9387
0
            goto failed;
9388
441
        Py_DECREF(value);
9389
441
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9390
441
                             ast2obj_stmt);
9391
441
        if (!value) goto failed;
9392
441
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9393
0
            goto failed;
9394
441
        Py_DECREF(value);
9395
441
        break;
9396
366
    case TryStar_kind:
9397
366
        tp = (PyTypeObject *)state->TryStar_type;
9398
366
        result = PyType_GenericNew(tp, NULL, NULL);
9399
366
        if (!result) goto failed;
9400
366
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9401
366
        if (!value) goto failed;
9402
366
        if (PyObject_SetAttr(result, state->body, value) == -1)
9403
0
            goto failed;
9404
366
        Py_DECREF(value);
9405
366
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9406
366
                             ast2obj_excepthandler);
9407
366
        if (!value) goto failed;
9408
366
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9409
0
            goto failed;
9410
366
        Py_DECREF(value);
9411
366
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9412
366
                             ast2obj_stmt);
9413
366
        if (!value) goto failed;
9414
366
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9415
0
            goto failed;
9416
366
        Py_DECREF(value);
9417
366
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9418
366
                             ast2obj_stmt);
9419
366
        if (!value) goto failed;
9420
366
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9421
0
            goto failed;
9422
366
        Py_DECREF(value);
9423
366
        break;
9424
308
    case Assert_kind:
9425
308
        tp = (PyTypeObject *)state->Assert_type;
9426
308
        result = PyType_GenericNew(tp, NULL, NULL);
9427
308
        if (!result) goto failed;
9428
308
        value = ast2obj_expr(state, o->v.Assert.test);
9429
308
        if (!value) goto failed;
9430
308
        if (PyObject_SetAttr(result, state->test, value) == -1)
9431
0
            goto failed;
9432
308
        Py_DECREF(value);
9433
308
        value = ast2obj_expr(state, o->v.Assert.msg);
9434
308
        if (!value) goto failed;
9435
308
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9436
0
            goto failed;
9437
308
        Py_DECREF(value);
9438
308
        break;
9439
572
    case Import_kind:
9440
572
        tp = (PyTypeObject *)state->Import_type;
9441
572
        result = PyType_GenericNew(tp, NULL, NULL);
9442
572
        if (!result) goto failed;
9443
572
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9444
572
                             ast2obj_alias);
9445
572
        if (!value) goto failed;
9446
572
        if (PyObject_SetAttr(result, state->names, value) == -1)
9447
0
            goto failed;
9448
572
        Py_DECREF(value);
9449
572
        value = ast2obj_int(state, o->v.Import.is_lazy);
9450
572
        if (!value) goto failed;
9451
572
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9452
0
            goto failed;
9453
572
        Py_DECREF(value);
9454
572
        break;
9455
667
    case ImportFrom_kind:
9456
667
        tp = (PyTypeObject *)state->ImportFrom_type;
9457
667
        result = PyType_GenericNew(tp, NULL, NULL);
9458
667
        if (!result) goto failed;
9459
667
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9460
667
        if (!value) goto failed;
9461
667
        if (PyObject_SetAttr(result, state->module, value) == -1)
9462
0
            goto failed;
9463
667
        Py_DECREF(value);
9464
667
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9465
667
                             ast2obj_alias);
9466
667
        if (!value) goto failed;
9467
667
        if (PyObject_SetAttr(result, state->names, value) == -1)
9468
0
            goto failed;
9469
667
        Py_DECREF(value);
9470
667
        value = ast2obj_int(state, o->v.ImportFrom.level);
9471
667
        if (!value) goto failed;
9472
667
        if (PyObject_SetAttr(result, state->level, value) == -1)
9473
0
            goto failed;
9474
667
        Py_DECREF(value);
9475
667
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
9476
667
        if (!value) goto failed;
9477
667
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9478
0
            goto failed;
9479
667
        Py_DECREF(value);
9480
667
        break;
9481
284
    case Global_kind:
9482
284
        tp = (PyTypeObject *)state->Global_type;
9483
284
        result = PyType_GenericNew(tp, NULL, NULL);
9484
284
        if (!result) goto failed;
9485
284
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9486
284
                             ast2obj_identifier);
9487
284
        if (!value) goto failed;
9488
284
        if (PyObject_SetAttr(result, state->names, value) == -1)
9489
0
            goto failed;
9490
284
        Py_DECREF(value);
9491
284
        break;
9492
70
    case Nonlocal_kind:
9493
70
        tp = (PyTypeObject *)state->Nonlocal_type;
9494
70
        result = PyType_GenericNew(tp, NULL, NULL);
9495
70
        if (!result) goto failed;
9496
70
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9497
70
                             ast2obj_identifier);
9498
70
        if (!value) goto failed;
9499
70
        if (PyObject_SetAttr(result, state->names, value) == -1)
9500
0
            goto failed;
9501
70
        Py_DECREF(value);
9502
70
        break;
9503
38.9k
    case Expr_kind:
9504
38.9k
        tp = (PyTypeObject *)state->Expr_type;
9505
38.9k
        result = PyType_GenericNew(tp, NULL, NULL);
9506
38.9k
        if (!result) goto failed;
9507
38.9k
        value = ast2obj_expr(state, o->v.Expr.value);
9508
38.9k
        if (!value) goto failed;
9509
38.9k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9510
0
            goto failed;
9511
38.9k
        Py_DECREF(value);
9512
38.9k
        break;
9513
265
    case Pass_kind:
9514
265
        tp = (PyTypeObject *)state->Pass_type;
9515
265
        result = PyType_GenericNew(tp, NULL, NULL);
9516
265
        if (!result) goto failed;
9517
265
        break;
9518
291
    case Break_kind:
9519
291
        tp = (PyTypeObject *)state->Break_type;
9520
291
        result = PyType_GenericNew(tp, NULL, NULL);
9521
291
        if (!result) goto failed;
9522
291
        break;
9523
291
    case Continue_kind:
9524
238
        tp = (PyTypeObject *)state->Continue_type;
9525
238
        result = PyType_GenericNew(tp, NULL, NULL);
9526
238
        if (!result) goto failed;
9527
238
        break;
9528
49.4k
    }
9529
49.4k
    value = ast2obj_int(state, o->lineno);
9530
49.4k
    if (!value) goto failed;
9531
49.4k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9532
0
        goto failed;
9533
49.4k
    Py_DECREF(value);
9534
49.4k
    value = ast2obj_int(state, o->col_offset);
9535
49.4k
    if (!value) goto failed;
9536
49.4k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9537
0
        goto failed;
9538
49.4k
    Py_DECREF(value);
9539
49.4k
    value = ast2obj_int(state, o->end_lineno);
9540
49.4k
    if (!value) goto failed;
9541
49.4k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9542
0
        goto failed;
9543
49.4k
    Py_DECREF(value);
9544
49.4k
    value = ast2obj_int(state, o->end_col_offset);
9545
49.4k
    if (!value) goto failed;
9546
49.4k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9547
0
        goto failed;
9548
49.4k
    Py_DECREF(value);
9549
49.4k
    Py_LeaveRecursiveCall();
9550
49.4k
    return result;
9551
0
failed:
9552
0
    Py_LeaveRecursiveCall();
9553
0
    Py_XDECREF(value);
9554
0
    Py_XDECREF(result);
9555
0
    return NULL;
9556
49.4k
}
9557
9558
PyObject*
9559
ast2obj_expr(struct ast_state *state, void* _o)
9560
431k
{
9561
431k
    expr_ty o = (expr_ty)_o;
9562
431k
    PyObject *result = NULL, *value = NULL;
9563
431k
    PyTypeObject *tp;
9564
431k
    if (!o) {
9565
56.8k
        Py_RETURN_NONE;
9566
56.8k
    }
9567
374k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9568
0
        return NULL;
9569
0
    }
9570
374k
    switch (o->kind) {
9571
531
    case BoolOp_kind:
9572
531
        tp = (PyTypeObject *)state->BoolOp_type;
9573
531
        result = PyType_GenericNew(tp, NULL, NULL);
9574
531
        if (!result) goto failed;
9575
531
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9576
531
        if (!value) goto failed;
9577
531
        if (PyObject_SetAttr(result, state->op, value) == -1)
9578
0
            goto failed;
9579
531
        Py_DECREF(value);
9580
531
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9581
531
                             ast2obj_expr);
9582
531
        if (!value) goto failed;
9583
531
        if (PyObject_SetAttr(result, state->values, value) == -1)
9584
0
            goto failed;
9585
531
        Py_DECREF(value);
9586
531
        break;
9587
70
    case NamedExpr_kind:
9588
70
        tp = (PyTypeObject *)state->NamedExpr_type;
9589
70
        result = PyType_GenericNew(tp, NULL, NULL);
9590
70
        if (!result) goto failed;
9591
70
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9592
70
        if (!value) goto failed;
9593
70
        if (PyObject_SetAttr(result, state->target, value) == -1)
9594
0
            goto failed;
9595
70
        Py_DECREF(value);
9596
70
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9597
70
        if (!value) goto failed;
9598
70
        if (PyObject_SetAttr(result, state->value, value) == -1)
9599
0
            goto failed;
9600
70
        Py_DECREF(value);
9601
70
        break;
9602
27.1k
    case BinOp_kind:
9603
27.1k
        tp = (PyTypeObject *)state->BinOp_type;
9604
27.1k
        result = PyType_GenericNew(tp, NULL, NULL);
9605
27.1k
        if (!result) goto failed;
9606
27.1k
        value = ast2obj_expr(state, o->v.BinOp.left);
9607
27.1k
        if (!value) goto failed;
9608
27.1k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9609
0
            goto failed;
9610
27.1k
        Py_DECREF(value);
9611
27.1k
        value = ast2obj_operator(state, o->v.BinOp.op);
9612
27.1k
        if (!value) goto failed;
9613
27.1k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9614
0
            goto failed;
9615
27.1k
        Py_DECREF(value);
9616
27.1k
        value = ast2obj_expr(state, o->v.BinOp.right);
9617
27.1k
        if (!value) goto failed;
9618
27.1k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9619
0
            goto failed;
9620
27.1k
        Py_DECREF(value);
9621
27.1k
        break;
9622
146k
    case UnaryOp_kind:
9623
146k
        tp = (PyTypeObject *)state->UnaryOp_type;
9624
146k
        result = PyType_GenericNew(tp, NULL, NULL);
9625
146k
        if (!result) goto failed;
9626
146k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9627
146k
        if (!value) goto failed;
9628
146k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9629
0
            goto failed;
9630
146k
        Py_DECREF(value);
9631
146k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9632
146k
        if (!value) goto failed;
9633
146k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9634
0
            goto failed;
9635
146k
        Py_DECREF(value);
9636
146k
        break;
9637
944
    case Lambda_kind:
9638
944
        tp = (PyTypeObject *)state->Lambda_type;
9639
944
        result = PyType_GenericNew(tp, NULL, NULL);
9640
944
        if (!result) goto failed;
9641
944
        value = ast2obj_arguments(state, o->v.Lambda.args);
9642
944
        if (!value) goto failed;
9643
944
        if (PyObject_SetAttr(result, state->args, value) == -1)
9644
0
            goto failed;
9645
944
        Py_DECREF(value);
9646
944
        value = ast2obj_expr(state, o->v.Lambda.body);
9647
944
        if (!value) goto failed;
9648
944
        if (PyObject_SetAttr(result, state->body, value) == -1)
9649
0
            goto failed;
9650
944
        Py_DECREF(value);
9651
944
        break;
9652
203
    case IfExp_kind:
9653
203
        tp = (PyTypeObject *)state->IfExp_type;
9654
203
        result = PyType_GenericNew(tp, NULL, NULL);
9655
203
        if (!result) goto failed;
9656
203
        value = ast2obj_expr(state, o->v.IfExp.test);
9657
203
        if (!value) goto failed;
9658
203
        if (PyObject_SetAttr(result, state->test, value) == -1)
9659
0
            goto failed;
9660
203
        Py_DECREF(value);
9661
203
        value = ast2obj_expr(state, o->v.IfExp.body);
9662
203
        if (!value) goto failed;
9663
203
        if (PyObject_SetAttr(result, state->body, value) == -1)
9664
0
            goto failed;
9665
203
        Py_DECREF(value);
9666
203
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9667
203
        if (!value) goto failed;
9668
203
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9669
0
            goto failed;
9670
203
        Py_DECREF(value);
9671
203
        break;
9672
1.21k
    case Dict_kind:
9673
1.21k
        tp = (PyTypeObject *)state->Dict_type;
9674
1.21k
        result = PyType_GenericNew(tp, NULL, NULL);
9675
1.21k
        if (!result) goto failed;
9676
1.21k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9677
1.21k
        if (!value) goto failed;
9678
1.21k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9679
0
            goto failed;
9680
1.21k
        Py_DECREF(value);
9681
1.21k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9682
1.21k
        if (!value) goto failed;
9683
1.21k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9684
0
            goto failed;
9685
1.21k
        Py_DECREF(value);
9686
1.21k
        break;
9687
379
    case Set_kind:
9688
379
        tp = (PyTypeObject *)state->Set_type;
9689
379
        result = PyType_GenericNew(tp, NULL, NULL);
9690
379
        if (!result) goto failed;
9691
379
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9692
379
        if (!value) goto failed;
9693
379
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9694
0
            goto failed;
9695
379
        Py_DECREF(value);
9696
379
        break;
9697
195
    case ListComp_kind:
9698
195
        tp = (PyTypeObject *)state->ListComp_type;
9699
195
        result = PyType_GenericNew(tp, NULL, NULL);
9700
195
        if (!result) goto failed;
9701
195
        value = ast2obj_expr(state, o->v.ListComp.elt);
9702
195
        if (!value) goto failed;
9703
195
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9704
0
            goto failed;
9705
195
        Py_DECREF(value);
9706
195
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9707
195
                             ast2obj_comprehension);
9708
195
        if (!value) goto failed;
9709
195
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9710
0
            goto failed;
9711
195
        Py_DECREF(value);
9712
195
        break;
9713
322
    case SetComp_kind:
9714
322
        tp = (PyTypeObject *)state->SetComp_type;
9715
322
        result = PyType_GenericNew(tp, NULL, NULL);
9716
322
        if (!result) goto failed;
9717
322
        value = ast2obj_expr(state, o->v.SetComp.elt);
9718
322
        if (!value) goto failed;
9719
322
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9720
0
            goto failed;
9721
322
        Py_DECREF(value);
9722
322
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9723
322
                             ast2obj_comprehension);
9724
322
        if (!value) goto failed;
9725
322
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9726
0
            goto failed;
9727
322
        Py_DECREF(value);
9728
322
        break;
9729
317
    case DictComp_kind:
9730
317
        tp = (PyTypeObject *)state->DictComp_type;
9731
317
        result = PyType_GenericNew(tp, NULL, NULL);
9732
317
        if (!result) goto failed;
9733
317
        value = ast2obj_expr(state, o->v.DictComp.key);
9734
317
        if (!value) goto failed;
9735
317
        if (PyObject_SetAttr(result, state->key, value) == -1)
9736
0
            goto failed;
9737
317
        Py_DECREF(value);
9738
317
        value = ast2obj_expr(state, o->v.DictComp.value);
9739
317
        if (!value) goto failed;
9740
317
        if (PyObject_SetAttr(result, state->value, value) == -1)
9741
0
            goto failed;
9742
317
        Py_DECREF(value);
9743
317
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9744
317
                             ast2obj_comprehension);
9745
317
        if (!value) goto failed;
9746
317
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9747
0
            goto failed;
9748
317
        Py_DECREF(value);
9749
317
        break;
9750
426
    case GeneratorExp_kind:
9751
426
        tp = (PyTypeObject *)state->GeneratorExp_type;
9752
426
        result = PyType_GenericNew(tp, NULL, NULL);
9753
426
        if (!result) goto failed;
9754
426
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9755
426
        if (!value) goto failed;
9756
426
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9757
0
            goto failed;
9758
426
        Py_DECREF(value);
9759
426
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9760
426
                             ast2obj_comprehension);
9761
426
        if (!value) goto failed;
9762
426
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9763
0
            goto failed;
9764
426
        Py_DECREF(value);
9765
426
        break;
9766
73
    case Await_kind:
9767
73
        tp = (PyTypeObject *)state->Await_type;
9768
73
        result = PyType_GenericNew(tp, NULL, NULL);
9769
73
        if (!result) goto failed;
9770
73
        value = ast2obj_expr(state, o->v.Await.value);
9771
73
        if (!value) goto failed;
9772
73
        if (PyObject_SetAttr(result, state->value, value) == -1)
9773
0
            goto failed;
9774
73
        Py_DECREF(value);
9775
73
        break;
9776
955
    case Yield_kind:
9777
955
        tp = (PyTypeObject *)state->Yield_type;
9778
955
        result = PyType_GenericNew(tp, NULL, NULL);
9779
955
        if (!result) goto failed;
9780
955
        value = ast2obj_expr(state, o->v.Yield.value);
9781
955
        if (!value) goto failed;
9782
955
        if (PyObject_SetAttr(result, state->value, value) == -1)
9783
0
            goto failed;
9784
955
        Py_DECREF(value);
9785
955
        break;
9786
74
    case YieldFrom_kind:
9787
74
        tp = (PyTypeObject *)state->YieldFrom_type;
9788
74
        result = PyType_GenericNew(tp, NULL, NULL);
9789
74
        if (!result) goto failed;
9790
74
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9791
74
        if (!value) goto failed;
9792
74
        if (PyObject_SetAttr(result, state->value, value) == -1)
9793
0
            goto failed;
9794
74
        Py_DECREF(value);
9795
74
        break;
9796
1.43k
    case Compare_kind:
9797
1.43k
        tp = (PyTypeObject *)state->Compare_type;
9798
1.43k
        result = PyType_GenericNew(tp, NULL, NULL);
9799
1.43k
        if (!result) goto failed;
9800
1.43k
        value = ast2obj_expr(state, o->v.Compare.left);
9801
1.43k
        if (!value) goto failed;
9802
1.43k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9803
0
            goto failed;
9804
1.43k
        Py_DECREF(value);
9805
1.43k
        {
9806
1.43k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9807
1.43k
            value = PyList_New(n);
9808
1.43k
            if (!value) goto failed;
9809
8.41k
            for(i = 0; i < n; i++)
9810
6.98k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9811
1.43k
        }
9812
1.43k
        if (!value) goto failed;
9813
1.43k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9814
0
            goto failed;
9815
1.43k
        Py_DECREF(value);
9816
1.43k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9817
1.43k
                             ast2obj_expr);
9818
1.43k
        if (!value) goto failed;
9819
1.43k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9820
0
            goto failed;
9821
1.43k
        Py_DECREF(value);
9822
1.43k
        break;
9823
7.53k
    case Call_kind:
9824
7.53k
        tp = (PyTypeObject *)state->Call_type;
9825
7.53k
        result = PyType_GenericNew(tp, NULL, NULL);
9826
7.53k
        if (!result) goto failed;
9827
7.53k
        value = ast2obj_expr(state, o->v.Call.func);
9828
7.53k
        if (!value) goto failed;
9829
7.53k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9830
0
            goto failed;
9831
7.53k
        Py_DECREF(value);
9832
7.53k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9833
7.53k
        if (!value) goto failed;
9834
7.53k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9835
0
            goto failed;
9836
7.53k
        Py_DECREF(value);
9837
7.53k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9838
7.53k
                             ast2obj_keyword);
9839
7.53k
        if (!value) goto failed;
9840
7.53k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9841
0
            goto failed;
9842
7.53k
        Py_DECREF(value);
9843
7.53k
        break;
9844
13.3k
    case FormattedValue_kind:
9845
13.3k
        tp = (PyTypeObject *)state->FormattedValue_type;
9846
13.3k
        result = PyType_GenericNew(tp, NULL, NULL);
9847
13.3k
        if (!result) goto failed;
9848
13.3k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9849
13.3k
        if (!value) goto failed;
9850
13.3k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9851
0
            goto failed;
9852
13.3k
        Py_DECREF(value);
9853
13.3k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9854
13.3k
        if (!value) goto failed;
9855
13.3k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9856
0
            goto failed;
9857
13.3k
        Py_DECREF(value);
9858
13.3k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9859
13.3k
        if (!value) goto failed;
9860
13.3k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9861
0
            goto failed;
9862
13.3k
        Py_DECREF(value);
9863
13.3k
        break;
9864
1.95k
    case Interpolation_kind:
9865
1.95k
        tp = (PyTypeObject *)state->Interpolation_type;
9866
1.95k
        result = PyType_GenericNew(tp, NULL, NULL);
9867
1.95k
        if (!result) goto failed;
9868
1.95k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9869
1.95k
        if (!value) goto failed;
9870
1.95k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9871
0
            goto failed;
9872
1.95k
        Py_DECREF(value);
9873
1.95k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9874
1.95k
        if (!value) goto failed;
9875
1.95k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9876
0
            goto failed;
9877
1.95k
        Py_DECREF(value);
9878
1.95k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9879
1.95k
        if (!value) goto failed;
9880
1.95k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9881
0
            goto failed;
9882
1.95k
        Py_DECREF(value);
9883
1.95k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9884
1.95k
        if (!value) goto failed;
9885
1.95k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9886
0
            goto failed;
9887
1.95k
        Py_DECREF(value);
9888
1.95k
        break;
9889
8.21k
    case JoinedStr_kind:
9890
8.21k
        tp = (PyTypeObject *)state->JoinedStr_type;
9891
8.21k
        result = PyType_GenericNew(tp, NULL, NULL);
9892
8.21k
        if (!result) goto failed;
9893
8.21k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9894
8.21k
                             ast2obj_expr);
9895
8.21k
        if (!value) goto failed;
9896
8.21k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9897
0
            goto failed;
9898
8.21k
        Py_DECREF(value);
9899
8.21k
        break;
9900
685
    case TemplateStr_kind:
9901
685
        tp = (PyTypeObject *)state->TemplateStr_type;
9902
685
        result = PyType_GenericNew(tp, NULL, NULL);
9903
685
        if (!result) goto failed;
9904
685
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9905
685
                             ast2obj_expr);
9906
685
        if (!value) goto failed;
9907
685
        if (PyObject_SetAttr(result, state->values, value) == -1)
9908
0
            goto failed;
9909
685
        Py_DECREF(value);
9910
685
        break;
9911
63.7k
    case Constant_kind:
9912
63.7k
        tp = (PyTypeObject *)state->Constant_type;
9913
63.7k
        result = PyType_GenericNew(tp, NULL, NULL);
9914
63.7k
        if (!result) goto failed;
9915
63.7k
        value = ast2obj_constant(state, o->v.Constant.value);
9916
63.7k
        if (!value) goto failed;
9917
63.7k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9918
0
            goto failed;
9919
63.7k
        Py_DECREF(value);
9920
63.7k
        value = ast2obj_string(state, o->v.Constant.kind);
9921
63.7k
        if (!value) goto failed;
9922
63.7k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9923
0
            goto failed;
9924
63.7k
        Py_DECREF(value);
9925
63.7k
        break;
9926
1.24k
    case Attribute_kind:
9927
1.24k
        tp = (PyTypeObject *)state->Attribute_type;
9928
1.24k
        result = PyType_GenericNew(tp, NULL, NULL);
9929
1.24k
        if (!result) goto failed;
9930
1.24k
        value = ast2obj_expr(state, o->v.Attribute.value);
9931
1.24k
        if (!value) goto failed;
9932
1.24k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9933
0
            goto failed;
9934
1.24k
        Py_DECREF(value);
9935
1.24k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9936
1.24k
        if (!value) goto failed;
9937
1.24k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9938
0
            goto failed;
9939
1.24k
        Py_DECREF(value);
9940
1.24k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9941
1.24k
        if (!value) goto failed;
9942
1.24k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9943
0
            goto failed;
9944
1.24k
        Py_DECREF(value);
9945
1.24k
        break;
9946
1.15k
    case Subscript_kind:
9947
1.15k
        tp = (PyTypeObject *)state->Subscript_type;
9948
1.15k
        result = PyType_GenericNew(tp, NULL, NULL);
9949
1.15k
        if (!result) goto failed;
9950
1.15k
        value = ast2obj_expr(state, o->v.Subscript.value);
9951
1.15k
        if (!value) goto failed;
9952
1.15k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9953
0
            goto failed;
9954
1.15k
        Py_DECREF(value);
9955
1.15k
        value = ast2obj_expr(state, o->v.Subscript.slice);
9956
1.15k
        if (!value) goto failed;
9957
1.15k
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9958
0
            goto failed;
9959
1.15k
        Py_DECREF(value);
9960
1.15k
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9961
1.15k
        if (!value) goto failed;
9962
1.15k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9963
0
            goto failed;
9964
1.15k
        Py_DECREF(value);
9965
1.15k
        break;
9966
1.49k
    case Starred_kind:
9967
1.49k
        tp = (PyTypeObject *)state->Starred_type;
9968
1.49k
        result = PyType_GenericNew(tp, NULL, NULL);
9969
1.49k
        if (!result) goto failed;
9970
1.49k
        value = ast2obj_expr(state, o->v.Starred.value);
9971
1.49k
        if (!value) goto failed;
9972
1.49k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9973
0
            goto failed;
9974
1.49k
        Py_DECREF(value);
9975
1.49k
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9976
1.49k
        if (!value) goto failed;
9977
1.49k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9978
0
            goto failed;
9979
1.49k
        Py_DECREF(value);
9980
1.49k
        break;
9981
74.1k
    case Name_kind:
9982
74.1k
        tp = (PyTypeObject *)state->Name_type;
9983
74.1k
        result = PyType_GenericNew(tp, NULL, NULL);
9984
74.1k
        if (!result) goto failed;
9985
74.1k
        value = ast2obj_identifier(state, o->v.Name.id);
9986
74.1k
        if (!value) goto failed;
9987
74.1k
        if (PyObject_SetAttr(result, state->id, value) == -1)
9988
0
            goto failed;
9989
74.1k
        Py_DECREF(value);
9990
74.1k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
9991
74.1k
        if (!value) goto failed;
9992
74.1k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9993
0
            goto failed;
9994
74.1k
        Py_DECREF(value);
9995
74.1k
        break;
9996
1.72k
    case List_kind:
9997
1.72k
        tp = (PyTypeObject *)state->List_type;
9998
1.72k
        result = PyType_GenericNew(tp, NULL, NULL);
9999
1.72k
        if (!result) goto failed;
10000
1.72k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10001
1.72k
        if (!value) goto failed;
10002
1.72k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10003
0
            goto failed;
10004
1.72k
        Py_DECREF(value);
10005
1.72k
        value = ast2obj_expr_context(state, o->v.List.ctx);
10006
1.72k
        if (!value) goto failed;
10007
1.72k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10008
0
            goto failed;
10009
1.72k
        Py_DECREF(value);
10010
1.72k
        break;
10011
14.0k
    case Tuple_kind:
10012
14.0k
        tp = (PyTypeObject *)state->Tuple_type;
10013
14.0k
        result = PyType_GenericNew(tp, NULL, NULL);
10014
14.0k
        if (!result) goto failed;
10015
14.0k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10016
14.0k
        if (!value) goto failed;
10017
14.0k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10018
0
            goto failed;
10019
14.0k
        Py_DECREF(value);
10020
14.0k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10021
14.0k
        if (!value) goto failed;
10022
14.0k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10023
0
            goto failed;
10024
14.0k
        Py_DECREF(value);
10025
14.0k
        break;
10026
4.35k
    case Slice_kind:
10027
4.35k
        tp = (PyTypeObject *)state->Slice_type;
10028
4.35k
        result = PyType_GenericNew(tp, NULL, NULL);
10029
4.35k
        if (!result) goto failed;
10030
4.35k
        value = ast2obj_expr(state, o->v.Slice.lower);
10031
4.35k
        if (!value) goto failed;
10032
4.35k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10033
0
            goto failed;
10034
4.35k
        Py_DECREF(value);
10035
4.35k
        value = ast2obj_expr(state, o->v.Slice.upper);
10036
4.35k
        if (!value) goto failed;
10037
4.35k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10038
0
            goto failed;
10039
4.35k
        Py_DECREF(value);
10040
4.35k
        value = ast2obj_expr(state, o->v.Slice.step);
10041
4.35k
        if (!value) goto failed;
10042
4.35k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10043
0
            goto failed;
10044
4.35k
        Py_DECREF(value);
10045
4.35k
        break;
10046
374k
    }
10047
374k
    value = ast2obj_int(state, o->lineno);
10048
374k
    if (!value) goto failed;
10049
374k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10050
0
        goto failed;
10051
374k
    Py_DECREF(value);
10052
374k
    value = ast2obj_int(state, o->col_offset);
10053
374k
    if (!value) goto failed;
10054
374k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10055
0
        goto failed;
10056
374k
    Py_DECREF(value);
10057
374k
    value = ast2obj_int(state, o->end_lineno);
10058
374k
    if (!value) goto failed;
10059
374k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10060
0
        goto failed;
10061
374k
    Py_DECREF(value);
10062
374k
    value = ast2obj_int(state, o->end_col_offset);
10063
374k
    if (!value) goto failed;
10064
374k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10065
0
        goto failed;
10066
374k
    Py_DECREF(value);
10067
374k
    Py_LeaveRecursiveCall();
10068
374k
    return result;
10069
0
failed:
10070
0
    Py_LeaveRecursiveCall();
10071
0
    Py_XDECREF(value);
10072
0
    Py_XDECREF(result);
10073
0
    return NULL;
10074
374k
}
10075
10076
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10077
93.8k
{
10078
93.8k
    switch(o) {
10079
86.4k
        case Load:
10080
86.4k
            return Py_NewRef(state->Load_singleton);
10081
6.40k
        case Store:
10082
6.40k
            return Py_NewRef(state->Store_singleton);
10083
945
        case Del:
10084
945
            return Py_NewRef(state->Del_singleton);
10085
93.8k
    }
10086
93.8k
    Py_UNREACHABLE();
10087
93.8k
}
10088
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10089
531
{
10090
531
    switch(o) {
10091
120
        case And:
10092
120
            return Py_NewRef(state->And_singleton);
10093
411
        case Or:
10094
411
            return Py_NewRef(state->Or_singleton);
10095
531
    }
10096
531
    Py_UNREACHABLE();
10097
531
}
10098
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10099
27.3k
{
10100
27.3k
    switch(o) {
10101
3.86k
        case Add:
10102
3.86k
            return Py_NewRef(state->Add_singleton);
10103
12.0k
        case Sub:
10104
12.0k
            return Py_NewRef(state->Sub_singleton);
10105
4.28k
        case Mult:
10106
4.28k
            return Py_NewRef(state->Mult_singleton);
10107
632
        case MatMult:
10108
632
            return Py_NewRef(state->MatMult_singleton);
10109
932
        case Div:
10110
932
            return Py_NewRef(state->Div_singleton);
10111
1.57k
        case Mod:
10112
1.57k
            return Py_NewRef(state->Mod_singleton);
10113
720
        case Pow:
10114
720
            return Py_NewRef(state->Pow_singleton);
10115
353
        case LShift:
10116
353
            return Py_NewRef(state->LShift_singleton);
10117
272
        case RShift:
10118
272
            return Py_NewRef(state->RShift_singleton);
10119
1.11k
        case BitOr:
10120
1.11k
            return Py_NewRef(state->BitOr_singleton);
10121
464
        case BitXor:
10122
464
            return Py_NewRef(state->BitXor_singleton);
10123
845
        case BitAnd:
10124
845
            return Py_NewRef(state->BitAnd_singleton);
10125
265
        case FloorDiv:
10126
265
            return Py_NewRef(state->FloorDiv_singleton);
10127
27.3k
    }
10128
27.3k
    Py_UNREACHABLE();
10129
27.3k
}
10130
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10131
146k
{
10132
146k
    switch(o) {
10133
43.4k
        case Invert:
10134
43.4k
            return Py_NewRef(state->Invert_singleton);
10135
95
        case Not:
10136
95
            return Py_NewRef(state->Not_singleton);
10137
48.1k
        case UAdd:
10138
48.1k
            return Py_NewRef(state->UAdd_singleton);
10139
55.0k
        case USub:
10140
55.0k
            return Py_NewRef(state->USub_singleton);
10141
146k
    }
10142
146k
    Py_UNREACHABLE();
10143
146k
}
10144
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10145
6.98k
{
10146
6.98k
    switch(o) {
10147
566
        case Eq:
10148
566
            return Py_NewRef(state->Eq_singleton);
10149
218
        case NotEq:
10150
218
            return Py_NewRef(state->NotEq_singleton);
10151
1.86k
        case Lt:
10152
1.86k
            return Py_NewRef(state->Lt_singleton);
10153
117
        case LtE:
10154
117
            return Py_NewRef(state->LtE_singleton);
10155
3.19k
        case Gt:
10156
3.19k
            return Py_NewRef(state->Gt_singleton);
10157
300
        case GtE:
10158
300
            return Py_NewRef(state->GtE_singleton);
10159
281
        case Is:
10160
281
            return Py_NewRef(state->Is_singleton);
10161
74
        case IsNot:
10162
74
            return Py_NewRef(state->IsNot_singleton);
10163
299
        case In:
10164
299
            return Py_NewRef(state->In_singleton);
10165
75
        case NotIn:
10166
75
            return Py_NewRef(state->NotIn_singleton);
10167
6.98k
    }
10168
6.98k
    Py_UNREACHABLE();
10169
6.98k
}
10170
PyObject*
10171
ast2obj_comprehension(struct ast_state *state, void* _o)
10172
1.29k
{
10173
1.29k
    comprehension_ty o = (comprehension_ty)_o;
10174
1.29k
    PyObject *result = NULL, *value = NULL;
10175
1.29k
    PyTypeObject *tp;
10176
1.29k
    if (!o) {
10177
0
        Py_RETURN_NONE;
10178
0
    }
10179
1.29k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10180
0
        return NULL;
10181
0
    }
10182
1.29k
    tp = (PyTypeObject *)state->comprehension_type;
10183
1.29k
    result = PyType_GenericNew(tp, NULL, NULL);
10184
1.29k
    if (!result) return NULL;
10185
1.29k
    value = ast2obj_expr(state, o->target);
10186
1.29k
    if (!value) goto failed;
10187
1.29k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10188
0
        goto failed;
10189
1.29k
    Py_DECREF(value);
10190
1.29k
    value = ast2obj_expr(state, o->iter);
10191
1.29k
    if (!value) goto failed;
10192
1.29k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10193
0
        goto failed;
10194
1.29k
    Py_DECREF(value);
10195
1.29k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10196
1.29k
    if (!value) goto failed;
10197
1.29k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10198
0
        goto failed;
10199
1.29k
    Py_DECREF(value);
10200
1.29k
    value = ast2obj_int(state, o->is_async);
10201
1.29k
    if (!value) goto failed;
10202
1.29k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10203
0
        goto failed;
10204
1.29k
    Py_DECREF(value);
10205
1.29k
    Py_LeaveRecursiveCall();
10206
1.29k
    return result;
10207
0
failed:
10208
0
    Py_LeaveRecursiveCall();
10209
0
    Py_XDECREF(value);
10210
0
    Py_XDECREF(result);
10211
0
    return NULL;
10212
1.29k
}
10213
10214
PyObject*
10215
ast2obj_excepthandler(struct ast_state *state, void* _o)
10216
1.28k
{
10217
1.28k
    excepthandler_ty o = (excepthandler_ty)_o;
10218
1.28k
    PyObject *result = NULL, *value = NULL;
10219
1.28k
    PyTypeObject *tp;
10220
1.28k
    if (!o) {
10221
0
        Py_RETURN_NONE;
10222
0
    }
10223
1.28k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10224
0
        return NULL;
10225
0
    }
10226
1.28k
    switch (o->kind) {
10227
1.28k
    case ExceptHandler_kind:
10228
1.28k
        tp = (PyTypeObject *)state->ExceptHandler_type;
10229
1.28k
        result = PyType_GenericNew(tp, NULL, NULL);
10230
1.28k
        if (!result) goto failed;
10231
1.28k
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10232
1.28k
        if (!value) goto failed;
10233
1.28k
        if (PyObject_SetAttr(result, state->type, value) == -1)
10234
0
            goto failed;
10235
1.28k
        Py_DECREF(value);
10236
1.28k
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10237
1.28k
        if (!value) goto failed;
10238
1.28k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10239
0
            goto failed;
10240
1.28k
        Py_DECREF(value);
10241
1.28k
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10242
1.28k
                             ast2obj_stmt);
10243
1.28k
        if (!value) goto failed;
10244
1.28k
        if (PyObject_SetAttr(result, state->body, value) == -1)
10245
0
            goto failed;
10246
1.28k
        Py_DECREF(value);
10247
1.28k
        break;
10248
1.28k
    }
10249
1.28k
    value = ast2obj_int(state, o->lineno);
10250
1.28k
    if (!value) goto failed;
10251
1.28k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10252
0
        goto failed;
10253
1.28k
    Py_DECREF(value);
10254
1.28k
    value = ast2obj_int(state, o->col_offset);
10255
1.28k
    if (!value) goto failed;
10256
1.28k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10257
0
        goto failed;
10258
1.28k
    Py_DECREF(value);
10259
1.28k
    value = ast2obj_int(state, o->end_lineno);
10260
1.28k
    if (!value) goto failed;
10261
1.28k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10262
0
        goto failed;
10263
1.28k
    Py_DECREF(value);
10264
1.28k
    value = ast2obj_int(state, o->end_col_offset);
10265
1.28k
    if (!value) goto failed;
10266
1.28k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10267
0
        goto failed;
10268
1.28k
    Py_DECREF(value);
10269
1.28k
    Py_LeaveRecursiveCall();
10270
1.28k
    return result;
10271
0
failed:
10272
0
    Py_LeaveRecursiveCall();
10273
0
    Py_XDECREF(value);
10274
0
    Py_XDECREF(result);
10275
0
    return NULL;
10276
1.28k
}
10277
10278
PyObject*
10279
ast2obj_arguments(struct ast_state *state, void* _o)
10280
2.78k
{
10281
2.78k
    arguments_ty o = (arguments_ty)_o;
10282
2.78k
    PyObject *result = NULL, *value = NULL;
10283
2.78k
    PyTypeObject *tp;
10284
2.78k
    if (!o) {
10285
0
        Py_RETURN_NONE;
10286
0
    }
10287
2.78k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10288
0
        return NULL;
10289
0
    }
10290
2.78k
    tp = (PyTypeObject *)state->arguments_type;
10291
2.78k
    result = PyType_GenericNew(tp, NULL, NULL);
10292
2.78k
    if (!result) return NULL;
10293
2.78k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10294
2.78k
    if (!value) goto failed;
10295
2.78k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10296
0
        goto failed;
10297
2.78k
    Py_DECREF(value);
10298
2.78k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10299
2.78k
    if (!value) goto failed;
10300
2.78k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10301
0
        goto failed;
10302
2.78k
    Py_DECREF(value);
10303
2.78k
    value = ast2obj_arg(state, o->vararg);
10304
2.78k
    if (!value) goto failed;
10305
2.78k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10306
0
        goto failed;
10307
2.78k
    Py_DECREF(value);
10308
2.78k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10309
2.78k
    if (!value) goto failed;
10310
2.78k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10311
0
        goto failed;
10312
2.78k
    Py_DECREF(value);
10313
2.78k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10314
2.78k
    if (!value) goto failed;
10315
2.78k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10316
0
        goto failed;
10317
2.78k
    Py_DECREF(value);
10318
2.78k
    value = ast2obj_arg(state, o->kwarg);
10319
2.78k
    if (!value) goto failed;
10320
2.78k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10321
0
        goto failed;
10322
2.78k
    Py_DECREF(value);
10323
2.78k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10324
2.78k
    if (!value) goto failed;
10325
2.78k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10326
0
        goto failed;
10327
2.78k
    Py_DECREF(value);
10328
2.78k
    Py_LeaveRecursiveCall();
10329
2.78k
    return result;
10330
0
failed:
10331
0
    Py_LeaveRecursiveCall();
10332
0
    Py_XDECREF(value);
10333
0
    Py_XDECREF(result);
10334
0
    return NULL;
10335
2.78k
}
10336
10337
PyObject*
10338
ast2obj_arg(struct ast_state *state, void* _o)
10339
21.1k
{
10340
21.1k
    arg_ty o = (arg_ty)_o;
10341
21.1k
    PyObject *result = NULL, *value = NULL;
10342
21.1k
    PyTypeObject *tp;
10343
21.1k
    if (!o) {
10344
4.68k
        Py_RETURN_NONE;
10345
4.68k
    }
10346
16.4k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10347
0
        return NULL;
10348
0
    }
10349
16.4k
    tp = (PyTypeObject *)state->arg_type;
10350
16.4k
    result = PyType_GenericNew(tp, NULL, NULL);
10351
16.4k
    if (!result) return NULL;
10352
16.4k
    value = ast2obj_identifier(state, o->arg);
10353
16.4k
    if (!value) goto failed;
10354
16.4k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10355
0
        goto failed;
10356
16.4k
    Py_DECREF(value);
10357
16.4k
    value = ast2obj_expr(state, o->annotation);
10358
16.4k
    if (!value) goto failed;
10359
16.4k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10360
0
        goto failed;
10361
16.4k
    Py_DECREF(value);
10362
16.4k
    value = ast2obj_string(state, o->type_comment);
10363
16.4k
    if (!value) goto failed;
10364
16.4k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10365
0
        goto failed;
10366
16.4k
    Py_DECREF(value);
10367
16.4k
    value = ast2obj_int(state, o->lineno);
10368
16.4k
    if (!value) goto failed;
10369
16.4k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10370
0
        goto failed;
10371
16.4k
    Py_DECREF(value);
10372
16.4k
    value = ast2obj_int(state, o->col_offset);
10373
16.4k
    if (!value) goto failed;
10374
16.4k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10375
0
        goto failed;
10376
16.4k
    Py_DECREF(value);
10377
16.4k
    value = ast2obj_int(state, o->end_lineno);
10378
16.4k
    if (!value) goto failed;
10379
16.4k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10380
0
        goto failed;
10381
16.4k
    Py_DECREF(value);
10382
16.4k
    value = ast2obj_int(state, o->end_col_offset);
10383
16.4k
    if (!value) goto failed;
10384
16.4k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10385
0
        goto failed;
10386
16.4k
    Py_DECREF(value);
10387
16.4k
    Py_LeaveRecursiveCall();
10388
16.4k
    return result;
10389
0
failed:
10390
0
    Py_LeaveRecursiveCall();
10391
0
    Py_XDECREF(value);
10392
0
    Py_XDECREF(result);
10393
0
    return NULL;
10394
16.4k
}
10395
10396
PyObject*
10397
ast2obj_keyword(struct ast_state *state, void* _o)
10398
1.90k
{
10399
1.90k
    keyword_ty o = (keyword_ty)_o;
10400
1.90k
    PyObject *result = NULL, *value = NULL;
10401
1.90k
    PyTypeObject *tp;
10402
1.90k
    if (!o) {
10403
0
        Py_RETURN_NONE;
10404
0
    }
10405
1.90k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10406
0
        return NULL;
10407
0
    }
10408
1.90k
    tp = (PyTypeObject *)state->keyword_type;
10409
1.90k
    result = PyType_GenericNew(tp, NULL, NULL);
10410
1.90k
    if (!result) return NULL;
10411
1.90k
    value = ast2obj_identifier(state, o->arg);
10412
1.90k
    if (!value) goto failed;
10413
1.90k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10414
0
        goto failed;
10415
1.90k
    Py_DECREF(value);
10416
1.90k
    value = ast2obj_expr(state, o->value);
10417
1.90k
    if (!value) goto failed;
10418
1.90k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10419
0
        goto failed;
10420
1.90k
    Py_DECREF(value);
10421
1.90k
    value = ast2obj_int(state, o->lineno);
10422
1.90k
    if (!value) goto failed;
10423
1.90k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10424
0
        goto failed;
10425
1.90k
    Py_DECREF(value);
10426
1.90k
    value = ast2obj_int(state, o->col_offset);
10427
1.90k
    if (!value) goto failed;
10428
1.90k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10429
0
        goto failed;
10430
1.90k
    Py_DECREF(value);
10431
1.90k
    value = ast2obj_int(state, o->end_lineno);
10432
1.90k
    if (!value) goto failed;
10433
1.90k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10434
0
        goto failed;
10435
1.90k
    Py_DECREF(value);
10436
1.90k
    value = ast2obj_int(state, o->end_col_offset);
10437
1.90k
    if (!value) goto failed;
10438
1.90k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10439
0
        goto failed;
10440
1.90k
    Py_DECREF(value);
10441
1.90k
    Py_LeaveRecursiveCall();
10442
1.90k
    return result;
10443
0
failed:
10444
0
    Py_LeaveRecursiveCall();
10445
0
    Py_XDECREF(value);
10446
0
    Py_XDECREF(result);
10447
0
    return NULL;
10448
1.90k
}
10449
10450
PyObject*
10451
ast2obj_alias(struct ast_state *state, void* _o)
10452
2.80k
{
10453
2.80k
    alias_ty o = (alias_ty)_o;
10454
2.80k
    PyObject *result = NULL, *value = NULL;
10455
2.80k
    PyTypeObject *tp;
10456
2.80k
    if (!o) {
10457
0
        Py_RETURN_NONE;
10458
0
    }
10459
2.80k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10460
0
        return NULL;
10461
0
    }
10462
2.80k
    tp = (PyTypeObject *)state->alias_type;
10463
2.80k
    result = PyType_GenericNew(tp, NULL, NULL);
10464
2.80k
    if (!result) return NULL;
10465
2.80k
    value = ast2obj_identifier(state, o->name);
10466
2.80k
    if (!value) goto failed;
10467
2.80k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10468
0
        goto failed;
10469
2.80k
    Py_DECREF(value);
10470
2.80k
    value = ast2obj_identifier(state, o->asname);
10471
2.80k
    if (!value) goto failed;
10472
2.80k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10473
0
        goto failed;
10474
2.80k
    Py_DECREF(value);
10475
2.80k
    value = ast2obj_int(state, o->lineno);
10476
2.80k
    if (!value) goto failed;
10477
2.80k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10478
0
        goto failed;
10479
2.80k
    Py_DECREF(value);
10480
2.80k
    value = ast2obj_int(state, o->col_offset);
10481
2.80k
    if (!value) goto failed;
10482
2.80k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10483
0
        goto failed;
10484
2.80k
    Py_DECREF(value);
10485
2.80k
    value = ast2obj_int(state, o->end_lineno);
10486
2.80k
    if (!value) goto failed;
10487
2.80k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10488
0
        goto failed;
10489
2.80k
    Py_DECREF(value);
10490
2.80k
    value = ast2obj_int(state, o->end_col_offset);
10491
2.80k
    if (!value) goto failed;
10492
2.80k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10493
0
        goto failed;
10494
2.80k
    Py_DECREF(value);
10495
2.80k
    Py_LeaveRecursiveCall();
10496
2.80k
    return result;
10497
0
failed:
10498
0
    Py_LeaveRecursiveCall();
10499
0
    Py_XDECREF(value);
10500
0
    Py_XDECREF(result);
10501
0
    return NULL;
10502
2.80k
}
10503
10504
PyObject*
10505
ast2obj_withitem(struct ast_state *state, void* _o)
10506
2.07k
{
10507
2.07k
    withitem_ty o = (withitem_ty)_o;
10508
2.07k
    PyObject *result = NULL, *value = NULL;
10509
2.07k
    PyTypeObject *tp;
10510
2.07k
    if (!o) {
10511
0
        Py_RETURN_NONE;
10512
0
    }
10513
2.07k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10514
0
        return NULL;
10515
0
    }
10516
2.07k
    tp = (PyTypeObject *)state->withitem_type;
10517
2.07k
    result = PyType_GenericNew(tp, NULL, NULL);
10518
2.07k
    if (!result) return NULL;
10519
2.07k
    value = ast2obj_expr(state, o->context_expr);
10520
2.07k
    if (!value) goto failed;
10521
2.07k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10522
0
        goto failed;
10523
2.07k
    Py_DECREF(value);
10524
2.07k
    value = ast2obj_expr(state, o->optional_vars);
10525
2.07k
    if (!value) goto failed;
10526
2.07k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10527
0
        goto failed;
10528
2.07k
    Py_DECREF(value);
10529
2.07k
    Py_LeaveRecursiveCall();
10530
2.07k
    return result;
10531
0
failed:
10532
0
    Py_LeaveRecursiveCall();
10533
0
    Py_XDECREF(value);
10534
0
    Py_XDECREF(result);
10535
0
    return NULL;
10536
2.07k
}
10537
10538
PyObject*
10539
ast2obj_match_case(struct ast_state *state, void* _o)
10540
859
{
10541
859
    match_case_ty o = (match_case_ty)_o;
10542
859
    PyObject *result = NULL, *value = NULL;
10543
859
    PyTypeObject *tp;
10544
859
    if (!o) {
10545
0
        Py_RETURN_NONE;
10546
0
    }
10547
859
    if (Py_EnterRecursiveCall("during  ast construction")) {
10548
0
        return NULL;
10549
0
    }
10550
859
    tp = (PyTypeObject *)state->match_case_type;
10551
859
    result = PyType_GenericNew(tp, NULL, NULL);
10552
859
    if (!result) return NULL;
10553
859
    value = ast2obj_pattern(state, o->pattern);
10554
859
    if (!value) goto failed;
10555
859
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10556
0
        goto failed;
10557
859
    Py_DECREF(value);
10558
859
    value = ast2obj_expr(state, o->guard);
10559
859
    if (!value) goto failed;
10560
859
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10561
0
        goto failed;
10562
859
    Py_DECREF(value);
10563
859
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10564
859
    if (!value) goto failed;
10565
859
    if (PyObject_SetAttr(result, state->body, value) == -1)
10566
0
        goto failed;
10567
859
    Py_DECREF(value);
10568
859
    Py_LeaveRecursiveCall();
10569
859
    return result;
10570
0
failed:
10571
0
    Py_LeaveRecursiveCall();
10572
0
    Py_XDECREF(value);
10573
0
    Py_XDECREF(result);
10574
0
    return NULL;
10575
859
}
10576
10577
PyObject*
10578
ast2obj_pattern(struct ast_state *state, void* _o)
10579
25.3k
{
10580
25.3k
    pattern_ty o = (pattern_ty)_o;
10581
25.3k
    PyObject *result = NULL, *value = NULL;
10582
25.3k
    PyTypeObject *tp;
10583
25.3k
    if (!o) {
10584
9.23k
        Py_RETURN_NONE;
10585
9.23k
    }
10586
16.0k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10587
0
        return NULL;
10588
0
    }
10589
16.0k
    switch (o->kind) {
10590
968
    case MatchValue_kind:
10591
968
        tp = (PyTypeObject *)state->MatchValue_type;
10592
968
        result = PyType_GenericNew(tp, NULL, NULL);
10593
968
        if (!result) goto failed;
10594
968
        value = ast2obj_expr(state, o->v.MatchValue.value);
10595
968
        if (!value) goto failed;
10596
968
        if (PyObject_SetAttr(result, state->value, value) == -1)
10597
0
            goto failed;
10598
968
        Py_DECREF(value);
10599
968
        break;
10600
478
    case MatchSingleton_kind:
10601
478
        tp = (PyTypeObject *)state->MatchSingleton_type;
10602
478
        result = PyType_GenericNew(tp, NULL, NULL);
10603
478
        if (!result) goto failed;
10604
478
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10605
478
        if (!value) goto failed;
10606
478
        if (PyObject_SetAttr(result, state->value, value) == -1)
10607
0
            goto failed;
10608
478
        Py_DECREF(value);
10609
478
        break;
10610
509
    case MatchSequence_kind:
10611
509
        tp = (PyTypeObject *)state->MatchSequence_type;
10612
509
        result = PyType_GenericNew(tp, NULL, NULL);
10613
509
        if (!result) goto failed;
10614
509
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10615
509
                             ast2obj_pattern);
10616
509
        if (!value) goto failed;
10617
509
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10618
0
            goto failed;
10619
509
        Py_DECREF(value);
10620
509
        break;
10621
346
    case MatchMapping_kind:
10622
346
        tp = (PyTypeObject *)state->MatchMapping_type;
10623
346
        result = PyType_GenericNew(tp, NULL, NULL);
10624
346
        if (!result) goto failed;
10625
346
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10626
346
                             ast2obj_expr);
10627
346
        if (!value) goto failed;
10628
346
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10629
0
            goto failed;
10630
346
        Py_DECREF(value);
10631
346
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10632
346
                             ast2obj_pattern);
10633
346
        if (!value) goto failed;
10634
346
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10635
0
            goto failed;
10636
346
        Py_DECREF(value);
10637
346
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10638
346
        if (!value) goto failed;
10639
346
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10640
0
            goto failed;
10641
346
        Py_DECREF(value);
10642
346
        break;
10643
979
    case MatchClass_kind:
10644
979
        tp = (PyTypeObject *)state->MatchClass_type;
10645
979
        result = PyType_GenericNew(tp, NULL, NULL);
10646
979
        if (!result) goto failed;
10647
979
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10648
979
        if (!value) goto failed;
10649
979
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10650
0
            goto failed;
10651
979
        Py_DECREF(value);
10652
979
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10653
979
                             ast2obj_pattern);
10654
979
        if (!value) goto failed;
10655
979
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10656
0
            goto failed;
10657
979
        Py_DECREF(value);
10658
979
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10659
979
                             ast2obj_identifier);
10660
979
        if (!value) goto failed;
10661
979
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10662
0
            goto failed;
10663
979
        Py_DECREF(value);
10664
979
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10665
979
                             ast2obj_pattern);
10666
979
        if (!value) goto failed;
10667
979
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10668
0
            goto failed;
10669
979
        Py_DECREF(value);
10670
979
        break;
10671
301
    case MatchStar_kind:
10672
301
        tp = (PyTypeObject *)state->MatchStar_type;
10673
301
        result = PyType_GenericNew(tp, NULL, NULL);
10674
301
        if (!result) goto failed;
10675
301
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10676
301
        if (!value) goto failed;
10677
301
        if (PyObject_SetAttr(result, state->name, value) == -1)
10678
0
            goto failed;
10679
301
        Py_DECREF(value);
10680
301
        break;
10681
9.29k
    case MatchAs_kind:
10682
9.29k
        tp = (PyTypeObject *)state->MatchAs_type;
10683
9.29k
        result = PyType_GenericNew(tp, NULL, NULL);
10684
9.29k
        if (!result) goto failed;
10685
9.29k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10686
9.29k
        if (!value) goto failed;
10687
9.29k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10688
0
            goto failed;
10689
9.29k
        Py_DECREF(value);
10690
9.29k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10691
9.29k
        if (!value) goto failed;
10692
9.29k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10693
0
            goto failed;
10694
9.29k
        Py_DECREF(value);
10695
9.29k
        break;
10696
3.19k
    case MatchOr_kind:
10697
3.19k
        tp = (PyTypeObject *)state->MatchOr_type;
10698
3.19k
        result = PyType_GenericNew(tp, NULL, NULL);
10699
3.19k
        if (!result) goto failed;
10700
3.19k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10701
3.19k
                             ast2obj_pattern);
10702
3.19k
        if (!value) goto failed;
10703
3.19k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10704
0
            goto failed;
10705
3.19k
        Py_DECREF(value);
10706
3.19k
        break;
10707
16.0k
    }
10708
16.0k
    value = ast2obj_int(state, o->lineno);
10709
16.0k
    if (!value) goto failed;
10710
16.0k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10711
0
        goto failed;
10712
16.0k
    Py_DECREF(value);
10713
16.0k
    value = ast2obj_int(state, o->col_offset);
10714
16.0k
    if (!value) goto failed;
10715
16.0k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10716
0
        goto failed;
10717
16.0k
    Py_DECREF(value);
10718
16.0k
    value = ast2obj_int(state, o->end_lineno);
10719
16.0k
    if (!value) goto failed;
10720
16.0k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10721
0
        goto failed;
10722
16.0k
    Py_DECREF(value);
10723
16.0k
    value = ast2obj_int(state, o->end_col_offset);
10724
16.0k
    if (!value) goto failed;
10725
16.0k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10726
0
        goto failed;
10727
16.0k
    Py_DECREF(value);
10728
16.0k
    Py_LeaveRecursiveCall();
10729
16.0k
    return result;
10730
0
failed:
10731
0
    Py_LeaveRecursiveCall();
10732
0
    Py_XDECREF(value);
10733
0
    Py_XDECREF(result);
10734
0
    return NULL;
10735
16.0k
}
10736
10737
PyObject*
10738
ast2obj_type_ignore(struct ast_state *state, void* _o)
10739
0
{
10740
0
    type_ignore_ty o = (type_ignore_ty)_o;
10741
0
    PyObject *result = NULL, *value = NULL;
10742
0
    PyTypeObject *tp;
10743
0
    if (!o) {
10744
0
        Py_RETURN_NONE;
10745
0
    }
10746
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10747
0
        return NULL;
10748
0
    }
10749
0
    switch (o->kind) {
10750
0
    case TypeIgnore_kind:
10751
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10752
0
        result = PyType_GenericNew(tp, NULL, NULL);
10753
0
        if (!result) goto failed;
10754
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10755
0
        if (!value) goto failed;
10756
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10757
0
            goto failed;
10758
0
        Py_DECREF(value);
10759
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10760
0
        if (!value) goto failed;
10761
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10762
0
            goto failed;
10763
0
        Py_DECREF(value);
10764
0
        break;
10765
0
    }
10766
0
    Py_LeaveRecursiveCall();
10767
0
    return result;
10768
0
failed:
10769
0
    Py_LeaveRecursiveCall();
10770
0
    Py_XDECREF(value);
10771
0
    Py_XDECREF(result);
10772
0
    return NULL;
10773
0
}
10774
10775
PyObject*
10776
ast2obj_type_param(struct ast_state *state, void* _o)
10777
7.91k
{
10778
7.91k
    type_param_ty o = (type_param_ty)_o;
10779
7.91k
    PyObject *result = NULL, *value = NULL;
10780
7.91k
    PyTypeObject *tp;
10781
7.91k
    if (!o) {
10782
0
        Py_RETURN_NONE;
10783
0
    }
10784
7.91k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10785
0
        return NULL;
10786
0
    }
10787
7.91k
    switch (o->kind) {
10788
6.08k
    case TypeVar_kind:
10789
6.08k
        tp = (PyTypeObject *)state->TypeVar_type;
10790
6.08k
        result = PyType_GenericNew(tp, NULL, NULL);
10791
6.08k
        if (!result) goto failed;
10792
6.08k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10793
6.08k
        if (!value) goto failed;
10794
6.08k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10795
0
            goto failed;
10796
6.08k
        Py_DECREF(value);
10797
6.08k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10798
6.08k
        if (!value) goto failed;
10799
6.08k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10800
0
            goto failed;
10801
6.08k
        Py_DECREF(value);
10802
6.08k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10803
6.08k
        if (!value) goto failed;
10804
6.08k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10805
0
            goto failed;
10806
6.08k
        Py_DECREF(value);
10807
6.08k
        break;
10808
691
    case ParamSpec_kind:
10809
691
        tp = (PyTypeObject *)state->ParamSpec_type;
10810
691
        result = PyType_GenericNew(tp, NULL, NULL);
10811
691
        if (!result) goto failed;
10812
691
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10813
691
        if (!value) goto failed;
10814
691
        if (PyObject_SetAttr(result, state->name, value) == -1)
10815
0
            goto failed;
10816
691
        Py_DECREF(value);
10817
691
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10818
691
        if (!value) goto failed;
10819
691
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10820
0
            goto failed;
10821
691
        Py_DECREF(value);
10822
691
        break;
10823
1.14k
    case TypeVarTuple_kind:
10824
1.14k
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10825
1.14k
        result = PyType_GenericNew(tp, NULL, NULL);
10826
1.14k
        if (!result) goto failed;
10827
1.14k
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10828
1.14k
        if (!value) goto failed;
10829
1.14k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10830
0
            goto failed;
10831
1.14k
        Py_DECREF(value);
10832
1.14k
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10833
1.14k
        if (!value) goto failed;
10834
1.14k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10835
0
            goto failed;
10836
1.14k
        Py_DECREF(value);
10837
1.14k
        break;
10838
7.91k
    }
10839
7.91k
    value = ast2obj_int(state, o->lineno);
10840
7.91k
    if (!value) goto failed;
10841
7.91k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10842
0
        goto failed;
10843
7.91k
    Py_DECREF(value);
10844
7.91k
    value = ast2obj_int(state, o->col_offset);
10845
7.91k
    if (!value) goto failed;
10846
7.91k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10847
0
        goto failed;
10848
7.91k
    Py_DECREF(value);
10849
7.91k
    value = ast2obj_int(state, o->end_lineno);
10850
7.91k
    if (!value) goto failed;
10851
7.91k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10852
0
        goto failed;
10853
7.91k
    Py_DECREF(value);
10854
7.91k
    value = ast2obj_int(state, o->end_col_offset);
10855
7.91k
    if (!value) goto failed;
10856
7.91k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10857
0
        goto failed;
10858
7.91k
    Py_DECREF(value);
10859
7.91k
    Py_LeaveRecursiveCall();
10860
7.91k
    return result;
10861
0
failed:
10862
0
    Py_LeaveRecursiveCall();
10863
0
    Py_XDECREF(value);
10864
0
    Py_XDECREF(result);
10865
0
    return NULL;
10866
7.91k
}
10867
10868
10869
int
10870
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, const char*
10871
            field, PyArena* arena)
10872
0
{
10873
0
    int isinstance;
10874
10875
0
    PyObject *tmp = NULL;
10876
0
    PyObject *tp;
10877
10878
0
    if (obj == Py_None) {
10879
0
        *out = NULL;
10880
0
        return 0;
10881
0
    }
10882
0
    tp = state->mod_type;
10883
0
    isinstance = PyObject_IsInstance(obj, tp);
10884
0
    if (isinstance == -1) {
10885
0
        return 1;
10886
0
    }
10887
0
    if (!isinstance && field != NULL) {
10888
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'mod', got '%T'", field, obj);
10889
0
        return 1;
10890
0
    }
10891
0
    tp = state->Module_type;
10892
0
    isinstance = PyObject_IsInstance(obj, tp);
10893
0
    if (isinstance == -1) {
10894
0
        return -1;
10895
0
    }
10896
0
    if (isinstance) {
10897
0
        asdl_stmt_seq* body;
10898
0
        asdl_type_ignore_seq* type_ignores;
10899
10900
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10901
0
            return -1;
10902
0
        }
10903
0
        if (tmp == NULL) {
10904
0
            tmp = PyList_New(0);
10905
0
            if (tmp == NULL) {
10906
0
                return -1;
10907
0
            }
10908
0
        }
10909
0
        {
10910
0
            int res;
10911
0
            Py_ssize_t len;
10912
0
            Py_ssize_t i;
10913
0
            if (!PyList_Check(tmp)) {
10914
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %T", tmp);
10915
0
                goto failed;
10916
0
            }
10917
0
            len = PyList_GET_SIZE(tmp);
10918
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10919
0
            if (body == NULL) goto failed;
10920
0
            for (i = 0; i < len; i++) {
10921
0
                stmt_ty val;
10922
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10923
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10924
0
                    goto failed;
10925
0
                }
10926
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
10927
0
                _Py_LeaveRecursiveCall();
10928
0
                Py_DECREF(tmp2);
10929
0
                if (res != 0) goto failed;
10930
0
                if (len != PyList_GET_SIZE(tmp)) {
10931
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10932
0
                    goto failed;
10933
0
                }
10934
0
                asdl_seq_SET(body, i, val);
10935
0
            }
10936
0
            Py_CLEAR(tmp);
10937
0
        }
10938
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10939
0
            return -1;
10940
0
        }
10941
0
        if (tmp == NULL) {
10942
0
            tmp = PyList_New(0);
10943
0
            if (tmp == NULL) {
10944
0
                return -1;
10945
0
            }
10946
0
        }
10947
0
        {
10948
0
            int res;
10949
0
            Py_ssize_t len;
10950
0
            Py_ssize_t i;
10951
0
            if (!PyList_Check(tmp)) {
10952
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %T", tmp);
10953
0
                goto failed;
10954
0
            }
10955
0
            len = PyList_GET_SIZE(tmp);
10956
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
10957
0
            if (type_ignores == NULL) goto failed;
10958
0
            for (i = 0; i < len; i++) {
10959
0
                type_ignore_ty val;
10960
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10961
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10962
0
                    goto failed;
10963
0
                }
10964
0
                res = obj2ast_type_ignore(state, tmp2, &val, "type_ignores", arena);
10965
0
                _Py_LeaveRecursiveCall();
10966
0
                Py_DECREF(tmp2);
10967
0
                if (res != 0) goto failed;
10968
0
                if (len != PyList_GET_SIZE(tmp)) {
10969
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
10970
0
                    goto failed;
10971
0
                }
10972
0
                asdl_seq_SET(type_ignores, i, val);
10973
0
            }
10974
0
            Py_CLEAR(tmp);
10975
0
        }
10976
0
        *out = _PyAST_Module(body, type_ignores, arena);
10977
0
        if (*out == NULL) goto failed;
10978
0
        return 0;
10979
0
    }
10980
0
    tp = state->Interactive_type;
10981
0
    isinstance = PyObject_IsInstance(obj, tp);
10982
0
    if (isinstance == -1) {
10983
0
        return -1;
10984
0
    }
10985
0
    if (isinstance) {
10986
0
        asdl_stmt_seq* body;
10987
10988
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10989
0
            return -1;
10990
0
        }
10991
0
        if (tmp == NULL) {
10992
0
            tmp = PyList_New(0);
10993
0
            if (tmp == NULL) {
10994
0
                return -1;
10995
0
            }
10996
0
        }
10997
0
        {
10998
0
            int res;
10999
0
            Py_ssize_t len;
11000
0
            Py_ssize_t i;
11001
0
            if (!PyList_Check(tmp)) {
11002
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %T", tmp);
11003
0
                goto failed;
11004
0
            }
11005
0
            len = PyList_GET_SIZE(tmp);
11006
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11007
0
            if (body == NULL) goto failed;
11008
0
            for (i = 0; i < len; i++) {
11009
0
                stmt_ty val;
11010
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11011
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
11012
0
                    goto failed;
11013
0
                }
11014
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11015
0
                _Py_LeaveRecursiveCall();
11016
0
                Py_DECREF(tmp2);
11017
0
                if (res != 0) goto failed;
11018
0
                if (len != PyList_GET_SIZE(tmp)) {
11019
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
11020
0
                    goto failed;
11021
0
                }
11022
0
                asdl_seq_SET(body, i, val);
11023
0
            }
11024
0
            Py_CLEAR(tmp);
11025
0
        }
11026
0
        *out = _PyAST_Interactive(body, arena);
11027
0
        if (*out == NULL) goto failed;
11028
0
        return 0;
11029
0
    }
11030
0
    tp = state->Expression_type;
11031
0
    isinstance = PyObject_IsInstance(obj, tp);
11032
0
    if (isinstance == -1) {
11033
0
        return -1;
11034
0
    }
11035
0
    if (isinstance) {
11036
0
        expr_ty body;
11037
11038
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11039
0
            return -1;
11040
0
        }
11041
0
        if (tmp == NULL) {
11042
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11043
0
            return -1;
11044
0
        }
11045
0
        else {
11046
0
            int res;
11047
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11048
0
                goto failed;
11049
0
            }
11050
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
11051
0
            _Py_LeaveRecursiveCall();
11052
0
            if (res != 0) goto failed;
11053
0
            Py_CLEAR(tmp);
11054
0
        }
11055
0
        *out = _PyAST_Expression(body, arena);
11056
0
        if (*out == NULL) goto failed;
11057
0
        return 0;
11058
0
    }
11059
0
    tp = state->FunctionType_type;
11060
0
    isinstance = PyObject_IsInstance(obj, tp);
11061
0
    if (isinstance == -1) {
11062
0
        return -1;
11063
0
    }
11064
0
    if (isinstance) {
11065
0
        asdl_expr_seq* argtypes;
11066
0
        expr_ty returns;
11067
11068
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11069
0
            return -1;
11070
0
        }
11071
0
        if (tmp == NULL) {
11072
0
            tmp = PyList_New(0);
11073
0
            if (tmp == NULL) {
11074
0
                return -1;
11075
0
            }
11076
0
        }
11077
0
        {
11078
0
            int res;
11079
0
            Py_ssize_t len;
11080
0
            Py_ssize_t i;
11081
0
            if (!PyList_Check(tmp)) {
11082
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %T", tmp);
11083
0
                goto failed;
11084
0
            }
11085
0
            len = PyList_GET_SIZE(tmp);
11086
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11087
0
            if (argtypes == NULL) goto failed;
11088
0
            for (i = 0; i < len; i++) {
11089
0
                expr_ty val;
11090
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11091
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11092
0
                    goto failed;
11093
0
                }
11094
0
                res = obj2ast_expr(state, tmp2, &val, "argtypes", arena);
11095
0
                _Py_LeaveRecursiveCall();
11096
0
                Py_DECREF(tmp2);
11097
0
                if (res != 0) goto failed;
11098
0
                if (len != PyList_GET_SIZE(tmp)) {
11099
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11100
0
                    goto failed;
11101
0
                }
11102
0
                asdl_seq_SET(argtypes, i, val);
11103
0
            }
11104
0
            Py_CLEAR(tmp);
11105
0
        }
11106
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11107
0
            return -1;
11108
0
        }
11109
0
        if (tmp == NULL) {
11110
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11111
0
            return -1;
11112
0
        }
11113
0
        else {
11114
0
            int res;
11115
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11116
0
                goto failed;
11117
0
            }
11118
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
11119
0
            _Py_LeaveRecursiveCall();
11120
0
            if (res != 0) goto failed;
11121
0
            Py_CLEAR(tmp);
11122
0
        }
11123
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11124
0
        if (*out == NULL) goto failed;
11125
0
        return 0;
11126
0
    }
11127
11128
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11129
0
    failed:
11130
0
    Py_XDECREF(tmp);
11131
0
    return -1;
11132
0
}
11133
11134
int
11135
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, const char*
11136
             field, PyArena* arena)
11137
0
{
11138
0
    int isinstance;
11139
11140
0
    PyObject *tmp = NULL;
11141
0
    PyObject *tp;
11142
0
    int lineno;
11143
0
    int col_offset;
11144
0
    int end_lineno;
11145
0
    int end_col_offset;
11146
11147
0
    if (obj == Py_None) {
11148
0
        *out = NULL;
11149
0
        return 0;
11150
0
    }
11151
0
    tp = state->stmt_type;
11152
0
    isinstance = PyObject_IsInstance(obj, tp);
11153
0
    if (isinstance == -1) {
11154
0
        return 1;
11155
0
    }
11156
0
    if (!isinstance && field != NULL) {
11157
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'stmt', got '%T'", field, obj);
11158
0
        return 1;
11159
0
    }
11160
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11161
0
        return -1;
11162
0
    }
11163
0
    if (tmp == NULL) {
11164
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11165
0
        return -1;
11166
0
    }
11167
0
    else {
11168
0
        int res;
11169
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11170
0
            goto failed;
11171
0
        }
11172
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
11173
0
        _Py_LeaveRecursiveCall();
11174
0
        if (res != 0) goto failed;
11175
0
        Py_CLEAR(tmp);
11176
0
    }
11177
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11178
0
        return -1;
11179
0
    }
11180
0
    if (tmp == NULL) {
11181
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11182
0
        return -1;
11183
0
    }
11184
0
    else {
11185
0
        int res;
11186
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11187
0
            goto failed;
11188
0
        }
11189
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
11190
0
        _Py_LeaveRecursiveCall();
11191
0
        if (res != 0) goto failed;
11192
0
        Py_CLEAR(tmp);
11193
0
    }
11194
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11195
0
        return -1;
11196
0
    }
11197
0
    if (tmp == NULL || tmp == Py_None) {
11198
0
        Py_CLEAR(tmp);
11199
0
        end_lineno = lineno;
11200
0
    }
11201
0
    else {
11202
0
        int res;
11203
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11204
0
            goto failed;
11205
0
        }
11206
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
11207
0
        _Py_LeaveRecursiveCall();
11208
0
        if (res != 0) goto failed;
11209
0
        Py_CLEAR(tmp);
11210
0
    }
11211
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11212
0
        return -1;
11213
0
    }
11214
0
    if (tmp == NULL || tmp == Py_None) {
11215
0
        Py_CLEAR(tmp);
11216
0
        end_col_offset = col_offset;
11217
0
    }
11218
0
    else {
11219
0
        int res;
11220
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11221
0
            goto failed;
11222
0
        }
11223
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
11224
0
        _Py_LeaveRecursiveCall();
11225
0
        if (res != 0) goto failed;
11226
0
        Py_CLEAR(tmp);
11227
0
    }
11228
0
    tp = state->FunctionDef_type;
11229
0
    isinstance = PyObject_IsInstance(obj, tp);
11230
0
    if (isinstance == -1) {
11231
0
        return -1;
11232
0
    }
11233
0
    if (isinstance) {
11234
0
        identifier name;
11235
0
        arguments_ty args;
11236
0
        asdl_stmt_seq* body;
11237
0
        asdl_expr_seq* decorator_list;
11238
0
        expr_ty returns;
11239
0
        string type_comment;
11240
0
        asdl_type_param_seq* type_params;
11241
11242
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11243
0
            return -1;
11244
0
        }
11245
0
        if (tmp == NULL) {
11246
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11247
0
            return -1;
11248
0
        }
11249
0
        else {
11250
0
            int res;
11251
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11252
0
                goto failed;
11253
0
            }
11254
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
11255
0
            _Py_LeaveRecursiveCall();
11256
0
            if (res != 0) goto failed;
11257
0
            Py_CLEAR(tmp);
11258
0
        }
11259
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11260
0
            return -1;
11261
0
        }
11262
0
        if (tmp == NULL) {
11263
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11264
0
            return -1;
11265
0
        }
11266
0
        else {
11267
0
            int res;
11268
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11269
0
                goto failed;
11270
0
            }
11271
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
11272
0
            _Py_LeaveRecursiveCall();
11273
0
            if (res != 0) goto failed;
11274
0
            Py_CLEAR(tmp);
11275
0
        }
11276
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11277
0
            return -1;
11278
0
        }
11279
0
        if (tmp == NULL) {
11280
0
            tmp = PyList_New(0);
11281
0
            if (tmp == NULL) {
11282
0
                return -1;
11283
0
            }
11284
0
        }
11285
0
        {
11286
0
            int res;
11287
0
            Py_ssize_t len;
11288
0
            Py_ssize_t i;
11289
0
            if (!PyList_Check(tmp)) {
11290
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %T", tmp);
11291
0
                goto failed;
11292
0
            }
11293
0
            len = PyList_GET_SIZE(tmp);
11294
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11295
0
            if (body == NULL) goto failed;
11296
0
            for (i = 0; i < len; i++) {
11297
0
                stmt_ty val;
11298
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11299
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11300
0
                    goto failed;
11301
0
                }
11302
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11303
0
                _Py_LeaveRecursiveCall();
11304
0
                Py_DECREF(tmp2);
11305
0
                if (res != 0) goto failed;
11306
0
                if (len != PyList_GET_SIZE(tmp)) {
11307
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11308
0
                    goto failed;
11309
0
                }
11310
0
                asdl_seq_SET(body, i, val);
11311
0
            }
11312
0
            Py_CLEAR(tmp);
11313
0
        }
11314
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11315
0
            return -1;
11316
0
        }
11317
0
        if (tmp == NULL) {
11318
0
            tmp = PyList_New(0);
11319
0
            if (tmp == NULL) {
11320
0
                return -1;
11321
0
            }
11322
0
        }
11323
0
        {
11324
0
            int res;
11325
0
            Py_ssize_t len;
11326
0
            Py_ssize_t i;
11327
0
            if (!PyList_Check(tmp)) {
11328
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %T", tmp);
11329
0
                goto failed;
11330
0
            }
11331
0
            len = PyList_GET_SIZE(tmp);
11332
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11333
0
            if (decorator_list == NULL) goto failed;
11334
0
            for (i = 0; i < len; i++) {
11335
0
                expr_ty val;
11336
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11337
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11338
0
                    goto failed;
11339
0
                }
11340
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
11341
0
                _Py_LeaveRecursiveCall();
11342
0
                Py_DECREF(tmp2);
11343
0
                if (res != 0) goto failed;
11344
0
                if (len != PyList_GET_SIZE(tmp)) {
11345
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11346
0
                    goto failed;
11347
0
                }
11348
0
                asdl_seq_SET(decorator_list, i, val);
11349
0
            }
11350
0
            Py_CLEAR(tmp);
11351
0
        }
11352
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11353
0
            return -1;
11354
0
        }
11355
0
        if (tmp == NULL || tmp == Py_None) {
11356
0
            Py_CLEAR(tmp);
11357
0
            returns = NULL;
11358
0
        }
11359
0
        else {
11360
0
            int res;
11361
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11362
0
                goto failed;
11363
0
            }
11364
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
11365
0
            _Py_LeaveRecursiveCall();
11366
0
            if (res != 0) goto failed;
11367
0
            Py_CLEAR(tmp);
11368
0
        }
11369
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11370
0
            return -1;
11371
0
        }
11372
0
        if (tmp == NULL || tmp == Py_None) {
11373
0
            Py_CLEAR(tmp);
11374
0
            type_comment = NULL;
11375
0
        }
11376
0
        else {
11377
0
            int res;
11378
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11379
0
                goto failed;
11380
0
            }
11381
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
11382
0
                                 arena);
11383
0
            _Py_LeaveRecursiveCall();
11384
0
            if (res != 0) goto failed;
11385
0
            Py_CLEAR(tmp);
11386
0
        }
11387
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11388
0
            return -1;
11389
0
        }
11390
0
        if (tmp == NULL) {
11391
0
            tmp = PyList_New(0);
11392
0
            if (tmp == NULL) {
11393
0
                return -1;
11394
0
            }
11395
0
        }
11396
0
        {
11397
0
            int res;
11398
0
            Py_ssize_t len;
11399
0
            Py_ssize_t i;
11400
0
            if (!PyList_Check(tmp)) {
11401
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %T", tmp);
11402
0
                goto failed;
11403
0
            }
11404
0
            len = PyList_GET_SIZE(tmp);
11405
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11406
0
            if (type_params == NULL) goto failed;
11407
0
            for (i = 0; i < len; i++) {
11408
0
                type_param_ty val;
11409
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11410
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11411
0
                    goto failed;
11412
0
                }
11413
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
11414
0
                _Py_LeaveRecursiveCall();
11415
0
                Py_DECREF(tmp2);
11416
0
                if (res != 0) goto failed;
11417
0
                if (len != PyList_GET_SIZE(tmp)) {
11418
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11419
0
                    goto failed;
11420
0
                }
11421
0
                asdl_seq_SET(type_params, i, val);
11422
0
            }
11423
0
            Py_CLEAR(tmp);
11424
0
        }
11425
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11426
0
                                  type_comment, type_params, lineno,
11427
0
                                  col_offset, end_lineno, end_col_offset,
11428
0
                                  arena);
11429
0
        if (*out == NULL) goto failed;
11430
0
        return 0;
11431
0
    }
11432
0
    tp = state->AsyncFunctionDef_type;
11433
0
    isinstance = PyObject_IsInstance(obj, tp);
11434
0
    if (isinstance == -1) {
11435
0
        return -1;
11436
0
    }
11437
0
    if (isinstance) {
11438
0
        identifier name;
11439
0
        arguments_ty args;
11440
0
        asdl_stmt_seq* body;
11441
0
        asdl_expr_seq* decorator_list;
11442
0
        expr_ty returns;
11443
0
        string type_comment;
11444
0
        asdl_type_param_seq* type_params;
11445
11446
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11447
0
            return -1;
11448
0
        }
11449
0
        if (tmp == NULL) {
11450
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11451
0
            return -1;
11452
0
        }
11453
0
        else {
11454
0
            int res;
11455
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11456
0
                goto failed;
11457
0
            }
11458
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
11459
0
            _Py_LeaveRecursiveCall();
11460
0
            if (res != 0) goto failed;
11461
0
            Py_CLEAR(tmp);
11462
0
        }
11463
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11464
0
            return -1;
11465
0
        }
11466
0
        if (tmp == NULL) {
11467
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11468
0
            return -1;
11469
0
        }
11470
0
        else {
11471
0
            int res;
11472
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11473
0
                goto failed;
11474
0
            }
11475
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
11476
0
            _Py_LeaveRecursiveCall();
11477
0
            if (res != 0) goto failed;
11478
0
            Py_CLEAR(tmp);
11479
0
        }
11480
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11481
0
            return -1;
11482
0
        }
11483
0
        if (tmp == NULL) {
11484
0
            tmp = PyList_New(0);
11485
0
            if (tmp == NULL) {
11486
0
                return -1;
11487
0
            }
11488
0
        }
11489
0
        {
11490
0
            int res;
11491
0
            Py_ssize_t len;
11492
0
            Py_ssize_t i;
11493
0
            if (!PyList_Check(tmp)) {
11494
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %T", tmp);
11495
0
                goto failed;
11496
0
            }
11497
0
            len = PyList_GET_SIZE(tmp);
11498
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11499
0
            if (body == NULL) goto failed;
11500
0
            for (i = 0; i < len; i++) {
11501
0
                stmt_ty val;
11502
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11503
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11504
0
                    goto failed;
11505
0
                }
11506
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11507
0
                _Py_LeaveRecursiveCall();
11508
0
                Py_DECREF(tmp2);
11509
0
                if (res != 0) goto failed;
11510
0
                if (len != PyList_GET_SIZE(tmp)) {
11511
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11512
0
                    goto failed;
11513
0
                }
11514
0
                asdl_seq_SET(body, i, val);
11515
0
            }
11516
0
            Py_CLEAR(tmp);
11517
0
        }
11518
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11519
0
            return -1;
11520
0
        }
11521
0
        if (tmp == NULL) {
11522
0
            tmp = PyList_New(0);
11523
0
            if (tmp == NULL) {
11524
0
                return -1;
11525
0
            }
11526
0
        }
11527
0
        {
11528
0
            int res;
11529
0
            Py_ssize_t len;
11530
0
            Py_ssize_t i;
11531
0
            if (!PyList_Check(tmp)) {
11532
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %T", tmp);
11533
0
                goto failed;
11534
0
            }
11535
0
            len = PyList_GET_SIZE(tmp);
11536
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11537
0
            if (decorator_list == NULL) goto failed;
11538
0
            for (i = 0; i < len; i++) {
11539
0
                expr_ty val;
11540
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11541
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11542
0
                    goto failed;
11543
0
                }
11544
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
11545
0
                _Py_LeaveRecursiveCall();
11546
0
                Py_DECREF(tmp2);
11547
0
                if (res != 0) goto failed;
11548
0
                if (len != PyList_GET_SIZE(tmp)) {
11549
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11550
0
                    goto failed;
11551
0
                }
11552
0
                asdl_seq_SET(decorator_list, i, val);
11553
0
            }
11554
0
            Py_CLEAR(tmp);
11555
0
        }
11556
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11557
0
            return -1;
11558
0
        }
11559
0
        if (tmp == NULL || tmp == Py_None) {
11560
0
            Py_CLEAR(tmp);
11561
0
            returns = NULL;
11562
0
        }
11563
0
        else {
11564
0
            int res;
11565
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11566
0
                goto failed;
11567
0
            }
11568
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
11569
0
            _Py_LeaveRecursiveCall();
11570
0
            if (res != 0) goto failed;
11571
0
            Py_CLEAR(tmp);
11572
0
        }
11573
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11574
0
            return -1;
11575
0
        }
11576
0
        if (tmp == NULL || tmp == Py_None) {
11577
0
            Py_CLEAR(tmp);
11578
0
            type_comment = NULL;
11579
0
        }
11580
0
        else {
11581
0
            int res;
11582
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11583
0
                goto failed;
11584
0
            }
11585
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
11586
0
                                 arena);
11587
0
            _Py_LeaveRecursiveCall();
11588
0
            if (res != 0) goto failed;
11589
0
            Py_CLEAR(tmp);
11590
0
        }
11591
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11592
0
            return -1;
11593
0
        }
11594
0
        if (tmp == NULL) {
11595
0
            tmp = PyList_New(0);
11596
0
            if (tmp == NULL) {
11597
0
                return -1;
11598
0
            }
11599
0
        }
11600
0
        {
11601
0
            int res;
11602
0
            Py_ssize_t len;
11603
0
            Py_ssize_t i;
11604
0
            if (!PyList_Check(tmp)) {
11605
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %T", tmp);
11606
0
                goto failed;
11607
0
            }
11608
0
            len = PyList_GET_SIZE(tmp);
11609
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11610
0
            if (type_params == NULL) goto failed;
11611
0
            for (i = 0; i < len; i++) {
11612
0
                type_param_ty val;
11613
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11614
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11615
0
                    goto failed;
11616
0
                }
11617
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
11618
0
                _Py_LeaveRecursiveCall();
11619
0
                Py_DECREF(tmp2);
11620
0
                if (res != 0) goto failed;
11621
0
                if (len != PyList_GET_SIZE(tmp)) {
11622
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11623
0
                    goto failed;
11624
0
                }
11625
0
                asdl_seq_SET(type_params, i, val);
11626
0
            }
11627
0
            Py_CLEAR(tmp);
11628
0
        }
11629
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11630
0
                                       returns, type_comment, type_params,
11631
0
                                       lineno, col_offset, end_lineno,
11632
0
                                       end_col_offset, arena);
11633
0
        if (*out == NULL) goto failed;
11634
0
        return 0;
11635
0
    }
11636
0
    tp = state->ClassDef_type;
11637
0
    isinstance = PyObject_IsInstance(obj, tp);
11638
0
    if (isinstance == -1) {
11639
0
        return -1;
11640
0
    }
11641
0
    if (isinstance) {
11642
0
        identifier name;
11643
0
        asdl_expr_seq* bases;
11644
0
        asdl_keyword_seq* keywords;
11645
0
        asdl_stmt_seq* body;
11646
0
        asdl_expr_seq* decorator_list;
11647
0
        asdl_type_param_seq* type_params;
11648
11649
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11650
0
            return -1;
11651
0
        }
11652
0
        if (tmp == NULL) {
11653
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11654
0
            return -1;
11655
0
        }
11656
0
        else {
11657
0
            int res;
11658
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11659
0
                goto failed;
11660
0
            }
11661
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
11662
0
            _Py_LeaveRecursiveCall();
11663
0
            if (res != 0) goto failed;
11664
0
            Py_CLEAR(tmp);
11665
0
        }
11666
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11667
0
            return -1;
11668
0
        }
11669
0
        if (tmp == NULL) {
11670
0
            tmp = PyList_New(0);
11671
0
            if (tmp == NULL) {
11672
0
                return -1;
11673
0
            }
11674
0
        }
11675
0
        {
11676
0
            int res;
11677
0
            Py_ssize_t len;
11678
0
            Py_ssize_t i;
11679
0
            if (!PyList_Check(tmp)) {
11680
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %T", tmp);
11681
0
                goto failed;
11682
0
            }
11683
0
            len = PyList_GET_SIZE(tmp);
11684
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11685
0
            if (bases == NULL) goto failed;
11686
0
            for (i = 0; i < len; i++) {
11687
0
                expr_ty val;
11688
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11689
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11690
0
                    goto failed;
11691
0
                }
11692
0
                res = obj2ast_expr(state, tmp2, &val, "bases", arena);
11693
0
                _Py_LeaveRecursiveCall();
11694
0
                Py_DECREF(tmp2);
11695
0
                if (res != 0) goto failed;
11696
0
                if (len != PyList_GET_SIZE(tmp)) {
11697
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11698
0
                    goto failed;
11699
0
                }
11700
0
                asdl_seq_SET(bases, i, val);
11701
0
            }
11702
0
            Py_CLEAR(tmp);
11703
0
        }
11704
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11705
0
            return -1;
11706
0
        }
11707
0
        if (tmp == NULL) {
11708
0
            tmp = PyList_New(0);
11709
0
            if (tmp == NULL) {
11710
0
                return -1;
11711
0
            }
11712
0
        }
11713
0
        {
11714
0
            int res;
11715
0
            Py_ssize_t len;
11716
0
            Py_ssize_t i;
11717
0
            if (!PyList_Check(tmp)) {
11718
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %T", tmp);
11719
0
                goto failed;
11720
0
            }
11721
0
            len = PyList_GET_SIZE(tmp);
11722
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11723
0
            if (keywords == NULL) goto failed;
11724
0
            for (i = 0; i < len; i++) {
11725
0
                keyword_ty val;
11726
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11727
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11728
0
                    goto failed;
11729
0
                }
11730
0
                res = obj2ast_keyword(state, tmp2, &val, "keywords", arena);
11731
0
                _Py_LeaveRecursiveCall();
11732
0
                Py_DECREF(tmp2);
11733
0
                if (res != 0) goto failed;
11734
0
                if (len != PyList_GET_SIZE(tmp)) {
11735
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11736
0
                    goto failed;
11737
0
                }
11738
0
                asdl_seq_SET(keywords, i, val);
11739
0
            }
11740
0
            Py_CLEAR(tmp);
11741
0
        }
11742
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11743
0
            return -1;
11744
0
        }
11745
0
        if (tmp == NULL) {
11746
0
            tmp = PyList_New(0);
11747
0
            if (tmp == NULL) {
11748
0
                return -1;
11749
0
            }
11750
0
        }
11751
0
        {
11752
0
            int res;
11753
0
            Py_ssize_t len;
11754
0
            Py_ssize_t i;
11755
0
            if (!PyList_Check(tmp)) {
11756
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %T", tmp);
11757
0
                goto failed;
11758
0
            }
11759
0
            len = PyList_GET_SIZE(tmp);
11760
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11761
0
            if (body == NULL) goto failed;
11762
0
            for (i = 0; i < len; i++) {
11763
0
                stmt_ty val;
11764
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11765
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11766
0
                    goto failed;
11767
0
                }
11768
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11769
0
                _Py_LeaveRecursiveCall();
11770
0
                Py_DECREF(tmp2);
11771
0
                if (res != 0) goto failed;
11772
0
                if (len != PyList_GET_SIZE(tmp)) {
11773
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11774
0
                    goto failed;
11775
0
                }
11776
0
                asdl_seq_SET(body, i, val);
11777
0
            }
11778
0
            Py_CLEAR(tmp);
11779
0
        }
11780
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11781
0
            return -1;
11782
0
        }
11783
0
        if (tmp == NULL) {
11784
0
            tmp = PyList_New(0);
11785
0
            if (tmp == NULL) {
11786
0
                return -1;
11787
0
            }
11788
0
        }
11789
0
        {
11790
0
            int res;
11791
0
            Py_ssize_t len;
11792
0
            Py_ssize_t i;
11793
0
            if (!PyList_Check(tmp)) {
11794
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %T", tmp);
11795
0
                goto failed;
11796
0
            }
11797
0
            len = PyList_GET_SIZE(tmp);
11798
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11799
0
            if (decorator_list == NULL) goto failed;
11800
0
            for (i = 0; i < len; i++) {
11801
0
                expr_ty val;
11802
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11803
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11804
0
                    goto failed;
11805
0
                }
11806
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
11807
0
                _Py_LeaveRecursiveCall();
11808
0
                Py_DECREF(tmp2);
11809
0
                if (res != 0) goto failed;
11810
0
                if (len != PyList_GET_SIZE(tmp)) {
11811
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11812
0
                    goto failed;
11813
0
                }
11814
0
                asdl_seq_SET(decorator_list, i, val);
11815
0
            }
11816
0
            Py_CLEAR(tmp);
11817
0
        }
11818
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11819
0
            return -1;
11820
0
        }
11821
0
        if (tmp == NULL) {
11822
0
            tmp = PyList_New(0);
11823
0
            if (tmp == NULL) {
11824
0
                return -1;
11825
0
            }
11826
0
        }
11827
0
        {
11828
0
            int res;
11829
0
            Py_ssize_t len;
11830
0
            Py_ssize_t i;
11831
0
            if (!PyList_Check(tmp)) {
11832
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %T", tmp);
11833
0
                goto failed;
11834
0
            }
11835
0
            len = PyList_GET_SIZE(tmp);
11836
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11837
0
            if (type_params == NULL) goto failed;
11838
0
            for (i = 0; i < len; i++) {
11839
0
                type_param_ty val;
11840
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11841
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11842
0
                    goto failed;
11843
0
                }
11844
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
11845
0
                _Py_LeaveRecursiveCall();
11846
0
                Py_DECREF(tmp2);
11847
0
                if (res != 0) goto failed;
11848
0
                if (len != PyList_GET_SIZE(tmp)) {
11849
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11850
0
                    goto failed;
11851
0
                }
11852
0
                asdl_seq_SET(type_params, i, val);
11853
0
            }
11854
0
            Py_CLEAR(tmp);
11855
0
        }
11856
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11857
0
                               type_params, lineno, col_offset, end_lineno,
11858
0
                               end_col_offset, arena);
11859
0
        if (*out == NULL) goto failed;
11860
0
        return 0;
11861
0
    }
11862
0
    tp = state->Return_type;
11863
0
    isinstance = PyObject_IsInstance(obj, tp);
11864
0
    if (isinstance == -1) {
11865
0
        return -1;
11866
0
    }
11867
0
    if (isinstance) {
11868
0
        expr_ty value;
11869
11870
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11871
0
            return -1;
11872
0
        }
11873
0
        if (tmp == NULL || tmp == Py_None) {
11874
0
            Py_CLEAR(tmp);
11875
0
            value = NULL;
11876
0
        }
11877
0
        else {
11878
0
            int res;
11879
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11880
0
                goto failed;
11881
0
            }
11882
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11883
0
            _Py_LeaveRecursiveCall();
11884
0
            if (res != 0) goto failed;
11885
0
            Py_CLEAR(tmp);
11886
0
        }
11887
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11888
0
                             end_col_offset, arena);
11889
0
        if (*out == NULL) goto failed;
11890
0
        return 0;
11891
0
    }
11892
0
    tp = state->Delete_type;
11893
0
    isinstance = PyObject_IsInstance(obj, tp);
11894
0
    if (isinstance == -1) {
11895
0
        return -1;
11896
0
    }
11897
0
    if (isinstance) {
11898
0
        asdl_expr_seq* targets;
11899
11900
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11901
0
            return -1;
11902
0
        }
11903
0
        if (tmp == NULL) {
11904
0
            tmp = PyList_New(0);
11905
0
            if (tmp == NULL) {
11906
0
                return -1;
11907
0
            }
11908
0
        }
11909
0
        {
11910
0
            int res;
11911
0
            Py_ssize_t len;
11912
0
            Py_ssize_t i;
11913
0
            if (!PyList_Check(tmp)) {
11914
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %T", tmp);
11915
0
                goto failed;
11916
0
            }
11917
0
            len = PyList_GET_SIZE(tmp);
11918
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11919
0
            if (targets == NULL) goto failed;
11920
0
            for (i = 0; i < len; i++) {
11921
0
                expr_ty val;
11922
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11923
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11924
0
                    goto failed;
11925
0
                }
11926
0
                res = obj2ast_expr(state, tmp2, &val, "targets", arena);
11927
0
                _Py_LeaveRecursiveCall();
11928
0
                Py_DECREF(tmp2);
11929
0
                if (res != 0) goto failed;
11930
0
                if (len != PyList_GET_SIZE(tmp)) {
11931
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11932
0
                    goto failed;
11933
0
                }
11934
0
                asdl_seq_SET(targets, i, val);
11935
0
            }
11936
0
            Py_CLEAR(tmp);
11937
0
        }
11938
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11939
0
                             end_col_offset, arena);
11940
0
        if (*out == NULL) goto failed;
11941
0
        return 0;
11942
0
    }
11943
0
    tp = state->Assign_type;
11944
0
    isinstance = PyObject_IsInstance(obj, tp);
11945
0
    if (isinstance == -1) {
11946
0
        return -1;
11947
0
    }
11948
0
    if (isinstance) {
11949
0
        asdl_expr_seq* targets;
11950
0
        expr_ty value;
11951
0
        string type_comment;
11952
11953
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11954
0
            return -1;
11955
0
        }
11956
0
        if (tmp == NULL) {
11957
0
            tmp = PyList_New(0);
11958
0
            if (tmp == NULL) {
11959
0
                return -1;
11960
0
            }
11961
0
        }
11962
0
        {
11963
0
            int res;
11964
0
            Py_ssize_t len;
11965
0
            Py_ssize_t i;
11966
0
            if (!PyList_Check(tmp)) {
11967
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %T", tmp);
11968
0
                goto failed;
11969
0
            }
11970
0
            len = PyList_GET_SIZE(tmp);
11971
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11972
0
            if (targets == NULL) goto failed;
11973
0
            for (i = 0; i < len; i++) {
11974
0
                expr_ty val;
11975
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11976
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11977
0
                    goto failed;
11978
0
                }
11979
0
                res = obj2ast_expr(state, tmp2, &val, "targets", arena);
11980
0
                _Py_LeaveRecursiveCall();
11981
0
                Py_DECREF(tmp2);
11982
0
                if (res != 0) goto failed;
11983
0
                if (len != PyList_GET_SIZE(tmp)) {
11984
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
11985
0
                    goto failed;
11986
0
                }
11987
0
                asdl_seq_SET(targets, i, val);
11988
0
            }
11989
0
            Py_CLEAR(tmp);
11990
0
        }
11991
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11992
0
            return -1;
11993
0
        }
11994
0
        if (tmp == NULL) {
11995
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11996
0
            return -1;
11997
0
        }
11998
0
        else {
11999
0
            int res;
12000
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12001
0
                goto failed;
12002
0
            }
12003
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12004
0
            _Py_LeaveRecursiveCall();
12005
0
            if (res != 0) goto failed;
12006
0
            Py_CLEAR(tmp);
12007
0
        }
12008
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12009
0
            return -1;
12010
0
        }
12011
0
        if (tmp == NULL || tmp == Py_None) {
12012
0
            Py_CLEAR(tmp);
12013
0
            type_comment = NULL;
12014
0
        }
12015
0
        else {
12016
0
            int res;
12017
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12018
0
                goto failed;
12019
0
            }
12020
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12021
0
                                 arena);
12022
0
            _Py_LeaveRecursiveCall();
12023
0
            if (res != 0) goto failed;
12024
0
            Py_CLEAR(tmp);
12025
0
        }
12026
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
12027
0
                             end_lineno, end_col_offset, arena);
12028
0
        if (*out == NULL) goto failed;
12029
0
        return 0;
12030
0
    }
12031
0
    tp = state->TypeAlias_type;
12032
0
    isinstance = PyObject_IsInstance(obj, tp);
12033
0
    if (isinstance == -1) {
12034
0
        return -1;
12035
0
    }
12036
0
    if (isinstance) {
12037
0
        expr_ty name;
12038
0
        asdl_type_param_seq* type_params;
12039
0
        expr_ty value;
12040
12041
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12042
0
            return -1;
12043
0
        }
12044
0
        if (tmp == NULL) {
12045
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12046
0
            return -1;
12047
0
        }
12048
0
        else {
12049
0
            int res;
12050
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12051
0
                goto failed;
12052
0
            }
12053
0
            res = obj2ast_expr(state, tmp, &name, "name", arena);
12054
0
            _Py_LeaveRecursiveCall();
12055
0
            if (res != 0) goto failed;
12056
0
            Py_CLEAR(tmp);
12057
0
        }
12058
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12059
0
            return -1;
12060
0
        }
12061
0
        if (tmp == NULL) {
12062
0
            tmp = PyList_New(0);
12063
0
            if (tmp == NULL) {
12064
0
                return -1;
12065
0
            }
12066
0
        }
12067
0
        {
12068
0
            int res;
12069
0
            Py_ssize_t len;
12070
0
            Py_ssize_t i;
12071
0
            if (!PyList_Check(tmp)) {
12072
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %T", tmp);
12073
0
                goto failed;
12074
0
            }
12075
0
            len = PyList_GET_SIZE(tmp);
12076
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12077
0
            if (type_params == NULL) goto failed;
12078
0
            for (i = 0; i < len; i++) {
12079
0
                type_param_ty val;
12080
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12081
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12082
0
                    goto failed;
12083
0
                }
12084
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
12085
0
                _Py_LeaveRecursiveCall();
12086
0
                Py_DECREF(tmp2);
12087
0
                if (res != 0) goto failed;
12088
0
                if (len != PyList_GET_SIZE(tmp)) {
12089
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12090
0
                    goto failed;
12091
0
                }
12092
0
                asdl_seq_SET(type_params, i, val);
12093
0
            }
12094
0
            Py_CLEAR(tmp);
12095
0
        }
12096
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12097
0
            return -1;
12098
0
        }
12099
0
        if (tmp == NULL) {
12100
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12101
0
            return -1;
12102
0
        }
12103
0
        else {
12104
0
            int res;
12105
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12106
0
                goto failed;
12107
0
            }
12108
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12109
0
            _Py_LeaveRecursiveCall();
12110
0
            if (res != 0) goto failed;
12111
0
            Py_CLEAR(tmp);
12112
0
        }
12113
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12114
0
                                end_lineno, end_col_offset, arena);
12115
0
        if (*out == NULL) goto failed;
12116
0
        return 0;
12117
0
    }
12118
0
    tp = state->AugAssign_type;
12119
0
    isinstance = PyObject_IsInstance(obj, tp);
12120
0
    if (isinstance == -1) {
12121
0
        return -1;
12122
0
    }
12123
0
    if (isinstance) {
12124
0
        expr_ty target;
12125
0
        operator_ty op;
12126
0
        expr_ty value;
12127
12128
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12129
0
            return -1;
12130
0
        }
12131
0
        if (tmp == NULL) {
12132
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12133
0
            return -1;
12134
0
        }
12135
0
        else {
12136
0
            int res;
12137
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12138
0
                goto failed;
12139
0
            }
12140
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12141
0
            _Py_LeaveRecursiveCall();
12142
0
            if (res != 0) goto failed;
12143
0
            Py_CLEAR(tmp);
12144
0
        }
12145
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12146
0
            return -1;
12147
0
        }
12148
0
        if (tmp == NULL) {
12149
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12150
0
            return -1;
12151
0
        }
12152
0
        else {
12153
0
            int res;
12154
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12155
0
                goto failed;
12156
0
            }
12157
0
            res = obj2ast_operator(state, tmp, &op, "op", arena);
12158
0
            _Py_LeaveRecursiveCall();
12159
0
            if (res != 0) goto failed;
12160
0
            Py_CLEAR(tmp);
12161
0
        }
12162
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12163
0
            return -1;
12164
0
        }
12165
0
        if (tmp == NULL) {
12166
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12167
0
            return -1;
12168
0
        }
12169
0
        else {
12170
0
            int res;
12171
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12172
0
                goto failed;
12173
0
            }
12174
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12175
0
            _Py_LeaveRecursiveCall();
12176
0
            if (res != 0) goto failed;
12177
0
            Py_CLEAR(tmp);
12178
0
        }
12179
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12180
0
                                end_lineno, end_col_offset, arena);
12181
0
        if (*out == NULL) goto failed;
12182
0
        return 0;
12183
0
    }
12184
0
    tp = state->AnnAssign_type;
12185
0
    isinstance = PyObject_IsInstance(obj, tp);
12186
0
    if (isinstance == -1) {
12187
0
        return -1;
12188
0
    }
12189
0
    if (isinstance) {
12190
0
        expr_ty target;
12191
0
        expr_ty annotation;
12192
0
        expr_ty value;
12193
0
        int simple;
12194
12195
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12196
0
            return -1;
12197
0
        }
12198
0
        if (tmp == NULL) {
12199
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12200
0
            return -1;
12201
0
        }
12202
0
        else {
12203
0
            int res;
12204
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12205
0
                goto failed;
12206
0
            }
12207
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12208
0
            _Py_LeaveRecursiveCall();
12209
0
            if (res != 0) goto failed;
12210
0
            Py_CLEAR(tmp);
12211
0
        }
12212
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12213
0
            return -1;
12214
0
        }
12215
0
        if (tmp == NULL) {
12216
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12217
0
            return -1;
12218
0
        }
12219
0
        else {
12220
0
            int res;
12221
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12222
0
                goto failed;
12223
0
            }
12224
0
            res = obj2ast_expr(state, tmp, &annotation, "annotation", arena);
12225
0
            _Py_LeaveRecursiveCall();
12226
0
            if (res != 0) goto failed;
12227
0
            Py_CLEAR(tmp);
12228
0
        }
12229
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12230
0
            return -1;
12231
0
        }
12232
0
        if (tmp == NULL || tmp == Py_None) {
12233
0
            Py_CLEAR(tmp);
12234
0
            value = NULL;
12235
0
        }
12236
0
        else {
12237
0
            int res;
12238
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12239
0
                goto failed;
12240
0
            }
12241
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12242
0
            _Py_LeaveRecursiveCall();
12243
0
            if (res != 0) goto failed;
12244
0
            Py_CLEAR(tmp);
12245
0
        }
12246
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
12247
0
            return -1;
12248
0
        }
12249
0
        if (tmp == NULL) {
12250
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12251
0
            return -1;
12252
0
        }
12253
0
        else {
12254
0
            int res;
12255
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12256
0
                goto failed;
12257
0
            }
12258
0
            res = obj2ast_int(state, tmp, &simple, "simple", arena);
12259
0
            _Py_LeaveRecursiveCall();
12260
0
            if (res != 0) goto failed;
12261
0
            Py_CLEAR(tmp);
12262
0
        }
12263
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12264
0
                                col_offset, end_lineno, end_col_offset, arena);
12265
0
        if (*out == NULL) goto failed;
12266
0
        return 0;
12267
0
    }
12268
0
    tp = state->For_type;
12269
0
    isinstance = PyObject_IsInstance(obj, tp);
12270
0
    if (isinstance == -1) {
12271
0
        return -1;
12272
0
    }
12273
0
    if (isinstance) {
12274
0
        expr_ty target;
12275
0
        expr_ty iter;
12276
0
        asdl_stmt_seq* body;
12277
0
        asdl_stmt_seq* orelse;
12278
0
        string type_comment;
12279
12280
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12281
0
            return -1;
12282
0
        }
12283
0
        if (tmp == NULL) {
12284
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12285
0
            return -1;
12286
0
        }
12287
0
        else {
12288
0
            int res;
12289
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12290
0
                goto failed;
12291
0
            }
12292
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12293
0
            _Py_LeaveRecursiveCall();
12294
0
            if (res != 0) goto failed;
12295
0
            Py_CLEAR(tmp);
12296
0
        }
12297
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12298
0
            return -1;
12299
0
        }
12300
0
        if (tmp == NULL) {
12301
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12302
0
            return -1;
12303
0
        }
12304
0
        else {
12305
0
            int res;
12306
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12307
0
                goto failed;
12308
0
            }
12309
0
            res = obj2ast_expr(state, tmp, &iter, "iter", arena);
12310
0
            _Py_LeaveRecursiveCall();
12311
0
            if (res != 0) goto failed;
12312
0
            Py_CLEAR(tmp);
12313
0
        }
12314
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12315
0
            return -1;
12316
0
        }
12317
0
        if (tmp == NULL) {
12318
0
            tmp = PyList_New(0);
12319
0
            if (tmp == NULL) {
12320
0
                return -1;
12321
0
            }
12322
0
        }
12323
0
        {
12324
0
            int res;
12325
0
            Py_ssize_t len;
12326
0
            Py_ssize_t i;
12327
0
            if (!PyList_Check(tmp)) {
12328
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %T", tmp);
12329
0
                goto failed;
12330
0
            }
12331
0
            len = PyList_GET_SIZE(tmp);
12332
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12333
0
            if (body == NULL) goto failed;
12334
0
            for (i = 0; i < len; i++) {
12335
0
                stmt_ty val;
12336
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12337
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12338
0
                    goto failed;
12339
0
                }
12340
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12341
0
                _Py_LeaveRecursiveCall();
12342
0
                Py_DECREF(tmp2);
12343
0
                if (res != 0) goto failed;
12344
0
                if (len != PyList_GET_SIZE(tmp)) {
12345
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12346
0
                    goto failed;
12347
0
                }
12348
0
                asdl_seq_SET(body, i, val);
12349
0
            }
12350
0
            Py_CLEAR(tmp);
12351
0
        }
12352
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12353
0
            return -1;
12354
0
        }
12355
0
        if (tmp == NULL) {
12356
0
            tmp = PyList_New(0);
12357
0
            if (tmp == NULL) {
12358
0
                return -1;
12359
0
            }
12360
0
        }
12361
0
        {
12362
0
            int res;
12363
0
            Py_ssize_t len;
12364
0
            Py_ssize_t i;
12365
0
            if (!PyList_Check(tmp)) {
12366
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %T", tmp);
12367
0
                goto failed;
12368
0
            }
12369
0
            len = PyList_GET_SIZE(tmp);
12370
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12371
0
            if (orelse == NULL) goto failed;
12372
0
            for (i = 0; i < len; i++) {
12373
0
                stmt_ty val;
12374
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12375
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12376
0
                    goto failed;
12377
0
                }
12378
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12379
0
                _Py_LeaveRecursiveCall();
12380
0
                Py_DECREF(tmp2);
12381
0
                if (res != 0) goto failed;
12382
0
                if (len != PyList_GET_SIZE(tmp)) {
12383
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12384
0
                    goto failed;
12385
0
                }
12386
0
                asdl_seq_SET(orelse, i, val);
12387
0
            }
12388
0
            Py_CLEAR(tmp);
12389
0
        }
12390
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12391
0
            return -1;
12392
0
        }
12393
0
        if (tmp == NULL || tmp == Py_None) {
12394
0
            Py_CLEAR(tmp);
12395
0
            type_comment = NULL;
12396
0
        }
12397
0
        else {
12398
0
            int res;
12399
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12400
0
                goto failed;
12401
0
            }
12402
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12403
0
                                 arena);
12404
0
            _Py_LeaveRecursiveCall();
12405
0
            if (res != 0) goto failed;
12406
0
            Py_CLEAR(tmp);
12407
0
        }
12408
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12409
0
                          col_offset, end_lineno, end_col_offset, arena);
12410
0
        if (*out == NULL) goto failed;
12411
0
        return 0;
12412
0
    }
12413
0
    tp = state->AsyncFor_type;
12414
0
    isinstance = PyObject_IsInstance(obj, tp);
12415
0
    if (isinstance == -1) {
12416
0
        return -1;
12417
0
    }
12418
0
    if (isinstance) {
12419
0
        expr_ty target;
12420
0
        expr_ty iter;
12421
0
        asdl_stmt_seq* body;
12422
0
        asdl_stmt_seq* orelse;
12423
0
        string type_comment;
12424
12425
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12426
0
            return -1;
12427
0
        }
12428
0
        if (tmp == NULL) {
12429
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12430
0
            return -1;
12431
0
        }
12432
0
        else {
12433
0
            int res;
12434
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12435
0
                goto failed;
12436
0
            }
12437
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12438
0
            _Py_LeaveRecursiveCall();
12439
0
            if (res != 0) goto failed;
12440
0
            Py_CLEAR(tmp);
12441
0
        }
12442
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12443
0
            return -1;
12444
0
        }
12445
0
        if (tmp == NULL) {
12446
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12447
0
            return -1;
12448
0
        }
12449
0
        else {
12450
0
            int res;
12451
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12452
0
                goto failed;
12453
0
            }
12454
0
            res = obj2ast_expr(state, tmp, &iter, "iter", arena);
12455
0
            _Py_LeaveRecursiveCall();
12456
0
            if (res != 0) goto failed;
12457
0
            Py_CLEAR(tmp);
12458
0
        }
12459
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12460
0
            return -1;
12461
0
        }
12462
0
        if (tmp == NULL) {
12463
0
            tmp = PyList_New(0);
12464
0
            if (tmp == NULL) {
12465
0
                return -1;
12466
0
            }
12467
0
        }
12468
0
        {
12469
0
            int res;
12470
0
            Py_ssize_t len;
12471
0
            Py_ssize_t i;
12472
0
            if (!PyList_Check(tmp)) {
12473
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %T", tmp);
12474
0
                goto failed;
12475
0
            }
12476
0
            len = PyList_GET_SIZE(tmp);
12477
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12478
0
            if (body == NULL) goto failed;
12479
0
            for (i = 0; i < len; i++) {
12480
0
                stmt_ty val;
12481
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12482
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12483
0
                    goto failed;
12484
0
                }
12485
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12486
0
                _Py_LeaveRecursiveCall();
12487
0
                Py_DECREF(tmp2);
12488
0
                if (res != 0) goto failed;
12489
0
                if (len != PyList_GET_SIZE(tmp)) {
12490
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12491
0
                    goto failed;
12492
0
                }
12493
0
                asdl_seq_SET(body, i, val);
12494
0
            }
12495
0
            Py_CLEAR(tmp);
12496
0
        }
12497
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12498
0
            return -1;
12499
0
        }
12500
0
        if (tmp == NULL) {
12501
0
            tmp = PyList_New(0);
12502
0
            if (tmp == NULL) {
12503
0
                return -1;
12504
0
            }
12505
0
        }
12506
0
        {
12507
0
            int res;
12508
0
            Py_ssize_t len;
12509
0
            Py_ssize_t i;
12510
0
            if (!PyList_Check(tmp)) {
12511
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %T", tmp);
12512
0
                goto failed;
12513
0
            }
12514
0
            len = PyList_GET_SIZE(tmp);
12515
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12516
0
            if (orelse == NULL) goto failed;
12517
0
            for (i = 0; i < len; i++) {
12518
0
                stmt_ty val;
12519
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12520
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12521
0
                    goto failed;
12522
0
                }
12523
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12524
0
                _Py_LeaveRecursiveCall();
12525
0
                Py_DECREF(tmp2);
12526
0
                if (res != 0) goto failed;
12527
0
                if (len != PyList_GET_SIZE(tmp)) {
12528
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12529
0
                    goto failed;
12530
0
                }
12531
0
                asdl_seq_SET(orelse, i, val);
12532
0
            }
12533
0
            Py_CLEAR(tmp);
12534
0
        }
12535
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12536
0
            return -1;
12537
0
        }
12538
0
        if (tmp == NULL || tmp == Py_None) {
12539
0
            Py_CLEAR(tmp);
12540
0
            type_comment = NULL;
12541
0
        }
12542
0
        else {
12543
0
            int res;
12544
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12545
0
                goto failed;
12546
0
            }
12547
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12548
0
                                 arena);
12549
0
            _Py_LeaveRecursiveCall();
12550
0
            if (res != 0) goto failed;
12551
0
            Py_CLEAR(tmp);
12552
0
        }
12553
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12554
0
                               lineno, col_offset, end_lineno, end_col_offset,
12555
0
                               arena);
12556
0
        if (*out == NULL) goto failed;
12557
0
        return 0;
12558
0
    }
12559
0
    tp = state->While_type;
12560
0
    isinstance = PyObject_IsInstance(obj, tp);
12561
0
    if (isinstance == -1) {
12562
0
        return -1;
12563
0
    }
12564
0
    if (isinstance) {
12565
0
        expr_ty test;
12566
0
        asdl_stmt_seq* body;
12567
0
        asdl_stmt_seq* orelse;
12568
12569
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12570
0
            return -1;
12571
0
        }
12572
0
        if (tmp == NULL) {
12573
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12574
0
            return -1;
12575
0
        }
12576
0
        else {
12577
0
            int res;
12578
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12579
0
                goto failed;
12580
0
            }
12581
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
12582
0
            _Py_LeaveRecursiveCall();
12583
0
            if (res != 0) goto failed;
12584
0
            Py_CLEAR(tmp);
12585
0
        }
12586
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12587
0
            return -1;
12588
0
        }
12589
0
        if (tmp == NULL) {
12590
0
            tmp = PyList_New(0);
12591
0
            if (tmp == NULL) {
12592
0
                return -1;
12593
0
            }
12594
0
        }
12595
0
        {
12596
0
            int res;
12597
0
            Py_ssize_t len;
12598
0
            Py_ssize_t i;
12599
0
            if (!PyList_Check(tmp)) {
12600
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %T", tmp);
12601
0
                goto failed;
12602
0
            }
12603
0
            len = PyList_GET_SIZE(tmp);
12604
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12605
0
            if (body == NULL) goto failed;
12606
0
            for (i = 0; i < len; i++) {
12607
0
                stmt_ty val;
12608
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12609
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12610
0
                    goto failed;
12611
0
                }
12612
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12613
0
                _Py_LeaveRecursiveCall();
12614
0
                Py_DECREF(tmp2);
12615
0
                if (res != 0) goto failed;
12616
0
                if (len != PyList_GET_SIZE(tmp)) {
12617
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12618
0
                    goto failed;
12619
0
                }
12620
0
                asdl_seq_SET(body, i, val);
12621
0
            }
12622
0
            Py_CLEAR(tmp);
12623
0
        }
12624
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12625
0
            return -1;
12626
0
        }
12627
0
        if (tmp == NULL) {
12628
0
            tmp = PyList_New(0);
12629
0
            if (tmp == NULL) {
12630
0
                return -1;
12631
0
            }
12632
0
        }
12633
0
        {
12634
0
            int res;
12635
0
            Py_ssize_t len;
12636
0
            Py_ssize_t i;
12637
0
            if (!PyList_Check(tmp)) {
12638
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %T", tmp);
12639
0
                goto failed;
12640
0
            }
12641
0
            len = PyList_GET_SIZE(tmp);
12642
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12643
0
            if (orelse == NULL) goto failed;
12644
0
            for (i = 0; i < len; i++) {
12645
0
                stmt_ty val;
12646
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12647
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12648
0
                    goto failed;
12649
0
                }
12650
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12651
0
                _Py_LeaveRecursiveCall();
12652
0
                Py_DECREF(tmp2);
12653
0
                if (res != 0) goto failed;
12654
0
                if (len != PyList_GET_SIZE(tmp)) {
12655
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12656
0
                    goto failed;
12657
0
                }
12658
0
                asdl_seq_SET(orelse, i, val);
12659
0
            }
12660
0
            Py_CLEAR(tmp);
12661
0
        }
12662
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12663
0
                            end_col_offset, arena);
12664
0
        if (*out == NULL) goto failed;
12665
0
        return 0;
12666
0
    }
12667
0
    tp = state->If_type;
12668
0
    isinstance = PyObject_IsInstance(obj, tp);
12669
0
    if (isinstance == -1) {
12670
0
        return -1;
12671
0
    }
12672
0
    if (isinstance) {
12673
0
        expr_ty test;
12674
0
        asdl_stmt_seq* body;
12675
0
        asdl_stmt_seq* orelse;
12676
12677
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12678
0
            return -1;
12679
0
        }
12680
0
        if (tmp == NULL) {
12681
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12682
0
            return -1;
12683
0
        }
12684
0
        else {
12685
0
            int res;
12686
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12687
0
                goto failed;
12688
0
            }
12689
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
12690
0
            _Py_LeaveRecursiveCall();
12691
0
            if (res != 0) goto failed;
12692
0
            Py_CLEAR(tmp);
12693
0
        }
12694
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12695
0
            return -1;
12696
0
        }
12697
0
        if (tmp == NULL) {
12698
0
            tmp = PyList_New(0);
12699
0
            if (tmp == NULL) {
12700
0
                return -1;
12701
0
            }
12702
0
        }
12703
0
        {
12704
0
            int res;
12705
0
            Py_ssize_t len;
12706
0
            Py_ssize_t i;
12707
0
            if (!PyList_Check(tmp)) {
12708
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %T", tmp);
12709
0
                goto failed;
12710
0
            }
12711
0
            len = PyList_GET_SIZE(tmp);
12712
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12713
0
            if (body == NULL) goto failed;
12714
0
            for (i = 0; i < len; i++) {
12715
0
                stmt_ty val;
12716
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12717
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12718
0
                    goto failed;
12719
0
                }
12720
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12721
0
                _Py_LeaveRecursiveCall();
12722
0
                Py_DECREF(tmp2);
12723
0
                if (res != 0) goto failed;
12724
0
                if (len != PyList_GET_SIZE(tmp)) {
12725
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12726
0
                    goto failed;
12727
0
                }
12728
0
                asdl_seq_SET(body, i, val);
12729
0
            }
12730
0
            Py_CLEAR(tmp);
12731
0
        }
12732
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12733
0
            return -1;
12734
0
        }
12735
0
        if (tmp == NULL) {
12736
0
            tmp = PyList_New(0);
12737
0
            if (tmp == NULL) {
12738
0
                return -1;
12739
0
            }
12740
0
        }
12741
0
        {
12742
0
            int res;
12743
0
            Py_ssize_t len;
12744
0
            Py_ssize_t i;
12745
0
            if (!PyList_Check(tmp)) {
12746
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %T", tmp);
12747
0
                goto failed;
12748
0
            }
12749
0
            len = PyList_GET_SIZE(tmp);
12750
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12751
0
            if (orelse == NULL) goto failed;
12752
0
            for (i = 0; i < len; i++) {
12753
0
                stmt_ty val;
12754
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12755
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12756
0
                    goto failed;
12757
0
                }
12758
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12759
0
                _Py_LeaveRecursiveCall();
12760
0
                Py_DECREF(tmp2);
12761
0
                if (res != 0) goto failed;
12762
0
                if (len != PyList_GET_SIZE(tmp)) {
12763
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12764
0
                    goto failed;
12765
0
                }
12766
0
                asdl_seq_SET(orelse, i, val);
12767
0
            }
12768
0
            Py_CLEAR(tmp);
12769
0
        }
12770
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12771
0
                         end_col_offset, arena);
12772
0
        if (*out == NULL) goto failed;
12773
0
        return 0;
12774
0
    }
12775
0
    tp = state->With_type;
12776
0
    isinstance = PyObject_IsInstance(obj, tp);
12777
0
    if (isinstance == -1) {
12778
0
        return -1;
12779
0
    }
12780
0
    if (isinstance) {
12781
0
        asdl_withitem_seq* items;
12782
0
        asdl_stmt_seq* body;
12783
0
        string type_comment;
12784
12785
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12786
0
            return -1;
12787
0
        }
12788
0
        if (tmp == NULL) {
12789
0
            tmp = PyList_New(0);
12790
0
            if (tmp == NULL) {
12791
0
                return -1;
12792
0
            }
12793
0
        }
12794
0
        {
12795
0
            int res;
12796
0
            Py_ssize_t len;
12797
0
            Py_ssize_t i;
12798
0
            if (!PyList_Check(tmp)) {
12799
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %T", tmp);
12800
0
                goto failed;
12801
0
            }
12802
0
            len = PyList_GET_SIZE(tmp);
12803
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12804
0
            if (items == NULL) goto failed;
12805
0
            for (i = 0; i < len; i++) {
12806
0
                withitem_ty val;
12807
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12808
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12809
0
                    goto failed;
12810
0
                }
12811
0
                res = obj2ast_withitem(state, tmp2, &val, "items", arena);
12812
0
                _Py_LeaveRecursiveCall();
12813
0
                Py_DECREF(tmp2);
12814
0
                if (res != 0) goto failed;
12815
0
                if (len != PyList_GET_SIZE(tmp)) {
12816
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12817
0
                    goto failed;
12818
0
                }
12819
0
                asdl_seq_SET(items, i, val);
12820
0
            }
12821
0
            Py_CLEAR(tmp);
12822
0
        }
12823
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12824
0
            return -1;
12825
0
        }
12826
0
        if (tmp == NULL) {
12827
0
            tmp = PyList_New(0);
12828
0
            if (tmp == NULL) {
12829
0
                return -1;
12830
0
            }
12831
0
        }
12832
0
        {
12833
0
            int res;
12834
0
            Py_ssize_t len;
12835
0
            Py_ssize_t i;
12836
0
            if (!PyList_Check(tmp)) {
12837
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %T", tmp);
12838
0
                goto failed;
12839
0
            }
12840
0
            len = PyList_GET_SIZE(tmp);
12841
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12842
0
            if (body == NULL) goto failed;
12843
0
            for (i = 0; i < len; i++) {
12844
0
                stmt_ty val;
12845
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12846
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12847
0
                    goto failed;
12848
0
                }
12849
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12850
0
                _Py_LeaveRecursiveCall();
12851
0
                Py_DECREF(tmp2);
12852
0
                if (res != 0) goto failed;
12853
0
                if (len != PyList_GET_SIZE(tmp)) {
12854
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12855
0
                    goto failed;
12856
0
                }
12857
0
                asdl_seq_SET(body, i, val);
12858
0
            }
12859
0
            Py_CLEAR(tmp);
12860
0
        }
12861
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12862
0
            return -1;
12863
0
        }
12864
0
        if (tmp == NULL || tmp == Py_None) {
12865
0
            Py_CLEAR(tmp);
12866
0
            type_comment = NULL;
12867
0
        }
12868
0
        else {
12869
0
            int res;
12870
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12871
0
                goto failed;
12872
0
            }
12873
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12874
0
                                 arena);
12875
0
            _Py_LeaveRecursiveCall();
12876
0
            if (res != 0) goto failed;
12877
0
            Py_CLEAR(tmp);
12878
0
        }
12879
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12880
0
                           end_lineno, end_col_offset, arena);
12881
0
        if (*out == NULL) goto failed;
12882
0
        return 0;
12883
0
    }
12884
0
    tp = state->AsyncWith_type;
12885
0
    isinstance = PyObject_IsInstance(obj, tp);
12886
0
    if (isinstance == -1) {
12887
0
        return -1;
12888
0
    }
12889
0
    if (isinstance) {
12890
0
        asdl_withitem_seq* items;
12891
0
        asdl_stmt_seq* body;
12892
0
        string type_comment;
12893
12894
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12895
0
            return -1;
12896
0
        }
12897
0
        if (tmp == NULL) {
12898
0
            tmp = PyList_New(0);
12899
0
            if (tmp == NULL) {
12900
0
                return -1;
12901
0
            }
12902
0
        }
12903
0
        {
12904
0
            int res;
12905
0
            Py_ssize_t len;
12906
0
            Py_ssize_t i;
12907
0
            if (!PyList_Check(tmp)) {
12908
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %T", tmp);
12909
0
                goto failed;
12910
0
            }
12911
0
            len = PyList_GET_SIZE(tmp);
12912
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12913
0
            if (items == NULL) goto failed;
12914
0
            for (i = 0; i < len; i++) {
12915
0
                withitem_ty val;
12916
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12917
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12918
0
                    goto failed;
12919
0
                }
12920
0
                res = obj2ast_withitem(state, tmp2, &val, "items", arena);
12921
0
                _Py_LeaveRecursiveCall();
12922
0
                Py_DECREF(tmp2);
12923
0
                if (res != 0) goto failed;
12924
0
                if (len != PyList_GET_SIZE(tmp)) {
12925
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12926
0
                    goto failed;
12927
0
                }
12928
0
                asdl_seq_SET(items, i, val);
12929
0
            }
12930
0
            Py_CLEAR(tmp);
12931
0
        }
12932
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12933
0
            return -1;
12934
0
        }
12935
0
        if (tmp == NULL) {
12936
0
            tmp = PyList_New(0);
12937
0
            if (tmp == NULL) {
12938
0
                return -1;
12939
0
            }
12940
0
        }
12941
0
        {
12942
0
            int res;
12943
0
            Py_ssize_t len;
12944
0
            Py_ssize_t i;
12945
0
            if (!PyList_Check(tmp)) {
12946
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %T", tmp);
12947
0
                goto failed;
12948
0
            }
12949
0
            len = PyList_GET_SIZE(tmp);
12950
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12951
0
            if (body == NULL) goto failed;
12952
0
            for (i = 0; i < len; i++) {
12953
0
                stmt_ty val;
12954
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12955
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12956
0
                    goto failed;
12957
0
                }
12958
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12959
0
                _Py_LeaveRecursiveCall();
12960
0
                Py_DECREF(tmp2);
12961
0
                if (res != 0) goto failed;
12962
0
                if (len != PyList_GET_SIZE(tmp)) {
12963
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12964
0
                    goto failed;
12965
0
                }
12966
0
                asdl_seq_SET(body, i, val);
12967
0
            }
12968
0
            Py_CLEAR(tmp);
12969
0
        }
12970
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12971
0
            return -1;
12972
0
        }
12973
0
        if (tmp == NULL || tmp == Py_None) {
12974
0
            Py_CLEAR(tmp);
12975
0
            type_comment = NULL;
12976
0
        }
12977
0
        else {
12978
0
            int res;
12979
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12980
0
                goto failed;
12981
0
            }
12982
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12983
0
                                 arena);
12984
0
            _Py_LeaveRecursiveCall();
12985
0
            if (res != 0) goto failed;
12986
0
            Py_CLEAR(tmp);
12987
0
        }
12988
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12989
0
                                end_lineno, end_col_offset, arena);
12990
0
        if (*out == NULL) goto failed;
12991
0
        return 0;
12992
0
    }
12993
0
    tp = state->Match_type;
12994
0
    isinstance = PyObject_IsInstance(obj, tp);
12995
0
    if (isinstance == -1) {
12996
0
        return -1;
12997
0
    }
12998
0
    if (isinstance) {
12999
0
        expr_ty subject;
13000
0
        asdl_match_case_seq* cases;
13001
13002
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
13003
0
            return -1;
13004
0
        }
13005
0
        if (tmp == NULL) {
13006
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
13007
0
            return -1;
13008
0
        }
13009
0
        else {
13010
0
            int res;
13011
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13012
0
                goto failed;
13013
0
            }
13014
0
            res = obj2ast_expr(state, tmp, &subject, "subject", arena);
13015
0
            _Py_LeaveRecursiveCall();
13016
0
            if (res != 0) goto failed;
13017
0
            Py_CLEAR(tmp);
13018
0
        }
13019
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
13020
0
            return -1;
13021
0
        }
13022
0
        if (tmp == NULL) {
13023
0
            tmp = PyList_New(0);
13024
0
            if (tmp == NULL) {
13025
0
                return -1;
13026
0
            }
13027
0
        }
13028
0
        {
13029
0
            int res;
13030
0
            Py_ssize_t len;
13031
0
            Py_ssize_t i;
13032
0
            if (!PyList_Check(tmp)) {
13033
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %T", tmp);
13034
0
                goto failed;
13035
0
            }
13036
0
            len = PyList_GET_SIZE(tmp);
13037
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13038
0
            if (cases == NULL) goto failed;
13039
0
            for (i = 0; i < len; i++) {
13040
0
                match_case_ty val;
13041
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13042
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13043
0
                    goto failed;
13044
0
                }
13045
0
                res = obj2ast_match_case(state, tmp2, &val, "cases", arena);
13046
0
                _Py_LeaveRecursiveCall();
13047
0
                Py_DECREF(tmp2);
13048
0
                if (res != 0) goto failed;
13049
0
                if (len != PyList_GET_SIZE(tmp)) {
13050
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13051
0
                    goto failed;
13052
0
                }
13053
0
                asdl_seq_SET(cases, i, val);
13054
0
            }
13055
0
            Py_CLEAR(tmp);
13056
0
        }
13057
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13058
0
                            end_col_offset, arena);
13059
0
        if (*out == NULL) goto failed;
13060
0
        return 0;
13061
0
    }
13062
0
    tp = state->Raise_type;
13063
0
    isinstance = PyObject_IsInstance(obj, tp);
13064
0
    if (isinstance == -1) {
13065
0
        return -1;
13066
0
    }
13067
0
    if (isinstance) {
13068
0
        expr_ty exc;
13069
0
        expr_ty cause;
13070
13071
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13072
0
            return -1;
13073
0
        }
13074
0
        if (tmp == NULL || tmp == Py_None) {
13075
0
            Py_CLEAR(tmp);
13076
0
            exc = 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, &exc, "exc", arena);
13084
0
            _Py_LeaveRecursiveCall();
13085
0
            if (res != 0) goto failed;
13086
0
            Py_CLEAR(tmp);
13087
0
        }
13088
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13089
0
            return -1;
13090
0
        }
13091
0
        if (tmp == NULL || tmp == Py_None) {
13092
0
            Py_CLEAR(tmp);
13093
0
            cause = NULL;
13094
0
        }
13095
0
        else {
13096
0
            int res;
13097
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13098
0
                goto failed;
13099
0
            }
13100
0
            res = obj2ast_expr(state, tmp, &cause, "cause", arena);
13101
0
            _Py_LeaveRecursiveCall();
13102
0
            if (res != 0) goto failed;
13103
0
            Py_CLEAR(tmp);
13104
0
        }
13105
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13106
0
                            end_col_offset, arena);
13107
0
        if (*out == NULL) goto failed;
13108
0
        return 0;
13109
0
    }
13110
0
    tp = state->Try_type;
13111
0
    isinstance = PyObject_IsInstance(obj, tp);
13112
0
    if (isinstance == -1) {
13113
0
        return -1;
13114
0
    }
13115
0
    if (isinstance) {
13116
0
        asdl_stmt_seq* body;
13117
0
        asdl_excepthandler_seq* handlers;
13118
0
        asdl_stmt_seq* orelse;
13119
0
        asdl_stmt_seq* finalbody;
13120
13121
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13122
0
            return -1;
13123
0
        }
13124
0
        if (tmp == NULL) {
13125
0
            tmp = PyList_New(0);
13126
0
            if (tmp == NULL) {
13127
0
                return -1;
13128
0
            }
13129
0
        }
13130
0
        {
13131
0
            int res;
13132
0
            Py_ssize_t len;
13133
0
            Py_ssize_t i;
13134
0
            if (!PyList_Check(tmp)) {
13135
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %T", tmp);
13136
0
                goto failed;
13137
0
            }
13138
0
            len = PyList_GET_SIZE(tmp);
13139
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13140
0
            if (body == NULL) goto failed;
13141
0
            for (i = 0; i < len; i++) {
13142
0
                stmt_ty val;
13143
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13144
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13145
0
                    goto failed;
13146
0
                }
13147
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
13148
0
                _Py_LeaveRecursiveCall();
13149
0
                Py_DECREF(tmp2);
13150
0
                if (res != 0) goto failed;
13151
0
                if (len != PyList_GET_SIZE(tmp)) {
13152
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13153
0
                    goto failed;
13154
0
                }
13155
0
                asdl_seq_SET(body, i, val);
13156
0
            }
13157
0
            Py_CLEAR(tmp);
13158
0
        }
13159
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13160
0
            return -1;
13161
0
        }
13162
0
        if (tmp == NULL) {
13163
0
            tmp = PyList_New(0);
13164
0
            if (tmp == NULL) {
13165
0
                return -1;
13166
0
            }
13167
0
        }
13168
0
        {
13169
0
            int res;
13170
0
            Py_ssize_t len;
13171
0
            Py_ssize_t i;
13172
0
            if (!PyList_Check(tmp)) {
13173
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %T", tmp);
13174
0
                goto failed;
13175
0
            }
13176
0
            len = PyList_GET_SIZE(tmp);
13177
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13178
0
            if (handlers == NULL) goto failed;
13179
0
            for (i = 0; i < len; i++) {
13180
0
                excepthandler_ty val;
13181
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13182
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13183
0
                    goto failed;
13184
0
                }
13185
0
                res = obj2ast_excepthandler(state, tmp2, &val, "handlers", arena);
13186
0
                _Py_LeaveRecursiveCall();
13187
0
                Py_DECREF(tmp2);
13188
0
                if (res != 0) goto failed;
13189
0
                if (len != PyList_GET_SIZE(tmp)) {
13190
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13191
0
                    goto failed;
13192
0
                }
13193
0
                asdl_seq_SET(handlers, i, val);
13194
0
            }
13195
0
            Py_CLEAR(tmp);
13196
0
        }
13197
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13198
0
            return -1;
13199
0
        }
13200
0
        if (tmp == NULL) {
13201
0
            tmp = PyList_New(0);
13202
0
            if (tmp == NULL) {
13203
0
                return -1;
13204
0
            }
13205
0
        }
13206
0
        {
13207
0
            int res;
13208
0
            Py_ssize_t len;
13209
0
            Py_ssize_t i;
13210
0
            if (!PyList_Check(tmp)) {
13211
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %T", tmp);
13212
0
                goto failed;
13213
0
            }
13214
0
            len = PyList_GET_SIZE(tmp);
13215
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13216
0
            if (orelse == NULL) goto failed;
13217
0
            for (i = 0; i < len; i++) {
13218
0
                stmt_ty val;
13219
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13220
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13221
0
                    goto failed;
13222
0
                }
13223
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
13224
0
                _Py_LeaveRecursiveCall();
13225
0
                Py_DECREF(tmp2);
13226
0
                if (res != 0) goto failed;
13227
0
                if (len != PyList_GET_SIZE(tmp)) {
13228
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13229
0
                    goto failed;
13230
0
                }
13231
0
                asdl_seq_SET(orelse, i, val);
13232
0
            }
13233
0
            Py_CLEAR(tmp);
13234
0
        }
13235
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13236
0
            return -1;
13237
0
        }
13238
0
        if (tmp == NULL) {
13239
0
            tmp = PyList_New(0);
13240
0
            if (tmp == NULL) {
13241
0
                return -1;
13242
0
            }
13243
0
        }
13244
0
        {
13245
0
            int res;
13246
0
            Py_ssize_t len;
13247
0
            Py_ssize_t i;
13248
0
            if (!PyList_Check(tmp)) {
13249
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %T", tmp);
13250
0
                goto failed;
13251
0
            }
13252
0
            len = PyList_GET_SIZE(tmp);
13253
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13254
0
            if (finalbody == NULL) goto failed;
13255
0
            for (i = 0; i < len; i++) {
13256
0
                stmt_ty val;
13257
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13258
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13259
0
                    goto failed;
13260
0
                }
13261
0
                res = obj2ast_stmt(state, tmp2, &val, "finalbody", arena);
13262
0
                _Py_LeaveRecursiveCall();
13263
0
                Py_DECREF(tmp2);
13264
0
                if (res != 0) goto failed;
13265
0
                if (len != PyList_GET_SIZE(tmp)) {
13266
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13267
0
                    goto failed;
13268
0
                }
13269
0
                asdl_seq_SET(finalbody, i, val);
13270
0
            }
13271
0
            Py_CLEAR(tmp);
13272
0
        }
13273
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13274
0
                          col_offset, end_lineno, end_col_offset, arena);
13275
0
        if (*out == NULL) goto failed;
13276
0
        return 0;
13277
0
    }
13278
0
    tp = state->TryStar_type;
13279
0
    isinstance = PyObject_IsInstance(obj, tp);
13280
0
    if (isinstance == -1) {
13281
0
        return -1;
13282
0
    }
13283
0
    if (isinstance) {
13284
0
        asdl_stmt_seq* body;
13285
0
        asdl_excepthandler_seq* handlers;
13286
0
        asdl_stmt_seq* orelse;
13287
0
        asdl_stmt_seq* finalbody;
13288
13289
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13290
0
            return -1;
13291
0
        }
13292
0
        if (tmp == NULL) {
13293
0
            tmp = PyList_New(0);
13294
0
            if (tmp == NULL) {
13295
0
                return -1;
13296
0
            }
13297
0
        }
13298
0
        {
13299
0
            int res;
13300
0
            Py_ssize_t len;
13301
0
            Py_ssize_t i;
13302
0
            if (!PyList_Check(tmp)) {
13303
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %T", tmp);
13304
0
                goto failed;
13305
0
            }
13306
0
            len = PyList_GET_SIZE(tmp);
13307
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13308
0
            if (body == NULL) goto failed;
13309
0
            for (i = 0; i < len; i++) {
13310
0
                stmt_ty val;
13311
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13312
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13313
0
                    goto failed;
13314
0
                }
13315
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
13316
0
                _Py_LeaveRecursiveCall();
13317
0
                Py_DECREF(tmp2);
13318
0
                if (res != 0) goto failed;
13319
0
                if (len != PyList_GET_SIZE(tmp)) {
13320
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13321
0
                    goto failed;
13322
0
                }
13323
0
                asdl_seq_SET(body, i, val);
13324
0
            }
13325
0
            Py_CLEAR(tmp);
13326
0
        }
13327
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13328
0
            return -1;
13329
0
        }
13330
0
        if (tmp == NULL) {
13331
0
            tmp = PyList_New(0);
13332
0
            if (tmp == NULL) {
13333
0
                return -1;
13334
0
            }
13335
0
        }
13336
0
        {
13337
0
            int res;
13338
0
            Py_ssize_t len;
13339
0
            Py_ssize_t i;
13340
0
            if (!PyList_Check(tmp)) {
13341
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %T", tmp);
13342
0
                goto failed;
13343
0
            }
13344
0
            len = PyList_GET_SIZE(tmp);
13345
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13346
0
            if (handlers == NULL) goto failed;
13347
0
            for (i = 0; i < len; i++) {
13348
0
                excepthandler_ty val;
13349
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13350
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13351
0
                    goto failed;
13352
0
                }
13353
0
                res = obj2ast_excepthandler(state, tmp2, &val, "handlers", arena);
13354
0
                _Py_LeaveRecursiveCall();
13355
0
                Py_DECREF(tmp2);
13356
0
                if (res != 0) goto failed;
13357
0
                if (len != PyList_GET_SIZE(tmp)) {
13358
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13359
0
                    goto failed;
13360
0
                }
13361
0
                asdl_seq_SET(handlers, i, val);
13362
0
            }
13363
0
            Py_CLEAR(tmp);
13364
0
        }
13365
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13366
0
            return -1;
13367
0
        }
13368
0
        if (tmp == NULL) {
13369
0
            tmp = PyList_New(0);
13370
0
            if (tmp == NULL) {
13371
0
                return -1;
13372
0
            }
13373
0
        }
13374
0
        {
13375
0
            int res;
13376
0
            Py_ssize_t len;
13377
0
            Py_ssize_t i;
13378
0
            if (!PyList_Check(tmp)) {
13379
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %T", tmp);
13380
0
                goto failed;
13381
0
            }
13382
0
            len = PyList_GET_SIZE(tmp);
13383
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13384
0
            if (orelse == NULL) goto failed;
13385
0
            for (i = 0; i < len; i++) {
13386
0
                stmt_ty val;
13387
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13388
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13389
0
                    goto failed;
13390
0
                }
13391
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
13392
0
                _Py_LeaveRecursiveCall();
13393
0
                Py_DECREF(tmp2);
13394
0
                if (res != 0) goto failed;
13395
0
                if (len != PyList_GET_SIZE(tmp)) {
13396
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13397
0
                    goto failed;
13398
0
                }
13399
0
                asdl_seq_SET(orelse, i, val);
13400
0
            }
13401
0
            Py_CLEAR(tmp);
13402
0
        }
13403
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13404
0
            return -1;
13405
0
        }
13406
0
        if (tmp == NULL) {
13407
0
            tmp = PyList_New(0);
13408
0
            if (tmp == NULL) {
13409
0
                return -1;
13410
0
            }
13411
0
        }
13412
0
        {
13413
0
            int res;
13414
0
            Py_ssize_t len;
13415
0
            Py_ssize_t i;
13416
0
            if (!PyList_Check(tmp)) {
13417
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %T", tmp);
13418
0
                goto failed;
13419
0
            }
13420
0
            len = PyList_GET_SIZE(tmp);
13421
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13422
0
            if (finalbody == NULL) goto failed;
13423
0
            for (i = 0; i < len; i++) {
13424
0
                stmt_ty val;
13425
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13426
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13427
0
                    goto failed;
13428
0
                }
13429
0
                res = obj2ast_stmt(state, tmp2, &val, "finalbody", arena);
13430
0
                _Py_LeaveRecursiveCall();
13431
0
                Py_DECREF(tmp2);
13432
0
                if (res != 0) goto failed;
13433
0
                if (len != PyList_GET_SIZE(tmp)) {
13434
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13435
0
                    goto failed;
13436
0
                }
13437
0
                asdl_seq_SET(finalbody, i, val);
13438
0
            }
13439
0
            Py_CLEAR(tmp);
13440
0
        }
13441
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13442
0
                              col_offset, end_lineno, end_col_offset, arena);
13443
0
        if (*out == NULL) goto failed;
13444
0
        return 0;
13445
0
    }
13446
0
    tp = state->Assert_type;
13447
0
    isinstance = PyObject_IsInstance(obj, tp);
13448
0
    if (isinstance == -1) {
13449
0
        return -1;
13450
0
    }
13451
0
    if (isinstance) {
13452
0
        expr_ty test;
13453
0
        expr_ty msg;
13454
13455
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13456
0
            return -1;
13457
0
        }
13458
0
        if (tmp == NULL) {
13459
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13460
0
            return -1;
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, &test, "test", arena);
13468
0
            _Py_LeaveRecursiveCall();
13469
0
            if (res != 0) goto failed;
13470
0
            Py_CLEAR(tmp);
13471
0
        }
13472
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13473
0
            return -1;
13474
0
        }
13475
0
        if (tmp == NULL || tmp == Py_None) {
13476
0
            Py_CLEAR(tmp);
13477
0
            msg = NULL;
13478
0
        }
13479
0
        else {
13480
0
            int res;
13481
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13482
0
                goto failed;
13483
0
            }
13484
0
            res = obj2ast_expr(state, tmp, &msg, "msg", arena);
13485
0
            _Py_LeaveRecursiveCall();
13486
0
            if (res != 0) goto failed;
13487
0
            Py_CLEAR(tmp);
13488
0
        }
13489
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13490
0
                             end_col_offset, arena);
13491
0
        if (*out == NULL) goto failed;
13492
0
        return 0;
13493
0
    }
13494
0
    tp = state->Import_type;
13495
0
    isinstance = PyObject_IsInstance(obj, tp);
13496
0
    if (isinstance == -1) {
13497
0
        return -1;
13498
0
    }
13499
0
    if (isinstance) {
13500
0
        asdl_alias_seq* names;
13501
0
        int is_lazy;
13502
13503
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13504
0
            return -1;
13505
0
        }
13506
0
        if (tmp == NULL) {
13507
0
            tmp = PyList_New(0);
13508
0
            if (tmp == NULL) {
13509
0
                return -1;
13510
0
            }
13511
0
        }
13512
0
        {
13513
0
            int res;
13514
0
            Py_ssize_t len;
13515
0
            Py_ssize_t i;
13516
0
            if (!PyList_Check(tmp)) {
13517
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %T", tmp);
13518
0
                goto failed;
13519
0
            }
13520
0
            len = PyList_GET_SIZE(tmp);
13521
0
            names = _Py_asdl_alias_seq_new(len, arena);
13522
0
            if (names == NULL) goto failed;
13523
0
            for (i = 0; i < len; i++) {
13524
0
                alias_ty val;
13525
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13526
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13527
0
                    goto failed;
13528
0
                }
13529
0
                res = obj2ast_alias(state, tmp2, &val, "names", arena);
13530
0
                _Py_LeaveRecursiveCall();
13531
0
                Py_DECREF(tmp2);
13532
0
                if (res != 0) goto failed;
13533
0
                if (len != PyList_GET_SIZE(tmp)) {
13534
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13535
0
                    goto failed;
13536
0
                }
13537
0
                asdl_seq_SET(names, i, val);
13538
0
            }
13539
0
            Py_CLEAR(tmp);
13540
0
        }
13541
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13542
0
            return -1;
13543
0
        }
13544
0
        if (tmp == NULL || tmp == Py_None) {
13545
0
            Py_CLEAR(tmp);
13546
0
            is_lazy = 0;
13547
0
        }
13548
0
        else {
13549
0
            int res;
13550
0
            if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13551
0
                goto failed;
13552
0
            }
13553
0
            res = obj2ast_int(state, tmp, &is_lazy, "is_lazy", arena);
13554
0
            _Py_LeaveRecursiveCall();
13555
0
            if (res != 0) goto failed;
13556
0
            Py_CLEAR(tmp);
13557
0
        }
13558
0
        *out = _PyAST_Import(names, is_lazy, lineno, col_offset, end_lineno,
13559
0
                             end_col_offset, arena);
13560
0
        if (*out == NULL) goto failed;
13561
0
        return 0;
13562
0
    }
13563
0
    tp = state->ImportFrom_type;
13564
0
    isinstance = PyObject_IsInstance(obj, tp);
13565
0
    if (isinstance == -1) {
13566
0
        return -1;
13567
0
    }
13568
0
    if (isinstance) {
13569
0
        identifier module;
13570
0
        asdl_alias_seq* names;
13571
0
        int level;
13572
0
        int is_lazy;
13573
13574
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13575
0
            return -1;
13576
0
        }
13577
0
        if (tmp == NULL || tmp == Py_None) {
13578
0
            Py_CLEAR(tmp);
13579
0
            module = NULL;
13580
0
        }
13581
0
        else {
13582
0
            int res;
13583
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13584
0
                goto failed;
13585
0
            }
13586
0
            res = obj2ast_identifier(state, tmp, &module, "module", arena);
13587
0
            _Py_LeaveRecursiveCall();
13588
0
            if (res != 0) goto failed;
13589
0
            Py_CLEAR(tmp);
13590
0
        }
13591
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13592
0
            return -1;
13593
0
        }
13594
0
        if (tmp == NULL) {
13595
0
            tmp = PyList_New(0);
13596
0
            if (tmp == NULL) {
13597
0
                return -1;
13598
0
            }
13599
0
        }
13600
0
        {
13601
0
            int res;
13602
0
            Py_ssize_t len;
13603
0
            Py_ssize_t i;
13604
0
            if (!PyList_Check(tmp)) {
13605
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %T", tmp);
13606
0
                goto failed;
13607
0
            }
13608
0
            len = PyList_GET_SIZE(tmp);
13609
0
            names = _Py_asdl_alias_seq_new(len, arena);
13610
0
            if (names == NULL) goto failed;
13611
0
            for (i = 0; i < len; i++) {
13612
0
                alias_ty val;
13613
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13614
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13615
0
                    goto failed;
13616
0
                }
13617
0
                res = obj2ast_alias(state, tmp2, &val, "names", arena);
13618
0
                _Py_LeaveRecursiveCall();
13619
0
                Py_DECREF(tmp2);
13620
0
                if (res != 0) goto failed;
13621
0
                if (len != PyList_GET_SIZE(tmp)) {
13622
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13623
0
                    goto failed;
13624
0
                }
13625
0
                asdl_seq_SET(names, i, val);
13626
0
            }
13627
0
            Py_CLEAR(tmp);
13628
0
        }
13629
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13630
0
            return -1;
13631
0
        }
13632
0
        if (tmp == NULL || tmp == Py_None) {
13633
0
            Py_CLEAR(tmp);
13634
0
            level = 0;
13635
0
        }
13636
0
        else {
13637
0
            int res;
13638
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13639
0
                goto failed;
13640
0
            }
13641
0
            res = obj2ast_int(state, tmp, &level, "level", arena);
13642
0
            _Py_LeaveRecursiveCall();
13643
0
            if (res != 0) goto failed;
13644
0
            Py_CLEAR(tmp);
13645
0
        }
13646
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13647
0
            return -1;
13648
0
        }
13649
0
        if (tmp == NULL || tmp == Py_None) {
13650
0
            Py_CLEAR(tmp);
13651
0
            is_lazy = 0;
13652
0
        }
13653
0
        else {
13654
0
            int res;
13655
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13656
0
                goto failed;
13657
0
            }
13658
0
            res = obj2ast_int(state, tmp, &is_lazy, "is_lazy", arena);
13659
0
            _Py_LeaveRecursiveCall();
13660
0
            if (res != 0) goto failed;
13661
0
            Py_CLEAR(tmp);
13662
0
        }
13663
0
        *out = _PyAST_ImportFrom(module, names, level, is_lazy, lineno,
13664
0
                                 col_offset, end_lineno, end_col_offset, arena);
13665
0
        if (*out == NULL) goto failed;
13666
0
        return 0;
13667
0
    }
13668
0
    tp = state->Global_type;
13669
0
    isinstance = PyObject_IsInstance(obj, tp);
13670
0
    if (isinstance == -1) {
13671
0
        return -1;
13672
0
    }
13673
0
    if (isinstance) {
13674
0
        asdl_identifier_seq* names;
13675
13676
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13677
0
            return -1;
13678
0
        }
13679
0
        if (tmp == NULL) {
13680
0
            tmp = PyList_New(0);
13681
0
            if (tmp == NULL) {
13682
0
                return -1;
13683
0
            }
13684
0
        }
13685
0
        {
13686
0
            int res;
13687
0
            Py_ssize_t len;
13688
0
            Py_ssize_t i;
13689
0
            if (!PyList_Check(tmp)) {
13690
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %T", tmp);
13691
0
                goto failed;
13692
0
            }
13693
0
            len = PyList_GET_SIZE(tmp);
13694
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13695
0
            if (names == NULL) goto failed;
13696
0
            for (i = 0; i < len; i++) {
13697
0
                identifier val;
13698
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13699
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13700
0
                    goto failed;
13701
0
                }
13702
0
                res = obj2ast_identifier(state, tmp2, &val, "names", arena);
13703
0
                _Py_LeaveRecursiveCall();
13704
0
                Py_DECREF(tmp2);
13705
0
                if (res != 0) goto failed;
13706
0
                if (len != PyList_GET_SIZE(tmp)) {
13707
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13708
0
                    goto failed;
13709
0
                }
13710
0
                asdl_seq_SET(names, i, val);
13711
0
            }
13712
0
            Py_CLEAR(tmp);
13713
0
        }
13714
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13715
0
                             end_col_offset, arena);
13716
0
        if (*out == NULL) goto failed;
13717
0
        return 0;
13718
0
    }
13719
0
    tp = state->Nonlocal_type;
13720
0
    isinstance = PyObject_IsInstance(obj, tp);
13721
0
    if (isinstance == -1) {
13722
0
        return -1;
13723
0
    }
13724
0
    if (isinstance) {
13725
0
        asdl_identifier_seq* names;
13726
13727
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13728
0
            return -1;
13729
0
        }
13730
0
        if (tmp == NULL) {
13731
0
            tmp = PyList_New(0);
13732
0
            if (tmp == NULL) {
13733
0
                return -1;
13734
0
            }
13735
0
        }
13736
0
        {
13737
0
            int res;
13738
0
            Py_ssize_t len;
13739
0
            Py_ssize_t i;
13740
0
            if (!PyList_Check(tmp)) {
13741
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %T", tmp);
13742
0
                goto failed;
13743
0
            }
13744
0
            len = PyList_GET_SIZE(tmp);
13745
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13746
0
            if (names == NULL) goto failed;
13747
0
            for (i = 0; i < len; i++) {
13748
0
                identifier val;
13749
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13750
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13751
0
                    goto failed;
13752
0
                }
13753
0
                res = obj2ast_identifier(state, tmp2, &val, "names", arena);
13754
0
                _Py_LeaveRecursiveCall();
13755
0
                Py_DECREF(tmp2);
13756
0
                if (res != 0) goto failed;
13757
0
                if (len != PyList_GET_SIZE(tmp)) {
13758
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13759
0
                    goto failed;
13760
0
                }
13761
0
                asdl_seq_SET(names, i, val);
13762
0
            }
13763
0
            Py_CLEAR(tmp);
13764
0
        }
13765
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13766
0
                               end_col_offset, arena);
13767
0
        if (*out == NULL) goto failed;
13768
0
        return 0;
13769
0
    }
13770
0
    tp = state->Expr_type;
13771
0
    isinstance = PyObject_IsInstance(obj, tp);
13772
0
    if (isinstance == -1) {
13773
0
        return -1;
13774
0
    }
13775
0
    if (isinstance) {
13776
0
        expr_ty value;
13777
13778
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13779
0
            return -1;
13780
0
        }
13781
0
        if (tmp == NULL) {
13782
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13783
0
            return -1;
13784
0
        }
13785
0
        else {
13786
0
            int res;
13787
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13788
0
                goto failed;
13789
0
            }
13790
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
13791
0
            _Py_LeaveRecursiveCall();
13792
0
            if (res != 0) goto failed;
13793
0
            Py_CLEAR(tmp);
13794
0
        }
13795
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13796
0
                           end_col_offset, arena);
13797
0
        if (*out == NULL) goto failed;
13798
0
        return 0;
13799
0
    }
13800
0
    tp = state->Pass_type;
13801
0
    isinstance = PyObject_IsInstance(obj, tp);
13802
0
    if (isinstance == -1) {
13803
0
        return -1;
13804
0
    }
13805
0
    if (isinstance) {
13806
13807
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13808
0
                           arena);
13809
0
        if (*out == NULL) goto failed;
13810
0
        return 0;
13811
0
    }
13812
0
    tp = state->Break_type;
13813
0
    isinstance = PyObject_IsInstance(obj, tp);
13814
0
    if (isinstance == -1) {
13815
0
        return -1;
13816
0
    }
13817
0
    if (isinstance) {
13818
13819
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13820
0
                            arena);
13821
0
        if (*out == NULL) goto failed;
13822
0
        return 0;
13823
0
    }
13824
0
    tp = state->Continue_type;
13825
0
    isinstance = PyObject_IsInstance(obj, tp);
13826
0
    if (isinstance == -1) {
13827
0
        return -1;
13828
0
    }
13829
0
    if (isinstance) {
13830
13831
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13832
0
                               arena);
13833
0
        if (*out == NULL) goto failed;
13834
0
        return 0;
13835
0
    }
13836
13837
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13838
0
    failed:
13839
0
    Py_XDECREF(tmp);
13840
0
    return -1;
13841
0
}
13842
13843
int
13844
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, const char*
13845
             field, PyArena* arena)
13846
0
{
13847
0
    int isinstance;
13848
13849
0
    PyObject *tmp = NULL;
13850
0
    PyObject *tp;
13851
0
    int lineno;
13852
0
    int col_offset;
13853
0
    int end_lineno;
13854
0
    int end_col_offset;
13855
13856
0
    if (obj == Py_None) {
13857
0
        *out = NULL;
13858
0
        return 0;
13859
0
    }
13860
0
    tp = state->expr_type;
13861
0
    isinstance = PyObject_IsInstance(obj, tp);
13862
0
    if (isinstance == -1) {
13863
0
        return 1;
13864
0
    }
13865
0
    if (!isinstance && field != NULL) {
13866
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'expr', got '%T'", field, obj);
13867
0
        return 1;
13868
0
    }
13869
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13870
0
        return -1;
13871
0
    }
13872
0
    if (tmp == NULL) {
13873
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13874
0
        return -1;
13875
0
    }
13876
0
    else {
13877
0
        int res;
13878
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13879
0
            goto failed;
13880
0
        }
13881
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
13882
0
        _Py_LeaveRecursiveCall();
13883
0
        if (res != 0) goto failed;
13884
0
        Py_CLEAR(tmp);
13885
0
    }
13886
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13887
0
        return -1;
13888
0
    }
13889
0
    if (tmp == NULL) {
13890
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13891
0
        return -1;
13892
0
    }
13893
0
    else {
13894
0
        int res;
13895
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13896
0
            goto failed;
13897
0
        }
13898
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
13899
0
        _Py_LeaveRecursiveCall();
13900
0
        if (res != 0) goto failed;
13901
0
        Py_CLEAR(tmp);
13902
0
    }
13903
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13904
0
        return -1;
13905
0
    }
13906
0
    if (tmp == NULL || tmp == Py_None) {
13907
0
        Py_CLEAR(tmp);
13908
0
        end_lineno = lineno;
13909
0
    }
13910
0
    else {
13911
0
        int res;
13912
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13913
0
            goto failed;
13914
0
        }
13915
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
13916
0
        _Py_LeaveRecursiveCall();
13917
0
        if (res != 0) goto failed;
13918
0
        Py_CLEAR(tmp);
13919
0
    }
13920
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13921
0
        return -1;
13922
0
    }
13923
0
    if (tmp == NULL || tmp == Py_None) {
13924
0
        Py_CLEAR(tmp);
13925
0
        end_col_offset = col_offset;
13926
0
    }
13927
0
    else {
13928
0
        int res;
13929
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13930
0
            goto failed;
13931
0
        }
13932
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
13933
0
        _Py_LeaveRecursiveCall();
13934
0
        if (res != 0) goto failed;
13935
0
        Py_CLEAR(tmp);
13936
0
    }
13937
0
    tp = state->BoolOp_type;
13938
0
    isinstance = PyObject_IsInstance(obj, tp);
13939
0
    if (isinstance == -1) {
13940
0
        return -1;
13941
0
    }
13942
0
    if (isinstance) {
13943
0
        boolop_ty op;
13944
0
        asdl_expr_seq* values;
13945
13946
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13947
0
            return -1;
13948
0
        }
13949
0
        if (tmp == NULL) {
13950
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13951
0
            return -1;
13952
0
        }
13953
0
        else {
13954
0
            int res;
13955
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13956
0
                goto failed;
13957
0
            }
13958
0
            res = obj2ast_boolop(state, tmp, &op, "op", arena);
13959
0
            _Py_LeaveRecursiveCall();
13960
0
            if (res != 0) goto failed;
13961
0
            Py_CLEAR(tmp);
13962
0
        }
13963
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13964
0
            return -1;
13965
0
        }
13966
0
        if (tmp == NULL) {
13967
0
            tmp = PyList_New(0);
13968
0
            if (tmp == NULL) {
13969
0
                return -1;
13970
0
            }
13971
0
        }
13972
0
        {
13973
0
            int res;
13974
0
            Py_ssize_t len;
13975
0
            Py_ssize_t i;
13976
0
            if (!PyList_Check(tmp)) {
13977
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %T", tmp);
13978
0
                goto failed;
13979
0
            }
13980
0
            len = PyList_GET_SIZE(tmp);
13981
0
            values = _Py_asdl_expr_seq_new(len, arena);
13982
0
            if (values == NULL) goto failed;
13983
0
            for (i = 0; i < len; i++) {
13984
0
                expr_ty val;
13985
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13986
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13987
0
                    goto failed;
13988
0
                }
13989
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
13990
0
                _Py_LeaveRecursiveCall();
13991
0
                Py_DECREF(tmp2);
13992
0
                if (res != 0) goto failed;
13993
0
                if (len != PyList_GET_SIZE(tmp)) {
13994
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13995
0
                    goto failed;
13996
0
                }
13997
0
                asdl_seq_SET(values, i, val);
13998
0
            }
13999
0
            Py_CLEAR(tmp);
14000
0
        }
14001
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
14002
0
                             end_col_offset, arena);
14003
0
        if (*out == NULL) goto failed;
14004
0
        return 0;
14005
0
    }
14006
0
    tp = state->NamedExpr_type;
14007
0
    isinstance = PyObject_IsInstance(obj, tp);
14008
0
    if (isinstance == -1) {
14009
0
        return -1;
14010
0
    }
14011
0
    if (isinstance) {
14012
0
        expr_ty target;
14013
0
        expr_ty value;
14014
14015
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
14016
0
            return -1;
14017
0
        }
14018
0
        if (tmp == NULL) {
14019
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
14020
0
            return -1;
14021
0
        }
14022
0
        else {
14023
0
            int res;
14024
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
14025
0
                goto failed;
14026
0
            }
14027
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
14028
0
            _Py_LeaveRecursiveCall();
14029
0
            if (res != 0) goto failed;
14030
0
            Py_CLEAR(tmp);
14031
0
        }
14032
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14033
0
            return -1;
14034
0
        }
14035
0
        if (tmp == NULL) {
14036
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
14037
0
            return -1;
14038
0
        }
14039
0
        else {
14040
0
            int res;
14041
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
14042
0
                goto failed;
14043
0
            }
14044
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14045
0
            _Py_LeaveRecursiveCall();
14046
0
            if (res != 0) goto failed;
14047
0
            Py_CLEAR(tmp);
14048
0
        }
14049
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
14050
0
                                end_col_offset, arena);
14051
0
        if (*out == NULL) goto failed;
14052
0
        return 0;
14053
0
    }
14054
0
    tp = state->BinOp_type;
14055
0
    isinstance = PyObject_IsInstance(obj, tp);
14056
0
    if (isinstance == -1) {
14057
0
        return -1;
14058
0
    }
14059
0
    if (isinstance) {
14060
0
        expr_ty left;
14061
0
        operator_ty op;
14062
0
        expr_ty right;
14063
14064
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14065
0
            return -1;
14066
0
        }
14067
0
        if (tmp == NULL) {
14068
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14069
0
            return -1;
14070
0
        }
14071
0
        else {
14072
0
            int res;
14073
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14074
0
                goto failed;
14075
0
            }
14076
0
            res = obj2ast_expr(state, tmp, &left, "left", arena);
14077
0
            _Py_LeaveRecursiveCall();
14078
0
            if (res != 0) goto failed;
14079
0
            Py_CLEAR(tmp);
14080
0
        }
14081
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14082
0
            return -1;
14083
0
        }
14084
0
        if (tmp == NULL) {
14085
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14086
0
            return -1;
14087
0
        }
14088
0
        else {
14089
0
            int res;
14090
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14091
0
                goto failed;
14092
0
            }
14093
0
            res = obj2ast_operator(state, tmp, &op, "op", arena);
14094
0
            _Py_LeaveRecursiveCall();
14095
0
            if (res != 0) goto failed;
14096
0
            Py_CLEAR(tmp);
14097
0
        }
14098
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14099
0
            return -1;
14100
0
        }
14101
0
        if (tmp == NULL) {
14102
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14103
0
            return -1;
14104
0
        }
14105
0
        else {
14106
0
            int res;
14107
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14108
0
                goto failed;
14109
0
            }
14110
0
            res = obj2ast_expr(state, tmp, &right, "right", arena);
14111
0
            _Py_LeaveRecursiveCall();
14112
0
            if (res != 0) goto failed;
14113
0
            Py_CLEAR(tmp);
14114
0
        }
14115
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14116
0
                            end_col_offset, arena);
14117
0
        if (*out == NULL) goto failed;
14118
0
        return 0;
14119
0
    }
14120
0
    tp = state->UnaryOp_type;
14121
0
    isinstance = PyObject_IsInstance(obj, tp);
14122
0
    if (isinstance == -1) {
14123
0
        return -1;
14124
0
    }
14125
0
    if (isinstance) {
14126
0
        unaryop_ty op;
14127
0
        expr_ty operand;
14128
14129
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14130
0
            return -1;
14131
0
        }
14132
0
        if (tmp == NULL) {
14133
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14134
0
            return -1;
14135
0
        }
14136
0
        else {
14137
0
            int res;
14138
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14139
0
                goto failed;
14140
0
            }
14141
0
            res = obj2ast_unaryop(state, tmp, &op, "op", arena);
14142
0
            _Py_LeaveRecursiveCall();
14143
0
            if (res != 0) goto failed;
14144
0
            Py_CLEAR(tmp);
14145
0
        }
14146
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
14147
0
            return -1;
14148
0
        }
14149
0
        if (tmp == NULL) {
14150
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14151
0
            return -1;
14152
0
        }
14153
0
        else {
14154
0
            int res;
14155
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14156
0
                goto failed;
14157
0
            }
14158
0
            res = obj2ast_expr(state, tmp, &operand, "operand", arena);
14159
0
            _Py_LeaveRecursiveCall();
14160
0
            if (res != 0) goto failed;
14161
0
            Py_CLEAR(tmp);
14162
0
        }
14163
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14164
0
                              end_col_offset, arena);
14165
0
        if (*out == NULL) goto failed;
14166
0
        return 0;
14167
0
    }
14168
0
    tp = state->Lambda_type;
14169
0
    isinstance = PyObject_IsInstance(obj, tp);
14170
0
    if (isinstance == -1) {
14171
0
        return -1;
14172
0
    }
14173
0
    if (isinstance) {
14174
0
        arguments_ty args;
14175
0
        expr_ty body;
14176
14177
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14178
0
            return -1;
14179
0
        }
14180
0
        if (tmp == NULL) {
14181
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14182
0
            return -1;
14183
0
        }
14184
0
        else {
14185
0
            int res;
14186
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14187
0
                goto failed;
14188
0
            }
14189
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
14190
0
            _Py_LeaveRecursiveCall();
14191
0
            if (res != 0) goto failed;
14192
0
            Py_CLEAR(tmp);
14193
0
        }
14194
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14195
0
            return -1;
14196
0
        }
14197
0
        if (tmp == NULL) {
14198
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14199
0
            return -1;
14200
0
        }
14201
0
        else {
14202
0
            int res;
14203
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14204
0
                goto failed;
14205
0
            }
14206
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
14207
0
            _Py_LeaveRecursiveCall();
14208
0
            if (res != 0) goto failed;
14209
0
            Py_CLEAR(tmp);
14210
0
        }
14211
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14212
0
                             end_col_offset, arena);
14213
0
        if (*out == NULL) goto failed;
14214
0
        return 0;
14215
0
    }
14216
0
    tp = state->IfExp_type;
14217
0
    isinstance = PyObject_IsInstance(obj, tp);
14218
0
    if (isinstance == -1) {
14219
0
        return -1;
14220
0
    }
14221
0
    if (isinstance) {
14222
0
        expr_ty test;
14223
0
        expr_ty body;
14224
0
        expr_ty orelse;
14225
14226
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14227
0
            return -1;
14228
0
        }
14229
0
        if (tmp == NULL) {
14230
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14231
0
            return -1;
14232
0
        }
14233
0
        else {
14234
0
            int res;
14235
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14236
0
                goto failed;
14237
0
            }
14238
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
14239
0
            _Py_LeaveRecursiveCall();
14240
0
            if (res != 0) goto failed;
14241
0
            Py_CLEAR(tmp);
14242
0
        }
14243
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14244
0
            return -1;
14245
0
        }
14246
0
        if (tmp == NULL) {
14247
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14248
0
            return -1;
14249
0
        }
14250
0
        else {
14251
0
            int res;
14252
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14253
0
                goto failed;
14254
0
            }
14255
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
14256
0
            _Py_LeaveRecursiveCall();
14257
0
            if (res != 0) goto failed;
14258
0
            Py_CLEAR(tmp);
14259
0
        }
14260
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14261
0
            return -1;
14262
0
        }
14263
0
        if (tmp == NULL) {
14264
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14265
0
            return -1;
14266
0
        }
14267
0
        else {
14268
0
            int res;
14269
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14270
0
                goto failed;
14271
0
            }
14272
0
            res = obj2ast_expr(state, tmp, &orelse, "orelse", arena);
14273
0
            _Py_LeaveRecursiveCall();
14274
0
            if (res != 0) goto failed;
14275
0
            Py_CLEAR(tmp);
14276
0
        }
14277
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14278
0
                            end_col_offset, arena);
14279
0
        if (*out == NULL) goto failed;
14280
0
        return 0;
14281
0
    }
14282
0
    tp = state->Dict_type;
14283
0
    isinstance = PyObject_IsInstance(obj, tp);
14284
0
    if (isinstance == -1) {
14285
0
        return -1;
14286
0
    }
14287
0
    if (isinstance) {
14288
0
        asdl_expr_seq* keys;
14289
0
        asdl_expr_seq* values;
14290
14291
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14292
0
            return -1;
14293
0
        }
14294
0
        if (tmp == NULL) {
14295
0
            tmp = PyList_New(0);
14296
0
            if (tmp == NULL) {
14297
0
                return -1;
14298
0
            }
14299
0
        }
14300
0
        {
14301
0
            int res;
14302
0
            Py_ssize_t len;
14303
0
            Py_ssize_t i;
14304
0
            if (!PyList_Check(tmp)) {
14305
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %T", tmp);
14306
0
                goto failed;
14307
0
            }
14308
0
            len = PyList_GET_SIZE(tmp);
14309
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14310
0
            if (keys == NULL) goto failed;
14311
0
            for (i = 0; i < len; i++) {
14312
0
                expr_ty val;
14313
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14314
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14315
0
                    goto failed;
14316
0
                }
14317
0
                res = obj2ast_expr(state, tmp2, &val, "keys", arena);
14318
0
                _Py_LeaveRecursiveCall();
14319
0
                Py_DECREF(tmp2);
14320
0
                if (res != 0) goto failed;
14321
0
                if (len != PyList_GET_SIZE(tmp)) {
14322
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14323
0
                    goto failed;
14324
0
                }
14325
0
                asdl_seq_SET(keys, i, val);
14326
0
            }
14327
0
            Py_CLEAR(tmp);
14328
0
        }
14329
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14330
0
            return -1;
14331
0
        }
14332
0
        if (tmp == NULL) {
14333
0
            tmp = PyList_New(0);
14334
0
            if (tmp == NULL) {
14335
0
                return -1;
14336
0
            }
14337
0
        }
14338
0
        {
14339
0
            int res;
14340
0
            Py_ssize_t len;
14341
0
            Py_ssize_t i;
14342
0
            if (!PyList_Check(tmp)) {
14343
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %T", tmp);
14344
0
                goto failed;
14345
0
            }
14346
0
            len = PyList_GET_SIZE(tmp);
14347
0
            values = _Py_asdl_expr_seq_new(len, arena);
14348
0
            if (values == NULL) goto failed;
14349
0
            for (i = 0; i < len; i++) {
14350
0
                expr_ty val;
14351
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14352
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14353
0
                    goto failed;
14354
0
                }
14355
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
14356
0
                _Py_LeaveRecursiveCall();
14357
0
                Py_DECREF(tmp2);
14358
0
                if (res != 0) goto failed;
14359
0
                if (len != PyList_GET_SIZE(tmp)) {
14360
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14361
0
                    goto failed;
14362
0
                }
14363
0
                asdl_seq_SET(values, i, val);
14364
0
            }
14365
0
            Py_CLEAR(tmp);
14366
0
        }
14367
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14368
0
                           end_col_offset, arena);
14369
0
        if (*out == NULL) goto failed;
14370
0
        return 0;
14371
0
    }
14372
0
    tp = state->Set_type;
14373
0
    isinstance = PyObject_IsInstance(obj, tp);
14374
0
    if (isinstance == -1) {
14375
0
        return -1;
14376
0
    }
14377
0
    if (isinstance) {
14378
0
        asdl_expr_seq* elts;
14379
14380
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14381
0
            return -1;
14382
0
        }
14383
0
        if (tmp == NULL) {
14384
0
            tmp = PyList_New(0);
14385
0
            if (tmp == NULL) {
14386
0
                return -1;
14387
0
            }
14388
0
        }
14389
0
        {
14390
0
            int res;
14391
0
            Py_ssize_t len;
14392
0
            Py_ssize_t i;
14393
0
            if (!PyList_Check(tmp)) {
14394
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %T", tmp);
14395
0
                goto failed;
14396
0
            }
14397
0
            len = PyList_GET_SIZE(tmp);
14398
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14399
0
            if (elts == NULL) goto failed;
14400
0
            for (i = 0; i < len; i++) {
14401
0
                expr_ty val;
14402
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14403
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14404
0
                    goto failed;
14405
0
                }
14406
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
14407
0
                _Py_LeaveRecursiveCall();
14408
0
                Py_DECREF(tmp2);
14409
0
                if (res != 0) goto failed;
14410
0
                if (len != PyList_GET_SIZE(tmp)) {
14411
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14412
0
                    goto failed;
14413
0
                }
14414
0
                asdl_seq_SET(elts, i, val);
14415
0
            }
14416
0
            Py_CLEAR(tmp);
14417
0
        }
14418
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14419
0
                          arena);
14420
0
        if (*out == NULL) goto failed;
14421
0
        return 0;
14422
0
    }
14423
0
    tp = state->ListComp_type;
14424
0
    isinstance = PyObject_IsInstance(obj, tp);
14425
0
    if (isinstance == -1) {
14426
0
        return -1;
14427
0
    }
14428
0
    if (isinstance) {
14429
0
        expr_ty elt;
14430
0
        asdl_comprehension_seq* generators;
14431
14432
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14433
0
            return -1;
14434
0
        }
14435
0
        if (tmp == NULL) {
14436
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14437
0
            return -1;
14438
0
        }
14439
0
        else {
14440
0
            int res;
14441
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14442
0
                goto failed;
14443
0
            }
14444
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
14445
0
            _Py_LeaveRecursiveCall();
14446
0
            if (res != 0) goto failed;
14447
0
            Py_CLEAR(tmp);
14448
0
        }
14449
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14450
0
            return -1;
14451
0
        }
14452
0
        if (tmp == NULL) {
14453
0
            tmp = PyList_New(0);
14454
0
            if (tmp == NULL) {
14455
0
                return -1;
14456
0
            }
14457
0
        }
14458
0
        {
14459
0
            int res;
14460
0
            Py_ssize_t len;
14461
0
            Py_ssize_t i;
14462
0
            if (!PyList_Check(tmp)) {
14463
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %T", tmp);
14464
0
                goto failed;
14465
0
            }
14466
0
            len = PyList_GET_SIZE(tmp);
14467
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14468
0
            if (generators == NULL) goto failed;
14469
0
            for (i = 0; i < len; i++) {
14470
0
                comprehension_ty val;
14471
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14472
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14473
0
                    goto failed;
14474
0
                }
14475
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14476
0
                _Py_LeaveRecursiveCall();
14477
0
                Py_DECREF(tmp2);
14478
0
                if (res != 0) goto failed;
14479
0
                if (len != PyList_GET_SIZE(tmp)) {
14480
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14481
0
                    goto failed;
14482
0
                }
14483
0
                asdl_seq_SET(generators, i, val);
14484
0
            }
14485
0
            Py_CLEAR(tmp);
14486
0
        }
14487
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14488
0
                               end_col_offset, arena);
14489
0
        if (*out == NULL) goto failed;
14490
0
        return 0;
14491
0
    }
14492
0
    tp = state->SetComp_type;
14493
0
    isinstance = PyObject_IsInstance(obj, tp);
14494
0
    if (isinstance == -1) {
14495
0
        return -1;
14496
0
    }
14497
0
    if (isinstance) {
14498
0
        expr_ty elt;
14499
0
        asdl_comprehension_seq* generators;
14500
14501
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14502
0
            return -1;
14503
0
        }
14504
0
        if (tmp == NULL) {
14505
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14506
0
            return -1;
14507
0
        }
14508
0
        else {
14509
0
            int res;
14510
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14511
0
                goto failed;
14512
0
            }
14513
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
14514
0
            _Py_LeaveRecursiveCall();
14515
0
            if (res != 0) goto failed;
14516
0
            Py_CLEAR(tmp);
14517
0
        }
14518
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14519
0
            return -1;
14520
0
        }
14521
0
        if (tmp == NULL) {
14522
0
            tmp = PyList_New(0);
14523
0
            if (tmp == NULL) {
14524
0
                return -1;
14525
0
            }
14526
0
        }
14527
0
        {
14528
0
            int res;
14529
0
            Py_ssize_t len;
14530
0
            Py_ssize_t i;
14531
0
            if (!PyList_Check(tmp)) {
14532
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %T", tmp);
14533
0
                goto failed;
14534
0
            }
14535
0
            len = PyList_GET_SIZE(tmp);
14536
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14537
0
            if (generators == NULL) goto failed;
14538
0
            for (i = 0; i < len; i++) {
14539
0
                comprehension_ty val;
14540
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14541
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14542
0
                    goto failed;
14543
0
                }
14544
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14545
0
                _Py_LeaveRecursiveCall();
14546
0
                Py_DECREF(tmp2);
14547
0
                if (res != 0) goto failed;
14548
0
                if (len != PyList_GET_SIZE(tmp)) {
14549
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14550
0
                    goto failed;
14551
0
                }
14552
0
                asdl_seq_SET(generators, i, val);
14553
0
            }
14554
0
            Py_CLEAR(tmp);
14555
0
        }
14556
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14557
0
                              end_col_offset, arena);
14558
0
        if (*out == NULL) goto failed;
14559
0
        return 0;
14560
0
    }
14561
0
    tp = state->DictComp_type;
14562
0
    isinstance = PyObject_IsInstance(obj, tp);
14563
0
    if (isinstance == -1) {
14564
0
        return -1;
14565
0
    }
14566
0
    if (isinstance) {
14567
0
        expr_ty key;
14568
0
        expr_ty value;
14569
0
        asdl_comprehension_seq* generators;
14570
14571
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14572
0
            return -1;
14573
0
        }
14574
0
        if (tmp == NULL) {
14575
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14576
0
            return -1;
14577
0
        }
14578
0
        else {
14579
0
            int res;
14580
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14581
0
                goto failed;
14582
0
            }
14583
0
            res = obj2ast_expr(state, tmp, &key, "key", arena);
14584
0
            _Py_LeaveRecursiveCall();
14585
0
            if (res != 0) goto failed;
14586
0
            Py_CLEAR(tmp);
14587
0
        }
14588
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14589
0
            return -1;
14590
0
        }
14591
0
        if (tmp == NULL || tmp == Py_None) {
14592
0
            Py_CLEAR(tmp);
14593
0
            value = NULL;
14594
0
        }
14595
0
        else {
14596
0
            int res;
14597
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14598
0
                goto failed;
14599
0
            }
14600
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14601
0
            _Py_LeaveRecursiveCall();
14602
0
            if (res != 0) goto failed;
14603
0
            Py_CLEAR(tmp);
14604
0
        }
14605
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14606
0
            return -1;
14607
0
        }
14608
0
        if (tmp == NULL) {
14609
0
            tmp = PyList_New(0);
14610
0
            if (tmp == NULL) {
14611
0
                return -1;
14612
0
            }
14613
0
        }
14614
0
        {
14615
0
            int res;
14616
0
            Py_ssize_t len;
14617
0
            Py_ssize_t i;
14618
0
            if (!PyList_Check(tmp)) {
14619
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %T", tmp);
14620
0
                goto failed;
14621
0
            }
14622
0
            len = PyList_GET_SIZE(tmp);
14623
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14624
0
            if (generators == NULL) goto failed;
14625
0
            for (i = 0; i < len; i++) {
14626
0
                comprehension_ty val;
14627
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14628
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14629
0
                    goto failed;
14630
0
                }
14631
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14632
0
                _Py_LeaveRecursiveCall();
14633
0
                Py_DECREF(tmp2);
14634
0
                if (res != 0) goto failed;
14635
0
                if (len != PyList_GET_SIZE(tmp)) {
14636
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14637
0
                    goto failed;
14638
0
                }
14639
0
                asdl_seq_SET(generators, i, val);
14640
0
            }
14641
0
            Py_CLEAR(tmp);
14642
0
        }
14643
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14644
0
                               end_lineno, end_col_offset, arena);
14645
0
        if (*out == NULL) goto failed;
14646
0
        return 0;
14647
0
    }
14648
0
    tp = state->GeneratorExp_type;
14649
0
    isinstance = PyObject_IsInstance(obj, tp);
14650
0
    if (isinstance == -1) {
14651
0
        return -1;
14652
0
    }
14653
0
    if (isinstance) {
14654
0
        expr_ty elt;
14655
0
        asdl_comprehension_seq* generators;
14656
14657
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14658
0
            return -1;
14659
0
        }
14660
0
        if (tmp == NULL) {
14661
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14662
0
            return -1;
14663
0
        }
14664
0
        else {
14665
0
            int res;
14666
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14667
0
                goto failed;
14668
0
            }
14669
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
14670
0
            _Py_LeaveRecursiveCall();
14671
0
            if (res != 0) goto failed;
14672
0
            Py_CLEAR(tmp);
14673
0
        }
14674
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14675
0
            return -1;
14676
0
        }
14677
0
        if (tmp == NULL) {
14678
0
            tmp = PyList_New(0);
14679
0
            if (tmp == NULL) {
14680
0
                return -1;
14681
0
            }
14682
0
        }
14683
0
        {
14684
0
            int res;
14685
0
            Py_ssize_t len;
14686
0
            Py_ssize_t i;
14687
0
            if (!PyList_Check(tmp)) {
14688
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %T", tmp);
14689
0
                goto failed;
14690
0
            }
14691
0
            len = PyList_GET_SIZE(tmp);
14692
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14693
0
            if (generators == NULL) goto failed;
14694
0
            for (i = 0; i < len; i++) {
14695
0
                comprehension_ty val;
14696
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14697
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14698
0
                    goto failed;
14699
0
                }
14700
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14701
0
                _Py_LeaveRecursiveCall();
14702
0
                Py_DECREF(tmp2);
14703
0
                if (res != 0) goto failed;
14704
0
                if (len != PyList_GET_SIZE(tmp)) {
14705
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14706
0
                    goto failed;
14707
0
                }
14708
0
                asdl_seq_SET(generators, i, val);
14709
0
            }
14710
0
            Py_CLEAR(tmp);
14711
0
        }
14712
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14713
0
                                   end_lineno, end_col_offset, arena);
14714
0
        if (*out == NULL) goto failed;
14715
0
        return 0;
14716
0
    }
14717
0
    tp = state->Await_type;
14718
0
    isinstance = PyObject_IsInstance(obj, tp);
14719
0
    if (isinstance == -1) {
14720
0
        return -1;
14721
0
    }
14722
0
    if (isinstance) {
14723
0
        expr_ty value;
14724
14725
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14726
0
            return -1;
14727
0
        }
14728
0
        if (tmp == NULL) {
14729
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14730
0
            return -1;
14731
0
        }
14732
0
        else {
14733
0
            int res;
14734
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14735
0
                goto failed;
14736
0
            }
14737
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14738
0
            _Py_LeaveRecursiveCall();
14739
0
            if (res != 0) goto failed;
14740
0
            Py_CLEAR(tmp);
14741
0
        }
14742
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14743
0
                            end_col_offset, arena);
14744
0
        if (*out == NULL) goto failed;
14745
0
        return 0;
14746
0
    }
14747
0
    tp = state->Yield_type;
14748
0
    isinstance = PyObject_IsInstance(obj, tp);
14749
0
    if (isinstance == -1) {
14750
0
        return -1;
14751
0
    }
14752
0
    if (isinstance) {
14753
0
        expr_ty value;
14754
14755
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14756
0
            return -1;
14757
0
        }
14758
0
        if (tmp == NULL || tmp == Py_None) {
14759
0
            Py_CLEAR(tmp);
14760
0
            value = NULL;
14761
0
        }
14762
0
        else {
14763
0
            int res;
14764
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14765
0
                goto failed;
14766
0
            }
14767
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14768
0
            _Py_LeaveRecursiveCall();
14769
0
            if (res != 0) goto failed;
14770
0
            Py_CLEAR(tmp);
14771
0
        }
14772
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14773
0
                            end_col_offset, arena);
14774
0
        if (*out == NULL) goto failed;
14775
0
        return 0;
14776
0
    }
14777
0
    tp = state->YieldFrom_type;
14778
0
    isinstance = PyObject_IsInstance(obj, tp);
14779
0
    if (isinstance == -1) {
14780
0
        return -1;
14781
0
    }
14782
0
    if (isinstance) {
14783
0
        expr_ty value;
14784
14785
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14786
0
            return -1;
14787
0
        }
14788
0
        if (tmp == NULL) {
14789
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14790
0
            return -1;
14791
0
        }
14792
0
        else {
14793
0
            int res;
14794
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14795
0
                goto failed;
14796
0
            }
14797
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14798
0
            _Py_LeaveRecursiveCall();
14799
0
            if (res != 0) goto failed;
14800
0
            Py_CLEAR(tmp);
14801
0
        }
14802
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14803
0
                                end_col_offset, arena);
14804
0
        if (*out == NULL) goto failed;
14805
0
        return 0;
14806
0
    }
14807
0
    tp = state->Compare_type;
14808
0
    isinstance = PyObject_IsInstance(obj, tp);
14809
0
    if (isinstance == -1) {
14810
0
        return -1;
14811
0
    }
14812
0
    if (isinstance) {
14813
0
        expr_ty left;
14814
0
        asdl_int_seq* ops;
14815
0
        asdl_expr_seq* comparators;
14816
14817
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14818
0
            return -1;
14819
0
        }
14820
0
        if (tmp == NULL) {
14821
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14822
0
            return -1;
14823
0
        }
14824
0
        else {
14825
0
            int res;
14826
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14827
0
                goto failed;
14828
0
            }
14829
0
            res = obj2ast_expr(state, tmp, &left, "left", arena);
14830
0
            _Py_LeaveRecursiveCall();
14831
0
            if (res != 0) goto failed;
14832
0
            Py_CLEAR(tmp);
14833
0
        }
14834
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14835
0
            return -1;
14836
0
        }
14837
0
        if (tmp == NULL) {
14838
0
            tmp = PyList_New(0);
14839
0
            if (tmp == NULL) {
14840
0
                return -1;
14841
0
            }
14842
0
        }
14843
0
        {
14844
0
            int res;
14845
0
            Py_ssize_t len;
14846
0
            Py_ssize_t i;
14847
0
            if (!PyList_Check(tmp)) {
14848
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %T", tmp);
14849
0
                goto failed;
14850
0
            }
14851
0
            len = PyList_GET_SIZE(tmp);
14852
0
            ops = _Py_asdl_int_seq_new(len, arena);
14853
0
            if (ops == NULL) goto failed;
14854
0
            for (i = 0; i < len; i++) {
14855
0
                cmpop_ty val;
14856
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14857
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14858
0
                    goto failed;
14859
0
                }
14860
0
                res = obj2ast_cmpop(state, tmp2, &val, "ops", arena);
14861
0
                _Py_LeaveRecursiveCall();
14862
0
                Py_DECREF(tmp2);
14863
0
                if (res != 0) goto failed;
14864
0
                if (len != PyList_GET_SIZE(tmp)) {
14865
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14866
0
                    goto failed;
14867
0
                }
14868
0
                asdl_seq_SET(ops, i, val);
14869
0
            }
14870
0
            Py_CLEAR(tmp);
14871
0
        }
14872
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14873
0
            return -1;
14874
0
        }
14875
0
        if (tmp == NULL) {
14876
0
            tmp = PyList_New(0);
14877
0
            if (tmp == NULL) {
14878
0
                return -1;
14879
0
            }
14880
0
        }
14881
0
        {
14882
0
            int res;
14883
0
            Py_ssize_t len;
14884
0
            Py_ssize_t i;
14885
0
            if (!PyList_Check(tmp)) {
14886
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %T", tmp);
14887
0
                goto failed;
14888
0
            }
14889
0
            len = PyList_GET_SIZE(tmp);
14890
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14891
0
            if (comparators == NULL) goto failed;
14892
0
            for (i = 0; i < len; i++) {
14893
0
                expr_ty val;
14894
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14895
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14896
0
                    goto failed;
14897
0
                }
14898
0
                res = obj2ast_expr(state, tmp2, &val, "comparators", arena);
14899
0
                _Py_LeaveRecursiveCall();
14900
0
                Py_DECREF(tmp2);
14901
0
                if (res != 0) goto failed;
14902
0
                if (len != PyList_GET_SIZE(tmp)) {
14903
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14904
0
                    goto failed;
14905
0
                }
14906
0
                asdl_seq_SET(comparators, i, val);
14907
0
            }
14908
0
            Py_CLEAR(tmp);
14909
0
        }
14910
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14911
0
                              end_lineno, end_col_offset, arena);
14912
0
        if (*out == NULL) goto failed;
14913
0
        return 0;
14914
0
    }
14915
0
    tp = state->Call_type;
14916
0
    isinstance = PyObject_IsInstance(obj, tp);
14917
0
    if (isinstance == -1) {
14918
0
        return -1;
14919
0
    }
14920
0
    if (isinstance) {
14921
0
        expr_ty func;
14922
0
        asdl_expr_seq* args;
14923
0
        asdl_keyword_seq* keywords;
14924
14925
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14926
0
            return -1;
14927
0
        }
14928
0
        if (tmp == NULL) {
14929
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14930
0
            return -1;
14931
0
        }
14932
0
        else {
14933
0
            int res;
14934
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14935
0
                goto failed;
14936
0
            }
14937
0
            res = obj2ast_expr(state, tmp, &func, "func", arena);
14938
0
            _Py_LeaveRecursiveCall();
14939
0
            if (res != 0) goto failed;
14940
0
            Py_CLEAR(tmp);
14941
0
        }
14942
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14943
0
            return -1;
14944
0
        }
14945
0
        if (tmp == NULL) {
14946
0
            tmp = PyList_New(0);
14947
0
            if (tmp == NULL) {
14948
0
                return -1;
14949
0
            }
14950
0
        }
14951
0
        {
14952
0
            int res;
14953
0
            Py_ssize_t len;
14954
0
            Py_ssize_t i;
14955
0
            if (!PyList_Check(tmp)) {
14956
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %T", tmp);
14957
0
                goto failed;
14958
0
            }
14959
0
            len = PyList_GET_SIZE(tmp);
14960
0
            args = _Py_asdl_expr_seq_new(len, arena);
14961
0
            if (args == NULL) goto failed;
14962
0
            for (i = 0; i < len; i++) {
14963
0
                expr_ty val;
14964
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14965
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14966
0
                    goto failed;
14967
0
                }
14968
0
                res = obj2ast_expr(state, tmp2, &val, "args", arena);
14969
0
                _Py_LeaveRecursiveCall();
14970
0
                Py_DECREF(tmp2);
14971
0
                if (res != 0) goto failed;
14972
0
                if (len != PyList_GET_SIZE(tmp)) {
14973
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14974
0
                    goto failed;
14975
0
                }
14976
0
                asdl_seq_SET(args, i, val);
14977
0
            }
14978
0
            Py_CLEAR(tmp);
14979
0
        }
14980
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14981
0
            return -1;
14982
0
        }
14983
0
        if (tmp == NULL) {
14984
0
            tmp = PyList_New(0);
14985
0
            if (tmp == NULL) {
14986
0
                return -1;
14987
0
            }
14988
0
        }
14989
0
        {
14990
0
            int res;
14991
0
            Py_ssize_t len;
14992
0
            Py_ssize_t i;
14993
0
            if (!PyList_Check(tmp)) {
14994
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %T", tmp);
14995
0
                goto failed;
14996
0
            }
14997
0
            len = PyList_GET_SIZE(tmp);
14998
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
14999
0
            if (keywords == NULL) goto failed;
15000
0
            for (i = 0; i < len; i++) {
15001
0
                keyword_ty val;
15002
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15003
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
15004
0
                    goto failed;
15005
0
                }
15006
0
                res = obj2ast_keyword(state, tmp2, &val, "keywords", arena);
15007
0
                _Py_LeaveRecursiveCall();
15008
0
                Py_DECREF(tmp2);
15009
0
                if (res != 0) goto failed;
15010
0
                if (len != PyList_GET_SIZE(tmp)) {
15011
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
15012
0
                    goto failed;
15013
0
                }
15014
0
                asdl_seq_SET(keywords, i, val);
15015
0
            }
15016
0
            Py_CLEAR(tmp);
15017
0
        }
15018
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
15019
0
                           end_lineno, end_col_offset, arena);
15020
0
        if (*out == NULL) goto failed;
15021
0
        return 0;
15022
0
    }
15023
0
    tp = state->FormattedValue_type;
15024
0
    isinstance = PyObject_IsInstance(obj, tp);
15025
0
    if (isinstance == -1) {
15026
0
        return -1;
15027
0
    }
15028
0
    if (isinstance) {
15029
0
        expr_ty value;
15030
0
        int conversion;
15031
0
        expr_ty format_spec;
15032
15033
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15034
0
            return -1;
15035
0
        }
15036
0
        if (tmp == NULL) {
15037
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
15038
0
            return -1;
15039
0
        }
15040
0
        else {
15041
0
            int res;
15042
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15043
0
                goto failed;
15044
0
            }
15045
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15046
0
            _Py_LeaveRecursiveCall();
15047
0
            if (res != 0) goto failed;
15048
0
            Py_CLEAR(tmp);
15049
0
        }
15050
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15051
0
            return -1;
15052
0
        }
15053
0
        if (tmp == NULL) {
15054
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
15055
0
            return -1;
15056
0
        }
15057
0
        else {
15058
0
            int res;
15059
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15060
0
                goto failed;
15061
0
            }
15062
0
            res = obj2ast_int(state, tmp, &conversion, "conversion", arena);
15063
0
            _Py_LeaveRecursiveCall();
15064
0
            if (res != 0) goto failed;
15065
0
            Py_CLEAR(tmp);
15066
0
        }
15067
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15068
0
            return -1;
15069
0
        }
15070
0
        if (tmp == NULL || tmp == Py_None) {
15071
0
            Py_CLEAR(tmp);
15072
0
            format_spec = NULL;
15073
0
        }
15074
0
        else {
15075
0
            int res;
15076
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15077
0
                goto failed;
15078
0
            }
15079
0
            res = obj2ast_expr(state, tmp, &format_spec, "format_spec", arena);
15080
0
            _Py_LeaveRecursiveCall();
15081
0
            if (res != 0) goto failed;
15082
0
            Py_CLEAR(tmp);
15083
0
        }
15084
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15085
0
                                     col_offset, end_lineno, end_col_offset,
15086
0
                                     arena);
15087
0
        if (*out == NULL) goto failed;
15088
0
        return 0;
15089
0
    }
15090
0
    tp = state->Interpolation_type;
15091
0
    isinstance = PyObject_IsInstance(obj, tp);
15092
0
    if (isinstance == -1) {
15093
0
        return -1;
15094
0
    }
15095
0
    if (isinstance) {
15096
0
        expr_ty value;
15097
0
        constant str;
15098
0
        int conversion;
15099
0
        expr_ty format_spec;
15100
15101
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15102
0
            return -1;
15103
0
        }
15104
0
        if (tmp == NULL) {
15105
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15106
0
            return -1;
15107
0
        }
15108
0
        else {
15109
0
            int res;
15110
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15111
0
                goto failed;
15112
0
            }
15113
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15114
0
            _Py_LeaveRecursiveCall();
15115
0
            if (res != 0) goto failed;
15116
0
            Py_CLEAR(tmp);
15117
0
        }
15118
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15119
0
            return -1;
15120
0
        }
15121
0
        if (tmp == NULL) {
15122
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15123
0
            return -1;
15124
0
        }
15125
0
        else {
15126
0
            int res;
15127
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15128
0
                goto failed;
15129
0
            }
15130
0
            res = obj2ast_constant(state, tmp, &str, "str", arena);
15131
0
            _Py_LeaveRecursiveCall();
15132
0
            if (res != 0) goto failed;
15133
0
            Py_CLEAR(tmp);
15134
0
        }
15135
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15136
0
            return -1;
15137
0
        }
15138
0
        if (tmp == NULL) {
15139
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15140
0
            return -1;
15141
0
        }
15142
0
        else {
15143
0
            int res;
15144
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15145
0
                goto failed;
15146
0
            }
15147
0
            res = obj2ast_int(state, tmp, &conversion, "conversion", arena);
15148
0
            _Py_LeaveRecursiveCall();
15149
0
            if (res != 0) goto failed;
15150
0
            Py_CLEAR(tmp);
15151
0
        }
15152
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15153
0
            return -1;
15154
0
        }
15155
0
        if (tmp == NULL || tmp == Py_None) {
15156
0
            Py_CLEAR(tmp);
15157
0
            format_spec = NULL;
15158
0
        }
15159
0
        else {
15160
0
            int res;
15161
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15162
0
                goto failed;
15163
0
            }
15164
0
            res = obj2ast_expr(state, tmp, &format_spec, "format_spec", arena);
15165
0
            _Py_LeaveRecursiveCall();
15166
0
            if (res != 0) goto failed;
15167
0
            Py_CLEAR(tmp);
15168
0
        }
15169
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15170
0
                                    lineno, col_offset, end_lineno,
15171
0
                                    end_col_offset, arena);
15172
0
        if (*out == NULL) goto failed;
15173
0
        return 0;
15174
0
    }
15175
0
    tp = state->JoinedStr_type;
15176
0
    isinstance = PyObject_IsInstance(obj, tp);
15177
0
    if (isinstance == -1) {
15178
0
        return -1;
15179
0
    }
15180
0
    if (isinstance) {
15181
0
        asdl_expr_seq* values;
15182
15183
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15184
0
            return -1;
15185
0
        }
15186
0
        if (tmp == NULL) {
15187
0
            tmp = PyList_New(0);
15188
0
            if (tmp == NULL) {
15189
0
                return -1;
15190
0
            }
15191
0
        }
15192
0
        {
15193
0
            int res;
15194
0
            Py_ssize_t len;
15195
0
            Py_ssize_t i;
15196
0
            if (!PyList_Check(tmp)) {
15197
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %T", tmp);
15198
0
                goto failed;
15199
0
            }
15200
0
            len = PyList_GET_SIZE(tmp);
15201
0
            values = _Py_asdl_expr_seq_new(len, arena);
15202
0
            if (values == NULL) goto failed;
15203
0
            for (i = 0; i < len; i++) {
15204
0
                expr_ty val;
15205
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15206
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15207
0
                    goto failed;
15208
0
                }
15209
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
15210
0
                _Py_LeaveRecursiveCall();
15211
0
                Py_DECREF(tmp2);
15212
0
                if (res != 0) goto failed;
15213
0
                if (len != PyList_GET_SIZE(tmp)) {
15214
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15215
0
                    goto failed;
15216
0
                }
15217
0
                asdl_seq_SET(values, i, val);
15218
0
            }
15219
0
            Py_CLEAR(tmp);
15220
0
        }
15221
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15222
0
                                end_col_offset, arena);
15223
0
        if (*out == NULL) goto failed;
15224
0
        return 0;
15225
0
    }
15226
0
    tp = state->TemplateStr_type;
15227
0
    isinstance = PyObject_IsInstance(obj, tp);
15228
0
    if (isinstance == -1) {
15229
0
        return -1;
15230
0
    }
15231
0
    if (isinstance) {
15232
0
        asdl_expr_seq* values;
15233
15234
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15235
0
            return -1;
15236
0
        }
15237
0
        if (tmp == NULL) {
15238
0
            tmp = PyList_New(0);
15239
0
            if (tmp == NULL) {
15240
0
                return -1;
15241
0
            }
15242
0
        }
15243
0
        {
15244
0
            int res;
15245
0
            Py_ssize_t len;
15246
0
            Py_ssize_t i;
15247
0
            if (!PyList_Check(tmp)) {
15248
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %T", tmp);
15249
0
                goto failed;
15250
0
            }
15251
0
            len = PyList_GET_SIZE(tmp);
15252
0
            values = _Py_asdl_expr_seq_new(len, arena);
15253
0
            if (values == NULL) goto failed;
15254
0
            for (i = 0; i < len; i++) {
15255
0
                expr_ty val;
15256
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15257
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15258
0
                    goto failed;
15259
0
                }
15260
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
15261
0
                _Py_LeaveRecursiveCall();
15262
0
                Py_DECREF(tmp2);
15263
0
                if (res != 0) goto failed;
15264
0
                if (len != PyList_GET_SIZE(tmp)) {
15265
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15266
0
                    goto failed;
15267
0
                }
15268
0
                asdl_seq_SET(values, i, val);
15269
0
            }
15270
0
            Py_CLEAR(tmp);
15271
0
        }
15272
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15273
0
                                  end_col_offset, arena);
15274
0
        if (*out == NULL) goto failed;
15275
0
        return 0;
15276
0
    }
15277
0
    tp = state->Constant_type;
15278
0
    isinstance = PyObject_IsInstance(obj, tp);
15279
0
    if (isinstance == -1) {
15280
0
        return -1;
15281
0
    }
15282
0
    if (isinstance) {
15283
0
        constant value;
15284
0
        string kind;
15285
15286
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15287
0
            return -1;
15288
0
        }
15289
0
        if (tmp == NULL) {
15290
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15291
0
            return -1;
15292
0
        }
15293
0
        else {
15294
0
            int res;
15295
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15296
0
                goto failed;
15297
0
            }
15298
0
            res = obj2ast_constant(state, tmp, &value, "value", arena);
15299
0
            _Py_LeaveRecursiveCall();
15300
0
            if (res != 0) goto failed;
15301
0
            Py_CLEAR(tmp);
15302
0
        }
15303
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15304
0
            return -1;
15305
0
        }
15306
0
        if (tmp == NULL || tmp == Py_None) {
15307
0
            Py_CLEAR(tmp);
15308
0
            kind = NULL;
15309
0
        }
15310
0
        else {
15311
0
            int res;
15312
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15313
0
                goto failed;
15314
0
            }
15315
0
            res = obj2ast_string(state, tmp, &kind, "kind", arena);
15316
0
            _Py_LeaveRecursiveCall();
15317
0
            if (res != 0) goto failed;
15318
0
            Py_CLEAR(tmp);
15319
0
        }
15320
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15321
0
                               end_col_offset, arena);
15322
0
        if (*out == NULL) goto failed;
15323
0
        return 0;
15324
0
    }
15325
0
    tp = state->Attribute_type;
15326
0
    isinstance = PyObject_IsInstance(obj, tp);
15327
0
    if (isinstance == -1) {
15328
0
        return -1;
15329
0
    }
15330
0
    if (isinstance) {
15331
0
        expr_ty value;
15332
0
        identifier attr;
15333
0
        expr_context_ty ctx;
15334
15335
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15336
0
            return -1;
15337
0
        }
15338
0
        if (tmp == NULL) {
15339
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15340
0
            return -1;
15341
0
        }
15342
0
        else {
15343
0
            int res;
15344
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15345
0
                goto failed;
15346
0
            }
15347
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15348
0
            _Py_LeaveRecursiveCall();
15349
0
            if (res != 0) goto failed;
15350
0
            Py_CLEAR(tmp);
15351
0
        }
15352
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15353
0
            return -1;
15354
0
        }
15355
0
        if (tmp == NULL) {
15356
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15357
0
            return -1;
15358
0
        }
15359
0
        else {
15360
0
            int res;
15361
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15362
0
                goto failed;
15363
0
            }
15364
0
            res = obj2ast_identifier(state, tmp, &attr, "attr", arena);
15365
0
            _Py_LeaveRecursiveCall();
15366
0
            if (res != 0) goto failed;
15367
0
            Py_CLEAR(tmp);
15368
0
        }
15369
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15370
0
            return -1;
15371
0
        }
15372
0
        if (tmp == NULL) {
15373
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15374
0
            return -1;
15375
0
        }
15376
0
        else {
15377
0
            int res;
15378
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15379
0
                goto failed;
15380
0
            }
15381
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15382
0
            _Py_LeaveRecursiveCall();
15383
0
            if (res != 0) goto failed;
15384
0
            Py_CLEAR(tmp);
15385
0
        }
15386
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15387
0
                                end_lineno, end_col_offset, arena);
15388
0
        if (*out == NULL) goto failed;
15389
0
        return 0;
15390
0
    }
15391
0
    tp = state->Subscript_type;
15392
0
    isinstance = PyObject_IsInstance(obj, tp);
15393
0
    if (isinstance == -1) {
15394
0
        return -1;
15395
0
    }
15396
0
    if (isinstance) {
15397
0
        expr_ty value;
15398
0
        expr_ty slice;
15399
0
        expr_context_ty ctx;
15400
15401
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15402
0
            return -1;
15403
0
        }
15404
0
        if (tmp == NULL) {
15405
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15406
0
            return -1;
15407
0
        }
15408
0
        else {
15409
0
            int res;
15410
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15411
0
                goto failed;
15412
0
            }
15413
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15414
0
            _Py_LeaveRecursiveCall();
15415
0
            if (res != 0) goto failed;
15416
0
            Py_CLEAR(tmp);
15417
0
        }
15418
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15419
0
            return -1;
15420
0
        }
15421
0
        if (tmp == NULL) {
15422
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15423
0
            return -1;
15424
0
        }
15425
0
        else {
15426
0
            int res;
15427
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15428
0
                goto failed;
15429
0
            }
15430
0
            res = obj2ast_expr(state, tmp, &slice, "slice", arena);
15431
0
            _Py_LeaveRecursiveCall();
15432
0
            if (res != 0) goto failed;
15433
0
            Py_CLEAR(tmp);
15434
0
        }
15435
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15436
0
            return -1;
15437
0
        }
15438
0
        if (tmp == NULL) {
15439
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15440
0
            return -1;
15441
0
        }
15442
0
        else {
15443
0
            int res;
15444
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15445
0
                goto failed;
15446
0
            }
15447
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15448
0
            _Py_LeaveRecursiveCall();
15449
0
            if (res != 0) goto failed;
15450
0
            Py_CLEAR(tmp);
15451
0
        }
15452
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15453
0
                                end_lineno, end_col_offset, arena);
15454
0
        if (*out == NULL) goto failed;
15455
0
        return 0;
15456
0
    }
15457
0
    tp = state->Starred_type;
15458
0
    isinstance = PyObject_IsInstance(obj, tp);
15459
0
    if (isinstance == -1) {
15460
0
        return -1;
15461
0
    }
15462
0
    if (isinstance) {
15463
0
        expr_ty value;
15464
0
        expr_context_ty ctx;
15465
15466
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15467
0
            return -1;
15468
0
        }
15469
0
        if (tmp == NULL) {
15470
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15471
0
            return -1;
15472
0
        }
15473
0
        else {
15474
0
            int res;
15475
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15476
0
                goto failed;
15477
0
            }
15478
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15479
0
            _Py_LeaveRecursiveCall();
15480
0
            if (res != 0) goto failed;
15481
0
            Py_CLEAR(tmp);
15482
0
        }
15483
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15484
0
            return -1;
15485
0
        }
15486
0
        if (tmp == NULL) {
15487
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15488
0
            return -1;
15489
0
        }
15490
0
        else {
15491
0
            int res;
15492
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15493
0
                goto failed;
15494
0
            }
15495
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15496
0
            _Py_LeaveRecursiveCall();
15497
0
            if (res != 0) goto failed;
15498
0
            Py_CLEAR(tmp);
15499
0
        }
15500
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15501
0
                              end_col_offset, arena);
15502
0
        if (*out == NULL) goto failed;
15503
0
        return 0;
15504
0
    }
15505
0
    tp = state->Name_type;
15506
0
    isinstance = PyObject_IsInstance(obj, tp);
15507
0
    if (isinstance == -1) {
15508
0
        return -1;
15509
0
    }
15510
0
    if (isinstance) {
15511
0
        identifier id;
15512
0
        expr_context_ty ctx;
15513
15514
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15515
0
            return -1;
15516
0
        }
15517
0
        if (tmp == NULL) {
15518
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15519
0
            return -1;
15520
0
        }
15521
0
        else {
15522
0
            int res;
15523
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15524
0
                goto failed;
15525
0
            }
15526
0
            res = obj2ast_identifier(state, tmp, &id, "id", arena);
15527
0
            _Py_LeaveRecursiveCall();
15528
0
            if (res != 0) goto failed;
15529
0
            Py_CLEAR(tmp);
15530
0
        }
15531
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15532
0
            return -1;
15533
0
        }
15534
0
        if (tmp == NULL) {
15535
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15536
0
            return -1;
15537
0
        }
15538
0
        else {
15539
0
            int res;
15540
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15541
0
                goto failed;
15542
0
            }
15543
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15544
0
            _Py_LeaveRecursiveCall();
15545
0
            if (res != 0) goto failed;
15546
0
            Py_CLEAR(tmp);
15547
0
        }
15548
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15549
0
                           end_col_offset, arena);
15550
0
        if (*out == NULL) goto failed;
15551
0
        return 0;
15552
0
    }
15553
0
    tp = state->List_type;
15554
0
    isinstance = PyObject_IsInstance(obj, tp);
15555
0
    if (isinstance == -1) {
15556
0
        return -1;
15557
0
    }
15558
0
    if (isinstance) {
15559
0
        asdl_expr_seq* elts;
15560
0
        expr_context_ty ctx;
15561
15562
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15563
0
            return -1;
15564
0
        }
15565
0
        if (tmp == NULL) {
15566
0
            tmp = PyList_New(0);
15567
0
            if (tmp == NULL) {
15568
0
                return -1;
15569
0
            }
15570
0
        }
15571
0
        {
15572
0
            int res;
15573
0
            Py_ssize_t len;
15574
0
            Py_ssize_t i;
15575
0
            if (!PyList_Check(tmp)) {
15576
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %T", tmp);
15577
0
                goto failed;
15578
0
            }
15579
0
            len = PyList_GET_SIZE(tmp);
15580
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15581
0
            if (elts == NULL) goto failed;
15582
0
            for (i = 0; i < len; i++) {
15583
0
                expr_ty val;
15584
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15585
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15586
0
                    goto failed;
15587
0
                }
15588
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
15589
0
                _Py_LeaveRecursiveCall();
15590
0
                Py_DECREF(tmp2);
15591
0
                if (res != 0) goto failed;
15592
0
                if (len != PyList_GET_SIZE(tmp)) {
15593
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15594
0
                    goto failed;
15595
0
                }
15596
0
                asdl_seq_SET(elts, i, val);
15597
0
            }
15598
0
            Py_CLEAR(tmp);
15599
0
        }
15600
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15601
0
            return -1;
15602
0
        }
15603
0
        if (tmp == NULL) {
15604
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15605
0
            return -1;
15606
0
        }
15607
0
        else {
15608
0
            int res;
15609
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15610
0
                goto failed;
15611
0
            }
15612
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15613
0
            _Py_LeaveRecursiveCall();
15614
0
            if (res != 0) goto failed;
15615
0
            Py_CLEAR(tmp);
15616
0
        }
15617
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15618
0
                           end_col_offset, arena);
15619
0
        if (*out == NULL) goto failed;
15620
0
        return 0;
15621
0
    }
15622
0
    tp = state->Tuple_type;
15623
0
    isinstance = PyObject_IsInstance(obj, tp);
15624
0
    if (isinstance == -1) {
15625
0
        return -1;
15626
0
    }
15627
0
    if (isinstance) {
15628
0
        asdl_expr_seq* elts;
15629
0
        expr_context_ty ctx;
15630
15631
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15632
0
            return -1;
15633
0
        }
15634
0
        if (tmp == NULL) {
15635
0
            tmp = PyList_New(0);
15636
0
            if (tmp == NULL) {
15637
0
                return -1;
15638
0
            }
15639
0
        }
15640
0
        {
15641
0
            int res;
15642
0
            Py_ssize_t len;
15643
0
            Py_ssize_t i;
15644
0
            if (!PyList_Check(tmp)) {
15645
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %T", tmp);
15646
0
                goto failed;
15647
0
            }
15648
0
            len = PyList_GET_SIZE(tmp);
15649
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15650
0
            if (elts == NULL) goto failed;
15651
0
            for (i = 0; i < len; i++) {
15652
0
                expr_ty val;
15653
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15654
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15655
0
                    goto failed;
15656
0
                }
15657
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
15658
0
                _Py_LeaveRecursiveCall();
15659
0
                Py_DECREF(tmp2);
15660
0
                if (res != 0) goto failed;
15661
0
                if (len != PyList_GET_SIZE(tmp)) {
15662
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15663
0
                    goto failed;
15664
0
                }
15665
0
                asdl_seq_SET(elts, i, val);
15666
0
            }
15667
0
            Py_CLEAR(tmp);
15668
0
        }
15669
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15670
0
            return -1;
15671
0
        }
15672
0
        if (tmp == NULL) {
15673
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15674
0
            return -1;
15675
0
        }
15676
0
        else {
15677
0
            int res;
15678
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15679
0
                goto failed;
15680
0
            }
15681
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15682
0
            _Py_LeaveRecursiveCall();
15683
0
            if (res != 0) goto failed;
15684
0
            Py_CLEAR(tmp);
15685
0
        }
15686
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15687
0
                            end_col_offset, arena);
15688
0
        if (*out == NULL) goto failed;
15689
0
        return 0;
15690
0
    }
15691
0
    tp = state->Slice_type;
15692
0
    isinstance = PyObject_IsInstance(obj, tp);
15693
0
    if (isinstance == -1) {
15694
0
        return -1;
15695
0
    }
15696
0
    if (isinstance) {
15697
0
        expr_ty lower;
15698
0
        expr_ty upper;
15699
0
        expr_ty step;
15700
15701
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15702
0
            return -1;
15703
0
        }
15704
0
        if (tmp == NULL || tmp == Py_None) {
15705
0
            Py_CLEAR(tmp);
15706
0
            lower = NULL;
15707
0
        }
15708
0
        else {
15709
0
            int res;
15710
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15711
0
                goto failed;
15712
0
            }
15713
0
            res = obj2ast_expr(state, tmp, &lower, "lower", arena);
15714
0
            _Py_LeaveRecursiveCall();
15715
0
            if (res != 0) goto failed;
15716
0
            Py_CLEAR(tmp);
15717
0
        }
15718
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15719
0
            return -1;
15720
0
        }
15721
0
        if (tmp == NULL || tmp == Py_None) {
15722
0
            Py_CLEAR(tmp);
15723
0
            upper = NULL;
15724
0
        }
15725
0
        else {
15726
0
            int res;
15727
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15728
0
                goto failed;
15729
0
            }
15730
0
            res = obj2ast_expr(state, tmp, &upper, "upper", arena);
15731
0
            _Py_LeaveRecursiveCall();
15732
0
            if (res != 0) goto failed;
15733
0
            Py_CLEAR(tmp);
15734
0
        }
15735
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15736
0
            return -1;
15737
0
        }
15738
0
        if (tmp == NULL || tmp == Py_None) {
15739
0
            Py_CLEAR(tmp);
15740
0
            step = NULL;
15741
0
        }
15742
0
        else {
15743
0
            int res;
15744
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15745
0
                goto failed;
15746
0
            }
15747
0
            res = obj2ast_expr(state, tmp, &step, "step", arena);
15748
0
            _Py_LeaveRecursiveCall();
15749
0
            if (res != 0) goto failed;
15750
0
            Py_CLEAR(tmp);
15751
0
        }
15752
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15753
0
                            end_col_offset, arena);
15754
0
        if (*out == NULL) goto failed;
15755
0
        return 0;
15756
0
    }
15757
15758
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15759
0
    failed:
15760
0
    Py_XDECREF(tmp);
15761
0
    return -1;
15762
0
}
15763
15764
int
15765
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15766
                     out, const char* field, PyArena* arena)
15767
0
{
15768
0
    int isinstance;
15769
15770
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15771
0
    if (isinstance == -1) {
15772
0
        return -1;
15773
0
    }
15774
0
    if (isinstance) {
15775
0
        *out = Load;
15776
0
        return 0;
15777
0
    }
15778
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15779
0
    if (isinstance == -1) {
15780
0
        return -1;
15781
0
    }
15782
0
    if (isinstance) {
15783
0
        *out = Store;
15784
0
        return 0;
15785
0
    }
15786
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15787
0
    if (isinstance == -1) {
15788
0
        return -1;
15789
0
    }
15790
0
    if (isinstance) {
15791
0
        *out = Del;
15792
0
        return 0;
15793
0
    }
15794
15795
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15796
0
    return -1;
15797
0
}
15798
15799
int
15800
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, const
15801
               char* field, PyArena* arena)
15802
0
{
15803
0
    int isinstance;
15804
15805
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15806
0
    if (isinstance == -1) {
15807
0
        return -1;
15808
0
    }
15809
0
    if (isinstance) {
15810
0
        *out = And;
15811
0
        return 0;
15812
0
    }
15813
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15814
0
    if (isinstance == -1) {
15815
0
        return -1;
15816
0
    }
15817
0
    if (isinstance) {
15818
0
        *out = Or;
15819
0
        return 0;
15820
0
    }
15821
15822
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15823
0
    return -1;
15824
0
}
15825
15826
int
15827
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15828
                 const char* field, PyArena* arena)
15829
0
{
15830
0
    int isinstance;
15831
15832
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15833
0
    if (isinstance == -1) {
15834
0
        return -1;
15835
0
    }
15836
0
    if (isinstance) {
15837
0
        *out = Add;
15838
0
        return 0;
15839
0
    }
15840
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15841
0
    if (isinstance == -1) {
15842
0
        return -1;
15843
0
    }
15844
0
    if (isinstance) {
15845
0
        *out = Sub;
15846
0
        return 0;
15847
0
    }
15848
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15849
0
    if (isinstance == -1) {
15850
0
        return -1;
15851
0
    }
15852
0
    if (isinstance) {
15853
0
        *out = Mult;
15854
0
        return 0;
15855
0
    }
15856
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15857
0
    if (isinstance == -1) {
15858
0
        return -1;
15859
0
    }
15860
0
    if (isinstance) {
15861
0
        *out = MatMult;
15862
0
        return 0;
15863
0
    }
15864
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15865
0
    if (isinstance == -1) {
15866
0
        return -1;
15867
0
    }
15868
0
    if (isinstance) {
15869
0
        *out = Div;
15870
0
        return 0;
15871
0
    }
15872
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15873
0
    if (isinstance == -1) {
15874
0
        return -1;
15875
0
    }
15876
0
    if (isinstance) {
15877
0
        *out = Mod;
15878
0
        return 0;
15879
0
    }
15880
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15881
0
    if (isinstance == -1) {
15882
0
        return -1;
15883
0
    }
15884
0
    if (isinstance) {
15885
0
        *out = Pow;
15886
0
        return 0;
15887
0
    }
15888
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15889
0
    if (isinstance == -1) {
15890
0
        return -1;
15891
0
    }
15892
0
    if (isinstance) {
15893
0
        *out = LShift;
15894
0
        return 0;
15895
0
    }
15896
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15897
0
    if (isinstance == -1) {
15898
0
        return -1;
15899
0
    }
15900
0
    if (isinstance) {
15901
0
        *out = RShift;
15902
0
        return 0;
15903
0
    }
15904
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15905
0
    if (isinstance == -1) {
15906
0
        return -1;
15907
0
    }
15908
0
    if (isinstance) {
15909
0
        *out = BitOr;
15910
0
        return 0;
15911
0
    }
15912
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15913
0
    if (isinstance == -1) {
15914
0
        return -1;
15915
0
    }
15916
0
    if (isinstance) {
15917
0
        *out = BitXor;
15918
0
        return 0;
15919
0
    }
15920
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15921
0
    if (isinstance == -1) {
15922
0
        return -1;
15923
0
    }
15924
0
    if (isinstance) {
15925
0
        *out = BitAnd;
15926
0
        return 0;
15927
0
    }
15928
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15929
0
    if (isinstance == -1) {
15930
0
        return -1;
15931
0
    }
15932
0
    if (isinstance) {
15933
0
        *out = FloorDiv;
15934
0
        return 0;
15935
0
    }
15936
15937
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15938
0
    return -1;
15939
0
}
15940
15941
int
15942
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out, const
15943
                char* field, PyArena* arena)
15944
0
{
15945
0
    int isinstance;
15946
15947
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15948
0
    if (isinstance == -1) {
15949
0
        return -1;
15950
0
    }
15951
0
    if (isinstance) {
15952
0
        *out = Invert;
15953
0
        return 0;
15954
0
    }
15955
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15956
0
    if (isinstance == -1) {
15957
0
        return -1;
15958
0
    }
15959
0
    if (isinstance) {
15960
0
        *out = Not;
15961
0
        return 0;
15962
0
    }
15963
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15964
0
    if (isinstance == -1) {
15965
0
        return -1;
15966
0
    }
15967
0
    if (isinstance) {
15968
0
        *out = UAdd;
15969
0
        return 0;
15970
0
    }
15971
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15972
0
    if (isinstance == -1) {
15973
0
        return -1;
15974
0
    }
15975
0
    if (isinstance) {
15976
0
        *out = USub;
15977
0
        return 0;
15978
0
    }
15979
15980
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15981
0
    return -1;
15982
0
}
15983
15984
int
15985
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, const
15986
              char* field, PyArena* arena)
15987
0
{
15988
0
    int isinstance;
15989
15990
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15991
0
    if (isinstance == -1) {
15992
0
        return -1;
15993
0
    }
15994
0
    if (isinstance) {
15995
0
        *out = Eq;
15996
0
        return 0;
15997
0
    }
15998
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
15999
0
    if (isinstance == -1) {
16000
0
        return -1;
16001
0
    }
16002
0
    if (isinstance) {
16003
0
        *out = NotEq;
16004
0
        return 0;
16005
0
    }
16006
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
16007
0
    if (isinstance == -1) {
16008
0
        return -1;
16009
0
    }
16010
0
    if (isinstance) {
16011
0
        *out = Lt;
16012
0
        return 0;
16013
0
    }
16014
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
16015
0
    if (isinstance == -1) {
16016
0
        return -1;
16017
0
    }
16018
0
    if (isinstance) {
16019
0
        *out = LtE;
16020
0
        return 0;
16021
0
    }
16022
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
16023
0
    if (isinstance == -1) {
16024
0
        return -1;
16025
0
    }
16026
0
    if (isinstance) {
16027
0
        *out = Gt;
16028
0
        return 0;
16029
0
    }
16030
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
16031
0
    if (isinstance == -1) {
16032
0
        return -1;
16033
0
    }
16034
0
    if (isinstance) {
16035
0
        *out = GtE;
16036
0
        return 0;
16037
0
    }
16038
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
16039
0
    if (isinstance == -1) {
16040
0
        return -1;
16041
0
    }
16042
0
    if (isinstance) {
16043
0
        *out = Is;
16044
0
        return 0;
16045
0
    }
16046
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
16047
0
    if (isinstance == -1) {
16048
0
        return -1;
16049
0
    }
16050
0
    if (isinstance) {
16051
0
        *out = IsNot;
16052
0
        return 0;
16053
0
    }
16054
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
16055
0
    if (isinstance == -1) {
16056
0
        return -1;
16057
0
    }
16058
0
    if (isinstance) {
16059
0
        *out = In;
16060
0
        return 0;
16061
0
    }
16062
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16063
0
    if (isinstance == -1) {
16064
0
        return -1;
16065
0
    }
16066
0
    if (isinstance) {
16067
0
        *out = NotIn;
16068
0
        return 0;
16069
0
    }
16070
16071
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16072
0
    return -1;
16073
0
}
16074
16075
int
16076
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16077
                      out, const char* field, PyArena* arena)
16078
0
{
16079
0
    PyObject* tmp = NULL;
16080
0
    expr_ty target;
16081
0
    expr_ty iter;
16082
0
    asdl_expr_seq* ifs;
16083
0
    int is_async;
16084
16085
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16086
0
        return -1;
16087
0
    }
16088
0
    if (tmp == NULL) {
16089
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16090
0
        return -1;
16091
0
    }
16092
0
    else {
16093
0
        int res;
16094
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16095
0
            goto failed;
16096
0
        }
16097
0
        res = obj2ast_expr(state, tmp, &target, "target", arena);
16098
0
        _Py_LeaveRecursiveCall();
16099
0
        if (res != 0) goto failed;
16100
0
        Py_CLEAR(tmp);
16101
0
    }
16102
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16103
0
        return -1;
16104
0
    }
16105
0
    if (tmp == NULL) {
16106
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16107
0
        return -1;
16108
0
    }
16109
0
    else {
16110
0
        int res;
16111
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16112
0
            goto failed;
16113
0
        }
16114
0
        res = obj2ast_expr(state, tmp, &iter, "iter", arena);
16115
0
        _Py_LeaveRecursiveCall();
16116
0
        if (res != 0) goto failed;
16117
0
        Py_CLEAR(tmp);
16118
0
    }
16119
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16120
0
        return -1;
16121
0
    }
16122
0
    if (tmp == NULL) {
16123
0
        tmp = PyList_New(0);
16124
0
        if (tmp == NULL) {
16125
0
            return -1;
16126
0
        }
16127
0
    }
16128
0
    {
16129
0
        int res;
16130
0
        Py_ssize_t len;
16131
0
        Py_ssize_t i;
16132
0
        if (!PyList_Check(tmp)) {
16133
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %T", tmp);
16134
0
            goto failed;
16135
0
        }
16136
0
        len = PyList_GET_SIZE(tmp);
16137
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16138
0
        if (ifs == NULL) goto failed;
16139
0
        for (i = 0; i < len; i++) {
16140
0
            expr_ty val;
16141
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16142
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16143
0
                goto failed;
16144
0
            }
16145
0
            res = obj2ast_expr(state, tmp2, &val, "ifs", arena);
16146
0
            _Py_LeaveRecursiveCall();
16147
0
            Py_DECREF(tmp2);
16148
0
            if (res != 0) goto failed;
16149
0
            if (len != PyList_GET_SIZE(tmp)) {
16150
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16151
0
                goto failed;
16152
0
            }
16153
0
            asdl_seq_SET(ifs, i, val);
16154
0
        }
16155
0
        Py_CLEAR(tmp);
16156
0
    }
16157
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16158
0
        return -1;
16159
0
    }
16160
0
    if (tmp == NULL) {
16161
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16162
0
        return -1;
16163
0
    }
16164
0
    else {
16165
0
        int res;
16166
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16167
0
            goto failed;
16168
0
        }
16169
0
        res = obj2ast_int(state, tmp, &is_async, "is_async", arena);
16170
0
        _Py_LeaveRecursiveCall();
16171
0
        if (res != 0) goto failed;
16172
0
        Py_CLEAR(tmp);
16173
0
    }
16174
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16175
0
    if (*out == NULL) goto failed;
16176
0
    return 0;
16177
0
failed:
16178
0
    Py_XDECREF(tmp);
16179
0
    return -1;
16180
0
}
16181
16182
int
16183
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16184
                      out, const char* field, PyArena* arena)
16185
0
{
16186
0
    int isinstance;
16187
16188
0
    PyObject *tmp = NULL;
16189
0
    PyObject *tp;
16190
0
    int lineno;
16191
0
    int col_offset;
16192
0
    int end_lineno;
16193
0
    int end_col_offset;
16194
16195
0
    if (obj == Py_None) {
16196
0
        *out = NULL;
16197
0
        return 0;
16198
0
    }
16199
0
    tp = state->excepthandler_type;
16200
0
    isinstance = PyObject_IsInstance(obj, tp);
16201
0
    if (isinstance == -1) {
16202
0
        return 1;
16203
0
    }
16204
0
    if (!isinstance && field != NULL) {
16205
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'excepthandler', got '%T'", field, obj);
16206
0
        return 1;
16207
0
    }
16208
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16209
0
        return -1;
16210
0
    }
16211
0
    if (tmp == NULL) {
16212
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16213
0
        return -1;
16214
0
    }
16215
0
    else {
16216
0
        int res;
16217
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16218
0
            goto failed;
16219
0
        }
16220
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16221
0
        _Py_LeaveRecursiveCall();
16222
0
        if (res != 0) goto failed;
16223
0
        Py_CLEAR(tmp);
16224
0
    }
16225
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16226
0
        return -1;
16227
0
    }
16228
0
    if (tmp == NULL) {
16229
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16230
0
        return -1;
16231
0
    }
16232
0
    else {
16233
0
        int res;
16234
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16235
0
            goto failed;
16236
0
        }
16237
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
16238
0
        _Py_LeaveRecursiveCall();
16239
0
        if (res != 0) goto failed;
16240
0
        Py_CLEAR(tmp);
16241
0
    }
16242
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16243
0
        return -1;
16244
0
    }
16245
0
    if (tmp == NULL || tmp == Py_None) {
16246
0
        Py_CLEAR(tmp);
16247
0
        end_lineno = lineno;
16248
0
    }
16249
0
    else {
16250
0
        int res;
16251
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16252
0
            goto failed;
16253
0
        }
16254
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16255
0
        _Py_LeaveRecursiveCall();
16256
0
        if (res != 0) goto failed;
16257
0
        Py_CLEAR(tmp);
16258
0
    }
16259
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16260
0
        return -1;
16261
0
    }
16262
0
    if (tmp == NULL || tmp == Py_None) {
16263
0
        Py_CLEAR(tmp);
16264
0
        end_col_offset = col_offset;
16265
0
    }
16266
0
    else {
16267
0
        int res;
16268
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16269
0
            goto failed;
16270
0
        }
16271
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16272
0
        _Py_LeaveRecursiveCall();
16273
0
        if (res != 0) goto failed;
16274
0
        Py_CLEAR(tmp);
16275
0
    }
16276
0
    tp = state->ExceptHandler_type;
16277
0
    isinstance = PyObject_IsInstance(obj, tp);
16278
0
    if (isinstance == -1) {
16279
0
        return -1;
16280
0
    }
16281
0
    if (isinstance) {
16282
0
        expr_ty type;
16283
0
        identifier name;
16284
0
        asdl_stmt_seq* body;
16285
16286
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16287
0
            return -1;
16288
0
        }
16289
0
        if (tmp == NULL || tmp == Py_None) {
16290
0
            Py_CLEAR(tmp);
16291
0
            type = NULL;
16292
0
        }
16293
0
        else {
16294
0
            int res;
16295
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16296
0
                goto failed;
16297
0
            }
16298
0
            res = obj2ast_expr(state, tmp, &type, "type", arena);
16299
0
            _Py_LeaveRecursiveCall();
16300
0
            if (res != 0) goto failed;
16301
0
            Py_CLEAR(tmp);
16302
0
        }
16303
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16304
0
            return -1;
16305
0
        }
16306
0
        if (tmp == NULL || tmp == Py_None) {
16307
0
            Py_CLEAR(tmp);
16308
0
            name = NULL;
16309
0
        }
16310
0
        else {
16311
0
            int res;
16312
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16313
0
                goto failed;
16314
0
            }
16315
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
16316
0
            _Py_LeaveRecursiveCall();
16317
0
            if (res != 0) goto failed;
16318
0
            Py_CLEAR(tmp);
16319
0
        }
16320
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16321
0
            return -1;
16322
0
        }
16323
0
        if (tmp == NULL) {
16324
0
            tmp = PyList_New(0);
16325
0
            if (tmp == NULL) {
16326
0
                return -1;
16327
0
            }
16328
0
        }
16329
0
        {
16330
0
            int res;
16331
0
            Py_ssize_t len;
16332
0
            Py_ssize_t i;
16333
0
            if (!PyList_Check(tmp)) {
16334
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %T", tmp);
16335
0
                goto failed;
16336
0
            }
16337
0
            len = PyList_GET_SIZE(tmp);
16338
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16339
0
            if (body == NULL) goto failed;
16340
0
            for (i = 0; i < len; i++) {
16341
0
                stmt_ty val;
16342
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16343
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16344
0
                    goto failed;
16345
0
                }
16346
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
16347
0
                _Py_LeaveRecursiveCall();
16348
0
                Py_DECREF(tmp2);
16349
0
                if (res != 0) goto failed;
16350
0
                if (len != PyList_GET_SIZE(tmp)) {
16351
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16352
0
                    goto failed;
16353
0
                }
16354
0
                asdl_seq_SET(body, i, val);
16355
0
            }
16356
0
            Py_CLEAR(tmp);
16357
0
        }
16358
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16359
0
                                    end_lineno, end_col_offset, arena);
16360
0
        if (*out == NULL) goto failed;
16361
0
        return 0;
16362
0
    }
16363
16364
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16365
0
    failed:
16366
0
    Py_XDECREF(tmp);
16367
0
    return -1;
16368
0
}
16369
16370
int
16371
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16372
                  const char* field, PyArena* arena)
16373
0
{
16374
0
    PyObject* tmp = NULL;
16375
0
    asdl_arg_seq* posonlyargs;
16376
0
    asdl_arg_seq* args;
16377
0
    arg_ty vararg;
16378
0
    asdl_arg_seq* kwonlyargs;
16379
0
    asdl_expr_seq* kw_defaults;
16380
0
    arg_ty kwarg;
16381
0
    asdl_expr_seq* defaults;
16382
16383
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16384
0
        return -1;
16385
0
    }
16386
0
    if (tmp == NULL) {
16387
0
        tmp = PyList_New(0);
16388
0
        if (tmp == NULL) {
16389
0
            return -1;
16390
0
        }
16391
0
    }
16392
0
    {
16393
0
        int res;
16394
0
        Py_ssize_t len;
16395
0
        Py_ssize_t i;
16396
0
        if (!PyList_Check(tmp)) {
16397
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %T", tmp);
16398
0
            goto failed;
16399
0
        }
16400
0
        len = PyList_GET_SIZE(tmp);
16401
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16402
0
        if (posonlyargs == NULL) goto failed;
16403
0
        for (i = 0; i < len; i++) {
16404
0
            arg_ty val;
16405
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16406
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16407
0
                goto failed;
16408
0
            }
16409
0
            res = obj2ast_arg(state, tmp2, &val, "posonlyargs", arena);
16410
0
            _Py_LeaveRecursiveCall();
16411
0
            Py_DECREF(tmp2);
16412
0
            if (res != 0) goto failed;
16413
0
            if (len != PyList_GET_SIZE(tmp)) {
16414
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16415
0
                goto failed;
16416
0
            }
16417
0
            asdl_seq_SET(posonlyargs, i, val);
16418
0
        }
16419
0
        Py_CLEAR(tmp);
16420
0
    }
16421
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16422
0
        return -1;
16423
0
    }
16424
0
    if (tmp == NULL) {
16425
0
        tmp = PyList_New(0);
16426
0
        if (tmp == NULL) {
16427
0
            return -1;
16428
0
        }
16429
0
    }
16430
0
    {
16431
0
        int res;
16432
0
        Py_ssize_t len;
16433
0
        Py_ssize_t i;
16434
0
        if (!PyList_Check(tmp)) {
16435
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %T", tmp);
16436
0
            goto failed;
16437
0
        }
16438
0
        len = PyList_GET_SIZE(tmp);
16439
0
        args = _Py_asdl_arg_seq_new(len, arena);
16440
0
        if (args == NULL) goto failed;
16441
0
        for (i = 0; i < len; i++) {
16442
0
            arg_ty val;
16443
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16444
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16445
0
                goto failed;
16446
0
            }
16447
0
            res = obj2ast_arg(state, tmp2, &val, "args", arena);
16448
0
            _Py_LeaveRecursiveCall();
16449
0
            Py_DECREF(tmp2);
16450
0
            if (res != 0) goto failed;
16451
0
            if (len != PyList_GET_SIZE(tmp)) {
16452
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16453
0
                goto failed;
16454
0
            }
16455
0
            asdl_seq_SET(args, i, val);
16456
0
        }
16457
0
        Py_CLEAR(tmp);
16458
0
    }
16459
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16460
0
        return -1;
16461
0
    }
16462
0
    if (tmp == NULL || tmp == Py_None) {
16463
0
        Py_CLEAR(tmp);
16464
0
        vararg = NULL;
16465
0
    }
16466
0
    else {
16467
0
        int res;
16468
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16469
0
            goto failed;
16470
0
        }
16471
0
        res = obj2ast_arg(state, tmp, &vararg, "vararg", arena);
16472
0
        _Py_LeaveRecursiveCall();
16473
0
        if (res != 0) goto failed;
16474
0
        Py_CLEAR(tmp);
16475
0
    }
16476
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16477
0
        return -1;
16478
0
    }
16479
0
    if (tmp == NULL) {
16480
0
        tmp = PyList_New(0);
16481
0
        if (tmp == NULL) {
16482
0
            return -1;
16483
0
        }
16484
0
    }
16485
0
    {
16486
0
        int res;
16487
0
        Py_ssize_t len;
16488
0
        Py_ssize_t i;
16489
0
        if (!PyList_Check(tmp)) {
16490
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %T", tmp);
16491
0
            goto failed;
16492
0
        }
16493
0
        len = PyList_GET_SIZE(tmp);
16494
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16495
0
        if (kwonlyargs == NULL) goto failed;
16496
0
        for (i = 0; i < len; i++) {
16497
0
            arg_ty val;
16498
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16499
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16500
0
                goto failed;
16501
0
            }
16502
0
            res = obj2ast_arg(state, tmp2, &val, "kwonlyargs", arena);
16503
0
            _Py_LeaveRecursiveCall();
16504
0
            Py_DECREF(tmp2);
16505
0
            if (res != 0) goto failed;
16506
0
            if (len != PyList_GET_SIZE(tmp)) {
16507
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16508
0
                goto failed;
16509
0
            }
16510
0
            asdl_seq_SET(kwonlyargs, i, val);
16511
0
        }
16512
0
        Py_CLEAR(tmp);
16513
0
    }
16514
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16515
0
        return -1;
16516
0
    }
16517
0
    if (tmp == NULL) {
16518
0
        tmp = PyList_New(0);
16519
0
        if (tmp == NULL) {
16520
0
            return -1;
16521
0
        }
16522
0
    }
16523
0
    {
16524
0
        int res;
16525
0
        Py_ssize_t len;
16526
0
        Py_ssize_t i;
16527
0
        if (!PyList_Check(tmp)) {
16528
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %T", tmp);
16529
0
            goto failed;
16530
0
        }
16531
0
        len = PyList_GET_SIZE(tmp);
16532
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16533
0
        if (kw_defaults == NULL) goto failed;
16534
0
        for (i = 0; i < len; i++) {
16535
0
            expr_ty val;
16536
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16537
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16538
0
                goto failed;
16539
0
            }
16540
0
            res = obj2ast_expr(state, tmp2, &val, "kw_defaults", arena);
16541
0
            _Py_LeaveRecursiveCall();
16542
0
            Py_DECREF(tmp2);
16543
0
            if (res != 0) goto failed;
16544
0
            if (len != PyList_GET_SIZE(tmp)) {
16545
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16546
0
                goto failed;
16547
0
            }
16548
0
            asdl_seq_SET(kw_defaults, i, val);
16549
0
        }
16550
0
        Py_CLEAR(tmp);
16551
0
    }
16552
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16553
0
        return -1;
16554
0
    }
16555
0
    if (tmp == NULL || tmp == Py_None) {
16556
0
        Py_CLEAR(tmp);
16557
0
        kwarg = NULL;
16558
0
    }
16559
0
    else {
16560
0
        int res;
16561
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16562
0
            goto failed;
16563
0
        }
16564
0
        res = obj2ast_arg(state, tmp, &kwarg, "kwarg", arena);
16565
0
        _Py_LeaveRecursiveCall();
16566
0
        if (res != 0) goto failed;
16567
0
        Py_CLEAR(tmp);
16568
0
    }
16569
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16570
0
        return -1;
16571
0
    }
16572
0
    if (tmp == NULL) {
16573
0
        tmp = PyList_New(0);
16574
0
        if (tmp == NULL) {
16575
0
            return -1;
16576
0
        }
16577
0
    }
16578
0
    {
16579
0
        int res;
16580
0
        Py_ssize_t len;
16581
0
        Py_ssize_t i;
16582
0
        if (!PyList_Check(tmp)) {
16583
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %T", tmp);
16584
0
            goto failed;
16585
0
        }
16586
0
        len = PyList_GET_SIZE(tmp);
16587
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16588
0
        if (defaults == NULL) goto failed;
16589
0
        for (i = 0; i < len; i++) {
16590
0
            expr_ty val;
16591
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16592
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16593
0
                goto failed;
16594
0
            }
16595
0
            res = obj2ast_expr(state, tmp2, &val, "defaults", arena);
16596
0
            _Py_LeaveRecursiveCall();
16597
0
            Py_DECREF(tmp2);
16598
0
            if (res != 0) goto failed;
16599
0
            if (len != PyList_GET_SIZE(tmp)) {
16600
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16601
0
                goto failed;
16602
0
            }
16603
0
            asdl_seq_SET(defaults, i, val);
16604
0
        }
16605
0
        Py_CLEAR(tmp);
16606
0
    }
16607
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16608
0
                            kwarg, defaults, arena);
16609
0
    if (*out == NULL) goto failed;
16610
0
    return 0;
16611
0
failed:
16612
0
    Py_XDECREF(tmp);
16613
0
    return -1;
16614
0
}
16615
16616
int
16617
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, const char*
16618
            field, PyArena* arena)
16619
0
{
16620
0
    PyObject* tmp = NULL;
16621
0
    identifier arg;
16622
0
    expr_ty annotation;
16623
0
    string type_comment;
16624
0
    int lineno;
16625
0
    int col_offset;
16626
0
    int end_lineno;
16627
0
    int end_col_offset;
16628
16629
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16630
0
        return -1;
16631
0
    }
16632
0
    if (tmp == NULL) {
16633
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16634
0
        return -1;
16635
0
    }
16636
0
    else {
16637
0
        int res;
16638
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16639
0
            goto failed;
16640
0
        }
16641
0
        res = obj2ast_identifier(state, tmp, &arg, "arg", arena);
16642
0
        _Py_LeaveRecursiveCall();
16643
0
        if (res != 0) goto failed;
16644
0
        Py_CLEAR(tmp);
16645
0
    }
16646
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16647
0
        return -1;
16648
0
    }
16649
0
    if (tmp == NULL || tmp == Py_None) {
16650
0
        Py_CLEAR(tmp);
16651
0
        annotation = NULL;
16652
0
    }
16653
0
    else {
16654
0
        int res;
16655
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16656
0
            goto failed;
16657
0
        }
16658
0
        res = obj2ast_expr(state, tmp, &annotation, "annotation", arena);
16659
0
        _Py_LeaveRecursiveCall();
16660
0
        if (res != 0) goto failed;
16661
0
        Py_CLEAR(tmp);
16662
0
    }
16663
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16664
0
        return -1;
16665
0
    }
16666
0
    if (tmp == NULL || tmp == Py_None) {
16667
0
        Py_CLEAR(tmp);
16668
0
        type_comment = NULL;
16669
0
    }
16670
0
    else {
16671
0
        int res;
16672
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16673
0
            goto failed;
16674
0
        }
16675
0
        res = obj2ast_string(state, tmp, &type_comment, "type_comment", arena);
16676
0
        _Py_LeaveRecursiveCall();
16677
0
        if (res != 0) goto failed;
16678
0
        Py_CLEAR(tmp);
16679
0
    }
16680
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16681
0
        return -1;
16682
0
    }
16683
0
    if (tmp == NULL) {
16684
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16685
0
        return -1;
16686
0
    }
16687
0
    else {
16688
0
        int res;
16689
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16690
0
            goto failed;
16691
0
        }
16692
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16693
0
        _Py_LeaveRecursiveCall();
16694
0
        if (res != 0) goto failed;
16695
0
        Py_CLEAR(tmp);
16696
0
    }
16697
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16698
0
        return -1;
16699
0
    }
16700
0
    if (tmp == NULL) {
16701
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16702
0
        return -1;
16703
0
    }
16704
0
    else {
16705
0
        int res;
16706
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16707
0
            goto failed;
16708
0
        }
16709
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", 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->end_lineno, &tmp) < 0) {
16715
0
        return -1;
16716
0
    }
16717
0
    if (tmp == NULL || tmp == Py_None) {
16718
0
        Py_CLEAR(tmp);
16719
0
        end_lineno = lineno;
16720
0
    }
16721
0
    else {
16722
0
        int res;
16723
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16724
0
            goto failed;
16725
0
        }
16726
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16727
0
        _Py_LeaveRecursiveCall();
16728
0
        if (res != 0) goto failed;
16729
0
        Py_CLEAR(tmp);
16730
0
    }
16731
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16732
0
        return -1;
16733
0
    }
16734
0
    if (tmp == NULL || tmp == Py_None) {
16735
0
        Py_CLEAR(tmp);
16736
0
        end_col_offset = col_offset;
16737
0
    }
16738
0
    else {
16739
0
        int res;
16740
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16741
0
            goto failed;
16742
0
        }
16743
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16744
0
        _Py_LeaveRecursiveCall();
16745
0
        if (res != 0) goto failed;
16746
0
        Py_CLEAR(tmp);
16747
0
    }
16748
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16749
0
                      end_lineno, end_col_offset, arena);
16750
0
    if (*out == NULL) goto failed;
16751
0
    return 0;
16752
0
failed:
16753
0
    Py_XDECREF(tmp);
16754
0
    return -1;
16755
0
}
16756
16757
int
16758
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out, const
16759
                char* field, PyArena* arena)
16760
0
{
16761
0
    PyObject* tmp = NULL;
16762
0
    identifier arg;
16763
0
    expr_ty value;
16764
0
    int lineno;
16765
0
    int col_offset;
16766
0
    int end_lineno;
16767
0
    int end_col_offset;
16768
16769
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16770
0
        return -1;
16771
0
    }
16772
0
    if (tmp == NULL || tmp == Py_None) {
16773
0
        Py_CLEAR(tmp);
16774
0
        arg = NULL;
16775
0
    }
16776
0
    else {
16777
0
        int res;
16778
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16779
0
            goto failed;
16780
0
        }
16781
0
        res = obj2ast_identifier(state, tmp, &arg, "arg", arena);
16782
0
        _Py_LeaveRecursiveCall();
16783
0
        if (res != 0) goto failed;
16784
0
        Py_CLEAR(tmp);
16785
0
    }
16786
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16787
0
        return -1;
16788
0
    }
16789
0
    if (tmp == NULL) {
16790
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16791
0
        return -1;
16792
0
    }
16793
0
    else {
16794
0
        int res;
16795
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16796
0
            goto failed;
16797
0
        }
16798
0
        res = obj2ast_expr(state, tmp, &value, "value", arena);
16799
0
        _Py_LeaveRecursiveCall();
16800
0
        if (res != 0) goto failed;
16801
0
        Py_CLEAR(tmp);
16802
0
    }
16803
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16804
0
        return -1;
16805
0
    }
16806
0
    if (tmp == NULL) {
16807
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16808
0
        return -1;
16809
0
    }
16810
0
    else {
16811
0
        int res;
16812
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16813
0
            goto failed;
16814
0
        }
16815
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16816
0
        _Py_LeaveRecursiveCall();
16817
0
        if (res != 0) goto failed;
16818
0
        Py_CLEAR(tmp);
16819
0
    }
16820
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16821
0
        return -1;
16822
0
    }
16823
0
    if (tmp == NULL) {
16824
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16825
0
        return -1;
16826
0
    }
16827
0
    else {
16828
0
        int res;
16829
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16830
0
            goto failed;
16831
0
        }
16832
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", 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->end_lineno, &tmp) < 0) {
16838
0
        return -1;
16839
0
    }
16840
0
    if (tmp == NULL || tmp == Py_None) {
16841
0
        Py_CLEAR(tmp);
16842
0
        end_lineno = lineno;
16843
0
    }
16844
0
    else {
16845
0
        int res;
16846
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16847
0
            goto failed;
16848
0
        }
16849
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16850
0
        _Py_LeaveRecursiveCall();
16851
0
        if (res != 0) goto failed;
16852
0
        Py_CLEAR(tmp);
16853
0
    }
16854
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16855
0
        return -1;
16856
0
    }
16857
0
    if (tmp == NULL || tmp == Py_None) {
16858
0
        Py_CLEAR(tmp);
16859
0
        end_col_offset = col_offset;
16860
0
    }
16861
0
    else {
16862
0
        int res;
16863
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16864
0
            goto failed;
16865
0
        }
16866
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16867
0
        _Py_LeaveRecursiveCall();
16868
0
        if (res != 0) goto failed;
16869
0
        Py_CLEAR(tmp);
16870
0
    }
16871
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16872
0
                          end_col_offset, arena);
16873
0
    if (*out == NULL) goto failed;
16874
0
    return 0;
16875
0
failed:
16876
0
    Py_XDECREF(tmp);
16877
0
    return -1;
16878
0
}
16879
16880
int
16881
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, const
16882
              char* field, PyArena* arena)
16883
0
{
16884
0
    PyObject* tmp = NULL;
16885
0
    identifier name;
16886
0
    identifier asname;
16887
0
    int lineno;
16888
0
    int col_offset;
16889
0
    int end_lineno;
16890
0
    int end_col_offset;
16891
16892
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16893
0
        return -1;
16894
0
    }
16895
0
    if (tmp == NULL) {
16896
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16897
0
        return -1;
16898
0
    }
16899
0
    else {
16900
0
        int res;
16901
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16902
0
            goto failed;
16903
0
        }
16904
0
        res = obj2ast_identifier(state, tmp, &name, "name", arena);
16905
0
        _Py_LeaveRecursiveCall();
16906
0
        if (res != 0) goto failed;
16907
0
        Py_CLEAR(tmp);
16908
0
    }
16909
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16910
0
        return -1;
16911
0
    }
16912
0
    if (tmp == NULL || tmp == Py_None) {
16913
0
        Py_CLEAR(tmp);
16914
0
        asname = NULL;
16915
0
    }
16916
0
    else {
16917
0
        int res;
16918
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16919
0
            goto failed;
16920
0
        }
16921
0
        res = obj2ast_identifier(state, tmp, &asname, "asname", arena);
16922
0
        _Py_LeaveRecursiveCall();
16923
0
        if (res != 0) goto failed;
16924
0
        Py_CLEAR(tmp);
16925
0
    }
16926
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16927
0
        return -1;
16928
0
    }
16929
0
    if (tmp == NULL) {
16930
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16931
0
        return -1;
16932
0
    }
16933
0
    else {
16934
0
        int res;
16935
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16936
0
            goto failed;
16937
0
        }
16938
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16939
0
        _Py_LeaveRecursiveCall();
16940
0
        if (res != 0) goto failed;
16941
0
        Py_CLEAR(tmp);
16942
0
    }
16943
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16944
0
        return -1;
16945
0
    }
16946
0
    if (tmp == NULL) {
16947
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16948
0
        return -1;
16949
0
    }
16950
0
    else {
16951
0
        int res;
16952
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16953
0
            goto failed;
16954
0
        }
16955
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
16956
0
        _Py_LeaveRecursiveCall();
16957
0
        if (res != 0) goto failed;
16958
0
        Py_CLEAR(tmp);
16959
0
    }
16960
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16961
0
        return -1;
16962
0
    }
16963
0
    if (tmp == NULL || tmp == Py_None) {
16964
0
        Py_CLEAR(tmp);
16965
0
        end_lineno = lineno;
16966
0
    }
16967
0
    else {
16968
0
        int res;
16969
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16970
0
            goto failed;
16971
0
        }
16972
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16973
0
        _Py_LeaveRecursiveCall();
16974
0
        if (res != 0) goto failed;
16975
0
        Py_CLEAR(tmp);
16976
0
    }
16977
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16978
0
        return -1;
16979
0
    }
16980
0
    if (tmp == NULL || tmp == Py_None) {
16981
0
        Py_CLEAR(tmp);
16982
0
        end_col_offset = col_offset;
16983
0
    }
16984
0
    else {
16985
0
        int res;
16986
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16987
0
            goto failed;
16988
0
        }
16989
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16990
0
        _Py_LeaveRecursiveCall();
16991
0
        if (res != 0) goto failed;
16992
0
        Py_CLEAR(tmp);
16993
0
    }
16994
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16995
0
                        end_col_offset, arena);
16996
0
    if (*out == NULL) goto failed;
16997
0
    return 0;
16998
0
failed:
16999
0
    Py_XDECREF(tmp);
17000
0
    return -1;
17001
0
}
17002
17003
int
17004
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
17005
                 const char* field, PyArena* arena)
17006
0
{
17007
0
    PyObject* tmp = NULL;
17008
0
    expr_ty context_expr;
17009
0
    expr_ty optional_vars;
17010
17011
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
17012
0
        return -1;
17013
0
    }
17014
0
    if (tmp == NULL) {
17015
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
17016
0
        return -1;
17017
0
    }
17018
0
    else {
17019
0
        int res;
17020
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
17021
0
            goto failed;
17022
0
        }
17023
0
        res = obj2ast_expr(state, tmp, &context_expr, "context_expr", arena);
17024
0
        _Py_LeaveRecursiveCall();
17025
0
        if (res != 0) goto failed;
17026
0
        Py_CLEAR(tmp);
17027
0
    }
17028
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
17029
0
        return -1;
17030
0
    }
17031
0
    if (tmp == NULL || tmp == Py_None) {
17032
0
        Py_CLEAR(tmp);
17033
0
        optional_vars = NULL;
17034
0
    }
17035
0
    else {
17036
0
        int res;
17037
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
17038
0
            goto failed;
17039
0
        }
17040
0
        res = obj2ast_expr(state, tmp, &optional_vars, "optional_vars", arena);
17041
0
        _Py_LeaveRecursiveCall();
17042
0
        if (res != 0) goto failed;
17043
0
        Py_CLEAR(tmp);
17044
0
    }
17045
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
17046
0
    if (*out == NULL) goto failed;
17047
0
    return 0;
17048
0
failed:
17049
0
    Py_XDECREF(tmp);
17050
0
    return -1;
17051
0
}
17052
17053
int
17054
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
17055
                   const char* field, PyArena* arena)
17056
0
{
17057
0
    PyObject* tmp = NULL;
17058
0
    pattern_ty pattern;
17059
0
    expr_ty guard;
17060
0
    asdl_stmt_seq* body;
17061
17062
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17063
0
        return -1;
17064
0
    }
17065
0
    if (tmp == NULL) {
17066
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
17067
0
        return -1;
17068
0
    }
17069
0
    else {
17070
0
        int res;
17071
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17072
0
            goto failed;
17073
0
        }
17074
0
        res = obj2ast_pattern(state, tmp, &pattern, "pattern", arena);
17075
0
        _Py_LeaveRecursiveCall();
17076
0
        if (res != 0) goto failed;
17077
0
        Py_CLEAR(tmp);
17078
0
    }
17079
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17080
0
        return -1;
17081
0
    }
17082
0
    if (tmp == NULL || tmp == Py_None) {
17083
0
        Py_CLEAR(tmp);
17084
0
        guard = NULL;
17085
0
    }
17086
0
    else {
17087
0
        int res;
17088
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17089
0
            goto failed;
17090
0
        }
17091
0
        res = obj2ast_expr(state, tmp, &guard, "guard", arena);
17092
0
        _Py_LeaveRecursiveCall();
17093
0
        if (res != 0) goto failed;
17094
0
        Py_CLEAR(tmp);
17095
0
    }
17096
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17097
0
        return -1;
17098
0
    }
17099
0
    if (tmp == NULL) {
17100
0
        tmp = PyList_New(0);
17101
0
        if (tmp == NULL) {
17102
0
            return -1;
17103
0
        }
17104
0
    }
17105
0
    {
17106
0
        int res;
17107
0
        Py_ssize_t len;
17108
0
        Py_ssize_t i;
17109
0
        if (!PyList_Check(tmp)) {
17110
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %T", tmp);
17111
0
            goto failed;
17112
0
        }
17113
0
        len = PyList_GET_SIZE(tmp);
17114
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17115
0
        if (body == NULL) goto failed;
17116
0
        for (i = 0; i < len; i++) {
17117
0
            stmt_ty val;
17118
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17119
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17120
0
                goto failed;
17121
0
            }
17122
0
            res = obj2ast_stmt(state, tmp2, &val, "body", arena);
17123
0
            _Py_LeaveRecursiveCall();
17124
0
            Py_DECREF(tmp2);
17125
0
            if (res != 0) goto failed;
17126
0
            if (len != PyList_GET_SIZE(tmp)) {
17127
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17128
0
                goto failed;
17129
0
            }
17130
0
            asdl_seq_SET(body, i, val);
17131
0
        }
17132
0
        Py_CLEAR(tmp);
17133
0
    }
17134
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17135
0
    if (*out == NULL) goto failed;
17136
0
    return 0;
17137
0
failed:
17138
0
    Py_XDECREF(tmp);
17139
0
    return -1;
17140
0
}
17141
17142
int
17143
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out, const
17144
                char* field, PyArena* arena)
17145
0
{
17146
0
    int isinstance;
17147
17148
0
    PyObject *tmp = NULL;
17149
0
    PyObject *tp;
17150
0
    int lineno;
17151
0
    int col_offset;
17152
0
    int end_lineno;
17153
0
    int end_col_offset;
17154
17155
0
    if (obj == Py_None) {
17156
0
        *out = NULL;
17157
0
        return 0;
17158
0
    }
17159
0
    tp = state->pattern_type;
17160
0
    isinstance = PyObject_IsInstance(obj, tp);
17161
0
    if (isinstance == -1) {
17162
0
        return 1;
17163
0
    }
17164
0
    if (!isinstance && field != NULL) {
17165
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'pattern', got '%T'", field, obj);
17166
0
        return 1;
17167
0
    }
17168
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17169
0
        return -1;
17170
0
    }
17171
0
    if (tmp == NULL) {
17172
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17173
0
        return -1;
17174
0
    }
17175
0
    else {
17176
0
        int res;
17177
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17178
0
            goto failed;
17179
0
        }
17180
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
17181
0
        _Py_LeaveRecursiveCall();
17182
0
        if (res != 0) goto failed;
17183
0
        Py_CLEAR(tmp);
17184
0
    }
17185
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17186
0
        return -1;
17187
0
    }
17188
0
    if (tmp == NULL) {
17189
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17190
0
        return -1;
17191
0
    }
17192
0
    else {
17193
0
        int res;
17194
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17195
0
            goto failed;
17196
0
        }
17197
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
17198
0
        _Py_LeaveRecursiveCall();
17199
0
        if (res != 0) goto failed;
17200
0
        Py_CLEAR(tmp);
17201
0
    }
17202
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17203
0
        return -1;
17204
0
    }
17205
0
    if (tmp == NULL) {
17206
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17207
0
        return -1;
17208
0
    }
17209
0
    else {
17210
0
        int res;
17211
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17212
0
            goto failed;
17213
0
        }
17214
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
17215
0
        _Py_LeaveRecursiveCall();
17216
0
        if (res != 0) goto failed;
17217
0
        Py_CLEAR(tmp);
17218
0
    }
17219
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17220
0
        return -1;
17221
0
    }
17222
0
    if (tmp == NULL) {
17223
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17224
0
        return -1;
17225
0
    }
17226
0
    else {
17227
0
        int res;
17228
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17229
0
            goto failed;
17230
0
        }
17231
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
17232
0
        _Py_LeaveRecursiveCall();
17233
0
        if (res != 0) goto failed;
17234
0
        Py_CLEAR(tmp);
17235
0
    }
17236
0
    tp = state->MatchValue_type;
17237
0
    isinstance = PyObject_IsInstance(obj, tp);
17238
0
    if (isinstance == -1) {
17239
0
        return -1;
17240
0
    }
17241
0
    if (isinstance) {
17242
0
        expr_ty value;
17243
17244
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17245
0
            return -1;
17246
0
        }
17247
0
        if (tmp == NULL) {
17248
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17249
0
            return -1;
17250
0
        }
17251
0
        else {
17252
0
            int res;
17253
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17254
0
                goto failed;
17255
0
            }
17256
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
17257
0
            _Py_LeaveRecursiveCall();
17258
0
            if (res != 0) goto failed;
17259
0
            Py_CLEAR(tmp);
17260
0
        }
17261
0
        *out = _PyAST_MatchValue(value, 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->MatchSingleton_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
        constant value;
17273
17274
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17275
0
            return -1;
17276
0
        }
17277
0
        if (tmp == NULL) {
17278
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17279
0
            return -1;
17280
0
        }
17281
0
        else {
17282
0
            int res;
17283
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17284
0
                goto failed;
17285
0
            }
17286
0
            res = obj2ast_constant(state, tmp, &value, "value", arena);
17287
0
            _Py_LeaveRecursiveCall();
17288
0
            if (res != 0) goto failed;
17289
0
            Py_CLEAR(tmp);
17290
0
        }
17291
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17292
0
                                     end_col_offset, arena);
17293
0
        if (*out == NULL) goto failed;
17294
0
        return 0;
17295
0
    }
17296
0
    tp = state->MatchSequence_type;
17297
0
    isinstance = PyObject_IsInstance(obj, tp);
17298
0
    if (isinstance == -1) {
17299
0
        return -1;
17300
0
    }
17301
0
    if (isinstance) {
17302
0
        asdl_pattern_seq* patterns;
17303
17304
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17305
0
            return -1;
17306
0
        }
17307
0
        if (tmp == NULL) {
17308
0
            tmp = PyList_New(0);
17309
0
            if (tmp == NULL) {
17310
0
                return -1;
17311
0
            }
17312
0
        }
17313
0
        {
17314
0
            int res;
17315
0
            Py_ssize_t len;
17316
0
            Py_ssize_t i;
17317
0
            if (!PyList_Check(tmp)) {
17318
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %T", tmp);
17319
0
                goto failed;
17320
0
            }
17321
0
            len = PyList_GET_SIZE(tmp);
17322
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17323
0
            if (patterns == NULL) goto failed;
17324
0
            for (i = 0; i < len; i++) {
17325
0
                pattern_ty val;
17326
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17327
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17328
0
                    goto failed;
17329
0
                }
17330
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17331
0
                _Py_LeaveRecursiveCall();
17332
0
                Py_DECREF(tmp2);
17333
0
                if (res != 0) goto failed;
17334
0
                if (len != PyList_GET_SIZE(tmp)) {
17335
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17336
0
                    goto failed;
17337
0
                }
17338
0
                asdl_seq_SET(patterns, i, val);
17339
0
            }
17340
0
            Py_CLEAR(tmp);
17341
0
        }
17342
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17343
0
                                    end_col_offset, arena);
17344
0
        if (*out == NULL) goto failed;
17345
0
        return 0;
17346
0
    }
17347
0
    tp = state->MatchMapping_type;
17348
0
    isinstance = PyObject_IsInstance(obj, tp);
17349
0
    if (isinstance == -1) {
17350
0
        return -1;
17351
0
    }
17352
0
    if (isinstance) {
17353
0
        asdl_expr_seq* keys;
17354
0
        asdl_pattern_seq* patterns;
17355
0
        identifier rest;
17356
17357
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17358
0
            return -1;
17359
0
        }
17360
0
        if (tmp == NULL) {
17361
0
            tmp = PyList_New(0);
17362
0
            if (tmp == NULL) {
17363
0
                return -1;
17364
0
            }
17365
0
        }
17366
0
        {
17367
0
            int res;
17368
0
            Py_ssize_t len;
17369
0
            Py_ssize_t i;
17370
0
            if (!PyList_Check(tmp)) {
17371
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %T", tmp);
17372
0
                goto failed;
17373
0
            }
17374
0
            len = PyList_GET_SIZE(tmp);
17375
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17376
0
            if (keys == NULL) goto failed;
17377
0
            for (i = 0; i < len; i++) {
17378
0
                expr_ty val;
17379
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17380
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17381
0
                    goto failed;
17382
0
                }
17383
0
                res = obj2ast_expr(state, tmp2, &val, "keys", arena);
17384
0
                _Py_LeaveRecursiveCall();
17385
0
                Py_DECREF(tmp2);
17386
0
                if (res != 0) goto failed;
17387
0
                if (len != PyList_GET_SIZE(tmp)) {
17388
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17389
0
                    goto failed;
17390
0
                }
17391
0
                asdl_seq_SET(keys, i, val);
17392
0
            }
17393
0
            Py_CLEAR(tmp);
17394
0
        }
17395
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17396
0
            return -1;
17397
0
        }
17398
0
        if (tmp == NULL) {
17399
0
            tmp = PyList_New(0);
17400
0
            if (tmp == NULL) {
17401
0
                return -1;
17402
0
            }
17403
0
        }
17404
0
        {
17405
0
            int res;
17406
0
            Py_ssize_t len;
17407
0
            Py_ssize_t i;
17408
0
            if (!PyList_Check(tmp)) {
17409
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %T", tmp);
17410
0
                goto failed;
17411
0
            }
17412
0
            len = PyList_GET_SIZE(tmp);
17413
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17414
0
            if (patterns == NULL) goto failed;
17415
0
            for (i = 0; i < len; i++) {
17416
0
                pattern_ty val;
17417
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17418
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17419
0
                    goto failed;
17420
0
                }
17421
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17422
0
                _Py_LeaveRecursiveCall();
17423
0
                Py_DECREF(tmp2);
17424
0
                if (res != 0) goto failed;
17425
0
                if (len != PyList_GET_SIZE(tmp)) {
17426
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17427
0
                    goto failed;
17428
0
                }
17429
0
                asdl_seq_SET(patterns, i, val);
17430
0
            }
17431
0
            Py_CLEAR(tmp);
17432
0
        }
17433
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17434
0
            return -1;
17435
0
        }
17436
0
        if (tmp == NULL || tmp == Py_None) {
17437
0
            Py_CLEAR(tmp);
17438
0
            rest = NULL;
17439
0
        }
17440
0
        else {
17441
0
            int res;
17442
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17443
0
                goto failed;
17444
0
            }
17445
0
            res = obj2ast_identifier(state, tmp, &rest, "rest", arena);
17446
0
            _Py_LeaveRecursiveCall();
17447
0
            if (res != 0) goto failed;
17448
0
            Py_CLEAR(tmp);
17449
0
        }
17450
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17451
0
                                   end_lineno, end_col_offset, arena);
17452
0
        if (*out == NULL) goto failed;
17453
0
        return 0;
17454
0
    }
17455
0
    tp = state->MatchClass_type;
17456
0
    isinstance = PyObject_IsInstance(obj, tp);
17457
0
    if (isinstance == -1) {
17458
0
        return -1;
17459
0
    }
17460
0
    if (isinstance) {
17461
0
        expr_ty cls;
17462
0
        asdl_pattern_seq* patterns;
17463
0
        asdl_identifier_seq* kwd_attrs;
17464
0
        asdl_pattern_seq* kwd_patterns;
17465
17466
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17467
0
            return -1;
17468
0
        }
17469
0
        if (tmp == NULL) {
17470
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17471
0
            return -1;
17472
0
        }
17473
0
        else {
17474
0
            int res;
17475
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17476
0
                goto failed;
17477
0
            }
17478
0
            res = obj2ast_expr(state, tmp, &cls, "cls", arena);
17479
0
            _Py_LeaveRecursiveCall();
17480
0
            if (res != 0) goto failed;
17481
0
            Py_CLEAR(tmp);
17482
0
        }
17483
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17484
0
            return -1;
17485
0
        }
17486
0
        if (tmp == NULL) {
17487
0
            tmp = PyList_New(0);
17488
0
            if (tmp == NULL) {
17489
0
                return -1;
17490
0
            }
17491
0
        }
17492
0
        {
17493
0
            int res;
17494
0
            Py_ssize_t len;
17495
0
            Py_ssize_t i;
17496
0
            if (!PyList_Check(tmp)) {
17497
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %T", tmp);
17498
0
                goto failed;
17499
0
            }
17500
0
            len = PyList_GET_SIZE(tmp);
17501
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17502
0
            if (patterns == NULL) goto failed;
17503
0
            for (i = 0; i < len; i++) {
17504
0
                pattern_ty val;
17505
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17506
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17507
0
                    goto failed;
17508
0
                }
17509
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17510
0
                _Py_LeaveRecursiveCall();
17511
0
                Py_DECREF(tmp2);
17512
0
                if (res != 0) goto failed;
17513
0
                if (len != PyList_GET_SIZE(tmp)) {
17514
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17515
0
                    goto failed;
17516
0
                }
17517
0
                asdl_seq_SET(patterns, i, val);
17518
0
            }
17519
0
            Py_CLEAR(tmp);
17520
0
        }
17521
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17522
0
            return -1;
17523
0
        }
17524
0
        if (tmp == NULL) {
17525
0
            tmp = PyList_New(0);
17526
0
            if (tmp == NULL) {
17527
0
                return -1;
17528
0
            }
17529
0
        }
17530
0
        {
17531
0
            int res;
17532
0
            Py_ssize_t len;
17533
0
            Py_ssize_t i;
17534
0
            if (!PyList_Check(tmp)) {
17535
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %T", tmp);
17536
0
                goto failed;
17537
0
            }
17538
0
            len = PyList_GET_SIZE(tmp);
17539
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17540
0
            if (kwd_attrs == NULL) goto failed;
17541
0
            for (i = 0; i < len; i++) {
17542
0
                identifier val;
17543
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17544
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17545
0
                    goto failed;
17546
0
                }
17547
0
                res = obj2ast_identifier(state, tmp2, &val, "kwd_attrs", arena);
17548
0
                _Py_LeaveRecursiveCall();
17549
0
                Py_DECREF(tmp2);
17550
0
                if (res != 0) goto failed;
17551
0
                if (len != PyList_GET_SIZE(tmp)) {
17552
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17553
0
                    goto failed;
17554
0
                }
17555
0
                asdl_seq_SET(kwd_attrs, i, val);
17556
0
            }
17557
0
            Py_CLEAR(tmp);
17558
0
        }
17559
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17560
0
            return -1;
17561
0
        }
17562
0
        if (tmp == NULL) {
17563
0
            tmp = PyList_New(0);
17564
0
            if (tmp == NULL) {
17565
0
                return -1;
17566
0
            }
17567
0
        }
17568
0
        {
17569
0
            int res;
17570
0
            Py_ssize_t len;
17571
0
            Py_ssize_t i;
17572
0
            if (!PyList_Check(tmp)) {
17573
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %T", tmp);
17574
0
                goto failed;
17575
0
            }
17576
0
            len = PyList_GET_SIZE(tmp);
17577
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17578
0
            if (kwd_patterns == NULL) goto failed;
17579
0
            for (i = 0; i < len; i++) {
17580
0
                pattern_ty val;
17581
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17582
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17583
0
                    goto failed;
17584
0
                }
17585
0
                res = obj2ast_pattern(state, tmp2, &val, "kwd_patterns", arena);
17586
0
                _Py_LeaveRecursiveCall();
17587
0
                Py_DECREF(tmp2);
17588
0
                if (res != 0) goto failed;
17589
0
                if (len != PyList_GET_SIZE(tmp)) {
17590
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17591
0
                    goto failed;
17592
0
                }
17593
0
                asdl_seq_SET(kwd_patterns, i, val);
17594
0
            }
17595
0
            Py_CLEAR(tmp);
17596
0
        }
17597
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17598
0
                                 lineno, col_offset, end_lineno,
17599
0
                                 end_col_offset, arena);
17600
0
        if (*out == NULL) goto failed;
17601
0
        return 0;
17602
0
    }
17603
0
    tp = state->MatchStar_type;
17604
0
    isinstance = PyObject_IsInstance(obj, tp);
17605
0
    if (isinstance == -1) {
17606
0
        return -1;
17607
0
    }
17608
0
    if (isinstance) {
17609
0
        identifier name;
17610
17611
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17612
0
            return -1;
17613
0
        }
17614
0
        if (tmp == NULL || tmp == Py_None) {
17615
0
            Py_CLEAR(tmp);
17616
0
            name = NULL;
17617
0
        }
17618
0
        else {
17619
0
            int res;
17620
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17621
0
                goto failed;
17622
0
            }
17623
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17624
0
            _Py_LeaveRecursiveCall();
17625
0
            if (res != 0) goto failed;
17626
0
            Py_CLEAR(tmp);
17627
0
        }
17628
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17629
0
                                end_col_offset, arena);
17630
0
        if (*out == NULL) goto failed;
17631
0
        return 0;
17632
0
    }
17633
0
    tp = state->MatchAs_type;
17634
0
    isinstance = PyObject_IsInstance(obj, tp);
17635
0
    if (isinstance == -1) {
17636
0
        return -1;
17637
0
    }
17638
0
    if (isinstance) {
17639
0
        pattern_ty pattern;
17640
0
        identifier name;
17641
17642
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17643
0
            return -1;
17644
0
        }
17645
0
        if (tmp == NULL || tmp == Py_None) {
17646
0
            Py_CLEAR(tmp);
17647
0
            pattern = NULL;
17648
0
        }
17649
0
        else {
17650
0
            int res;
17651
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17652
0
                goto failed;
17653
0
            }
17654
0
            res = obj2ast_pattern(state, tmp, &pattern, "pattern", arena);
17655
0
            _Py_LeaveRecursiveCall();
17656
0
            if (res != 0) goto failed;
17657
0
            Py_CLEAR(tmp);
17658
0
        }
17659
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17660
0
            return -1;
17661
0
        }
17662
0
        if (tmp == NULL || tmp == Py_None) {
17663
0
            Py_CLEAR(tmp);
17664
0
            name = NULL;
17665
0
        }
17666
0
        else {
17667
0
            int res;
17668
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17669
0
                goto failed;
17670
0
            }
17671
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17672
0
            _Py_LeaveRecursiveCall();
17673
0
            if (res != 0) goto failed;
17674
0
            Py_CLEAR(tmp);
17675
0
        }
17676
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17677
0
                              end_col_offset, arena);
17678
0
        if (*out == NULL) goto failed;
17679
0
        return 0;
17680
0
    }
17681
0
    tp = state->MatchOr_type;
17682
0
    isinstance = PyObject_IsInstance(obj, tp);
17683
0
    if (isinstance == -1) {
17684
0
        return -1;
17685
0
    }
17686
0
    if (isinstance) {
17687
0
        asdl_pattern_seq* patterns;
17688
17689
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17690
0
            return -1;
17691
0
        }
17692
0
        if (tmp == NULL) {
17693
0
            tmp = PyList_New(0);
17694
0
            if (tmp == NULL) {
17695
0
                return -1;
17696
0
            }
17697
0
        }
17698
0
        {
17699
0
            int res;
17700
0
            Py_ssize_t len;
17701
0
            Py_ssize_t i;
17702
0
            if (!PyList_Check(tmp)) {
17703
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %T", tmp);
17704
0
                goto failed;
17705
0
            }
17706
0
            len = PyList_GET_SIZE(tmp);
17707
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17708
0
            if (patterns == NULL) goto failed;
17709
0
            for (i = 0; i < len; i++) {
17710
0
                pattern_ty val;
17711
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17712
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17713
0
                    goto failed;
17714
0
                }
17715
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17716
0
                _Py_LeaveRecursiveCall();
17717
0
                Py_DECREF(tmp2);
17718
0
                if (res != 0) goto failed;
17719
0
                if (len != PyList_GET_SIZE(tmp)) {
17720
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17721
0
                    goto failed;
17722
0
                }
17723
0
                asdl_seq_SET(patterns, i, val);
17724
0
            }
17725
0
            Py_CLEAR(tmp);
17726
0
        }
17727
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17728
0
                              end_col_offset, arena);
17729
0
        if (*out == NULL) goto failed;
17730
0
        return 0;
17731
0
    }
17732
17733
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17734
0
    failed:
17735
0
    Py_XDECREF(tmp);
17736
0
    return -1;
17737
0
}
17738
17739
int
17740
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17741
                    out, const char* field, PyArena* arena)
17742
0
{
17743
0
    int isinstance;
17744
17745
0
    PyObject *tmp = NULL;
17746
0
    PyObject *tp;
17747
17748
0
    if (obj == Py_None) {
17749
0
        *out = NULL;
17750
0
        return 0;
17751
0
    }
17752
0
    tp = state->type_ignore_type;
17753
0
    isinstance = PyObject_IsInstance(obj, tp);
17754
0
    if (isinstance == -1) {
17755
0
        return 1;
17756
0
    }
17757
0
    if (!isinstance && field != NULL) {
17758
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'type_ignore', got '%T'", field, obj);
17759
0
        return 1;
17760
0
    }
17761
0
    tp = state->TypeIgnore_type;
17762
0
    isinstance = PyObject_IsInstance(obj, tp);
17763
0
    if (isinstance == -1) {
17764
0
        return -1;
17765
0
    }
17766
0
    if (isinstance) {
17767
0
        int lineno;
17768
0
        string tag;
17769
17770
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17771
0
            return -1;
17772
0
        }
17773
0
        if (tmp == NULL) {
17774
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17775
0
            return -1;
17776
0
        }
17777
0
        else {
17778
0
            int res;
17779
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17780
0
                goto failed;
17781
0
            }
17782
0
            res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
17783
0
            _Py_LeaveRecursiveCall();
17784
0
            if (res != 0) goto failed;
17785
0
            Py_CLEAR(tmp);
17786
0
        }
17787
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17788
0
            return -1;
17789
0
        }
17790
0
        if (tmp == NULL) {
17791
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17792
0
            return -1;
17793
0
        }
17794
0
        else {
17795
0
            int res;
17796
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17797
0
                goto failed;
17798
0
            }
17799
0
            res = obj2ast_string(state, tmp, &tag, "tag", arena);
17800
0
            _Py_LeaveRecursiveCall();
17801
0
            if (res != 0) goto failed;
17802
0
            Py_CLEAR(tmp);
17803
0
        }
17804
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17805
0
        if (*out == NULL) goto failed;
17806
0
        return 0;
17807
0
    }
17808
17809
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17810
0
    failed:
17811
0
    Py_XDECREF(tmp);
17812
0
    return -1;
17813
0
}
17814
17815
int
17816
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17817
                   const char* field, PyArena* arena)
17818
0
{
17819
0
    int isinstance;
17820
17821
0
    PyObject *tmp = NULL;
17822
0
    PyObject *tp;
17823
0
    int lineno;
17824
0
    int col_offset;
17825
0
    int end_lineno;
17826
0
    int end_col_offset;
17827
17828
0
    if (obj == Py_None) {
17829
0
        *out = NULL;
17830
0
        return 0;
17831
0
    }
17832
0
    tp = state->type_param_type;
17833
0
    isinstance = PyObject_IsInstance(obj, tp);
17834
0
    if (isinstance == -1) {
17835
0
        return 1;
17836
0
    }
17837
0
    if (!isinstance && field != NULL) {
17838
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'type_param', got '%T'", field, obj);
17839
0
        return 1;
17840
0
    }
17841
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17842
0
        return -1;
17843
0
    }
17844
0
    if (tmp == NULL) {
17845
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17846
0
        return -1;
17847
0
    }
17848
0
    else {
17849
0
        int res;
17850
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17851
0
            goto failed;
17852
0
        }
17853
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
17854
0
        _Py_LeaveRecursiveCall();
17855
0
        if (res != 0) goto failed;
17856
0
        Py_CLEAR(tmp);
17857
0
    }
17858
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17859
0
        return -1;
17860
0
    }
17861
0
    if (tmp == NULL) {
17862
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17863
0
        return -1;
17864
0
    }
17865
0
    else {
17866
0
        int res;
17867
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17868
0
            goto failed;
17869
0
        }
17870
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
17871
0
        _Py_LeaveRecursiveCall();
17872
0
        if (res != 0) goto failed;
17873
0
        Py_CLEAR(tmp);
17874
0
    }
17875
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17876
0
        return -1;
17877
0
    }
17878
0
    if (tmp == NULL) {
17879
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17880
0
        return -1;
17881
0
    }
17882
0
    else {
17883
0
        int res;
17884
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17885
0
            goto failed;
17886
0
        }
17887
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
17888
0
        _Py_LeaveRecursiveCall();
17889
0
        if (res != 0) goto failed;
17890
0
        Py_CLEAR(tmp);
17891
0
    }
17892
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17893
0
        return -1;
17894
0
    }
17895
0
    if (tmp == NULL) {
17896
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17897
0
        return -1;
17898
0
    }
17899
0
    else {
17900
0
        int res;
17901
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17902
0
            goto failed;
17903
0
        }
17904
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
17905
0
        _Py_LeaveRecursiveCall();
17906
0
        if (res != 0) goto failed;
17907
0
        Py_CLEAR(tmp);
17908
0
    }
17909
0
    tp = state->TypeVar_type;
17910
0
    isinstance = PyObject_IsInstance(obj, tp);
17911
0
    if (isinstance == -1) {
17912
0
        return -1;
17913
0
    }
17914
0
    if (isinstance) {
17915
0
        identifier name;
17916
0
        expr_ty bound;
17917
0
        expr_ty default_value;
17918
17919
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17920
0
            return -1;
17921
0
        }
17922
0
        if (tmp == NULL) {
17923
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17924
0
            return -1;
17925
0
        }
17926
0
        else {
17927
0
            int res;
17928
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17929
0
                goto failed;
17930
0
            }
17931
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17932
0
            _Py_LeaveRecursiveCall();
17933
0
            if (res != 0) goto failed;
17934
0
            Py_CLEAR(tmp);
17935
0
        }
17936
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17937
0
            return -1;
17938
0
        }
17939
0
        if (tmp == NULL || tmp == Py_None) {
17940
0
            Py_CLEAR(tmp);
17941
0
            bound = NULL;
17942
0
        }
17943
0
        else {
17944
0
            int res;
17945
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17946
0
                goto failed;
17947
0
            }
17948
0
            res = obj2ast_expr(state, tmp, &bound, "bound", arena);
17949
0
            _Py_LeaveRecursiveCall();
17950
0
            if (res != 0) goto failed;
17951
0
            Py_CLEAR(tmp);
17952
0
        }
17953
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17954
0
            return -1;
17955
0
        }
17956
0
        if (tmp == NULL || tmp == Py_None) {
17957
0
            Py_CLEAR(tmp);
17958
0
            default_value = NULL;
17959
0
        }
17960
0
        else {
17961
0
            int res;
17962
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17963
0
                goto failed;
17964
0
            }
17965
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
17966
0
                               arena);
17967
0
            _Py_LeaveRecursiveCall();
17968
0
            if (res != 0) goto failed;
17969
0
            Py_CLEAR(tmp);
17970
0
        }
17971
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17972
0
                              end_lineno, end_col_offset, arena);
17973
0
        if (*out == NULL) goto failed;
17974
0
        return 0;
17975
0
    }
17976
0
    tp = state->ParamSpec_type;
17977
0
    isinstance = PyObject_IsInstance(obj, tp);
17978
0
    if (isinstance == -1) {
17979
0
        return -1;
17980
0
    }
17981
0
    if (isinstance) {
17982
0
        identifier name;
17983
0
        expr_ty default_value;
17984
17985
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17986
0
            return -1;
17987
0
        }
17988
0
        if (tmp == NULL) {
17989
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17990
0
            return -1;
17991
0
        }
17992
0
        else {
17993
0
            int res;
17994
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17995
0
                goto failed;
17996
0
            }
17997
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17998
0
            _Py_LeaveRecursiveCall();
17999
0
            if (res != 0) goto failed;
18000
0
            Py_CLEAR(tmp);
18001
0
        }
18002
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
18003
0
            return -1;
18004
0
        }
18005
0
        if (tmp == NULL || tmp == Py_None) {
18006
0
            Py_CLEAR(tmp);
18007
0
            default_value = NULL;
18008
0
        }
18009
0
        else {
18010
0
            int res;
18011
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
18012
0
                goto failed;
18013
0
            }
18014
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
18015
0
                               arena);
18016
0
            _Py_LeaveRecursiveCall();
18017
0
            if (res != 0) goto failed;
18018
0
            Py_CLEAR(tmp);
18019
0
        }
18020
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
18021
0
                                end_lineno, end_col_offset, arena);
18022
0
        if (*out == NULL) goto failed;
18023
0
        return 0;
18024
0
    }
18025
0
    tp = state->TypeVarTuple_type;
18026
0
    isinstance = PyObject_IsInstance(obj, tp);
18027
0
    if (isinstance == -1) {
18028
0
        return -1;
18029
0
    }
18030
0
    if (isinstance) {
18031
0
        identifier name;
18032
0
        expr_ty default_value;
18033
18034
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
18035
0
            return -1;
18036
0
        }
18037
0
        if (tmp == NULL) {
18038
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
18039
0
            return -1;
18040
0
        }
18041
0
        else {
18042
0
            int res;
18043
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
18044
0
                goto failed;
18045
0
            }
18046
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
18047
0
            _Py_LeaveRecursiveCall();
18048
0
            if (res != 0) goto failed;
18049
0
            Py_CLEAR(tmp);
18050
0
        }
18051
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
18052
0
            return -1;
18053
0
        }
18054
0
        if (tmp == NULL || tmp == Py_None) {
18055
0
            Py_CLEAR(tmp);
18056
0
            default_value = NULL;
18057
0
        }
18058
0
        else {
18059
0
            int res;
18060
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
18061
0
                goto failed;
18062
0
            }
18063
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
18064
0
                               arena);
18065
0
            _Py_LeaveRecursiveCall();
18066
0
            if (res != 0) goto failed;
18067
0
            Py_CLEAR(tmp);
18068
0
        }
18069
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
18070
0
                                   end_lineno, end_col_offset, arena);
18071
0
        if (*out == NULL) goto failed;
18072
0
        return 0;
18073
0
    }
18074
18075
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
18076
0
    failed:
18077
0
    Py_XDECREF(tmp);
18078
0
    return -1;
18079
0
}
18080
18081
18082
/* Helper for checking if a node class is abstract in the tests. */
18083
static PyObject *
18084
0
ast_is_abstract(PyObject *Py_UNUSED(module), PyObject *cls) {
18085
0
    struct ast_state *state = get_ast_state();
18086
0
    if (state == NULL) {
18087
0
        return NULL;
18088
0
    }
18089
0
    int contains = PySet_Contains(state->abstract_types, cls);
18090
0
    if (contains == -1) {
18091
0
        return NULL;
18092
0
    }
18093
0
    else if (contains == 1) {
18094
0
        Py_RETURN_TRUE;
18095
0
    }
18096
0
    Py_RETURN_FALSE;
18097
0
}
18098
18099
static struct PyMethodDef astmodule_methods[] = {
18100
    {"_is_abstract", ast_is_abstract, METH_O, NULL},
18101
    {NULL}  /* Sentinel */
18102
};
18103
18104
static int
18105
astmodule_exec(PyObject *m)
18106
9
{
18107
9
    struct ast_state *state = get_ast_state();
18108
9
    if (state == NULL) {
18109
0
        return -1;
18110
0
    }
18111
9
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
18112
0
        return -1;
18113
0
    }
18114
9
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
18115
0
        return -1;
18116
0
    }
18117
9
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
18118
0
        return -1;
18119
0
    }
18120
9
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
18121
0
        return -1;
18122
0
    }
18123
9
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18124
0
        return -1;
18125
0
    }
18126
9
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18127
0
        return -1;
18128
0
    }
18129
9
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18130
0
        return -1;
18131
0
    }
18132
9
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18133
0
        return -1;
18134
0
    }
18135
9
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18136
0
        return -1;
18137
0
    }
18138
9
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18139
0
        {
18140
0
        return -1;
18141
0
    }
18142
9
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18143
0
        return -1;
18144
0
    }
18145
9
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18146
0
        return -1;
18147
0
    }
18148
9
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18149
9
        state->AsyncFunctionDef_type) < 0) {
18150
0
        return -1;
18151
0
    }
18152
9
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18153
0
        return -1;
18154
0
    }
18155
9
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18156
0
        return -1;
18157
0
    }
18158
9
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18159
0
        return -1;
18160
0
    }
18161
9
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18162
0
        return -1;
18163
0
    }
18164
9
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18165
0
        return -1;
18166
0
    }
18167
9
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18168
0
        return -1;
18169
0
    }
18170
9
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18171
0
        return -1;
18172
0
    }
18173
9
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18174
0
        return -1;
18175
0
    }
18176
9
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18177
0
        return -1;
18178
0
    }
18179
9
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18180
0
        return -1;
18181
0
    }
18182
9
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18183
0
        return -1;
18184
0
    }
18185
9
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18186
0
        return -1;
18187
0
    }
18188
9
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18189
0
        return -1;
18190
0
    }
18191
9
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18192
0
        return -1;
18193
0
    }
18194
9
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18195
0
        return -1;
18196
0
    }
18197
9
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18198
0
        return -1;
18199
0
    }
18200
9
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18201
0
        return -1;
18202
0
    }
18203
9
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18204
0
        return -1;
18205
0
    }
18206
9
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18207
0
        return -1;
18208
0
    }
18209
9
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18210
0
        return -1;
18211
0
    }
18212
9
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18213
0
        return -1;
18214
0
    }
18215
9
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18216
0
        return -1;
18217
0
    }
18218
9
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18219
0
        return -1;
18220
0
    }
18221
9
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18222
0
        return -1;
18223
0
    }
18224
9
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18225
0
        return -1;
18226
0
    }
18227
9
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18228
0
        return -1;
18229
0
    }
18230
9
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18231
0
        return -1;
18232
0
    }
18233
9
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18234
0
        return -1;
18235
0
    }
18236
9
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18237
0
        return -1;
18238
0
    }
18239
9
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18240
0
        return -1;
18241
0
    }
18242
9
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18243
0
        return -1;
18244
0
    }
18245
9
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18246
0
        return -1;
18247
0
    }
18248
9
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18249
0
        return -1;
18250
0
    }
18251
9
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18252
0
        return -1;
18253
0
    }
18254
9
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18255
0
        return -1;
18256
0
    }
18257
9
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18258
0
        return -1;
18259
0
    }
18260
9
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18261
0
        return -1;
18262
0
    }
18263
9
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18264
0
        return -1;
18265
0
    }
18266
9
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18267
0
        {
18268
0
        return -1;
18269
0
    }
18270
9
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18271
0
        return -1;
18272
0
    }
18273
9
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18274
0
        return -1;
18275
0
    }
18276
9
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18277
0
        return -1;
18278
0
    }
18279
9
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18280
0
        return -1;
18281
0
    }
18282
9
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18283
0
        return -1;
18284
0
    }
18285
9
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18286
9
        < 0) {
18287
0
        return -1;
18288
0
    }
18289
9
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18290
9
        0) {
18291
0
        return -1;
18292
0
    }
18293
9
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18294
0
        return -1;
18295
0
    }
18296
9
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18297
0
        return -1;
18298
0
    }
18299
9
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18300
0
        return -1;
18301
0
    }
18302
9
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18303
0
        return -1;
18304
0
    }
18305
9
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18306
0
        return -1;
18307
0
    }
18308
9
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18309
0
        return -1;
18310
0
    }
18311
9
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18312
0
        return -1;
18313
0
    }
18314
9
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18315
0
        return -1;
18316
0
    }
18317
9
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18318
0
        return -1;
18319
0
    }
18320
9
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18321
0
        return -1;
18322
0
    }
18323
9
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18324
0
        {
18325
0
        return -1;
18326
0
    }
18327
9
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18328
0
        return -1;
18329
0
    }
18330
9
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18331
0
        return -1;
18332
0
    }
18333
9
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18334
0
        return -1;
18335
0
    }
18336
9
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18337
0
        return -1;
18338
0
    }
18339
9
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18340
0
        return -1;
18341
0
    }
18342
9
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18343
0
        return -1;
18344
0
    }
18345
9
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18346
0
        return -1;
18347
0
    }
18348
9
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18349
0
        return -1;
18350
0
    }
18351
9
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18352
0
        return -1;
18353
0
    }
18354
9
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18355
0
        return -1;
18356
0
    }
18357
9
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18358
0
        return -1;
18359
0
    }
18360
9
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18361
0
        return -1;
18362
0
    }
18363
9
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18364
0
        return -1;
18365
0
    }
18366
9
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18367
0
        return -1;
18368
0
    }
18369
9
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18370
0
        return -1;
18371
0
    }
18372
9
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18373
0
        return -1;
18374
0
    }
18375
9
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18376
0
        return -1;
18377
0
    }
18378
9
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18379
0
        return -1;
18380
0
    }
18381
9
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18382
0
        return -1;
18383
0
    }
18384
9
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18385
0
        return -1;
18386
0
    }
18387
9
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18388
0
        return -1;
18389
0
    }
18390
9
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18391
0
        return -1;
18392
0
    }
18393
9
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18394
0
        return -1;
18395
0
    }
18396
9
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18397
0
        return -1;
18398
0
    }
18399
9
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18400
0
        return -1;
18401
0
    }
18402
9
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18403
0
        return -1;
18404
0
    }
18405
9
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18406
0
        return -1;
18407
0
    }
18408
9
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18409
0
        return -1;
18410
0
    }
18411
9
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18412
0
        return -1;
18413
0
    }
18414
9
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18415
0
        return -1;
18416
0
    }
18417
9
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18418
0
        return -1;
18419
0
    }
18420
9
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18421
0
        return -1;
18422
0
    }
18423
9
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18424
0
        return -1;
18425
0
    }
18426
9
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18427
0
        return -1;
18428
0
    }
18429
9
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18430
0
        return -1;
18431
0
    }
18432
9
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18433
0
        return -1;
18434
0
    }
18435
9
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18436
9
        0) {
18437
0
        return -1;
18438
0
    }
18439
9
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18440
9
        0) {
18441
0
        return -1;
18442
0
    }
18443
9
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18444
9
        0) {
18445
0
        return -1;
18446
0
    }
18447
9
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18448
0
        return -1;
18449
0
    }
18450
9
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18451
0
        return -1;
18452
0
    }
18453
9
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18454
0
        return -1;
18455
0
    }
18456
9
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18457
0
        return -1;
18458
0
    }
18459
9
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18460
0
        return -1;
18461
0
    }
18462
9
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18463
0
        return -1;
18464
0
    }
18465
9
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18466
0
        return -1;
18467
0
    }
18468
9
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18469
0
        return -1;
18470
0
    }
18471
9
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18472
9
        < 0) {
18473
0
        return -1;
18474
0
    }
18475
9
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18476
9
        0) {
18477
0
        return -1;
18478
0
    }
18479
9
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18480
0
        {
18481
0
        return -1;
18482
0
    }
18483
9
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18484
0
        return -1;
18485
0
    }
18486
9
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18487
0
        return -1;
18488
0
    }
18489
9
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18490
0
        return -1;
18491
0
    }
18492
9
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18493
0
        return -1;
18494
0
    }
18495
9
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18496
0
        return -1;
18497
0
    }
18498
9
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18499
0
        return -1;
18500
0
    }
18501
9
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18502
0
        return -1;
18503
0
    }
18504
9
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18505
0
        return -1;
18506
0
    }
18507
9
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18508
0
        return -1;
18509
0
    }
18510
9
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18511
0
        {
18512
0
        return -1;
18513
0
    }
18514
9
    return 0;
18515
9
}
18516
18517
static PyModuleDef_Slot astmodule_slots[] = {
18518
    _Py_ABI_SLOT,
18519
    {Py_mod_exec, astmodule_exec},
18520
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18521
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18522
    {0, NULL}
18523
};
18524
18525
static struct PyModuleDef _astmodule = {
18526
    PyModuleDef_HEAD_INIT,
18527
    .m_name = "_ast",
18528
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18529
    .m_size = 0,
18530
    .m_methods = astmodule_methods,
18531
    .m_slots = astmodule_slots
18532
};
18533
18534
PyMODINIT_FUNC
18535
PyInit__ast(void)
18536
9
{
18537
9
    return PyModuleDef_Init(&_astmodule);
18538
9
}
18539
18540
18541
PyObject* PyAST_mod2obj(mod_ty t)
18542
7.01k
{
18543
7.01k
    struct ast_state *state = get_ast_state();
18544
7.01k
    if (state == NULL) {
18545
0
        return NULL;
18546
0
    }
18547
7.01k
    PyObject *result = ast2obj_mod(state, t);
18548
18549
7.01k
    return result;
18550
7.01k
}
18551
18552
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18553
int PyAst_CheckMode(PyObject *ast, int mode)
18554
0
{
18555
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18556
18557
0
    struct ast_state *state = get_ast_state();
18558
0
    if (state == NULL) {
18559
0
        return -1;
18560
0
    }
18561
18562
0
    PyObject *req_type[3];
18563
0
    req_type[0] = state->Module_type;
18564
0
    req_type[1] = state->Expression_type;
18565
0
    req_type[2] = state->Interactive_type;
18566
18567
0
    assert(0 <= mode && mode <= 2);
18568
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18569
0
    if (isinstance == -1) {
18570
0
        return -1;
18571
0
    }
18572
0
    if (!isinstance) {
18573
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %T",
18574
0
                     req_name[mode], ast);
18575
0
        return -1;
18576
0
    }
18577
0
    return 0;
18578
0
}
18579
18580
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18581
0
{
18582
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18583
0
        return NULL;
18584
0
    }
18585
18586
0
    struct ast_state *state = get_ast_state();
18587
0
    if (state == NULL) {
18588
0
        return NULL;
18589
0
    }
18590
18591
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18592
0
        return NULL;
18593
0
    }
18594
18595
0
    mod_ty res = NULL;
18596
0
    if (obj2ast_mod(state, ast, &res, NULL, arena) != 0)
18597
0
        return NULL;
18598
0
    else
18599
0
        return res;
18600
0
}
18601
18602
int PyAST_Check(PyObject* obj)
18603
102k
{
18604
102k
    struct ast_state *state = get_ast_state();
18605
102k
    if (state == NULL) {
18606
0
        return -1;
18607
0
    }
18608
102k
    return PyObject_IsInstance(obj, state->AST_type);
18609
102k
}
18610
18611