Coverage Report

Created: 2026-05-30 06:18

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
106k
{
23
106k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
106k
    struct ast_state *state = &interp->ast;
25
106k
    assert(!state->finalized);
26
106k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
106k
    return state;
30
106k
}
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
17
{
291
17
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
292
17
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
293
17
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
294
17
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
295
17
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
296
17
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
297
17
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
298
17
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
299
17
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
300
17
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
301
17
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
302
17
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
303
17
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
304
17
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
305
17
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
306
17
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
307
17
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
308
17
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
309
17
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
310
17
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
311
17
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
312
17
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
313
17
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
314
17
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
315
17
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
316
17
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
317
17
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
318
17
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
319
17
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
320
17
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
321
17
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
322
17
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
323
17
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
324
17
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
325
17
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
326
17
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
327
17
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
328
17
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
329
17
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
330
17
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
331
17
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
332
17
    if ((state->is_lazy = PyUnicode_InternFromString("is_lazy")) == NULL) return -1;
333
17
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
334
17
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
335
17
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
336
17
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
337
17
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
338
17
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
339
17
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
340
17
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
341
17
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
342
17
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
343
17
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
344
17
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
345
17
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
346
17
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
347
17
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
348
17
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
349
17
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
350
17
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
351
17
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
352
17
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
353
17
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
354
17
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
355
17
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
356
17
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
357
17
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
358
17
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
359
17
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
360
17
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
361
17
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
362
17
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
363
17
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
364
17
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
365
17
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
366
17
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
367
17
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
368
17
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
369
17
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
370
17
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
371
17
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
372
17
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
373
17
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
374
17
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
375
17
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
376
17
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
377
17
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
378
17
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
379
17
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
380
17
    return 0;
381
17
};
382
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
384
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
385
745k
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
994k
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
390
9.65k
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.43k
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
17
{
824
17
    bool cond;
825
17
    PyObject *Module_annotations = PyDict_New();
826
17
    if (!Module_annotations) return 0;
827
17
    {
828
17
        PyObject *type = state->stmt_type;
829
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
830
17
        cond = type != NULL;
831
17
        if (!cond) {
832
0
            Py_DECREF(Module_annotations);
833
0
            return 0;
834
0
        }
835
17
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
836
17
        Py_DECREF(type);
837
17
        if (!cond) {
838
0
            Py_DECREF(Module_annotations);
839
0
            return 0;
840
0
        }
841
17
    }
842
17
    {
843
17
        PyObject *type = state->type_ignore_type;
844
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
845
17
        cond = type != NULL;
846
17
        if (!cond) {
847
0
            Py_DECREF(Module_annotations);
848
0
            return 0;
849
0
        }
850
17
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
851
17
                                    == 0;
852
17
        Py_DECREF(type);
853
17
        if (!cond) {
854
0
            Py_DECREF(Module_annotations);
855
0
            return 0;
856
0
        }
857
17
    }
858
17
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
859
17
                                  Module_annotations) == 0;
860
17
    if (!cond) {
861
0
        Py_DECREF(Module_annotations);
862
0
        return 0;
863
0
    }
864
17
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
865
17
                                  Module_annotations) == 0;
866
17
    if (!cond) {
867
0
        Py_DECREF(Module_annotations);
868
0
        return 0;
869
0
    }
870
17
    Py_DECREF(Module_annotations);
871
17
    PyObject *Interactive_annotations = PyDict_New();
872
17
    if (!Interactive_annotations) return 0;
873
17
    {
874
17
        PyObject *type = state->stmt_type;
875
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
876
17
        cond = type != NULL;
877
17
        if (!cond) {
878
0
            Py_DECREF(Interactive_annotations);
879
0
            return 0;
880
0
        }
881
17
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
882
17
        Py_DECREF(type);
883
17
        if (!cond) {
884
0
            Py_DECREF(Interactive_annotations);
885
0
            return 0;
886
0
        }
887
17
    }
888
17
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
889
17
                                  Interactive_annotations) == 0;
890
17
    if (!cond) {
891
0
        Py_DECREF(Interactive_annotations);
892
0
        return 0;
893
0
    }
894
17
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
895
17
                                  Interactive_annotations) == 0;
896
17
    if (!cond) {
897
0
        Py_DECREF(Interactive_annotations);
898
0
        return 0;
899
0
    }
900
17
    Py_DECREF(Interactive_annotations);
901
17
    PyObject *Expression_annotations = PyDict_New();
902
17
    if (!Expression_annotations) return 0;
903
17
    {
904
17
        PyObject *type = state->expr_type;
905
17
        Py_INCREF(type);
906
17
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
907
17
        Py_DECREF(type);
908
17
        if (!cond) {
909
0
            Py_DECREF(Expression_annotations);
910
0
            return 0;
911
0
        }
912
17
    }
913
17
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
914
17
                                  Expression_annotations) == 0;
915
17
    if (!cond) {
916
0
        Py_DECREF(Expression_annotations);
917
0
        return 0;
918
0
    }
919
17
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
920
17
                                  Expression_annotations) == 0;
921
17
    if (!cond) {
922
0
        Py_DECREF(Expression_annotations);
923
0
        return 0;
924
0
    }
925
17
    Py_DECREF(Expression_annotations);
926
17
    PyObject *FunctionType_annotations = PyDict_New();
927
17
    if (!FunctionType_annotations) return 0;
928
17
    {
929
17
        PyObject *type = state->expr_type;
930
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
931
17
        cond = type != NULL;
932
17
        if (!cond) {
933
0
            Py_DECREF(FunctionType_annotations);
934
0
            return 0;
935
0
        }
936
17
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
937
17
                                    == 0;
938
17
        Py_DECREF(type);
939
17
        if (!cond) {
940
0
            Py_DECREF(FunctionType_annotations);
941
0
            return 0;
942
0
        }
943
17
    }
944
17
    {
945
17
        PyObject *type = state->expr_type;
946
17
        Py_INCREF(type);
947
17
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
948
17
                                    == 0;
949
17
        Py_DECREF(type);
950
17
        if (!cond) {
951
0
            Py_DECREF(FunctionType_annotations);
952
0
            return 0;
953
0
        }
954
17
    }
955
17
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
956
17
                                  FunctionType_annotations) == 0;
957
17
    if (!cond) {
958
0
        Py_DECREF(FunctionType_annotations);
959
0
        return 0;
960
0
    }
961
17
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
962
17
                                  FunctionType_annotations) == 0;
963
17
    if (!cond) {
964
0
        Py_DECREF(FunctionType_annotations);
965
0
        return 0;
966
0
    }
967
17
    Py_DECREF(FunctionType_annotations);
968
17
    PyObject *FunctionDef_annotations = PyDict_New();
969
17
    if (!FunctionDef_annotations) return 0;
970
17
    {
971
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
972
17
        Py_INCREF(type);
973
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
974
17
        Py_DECREF(type);
975
17
        if (!cond) {
976
0
            Py_DECREF(FunctionDef_annotations);
977
0
            return 0;
978
0
        }
979
17
    }
980
17
    {
981
17
        PyObject *type = state->arguments_type;
982
17
        Py_INCREF(type);
983
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
984
17
        Py_DECREF(type);
985
17
        if (!cond) {
986
0
            Py_DECREF(FunctionDef_annotations);
987
0
            return 0;
988
0
        }
989
17
    }
990
17
    {
991
17
        PyObject *type = state->stmt_type;
992
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
993
17
        cond = type != NULL;
994
17
        if (!cond) {
995
0
            Py_DECREF(FunctionDef_annotations);
996
0
            return 0;
997
0
        }
998
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
999
17
        Py_DECREF(type);
1000
17
        if (!cond) {
1001
0
            Py_DECREF(FunctionDef_annotations);
1002
0
            return 0;
1003
0
        }
1004
17
    }
1005
17
    {
1006
17
        PyObject *type = state->expr_type;
1007
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1008
17
        cond = type != NULL;
1009
17
        if (!cond) {
1010
0
            Py_DECREF(FunctionDef_annotations);
1011
0
            return 0;
1012
0
        }
1013
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1014
17
                                    type) == 0;
1015
17
        Py_DECREF(type);
1016
17
        if (!cond) {
1017
0
            Py_DECREF(FunctionDef_annotations);
1018
0
            return 0;
1019
0
        }
1020
17
    }
1021
17
    {
1022
17
        PyObject *type = state->expr_type;
1023
17
        type = _Py_union_type_or(type, Py_None);
1024
17
        cond = type != NULL;
1025
17
        if (!cond) {
1026
0
            Py_DECREF(FunctionDef_annotations);
1027
0
            return 0;
1028
0
        }
1029
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1030
17
                                    == 0;
1031
17
        Py_DECREF(type);
1032
17
        if (!cond) {
1033
0
            Py_DECREF(FunctionDef_annotations);
1034
0
            return 0;
1035
0
        }
1036
17
    }
1037
17
    {
1038
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1039
17
        type = _Py_union_type_or(type, Py_None);
1040
17
        cond = type != NULL;
1041
17
        if (!cond) {
1042
0
            Py_DECREF(FunctionDef_annotations);
1043
0
            return 0;
1044
0
        }
1045
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1046
17
                                    type) == 0;
1047
17
        Py_DECREF(type);
1048
17
        if (!cond) {
1049
0
            Py_DECREF(FunctionDef_annotations);
1050
0
            return 0;
1051
0
        }
1052
17
    }
1053
17
    {
1054
17
        PyObject *type = state->type_param_type;
1055
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1056
17
        cond = type != NULL;
1057
17
        if (!cond) {
1058
0
            Py_DECREF(FunctionDef_annotations);
1059
0
            return 0;
1060
0
        }
1061
17
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1062
17
                                    type) == 0;
1063
17
        Py_DECREF(type);
1064
17
        if (!cond) {
1065
0
            Py_DECREF(FunctionDef_annotations);
1066
0
            return 0;
1067
0
        }
1068
17
    }
1069
17
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1070
17
                                  FunctionDef_annotations) == 0;
1071
17
    if (!cond) {
1072
0
        Py_DECREF(FunctionDef_annotations);
1073
0
        return 0;
1074
0
    }
1075
17
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1076
17
                                  FunctionDef_annotations) == 0;
1077
17
    if (!cond) {
1078
0
        Py_DECREF(FunctionDef_annotations);
1079
0
        return 0;
1080
0
    }
1081
17
    Py_DECREF(FunctionDef_annotations);
1082
17
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1083
17
    if (!AsyncFunctionDef_annotations) return 0;
1084
17
    {
1085
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1086
17
        Py_INCREF(type);
1087
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1088
17
                                    == 0;
1089
17
        Py_DECREF(type);
1090
17
        if (!cond) {
1091
0
            Py_DECREF(AsyncFunctionDef_annotations);
1092
0
            return 0;
1093
0
        }
1094
17
    }
1095
17
    {
1096
17
        PyObject *type = state->arguments_type;
1097
17
        Py_INCREF(type);
1098
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1099
17
                                    == 0;
1100
17
        Py_DECREF(type);
1101
17
        if (!cond) {
1102
0
            Py_DECREF(AsyncFunctionDef_annotations);
1103
0
            return 0;
1104
0
        }
1105
17
    }
1106
17
    {
1107
17
        PyObject *type = state->stmt_type;
1108
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1109
17
        cond = type != NULL;
1110
17
        if (!cond) {
1111
0
            Py_DECREF(AsyncFunctionDef_annotations);
1112
0
            return 0;
1113
0
        }
1114
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1115
17
                                    == 0;
1116
17
        Py_DECREF(type);
1117
17
        if (!cond) {
1118
0
            Py_DECREF(AsyncFunctionDef_annotations);
1119
0
            return 0;
1120
0
        }
1121
17
    }
1122
17
    {
1123
17
        PyObject *type = state->expr_type;
1124
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1125
17
        cond = type != NULL;
1126
17
        if (!cond) {
1127
0
            Py_DECREF(AsyncFunctionDef_annotations);
1128
0
            return 0;
1129
0
        }
1130
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1131
17
                                    "decorator_list", type) == 0;
1132
17
        Py_DECREF(type);
1133
17
        if (!cond) {
1134
0
            Py_DECREF(AsyncFunctionDef_annotations);
1135
0
            return 0;
1136
0
        }
1137
17
    }
1138
17
    {
1139
17
        PyObject *type = state->expr_type;
1140
17
        type = _Py_union_type_or(type, Py_None);
1141
17
        cond = type != NULL;
1142
17
        if (!cond) {
1143
0
            Py_DECREF(AsyncFunctionDef_annotations);
1144
0
            return 0;
1145
0
        }
1146
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1147
17
                                    type) == 0;
1148
17
        Py_DECREF(type);
1149
17
        if (!cond) {
1150
0
            Py_DECREF(AsyncFunctionDef_annotations);
1151
0
            return 0;
1152
0
        }
1153
17
    }
1154
17
    {
1155
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1156
17
        type = _Py_union_type_or(type, Py_None);
1157
17
        cond = type != NULL;
1158
17
        if (!cond) {
1159
0
            Py_DECREF(AsyncFunctionDef_annotations);
1160
0
            return 0;
1161
0
        }
1162
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1163
17
                                    "type_comment", type) == 0;
1164
17
        Py_DECREF(type);
1165
17
        if (!cond) {
1166
0
            Py_DECREF(AsyncFunctionDef_annotations);
1167
0
            return 0;
1168
0
        }
1169
17
    }
1170
17
    {
1171
17
        PyObject *type = state->type_param_type;
1172
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1173
17
        cond = type != NULL;
1174
17
        if (!cond) {
1175
0
            Py_DECREF(AsyncFunctionDef_annotations);
1176
0
            return 0;
1177
0
        }
1178
17
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1179
17
                                    "type_params", type) == 0;
1180
17
        Py_DECREF(type);
1181
17
        if (!cond) {
1182
0
            Py_DECREF(AsyncFunctionDef_annotations);
1183
0
            return 0;
1184
0
        }
1185
17
    }
1186
17
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1187
17
                                  AsyncFunctionDef_annotations) == 0;
1188
17
    if (!cond) {
1189
0
        Py_DECREF(AsyncFunctionDef_annotations);
1190
0
        return 0;
1191
0
    }
1192
17
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1193
17
                                  "__annotations__",
1194
17
                                  AsyncFunctionDef_annotations) == 0;
1195
17
    if (!cond) {
1196
0
        Py_DECREF(AsyncFunctionDef_annotations);
1197
0
        return 0;
1198
0
    }
1199
17
    Py_DECREF(AsyncFunctionDef_annotations);
1200
17
    PyObject *ClassDef_annotations = PyDict_New();
1201
17
    if (!ClassDef_annotations) return 0;
1202
17
    {
1203
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1204
17
        Py_INCREF(type);
1205
17
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1206
17
        Py_DECREF(type);
1207
17
        if (!cond) {
1208
0
            Py_DECREF(ClassDef_annotations);
1209
0
            return 0;
1210
0
        }
1211
17
    }
1212
17
    {
1213
17
        PyObject *type = state->expr_type;
1214
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1215
17
        cond = type != NULL;
1216
17
        if (!cond) {
1217
0
            Py_DECREF(ClassDef_annotations);
1218
0
            return 0;
1219
0
        }
1220
17
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1221
17
        Py_DECREF(type);
1222
17
        if (!cond) {
1223
0
            Py_DECREF(ClassDef_annotations);
1224
0
            return 0;
1225
0
        }
1226
17
    }
1227
17
    {
1228
17
        PyObject *type = state->keyword_type;
1229
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1230
17
        cond = type != NULL;
1231
17
        if (!cond) {
1232
0
            Py_DECREF(ClassDef_annotations);
1233
0
            return 0;
1234
0
        }
1235
17
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1236
17
                                    0;
1237
17
        Py_DECREF(type);
1238
17
        if (!cond) {
1239
0
            Py_DECREF(ClassDef_annotations);
1240
0
            return 0;
1241
0
        }
1242
17
    }
1243
17
    {
1244
17
        PyObject *type = state->stmt_type;
1245
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1246
17
        cond = type != NULL;
1247
17
        if (!cond) {
1248
0
            Py_DECREF(ClassDef_annotations);
1249
0
            return 0;
1250
0
        }
1251
17
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1252
17
        Py_DECREF(type);
1253
17
        if (!cond) {
1254
0
            Py_DECREF(ClassDef_annotations);
1255
0
            return 0;
1256
0
        }
1257
17
    }
1258
17
    {
1259
17
        PyObject *type = state->expr_type;
1260
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1261
17
        cond = type != NULL;
1262
17
        if (!cond) {
1263
0
            Py_DECREF(ClassDef_annotations);
1264
0
            return 0;
1265
0
        }
1266
17
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1267
17
                                    type) == 0;
1268
17
        Py_DECREF(type);
1269
17
        if (!cond) {
1270
0
            Py_DECREF(ClassDef_annotations);
1271
0
            return 0;
1272
0
        }
1273
17
    }
1274
17
    {
1275
17
        PyObject *type = state->type_param_type;
1276
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1277
17
        cond = type != NULL;
1278
17
        if (!cond) {
1279
0
            Py_DECREF(ClassDef_annotations);
1280
0
            return 0;
1281
0
        }
1282
17
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1283
17
                                    == 0;
1284
17
        Py_DECREF(type);
1285
17
        if (!cond) {
1286
0
            Py_DECREF(ClassDef_annotations);
1287
0
            return 0;
1288
0
        }
1289
17
    }
1290
17
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1291
17
                                  ClassDef_annotations) == 0;
1292
17
    if (!cond) {
1293
0
        Py_DECREF(ClassDef_annotations);
1294
0
        return 0;
1295
0
    }
1296
17
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1297
17
                                  ClassDef_annotations) == 0;
1298
17
    if (!cond) {
1299
0
        Py_DECREF(ClassDef_annotations);
1300
0
        return 0;
1301
0
    }
1302
17
    Py_DECREF(ClassDef_annotations);
1303
17
    PyObject *Return_annotations = PyDict_New();
1304
17
    if (!Return_annotations) return 0;
1305
17
    {
1306
17
        PyObject *type = state->expr_type;
1307
17
        type = _Py_union_type_or(type, Py_None);
1308
17
        cond = type != NULL;
1309
17
        if (!cond) {
1310
0
            Py_DECREF(Return_annotations);
1311
0
            return 0;
1312
0
        }
1313
17
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1314
17
        Py_DECREF(type);
1315
17
        if (!cond) {
1316
0
            Py_DECREF(Return_annotations);
1317
0
            return 0;
1318
0
        }
1319
17
    }
1320
17
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1321
17
                                  Return_annotations) == 0;
1322
17
    if (!cond) {
1323
0
        Py_DECREF(Return_annotations);
1324
0
        return 0;
1325
0
    }
1326
17
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1327
17
                                  Return_annotations) == 0;
1328
17
    if (!cond) {
1329
0
        Py_DECREF(Return_annotations);
1330
0
        return 0;
1331
0
    }
1332
17
    Py_DECREF(Return_annotations);
1333
17
    PyObject *Delete_annotations = PyDict_New();
1334
17
    if (!Delete_annotations) return 0;
1335
17
    {
1336
17
        PyObject *type = state->expr_type;
1337
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1338
17
        cond = type != NULL;
1339
17
        if (!cond) {
1340
0
            Py_DECREF(Delete_annotations);
1341
0
            return 0;
1342
0
        }
1343
17
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1344
17
        Py_DECREF(type);
1345
17
        if (!cond) {
1346
0
            Py_DECREF(Delete_annotations);
1347
0
            return 0;
1348
0
        }
1349
17
    }
1350
17
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1351
17
                                  Delete_annotations) == 0;
1352
17
    if (!cond) {
1353
0
        Py_DECREF(Delete_annotations);
1354
0
        return 0;
1355
0
    }
1356
17
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1357
17
                                  Delete_annotations) == 0;
1358
17
    if (!cond) {
1359
0
        Py_DECREF(Delete_annotations);
1360
0
        return 0;
1361
0
    }
1362
17
    Py_DECREF(Delete_annotations);
1363
17
    PyObject *Assign_annotations = PyDict_New();
1364
17
    if (!Assign_annotations) return 0;
1365
17
    {
1366
17
        PyObject *type = state->expr_type;
1367
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1368
17
        cond = type != NULL;
1369
17
        if (!cond) {
1370
0
            Py_DECREF(Assign_annotations);
1371
0
            return 0;
1372
0
        }
1373
17
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1374
17
        Py_DECREF(type);
1375
17
        if (!cond) {
1376
0
            Py_DECREF(Assign_annotations);
1377
0
            return 0;
1378
0
        }
1379
17
    }
1380
17
    {
1381
17
        PyObject *type = state->expr_type;
1382
17
        Py_INCREF(type);
1383
17
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1384
17
        Py_DECREF(type);
1385
17
        if (!cond) {
1386
0
            Py_DECREF(Assign_annotations);
1387
0
            return 0;
1388
0
        }
1389
17
    }
1390
17
    {
1391
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1392
17
        type = _Py_union_type_or(type, Py_None);
1393
17
        cond = type != NULL;
1394
17
        if (!cond) {
1395
0
            Py_DECREF(Assign_annotations);
1396
0
            return 0;
1397
0
        }
1398
17
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1399
17
                                    == 0;
1400
17
        Py_DECREF(type);
1401
17
        if (!cond) {
1402
0
            Py_DECREF(Assign_annotations);
1403
0
            return 0;
1404
0
        }
1405
17
    }
1406
17
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1407
17
                                  Assign_annotations) == 0;
1408
17
    if (!cond) {
1409
0
        Py_DECREF(Assign_annotations);
1410
0
        return 0;
1411
0
    }
1412
17
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1413
17
                                  Assign_annotations) == 0;
1414
17
    if (!cond) {
1415
0
        Py_DECREF(Assign_annotations);
1416
0
        return 0;
1417
0
    }
1418
17
    Py_DECREF(Assign_annotations);
1419
17
    PyObject *TypeAlias_annotations = PyDict_New();
1420
17
    if (!TypeAlias_annotations) return 0;
1421
17
    {
1422
17
        PyObject *type = state->expr_type;
1423
17
        Py_INCREF(type);
1424
17
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1425
17
        Py_DECREF(type);
1426
17
        if (!cond) {
1427
0
            Py_DECREF(TypeAlias_annotations);
1428
0
            return 0;
1429
0
        }
1430
17
    }
1431
17
    {
1432
17
        PyObject *type = state->type_param_type;
1433
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1434
17
        cond = type != NULL;
1435
17
        if (!cond) {
1436
0
            Py_DECREF(TypeAlias_annotations);
1437
0
            return 0;
1438
0
        }
1439
17
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1440
17
                                    == 0;
1441
17
        Py_DECREF(type);
1442
17
        if (!cond) {
1443
0
            Py_DECREF(TypeAlias_annotations);
1444
0
            return 0;
1445
0
        }
1446
17
    }
1447
17
    {
1448
17
        PyObject *type = state->expr_type;
1449
17
        Py_INCREF(type);
1450
17
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1451
17
        Py_DECREF(type);
1452
17
        if (!cond) {
1453
0
            Py_DECREF(TypeAlias_annotations);
1454
0
            return 0;
1455
0
        }
1456
17
    }
1457
17
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1458
17
                                  TypeAlias_annotations) == 0;
1459
17
    if (!cond) {
1460
0
        Py_DECREF(TypeAlias_annotations);
1461
0
        return 0;
1462
0
    }
1463
17
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1464
17
                                  TypeAlias_annotations) == 0;
1465
17
    if (!cond) {
1466
0
        Py_DECREF(TypeAlias_annotations);
1467
0
        return 0;
1468
0
    }
1469
17
    Py_DECREF(TypeAlias_annotations);
1470
17
    PyObject *AugAssign_annotations = PyDict_New();
1471
17
    if (!AugAssign_annotations) return 0;
1472
17
    {
1473
17
        PyObject *type = state->expr_type;
1474
17
        Py_INCREF(type);
1475
17
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1476
17
        Py_DECREF(type);
1477
17
        if (!cond) {
1478
0
            Py_DECREF(AugAssign_annotations);
1479
0
            return 0;
1480
0
        }
1481
17
    }
1482
17
    {
1483
17
        PyObject *type = state->operator_type;
1484
17
        Py_INCREF(type);
1485
17
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1486
17
        Py_DECREF(type);
1487
17
        if (!cond) {
1488
0
            Py_DECREF(AugAssign_annotations);
1489
0
            return 0;
1490
0
        }
1491
17
    }
1492
17
    {
1493
17
        PyObject *type = state->expr_type;
1494
17
        Py_INCREF(type);
1495
17
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1496
17
        Py_DECREF(type);
1497
17
        if (!cond) {
1498
0
            Py_DECREF(AugAssign_annotations);
1499
0
            return 0;
1500
0
        }
1501
17
    }
1502
17
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1503
17
                                  AugAssign_annotations) == 0;
1504
17
    if (!cond) {
1505
0
        Py_DECREF(AugAssign_annotations);
1506
0
        return 0;
1507
0
    }
1508
17
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1509
17
                                  AugAssign_annotations) == 0;
1510
17
    if (!cond) {
1511
0
        Py_DECREF(AugAssign_annotations);
1512
0
        return 0;
1513
0
    }
1514
17
    Py_DECREF(AugAssign_annotations);
1515
17
    PyObject *AnnAssign_annotations = PyDict_New();
1516
17
    if (!AnnAssign_annotations) return 0;
1517
17
    {
1518
17
        PyObject *type = state->expr_type;
1519
17
        Py_INCREF(type);
1520
17
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1521
17
        Py_DECREF(type);
1522
17
        if (!cond) {
1523
0
            Py_DECREF(AnnAssign_annotations);
1524
0
            return 0;
1525
0
        }
1526
17
    }
1527
17
    {
1528
17
        PyObject *type = state->expr_type;
1529
17
        Py_INCREF(type);
1530
17
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1531
17
                                    == 0;
1532
17
        Py_DECREF(type);
1533
17
        if (!cond) {
1534
0
            Py_DECREF(AnnAssign_annotations);
1535
0
            return 0;
1536
0
        }
1537
17
    }
1538
17
    {
1539
17
        PyObject *type = state->expr_type;
1540
17
        type = _Py_union_type_or(type, Py_None);
1541
17
        cond = type != NULL;
1542
17
        if (!cond) {
1543
0
            Py_DECREF(AnnAssign_annotations);
1544
0
            return 0;
1545
0
        }
1546
17
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1547
17
        Py_DECREF(type);
1548
17
        if (!cond) {
1549
0
            Py_DECREF(AnnAssign_annotations);
1550
0
            return 0;
1551
0
        }
1552
17
    }
1553
17
    {
1554
17
        PyObject *type = (PyObject *)&PyLong_Type;
1555
17
        Py_INCREF(type);
1556
17
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1557
17
        Py_DECREF(type);
1558
17
        if (!cond) {
1559
0
            Py_DECREF(AnnAssign_annotations);
1560
0
            return 0;
1561
0
        }
1562
17
    }
1563
17
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1564
17
                                  AnnAssign_annotations) == 0;
1565
17
    if (!cond) {
1566
0
        Py_DECREF(AnnAssign_annotations);
1567
0
        return 0;
1568
0
    }
1569
17
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1570
17
                                  AnnAssign_annotations) == 0;
1571
17
    if (!cond) {
1572
0
        Py_DECREF(AnnAssign_annotations);
1573
0
        return 0;
1574
0
    }
1575
17
    Py_DECREF(AnnAssign_annotations);
1576
17
    PyObject *For_annotations = PyDict_New();
1577
17
    if (!For_annotations) return 0;
1578
17
    {
1579
17
        PyObject *type = state->expr_type;
1580
17
        Py_INCREF(type);
1581
17
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1582
17
        Py_DECREF(type);
1583
17
        if (!cond) {
1584
0
            Py_DECREF(For_annotations);
1585
0
            return 0;
1586
0
        }
1587
17
    }
1588
17
    {
1589
17
        PyObject *type = state->expr_type;
1590
17
        Py_INCREF(type);
1591
17
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1592
17
        Py_DECREF(type);
1593
17
        if (!cond) {
1594
0
            Py_DECREF(For_annotations);
1595
0
            return 0;
1596
0
        }
1597
17
    }
1598
17
    {
1599
17
        PyObject *type = state->stmt_type;
1600
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1601
17
        cond = type != NULL;
1602
17
        if (!cond) {
1603
0
            Py_DECREF(For_annotations);
1604
0
            return 0;
1605
0
        }
1606
17
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1607
17
        Py_DECREF(type);
1608
17
        if (!cond) {
1609
0
            Py_DECREF(For_annotations);
1610
0
            return 0;
1611
0
        }
1612
17
    }
1613
17
    {
1614
17
        PyObject *type = state->stmt_type;
1615
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1616
17
        cond = type != NULL;
1617
17
        if (!cond) {
1618
0
            Py_DECREF(For_annotations);
1619
0
            return 0;
1620
0
        }
1621
17
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1622
17
        Py_DECREF(type);
1623
17
        if (!cond) {
1624
0
            Py_DECREF(For_annotations);
1625
0
            return 0;
1626
0
        }
1627
17
    }
1628
17
    {
1629
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1630
17
        type = _Py_union_type_or(type, Py_None);
1631
17
        cond = type != NULL;
1632
17
        if (!cond) {
1633
0
            Py_DECREF(For_annotations);
1634
0
            return 0;
1635
0
        }
1636
17
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1637
17
        Py_DECREF(type);
1638
17
        if (!cond) {
1639
0
            Py_DECREF(For_annotations);
1640
0
            return 0;
1641
0
        }
1642
17
    }
1643
17
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1644
17
                                  For_annotations) == 0;
1645
17
    if (!cond) {
1646
0
        Py_DECREF(For_annotations);
1647
0
        return 0;
1648
0
    }
1649
17
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1650
17
                                  For_annotations) == 0;
1651
17
    if (!cond) {
1652
0
        Py_DECREF(For_annotations);
1653
0
        return 0;
1654
0
    }
1655
17
    Py_DECREF(For_annotations);
1656
17
    PyObject *AsyncFor_annotations = PyDict_New();
1657
17
    if (!AsyncFor_annotations) return 0;
1658
17
    {
1659
17
        PyObject *type = state->expr_type;
1660
17
        Py_INCREF(type);
1661
17
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1662
17
        Py_DECREF(type);
1663
17
        if (!cond) {
1664
0
            Py_DECREF(AsyncFor_annotations);
1665
0
            return 0;
1666
0
        }
1667
17
    }
1668
17
    {
1669
17
        PyObject *type = state->expr_type;
1670
17
        Py_INCREF(type);
1671
17
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1672
17
        Py_DECREF(type);
1673
17
        if (!cond) {
1674
0
            Py_DECREF(AsyncFor_annotations);
1675
0
            return 0;
1676
0
        }
1677
17
    }
1678
17
    {
1679
17
        PyObject *type = state->stmt_type;
1680
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1681
17
        cond = type != NULL;
1682
17
        if (!cond) {
1683
0
            Py_DECREF(AsyncFor_annotations);
1684
0
            return 0;
1685
0
        }
1686
17
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1687
17
        Py_DECREF(type);
1688
17
        if (!cond) {
1689
0
            Py_DECREF(AsyncFor_annotations);
1690
0
            return 0;
1691
0
        }
1692
17
    }
1693
17
    {
1694
17
        PyObject *type = state->stmt_type;
1695
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1696
17
        cond = type != NULL;
1697
17
        if (!cond) {
1698
0
            Py_DECREF(AsyncFor_annotations);
1699
0
            return 0;
1700
0
        }
1701
17
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1702
17
        Py_DECREF(type);
1703
17
        if (!cond) {
1704
0
            Py_DECREF(AsyncFor_annotations);
1705
0
            return 0;
1706
0
        }
1707
17
    }
1708
17
    {
1709
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1710
17
        type = _Py_union_type_or(type, Py_None);
1711
17
        cond = type != NULL;
1712
17
        if (!cond) {
1713
0
            Py_DECREF(AsyncFor_annotations);
1714
0
            return 0;
1715
0
        }
1716
17
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1717
17
                                    == 0;
1718
17
        Py_DECREF(type);
1719
17
        if (!cond) {
1720
0
            Py_DECREF(AsyncFor_annotations);
1721
0
            return 0;
1722
0
        }
1723
17
    }
1724
17
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1725
17
                                  AsyncFor_annotations) == 0;
1726
17
    if (!cond) {
1727
0
        Py_DECREF(AsyncFor_annotations);
1728
0
        return 0;
1729
0
    }
1730
17
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1731
17
                                  AsyncFor_annotations) == 0;
1732
17
    if (!cond) {
1733
0
        Py_DECREF(AsyncFor_annotations);
1734
0
        return 0;
1735
0
    }
1736
17
    Py_DECREF(AsyncFor_annotations);
1737
17
    PyObject *While_annotations = PyDict_New();
1738
17
    if (!While_annotations) return 0;
1739
17
    {
1740
17
        PyObject *type = state->expr_type;
1741
17
        Py_INCREF(type);
1742
17
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1743
17
        Py_DECREF(type);
1744
17
        if (!cond) {
1745
0
            Py_DECREF(While_annotations);
1746
0
            return 0;
1747
0
        }
1748
17
    }
1749
17
    {
1750
17
        PyObject *type = state->stmt_type;
1751
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1752
17
        cond = type != NULL;
1753
17
        if (!cond) {
1754
0
            Py_DECREF(While_annotations);
1755
0
            return 0;
1756
0
        }
1757
17
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1758
17
        Py_DECREF(type);
1759
17
        if (!cond) {
1760
0
            Py_DECREF(While_annotations);
1761
0
            return 0;
1762
0
        }
1763
17
    }
1764
17
    {
1765
17
        PyObject *type = state->stmt_type;
1766
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1767
17
        cond = type != NULL;
1768
17
        if (!cond) {
1769
0
            Py_DECREF(While_annotations);
1770
0
            return 0;
1771
0
        }
1772
17
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1773
17
        Py_DECREF(type);
1774
17
        if (!cond) {
1775
0
            Py_DECREF(While_annotations);
1776
0
            return 0;
1777
0
        }
1778
17
    }
1779
17
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1780
17
                                  While_annotations) == 0;
1781
17
    if (!cond) {
1782
0
        Py_DECREF(While_annotations);
1783
0
        return 0;
1784
0
    }
1785
17
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1786
17
                                  While_annotations) == 0;
1787
17
    if (!cond) {
1788
0
        Py_DECREF(While_annotations);
1789
0
        return 0;
1790
0
    }
1791
17
    Py_DECREF(While_annotations);
1792
17
    PyObject *If_annotations = PyDict_New();
1793
17
    if (!If_annotations) return 0;
1794
17
    {
1795
17
        PyObject *type = state->expr_type;
1796
17
        Py_INCREF(type);
1797
17
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1798
17
        Py_DECREF(type);
1799
17
        if (!cond) {
1800
0
            Py_DECREF(If_annotations);
1801
0
            return 0;
1802
0
        }
1803
17
    }
1804
17
    {
1805
17
        PyObject *type = state->stmt_type;
1806
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1807
17
        cond = type != NULL;
1808
17
        if (!cond) {
1809
0
            Py_DECREF(If_annotations);
1810
0
            return 0;
1811
0
        }
1812
17
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1813
17
        Py_DECREF(type);
1814
17
        if (!cond) {
1815
0
            Py_DECREF(If_annotations);
1816
0
            return 0;
1817
0
        }
1818
17
    }
1819
17
    {
1820
17
        PyObject *type = state->stmt_type;
1821
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1822
17
        cond = type != NULL;
1823
17
        if (!cond) {
1824
0
            Py_DECREF(If_annotations);
1825
0
            return 0;
1826
0
        }
1827
17
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1828
17
        Py_DECREF(type);
1829
17
        if (!cond) {
1830
0
            Py_DECREF(If_annotations);
1831
0
            return 0;
1832
0
        }
1833
17
    }
1834
17
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1835
17
                                  If_annotations) == 0;
1836
17
    if (!cond) {
1837
0
        Py_DECREF(If_annotations);
1838
0
        return 0;
1839
0
    }
1840
17
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1841
17
                                  If_annotations) == 0;
1842
17
    if (!cond) {
1843
0
        Py_DECREF(If_annotations);
1844
0
        return 0;
1845
0
    }
1846
17
    Py_DECREF(If_annotations);
1847
17
    PyObject *With_annotations = PyDict_New();
1848
17
    if (!With_annotations) return 0;
1849
17
    {
1850
17
        PyObject *type = state->withitem_type;
1851
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1852
17
        cond = type != NULL;
1853
17
        if (!cond) {
1854
0
            Py_DECREF(With_annotations);
1855
0
            return 0;
1856
0
        }
1857
17
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1858
17
        Py_DECREF(type);
1859
17
        if (!cond) {
1860
0
            Py_DECREF(With_annotations);
1861
0
            return 0;
1862
0
        }
1863
17
    }
1864
17
    {
1865
17
        PyObject *type = state->stmt_type;
1866
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1867
17
        cond = type != NULL;
1868
17
        if (!cond) {
1869
0
            Py_DECREF(With_annotations);
1870
0
            return 0;
1871
0
        }
1872
17
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1873
17
        Py_DECREF(type);
1874
17
        if (!cond) {
1875
0
            Py_DECREF(With_annotations);
1876
0
            return 0;
1877
0
        }
1878
17
    }
1879
17
    {
1880
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1881
17
        type = _Py_union_type_or(type, Py_None);
1882
17
        cond = type != NULL;
1883
17
        if (!cond) {
1884
0
            Py_DECREF(With_annotations);
1885
0
            return 0;
1886
0
        }
1887
17
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1888
17
                                    0;
1889
17
        Py_DECREF(type);
1890
17
        if (!cond) {
1891
0
            Py_DECREF(With_annotations);
1892
0
            return 0;
1893
0
        }
1894
17
    }
1895
17
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1896
17
                                  With_annotations) == 0;
1897
17
    if (!cond) {
1898
0
        Py_DECREF(With_annotations);
1899
0
        return 0;
1900
0
    }
1901
17
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1902
17
                                  With_annotations) == 0;
1903
17
    if (!cond) {
1904
0
        Py_DECREF(With_annotations);
1905
0
        return 0;
1906
0
    }
1907
17
    Py_DECREF(With_annotations);
1908
17
    PyObject *AsyncWith_annotations = PyDict_New();
1909
17
    if (!AsyncWith_annotations) return 0;
1910
17
    {
1911
17
        PyObject *type = state->withitem_type;
1912
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1913
17
        cond = type != NULL;
1914
17
        if (!cond) {
1915
0
            Py_DECREF(AsyncWith_annotations);
1916
0
            return 0;
1917
0
        }
1918
17
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1919
17
        Py_DECREF(type);
1920
17
        if (!cond) {
1921
0
            Py_DECREF(AsyncWith_annotations);
1922
0
            return 0;
1923
0
        }
1924
17
    }
1925
17
    {
1926
17
        PyObject *type = state->stmt_type;
1927
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1928
17
        cond = type != NULL;
1929
17
        if (!cond) {
1930
0
            Py_DECREF(AsyncWith_annotations);
1931
0
            return 0;
1932
0
        }
1933
17
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1934
17
        Py_DECREF(type);
1935
17
        if (!cond) {
1936
0
            Py_DECREF(AsyncWith_annotations);
1937
0
            return 0;
1938
0
        }
1939
17
    }
1940
17
    {
1941
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
1942
17
        type = _Py_union_type_or(type, Py_None);
1943
17
        cond = type != NULL;
1944
17
        if (!cond) {
1945
0
            Py_DECREF(AsyncWith_annotations);
1946
0
            return 0;
1947
0
        }
1948
17
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1949
17
                                    type) == 0;
1950
17
        Py_DECREF(type);
1951
17
        if (!cond) {
1952
0
            Py_DECREF(AsyncWith_annotations);
1953
0
            return 0;
1954
0
        }
1955
17
    }
1956
17
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1957
17
                                  AsyncWith_annotations) == 0;
1958
17
    if (!cond) {
1959
0
        Py_DECREF(AsyncWith_annotations);
1960
0
        return 0;
1961
0
    }
1962
17
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1963
17
                                  AsyncWith_annotations) == 0;
1964
17
    if (!cond) {
1965
0
        Py_DECREF(AsyncWith_annotations);
1966
0
        return 0;
1967
0
    }
1968
17
    Py_DECREF(AsyncWith_annotations);
1969
17
    PyObject *Match_annotations = PyDict_New();
1970
17
    if (!Match_annotations) return 0;
1971
17
    {
1972
17
        PyObject *type = state->expr_type;
1973
17
        Py_INCREF(type);
1974
17
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1975
17
        Py_DECREF(type);
1976
17
        if (!cond) {
1977
0
            Py_DECREF(Match_annotations);
1978
0
            return 0;
1979
0
        }
1980
17
    }
1981
17
    {
1982
17
        PyObject *type = state->match_case_type;
1983
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1984
17
        cond = type != NULL;
1985
17
        if (!cond) {
1986
0
            Py_DECREF(Match_annotations);
1987
0
            return 0;
1988
0
        }
1989
17
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1990
17
        Py_DECREF(type);
1991
17
        if (!cond) {
1992
0
            Py_DECREF(Match_annotations);
1993
0
            return 0;
1994
0
        }
1995
17
    }
1996
17
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1997
17
                                  Match_annotations) == 0;
1998
17
    if (!cond) {
1999
0
        Py_DECREF(Match_annotations);
2000
0
        return 0;
2001
0
    }
2002
17
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
2003
17
                                  Match_annotations) == 0;
2004
17
    if (!cond) {
2005
0
        Py_DECREF(Match_annotations);
2006
0
        return 0;
2007
0
    }
2008
17
    Py_DECREF(Match_annotations);
2009
17
    PyObject *Raise_annotations = PyDict_New();
2010
17
    if (!Raise_annotations) return 0;
2011
17
    {
2012
17
        PyObject *type = state->expr_type;
2013
17
        type = _Py_union_type_or(type, Py_None);
2014
17
        cond = type != NULL;
2015
17
        if (!cond) {
2016
0
            Py_DECREF(Raise_annotations);
2017
0
            return 0;
2018
0
        }
2019
17
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2020
17
        Py_DECREF(type);
2021
17
        if (!cond) {
2022
0
            Py_DECREF(Raise_annotations);
2023
0
            return 0;
2024
0
        }
2025
17
    }
2026
17
    {
2027
17
        PyObject *type = state->expr_type;
2028
17
        type = _Py_union_type_or(type, Py_None);
2029
17
        cond = type != NULL;
2030
17
        if (!cond) {
2031
0
            Py_DECREF(Raise_annotations);
2032
0
            return 0;
2033
0
        }
2034
17
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2035
17
        Py_DECREF(type);
2036
17
        if (!cond) {
2037
0
            Py_DECREF(Raise_annotations);
2038
0
            return 0;
2039
0
        }
2040
17
    }
2041
17
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2042
17
                                  Raise_annotations) == 0;
2043
17
    if (!cond) {
2044
0
        Py_DECREF(Raise_annotations);
2045
0
        return 0;
2046
0
    }
2047
17
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2048
17
                                  Raise_annotations) == 0;
2049
17
    if (!cond) {
2050
0
        Py_DECREF(Raise_annotations);
2051
0
        return 0;
2052
0
    }
2053
17
    Py_DECREF(Raise_annotations);
2054
17
    PyObject *Try_annotations = PyDict_New();
2055
17
    if (!Try_annotations) return 0;
2056
17
    {
2057
17
        PyObject *type = state->stmt_type;
2058
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2059
17
        cond = type != NULL;
2060
17
        if (!cond) {
2061
0
            Py_DECREF(Try_annotations);
2062
0
            return 0;
2063
0
        }
2064
17
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2065
17
        Py_DECREF(type);
2066
17
        if (!cond) {
2067
0
            Py_DECREF(Try_annotations);
2068
0
            return 0;
2069
0
        }
2070
17
    }
2071
17
    {
2072
17
        PyObject *type = state->excepthandler_type;
2073
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2074
17
        cond = type != NULL;
2075
17
        if (!cond) {
2076
0
            Py_DECREF(Try_annotations);
2077
0
            return 0;
2078
0
        }
2079
17
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2080
17
        Py_DECREF(type);
2081
17
        if (!cond) {
2082
0
            Py_DECREF(Try_annotations);
2083
0
            return 0;
2084
0
        }
2085
17
    }
2086
17
    {
2087
17
        PyObject *type = state->stmt_type;
2088
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2089
17
        cond = type != NULL;
2090
17
        if (!cond) {
2091
0
            Py_DECREF(Try_annotations);
2092
0
            return 0;
2093
0
        }
2094
17
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2095
17
        Py_DECREF(type);
2096
17
        if (!cond) {
2097
0
            Py_DECREF(Try_annotations);
2098
0
            return 0;
2099
0
        }
2100
17
    }
2101
17
    {
2102
17
        PyObject *type = state->stmt_type;
2103
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2104
17
        cond = type != NULL;
2105
17
        if (!cond) {
2106
0
            Py_DECREF(Try_annotations);
2107
0
            return 0;
2108
0
        }
2109
17
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2110
17
        Py_DECREF(type);
2111
17
        if (!cond) {
2112
0
            Py_DECREF(Try_annotations);
2113
0
            return 0;
2114
0
        }
2115
17
    }
2116
17
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2117
17
                                  Try_annotations) == 0;
2118
17
    if (!cond) {
2119
0
        Py_DECREF(Try_annotations);
2120
0
        return 0;
2121
0
    }
2122
17
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2123
17
                                  Try_annotations) == 0;
2124
17
    if (!cond) {
2125
0
        Py_DECREF(Try_annotations);
2126
0
        return 0;
2127
0
    }
2128
17
    Py_DECREF(Try_annotations);
2129
17
    PyObject *TryStar_annotations = PyDict_New();
2130
17
    if (!TryStar_annotations) return 0;
2131
17
    {
2132
17
        PyObject *type = state->stmt_type;
2133
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2134
17
        cond = type != NULL;
2135
17
        if (!cond) {
2136
0
            Py_DECREF(TryStar_annotations);
2137
0
            return 0;
2138
0
        }
2139
17
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2140
17
        Py_DECREF(type);
2141
17
        if (!cond) {
2142
0
            Py_DECREF(TryStar_annotations);
2143
0
            return 0;
2144
0
        }
2145
17
    }
2146
17
    {
2147
17
        PyObject *type = state->excepthandler_type;
2148
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2149
17
        cond = type != NULL;
2150
17
        if (!cond) {
2151
0
            Py_DECREF(TryStar_annotations);
2152
0
            return 0;
2153
0
        }
2154
17
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2155
17
        Py_DECREF(type);
2156
17
        if (!cond) {
2157
0
            Py_DECREF(TryStar_annotations);
2158
0
            return 0;
2159
0
        }
2160
17
    }
2161
17
    {
2162
17
        PyObject *type = state->stmt_type;
2163
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2164
17
        cond = type != NULL;
2165
17
        if (!cond) {
2166
0
            Py_DECREF(TryStar_annotations);
2167
0
            return 0;
2168
0
        }
2169
17
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2170
17
        Py_DECREF(type);
2171
17
        if (!cond) {
2172
0
            Py_DECREF(TryStar_annotations);
2173
0
            return 0;
2174
0
        }
2175
17
    }
2176
17
    {
2177
17
        PyObject *type = state->stmt_type;
2178
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2179
17
        cond = type != NULL;
2180
17
        if (!cond) {
2181
0
            Py_DECREF(TryStar_annotations);
2182
0
            return 0;
2183
0
        }
2184
17
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2185
17
                                    0;
2186
17
        Py_DECREF(type);
2187
17
        if (!cond) {
2188
0
            Py_DECREF(TryStar_annotations);
2189
0
            return 0;
2190
0
        }
2191
17
    }
2192
17
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2193
17
                                  TryStar_annotations) == 0;
2194
17
    if (!cond) {
2195
0
        Py_DECREF(TryStar_annotations);
2196
0
        return 0;
2197
0
    }
2198
17
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2199
17
                                  TryStar_annotations) == 0;
2200
17
    if (!cond) {
2201
0
        Py_DECREF(TryStar_annotations);
2202
0
        return 0;
2203
0
    }
2204
17
    Py_DECREF(TryStar_annotations);
2205
17
    PyObject *Assert_annotations = PyDict_New();
2206
17
    if (!Assert_annotations) return 0;
2207
17
    {
2208
17
        PyObject *type = state->expr_type;
2209
17
        Py_INCREF(type);
2210
17
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2211
17
        Py_DECREF(type);
2212
17
        if (!cond) {
2213
0
            Py_DECREF(Assert_annotations);
2214
0
            return 0;
2215
0
        }
2216
17
    }
2217
17
    {
2218
17
        PyObject *type = state->expr_type;
2219
17
        type = _Py_union_type_or(type, Py_None);
2220
17
        cond = type != NULL;
2221
17
        if (!cond) {
2222
0
            Py_DECREF(Assert_annotations);
2223
0
            return 0;
2224
0
        }
2225
17
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2226
17
        Py_DECREF(type);
2227
17
        if (!cond) {
2228
0
            Py_DECREF(Assert_annotations);
2229
0
            return 0;
2230
0
        }
2231
17
    }
2232
17
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2233
17
                                  Assert_annotations) == 0;
2234
17
    if (!cond) {
2235
0
        Py_DECREF(Assert_annotations);
2236
0
        return 0;
2237
0
    }
2238
17
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2239
17
                                  Assert_annotations) == 0;
2240
17
    if (!cond) {
2241
0
        Py_DECREF(Assert_annotations);
2242
0
        return 0;
2243
0
    }
2244
17
    Py_DECREF(Assert_annotations);
2245
17
    PyObject *Import_annotations = PyDict_New();
2246
17
    if (!Import_annotations) return 0;
2247
17
    {
2248
17
        PyObject *type = state->alias_type;
2249
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2250
17
        cond = type != NULL;
2251
17
        if (!cond) {
2252
0
            Py_DECREF(Import_annotations);
2253
0
            return 0;
2254
0
        }
2255
17
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2256
17
        Py_DECREF(type);
2257
17
        if (!cond) {
2258
0
            Py_DECREF(Import_annotations);
2259
0
            return 0;
2260
0
        }
2261
17
    }
2262
17
    {
2263
17
        PyObject *type = (PyObject *)&PyLong_Type;
2264
17
        type = _Py_union_type_or(type, Py_None);
2265
17
        cond = type != NULL;
2266
17
        if (!cond) {
2267
0
            Py_DECREF(Import_annotations);
2268
0
            return 0;
2269
0
        }
2270
17
        cond = PyDict_SetItemString(Import_annotations, "is_lazy", type) == 0;
2271
17
        Py_DECREF(type);
2272
17
        if (!cond) {
2273
0
            Py_DECREF(Import_annotations);
2274
0
            return 0;
2275
0
        }
2276
17
    }
2277
17
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2278
17
                                  Import_annotations) == 0;
2279
17
    if (!cond) {
2280
0
        Py_DECREF(Import_annotations);
2281
0
        return 0;
2282
0
    }
2283
17
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2284
17
                                  Import_annotations) == 0;
2285
17
    if (!cond) {
2286
0
        Py_DECREF(Import_annotations);
2287
0
        return 0;
2288
0
    }
2289
17
    Py_DECREF(Import_annotations);
2290
17
    PyObject *ImportFrom_annotations = PyDict_New();
2291
17
    if (!ImportFrom_annotations) return 0;
2292
17
    {
2293
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
2294
17
        type = _Py_union_type_or(type, Py_None);
2295
17
        cond = type != NULL;
2296
17
        if (!cond) {
2297
0
            Py_DECREF(ImportFrom_annotations);
2298
0
            return 0;
2299
0
        }
2300
17
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2301
17
                                    0;
2302
17
        Py_DECREF(type);
2303
17
        if (!cond) {
2304
0
            Py_DECREF(ImportFrom_annotations);
2305
0
            return 0;
2306
0
        }
2307
17
    }
2308
17
    {
2309
17
        PyObject *type = state->alias_type;
2310
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2311
17
        cond = type != NULL;
2312
17
        if (!cond) {
2313
0
            Py_DECREF(ImportFrom_annotations);
2314
0
            return 0;
2315
0
        }
2316
17
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2317
17
        Py_DECREF(type);
2318
17
        if (!cond) {
2319
0
            Py_DECREF(ImportFrom_annotations);
2320
0
            return 0;
2321
0
        }
2322
17
    }
2323
17
    {
2324
17
        PyObject *type = (PyObject *)&PyLong_Type;
2325
17
        type = _Py_union_type_or(type, Py_None);
2326
17
        cond = type != NULL;
2327
17
        if (!cond) {
2328
0
            Py_DECREF(ImportFrom_annotations);
2329
0
            return 0;
2330
0
        }
2331
17
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2332
17
        Py_DECREF(type);
2333
17
        if (!cond) {
2334
0
            Py_DECREF(ImportFrom_annotations);
2335
0
            return 0;
2336
0
        }
2337
17
    }
2338
17
    {
2339
17
        PyObject *type = (PyObject *)&PyLong_Type;
2340
17
        type = _Py_union_type_or(type, Py_None);
2341
17
        cond = type != NULL;
2342
17
        if (!cond) {
2343
0
            Py_DECREF(ImportFrom_annotations);
2344
0
            return 0;
2345
0
        }
2346
17
        cond = PyDict_SetItemString(ImportFrom_annotations, "is_lazy", type) ==
2347
17
                                    0;
2348
17
        Py_DECREF(type);
2349
17
        if (!cond) {
2350
0
            Py_DECREF(ImportFrom_annotations);
2351
0
            return 0;
2352
0
        }
2353
17
    }
2354
17
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2355
17
                                  ImportFrom_annotations) == 0;
2356
17
    if (!cond) {
2357
0
        Py_DECREF(ImportFrom_annotations);
2358
0
        return 0;
2359
0
    }
2360
17
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2361
17
                                  ImportFrom_annotations) == 0;
2362
17
    if (!cond) {
2363
0
        Py_DECREF(ImportFrom_annotations);
2364
0
        return 0;
2365
0
    }
2366
17
    Py_DECREF(ImportFrom_annotations);
2367
17
    PyObject *Global_annotations = PyDict_New();
2368
17
    if (!Global_annotations) return 0;
2369
17
    {
2370
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
2371
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2372
17
        cond = type != NULL;
2373
17
        if (!cond) {
2374
0
            Py_DECREF(Global_annotations);
2375
0
            return 0;
2376
0
        }
2377
17
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2378
17
        Py_DECREF(type);
2379
17
        if (!cond) {
2380
0
            Py_DECREF(Global_annotations);
2381
0
            return 0;
2382
0
        }
2383
17
    }
2384
17
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2385
17
                                  Global_annotations) == 0;
2386
17
    if (!cond) {
2387
0
        Py_DECREF(Global_annotations);
2388
0
        return 0;
2389
0
    }
2390
17
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2391
17
                                  Global_annotations) == 0;
2392
17
    if (!cond) {
2393
0
        Py_DECREF(Global_annotations);
2394
0
        return 0;
2395
0
    }
2396
17
    Py_DECREF(Global_annotations);
2397
17
    PyObject *Nonlocal_annotations = PyDict_New();
2398
17
    if (!Nonlocal_annotations) return 0;
2399
17
    {
2400
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
2401
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2402
17
        cond = type != NULL;
2403
17
        if (!cond) {
2404
0
            Py_DECREF(Nonlocal_annotations);
2405
0
            return 0;
2406
0
        }
2407
17
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2408
17
        Py_DECREF(type);
2409
17
        if (!cond) {
2410
0
            Py_DECREF(Nonlocal_annotations);
2411
0
            return 0;
2412
0
        }
2413
17
    }
2414
17
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2415
17
                                  Nonlocal_annotations) == 0;
2416
17
    if (!cond) {
2417
0
        Py_DECREF(Nonlocal_annotations);
2418
0
        return 0;
2419
0
    }
2420
17
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2421
17
                                  Nonlocal_annotations) == 0;
2422
17
    if (!cond) {
2423
0
        Py_DECREF(Nonlocal_annotations);
2424
0
        return 0;
2425
0
    }
2426
17
    Py_DECREF(Nonlocal_annotations);
2427
17
    PyObject *Expr_annotations = PyDict_New();
2428
17
    if (!Expr_annotations) return 0;
2429
17
    {
2430
17
        PyObject *type = state->expr_type;
2431
17
        Py_INCREF(type);
2432
17
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2433
17
        Py_DECREF(type);
2434
17
        if (!cond) {
2435
0
            Py_DECREF(Expr_annotations);
2436
0
            return 0;
2437
0
        }
2438
17
    }
2439
17
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2440
17
                                  Expr_annotations) == 0;
2441
17
    if (!cond) {
2442
0
        Py_DECREF(Expr_annotations);
2443
0
        return 0;
2444
0
    }
2445
17
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2446
17
                                  Expr_annotations) == 0;
2447
17
    if (!cond) {
2448
0
        Py_DECREF(Expr_annotations);
2449
0
        return 0;
2450
0
    }
2451
17
    Py_DECREF(Expr_annotations);
2452
17
    PyObject *Pass_annotations = PyDict_New();
2453
17
    if (!Pass_annotations) return 0;
2454
17
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2455
17
                                  Pass_annotations) == 0;
2456
17
    if (!cond) {
2457
0
        Py_DECREF(Pass_annotations);
2458
0
        return 0;
2459
0
    }
2460
17
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2461
17
                                  Pass_annotations) == 0;
2462
17
    if (!cond) {
2463
0
        Py_DECREF(Pass_annotations);
2464
0
        return 0;
2465
0
    }
2466
17
    Py_DECREF(Pass_annotations);
2467
17
    PyObject *Break_annotations = PyDict_New();
2468
17
    if (!Break_annotations) return 0;
2469
17
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2470
17
                                  Break_annotations) == 0;
2471
17
    if (!cond) {
2472
0
        Py_DECREF(Break_annotations);
2473
0
        return 0;
2474
0
    }
2475
17
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2476
17
                                  Break_annotations) == 0;
2477
17
    if (!cond) {
2478
0
        Py_DECREF(Break_annotations);
2479
0
        return 0;
2480
0
    }
2481
17
    Py_DECREF(Break_annotations);
2482
17
    PyObject *Continue_annotations = PyDict_New();
2483
17
    if (!Continue_annotations) return 0;
2484
17
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2485
17
                                  Continue_annotations) == 0;
2486
17
    if (!cond) {
2487
0
        Py_DECREF(Continue_annotations);
2488
0
        return 0;
2489
0
    }
2490
17
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2491
17
                                  Continue_annotations) == 0;
2492
17
    if (!cond) {
2493
0
        Py_DECREF(Continue_annotations);
2494
0
        return 0;
2495
0
    }
2496
17
    Py_DECREF(Continue_annotations);
2497
17
    PyObject *BoolOp_annotations = PyDict_New();
2498
17
    if (!BoolOp_annotations) return 0;
2499
17
    {
2500
17
        PyObject *type = state->boolop_type;
2501
17
        Py_INCREF(type);
2502
17
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2503
17
        Py_DECREF(type);
2504
17
        if (!cond) {
2505
0
            Py_DECREF(BoolOp_annotations);
2506
0
            return 0;
2507
0
        }
2508
17
    }
2509
17
    {
2510
17
        PyObject *type = state->expr_type;
2511
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2512
17
        cond = type != NULL;
2513
17
        if (!cond) {
2514
0
            Py_DECREF(BoolOp_annotations);
2515
0
            return 0;
2516
0
        }
2517
17
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2518
17
        Py_DECREF(type);
2519
17
        if (!cond) {
2520
0
            Py_DECREF(BoolOp_annotations);
2521
0
            return 0;
2522
0
        }
2523
17
    }
2524
17
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2525
17
                                  BoolOp_annotations) == 0;
2526
17
    if (!cond) {
2527
0
        Py_DECREF(BoolOp_annotations);
2528
0
        return 0;
2529
0
    }
2530
17
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2531
17
                                  BoolOp_annotations) == 0;
2532
17
    if (!cond) {
2533
0
        Py_DECREF(BoolOp_annotations);
2534
0
        return 0;
2535
0
    }
2536
17
    Py_DECREF(BoolOp_annotations);
2537
17
    PyObject *NamedExpr_annotations = PyDict_New();
2538
17
    if (!NamedExpr_annotations) return 0;
2539
17
    {
2540
17
        PyObject *type = state->expr_type;
2541
17
        Py_INCREF(type);
2542
17
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2543
17
        Py_DECREF(type);
2544
17
        if (!cond) {
2545
0
            Py_DECREF(NamedExpr_annotations);
2546
0
            return 0;
2547
0
        }
2548
17
    }
2549
17
    {
2550
17
        PyObject *type = state->expr_type;
2551
17
        Py_INCREF(type);
2552
17
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2553
17
        Py_DECREF(type);
2554
17
        if (!cond) {
2555
0
            Py_DECREF(NamedExpr_annotations);
2556
0
            return 0;
2557
0
        }
2558
17
    }
2559
17
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2560
17
                                  NamedExpr_annotations) == 0;
2561
17
    if (!cond) {
2562
0
        Py_DECREF(NamedExpr_annotations);
2563
0
        return 0;
2564
0
    }
2565
17
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2566
17
                                  NamedExpr_annotations) == 0;
2567
17
    if (!cond) {
2568
0
        Py_DECREF(NamedExpr_annotations);
2569
0
        return 0;
2570
0
    }
2571
17
    Py_DECREF(NamedExpr_annotations);
2572
17
    PyObject *BinOp_annotations = PyDict_New();
2573
17
    if (!BinOp_annotations) return 0;
2574
17
    {
2575
17
        PyObject *type = state->expr_type;
2576
17
        Py_INCREF(type);
2577
17
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2578
17
        Py_DECREF(type);
2579
17
        if (!cond) {
2580
0
            Py_DECREF(BinOp_annotations);
2581
0
            return 0;
2582
0
        }
2583
17
    }
2584
17
    {
2585
17
        PyObject *type = state->operator_type;
2586
17
        Py_INCREF(type);
2587
17
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2588
17
        Py_DECREF(type);
2589
17
        if (!cond) {
2590
0
            Py_DECREF(BinOp_annotations);
2591
0
            return 0;
2592
0
        }
2593
17
    }
2594
17
    {
2595
17
        PyObject *type = state->expr_type;
2596
17
        Py_INCREF(type);
2597
17
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2598
17
        Py_DECREF(type);
2599
17
        if (!cond) {
2600
0
            Py_DECREF(BinOp_annotations);
2601
0
            return 0;
2602
0
        }
2603
17
    }
2604
17
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2605
17
                                  BinOp_annotations) == 0;
2606
17
    if (!cond) {
2607
0
        Py_DECREF(BinOp_annotations);
2608
0
        return 0;
2609
0
    }
2610
17
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2611
17
                                  BinOp_annotations) == 0;
2612
17
    if (!cond) {
2613
0
        Py_DECREF(BinOp_annotations);
2614
0
        return 0;
2615
0
    }
2616
17
    Py_DECREF(BinOp_annotations);
2617
17
    PyObject *UnaryOp_annotations = PyDict_New();
2618
17
    if (!UnaryOp_annotations) return 0;
2619
17
    {
2620
17
        PyObject *type = state->unaryop_type;
2621
17
        Py_INCREF(type);
2622
17
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2623
17
        Py_DECREF(type);
2624
17
        if (!cond) {
2625
0
            Py_DECREF(UnaryOp_annotations);
2626
0
            return 0;
2627
0
        }
2628
17
    }
2629
17
    {
2630
17
        PyObject *type = state->expr_type;
2631
17
        Py_INCREF(type);
2632
17
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2633
17
        Py_DECREF(type);
2634
17
        if (!cond) {
2635
0
            Py_DECREF(UnaryOp_annotations);
2636
0
            return 0;
2637
0
        }
2638
17
    }
2639
17
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2640
17
                                  UnaryOp_annotations) == 0;
2641
17
    if (!cond) {
2642
0
        Py_DECREF(UnaryOp_annotations);
2643
0
        return 0;
2644
0
    }
2645
17
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2646
17
                                  UnaryOp_annotations) == 0;
2647
17
    if (!cond) {
2648
0
        Py_DECREF(UnaryOp_annotations);
2649
0
        return 0;
2650
0
    }
2651
17
    Py_DECREF(UnaryOp_annotations);
2652
17
    PyObject *Lambda_annotations = PyDict_New();
2653
17
    if (!Lambda_annotations) return 0;
2654
17
    {
2655
17
        PyObject *type = state->arguments_type;
2656
17
        Py_INCREF(type);
2657
17
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2658
17
        Py_DECREF(type);
2659
17
        if (!cond) {
2660
0
            Py_DECREF(Lambda_annotations);
2661
0
            return 0;
2662
0
        }
2663
17
    }
2664
17
    {
2665
17
        PyObject *type = state->expr_type;
2666
17
        Py_INCREF(type);
2667
17
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2668
17
        Py_DECREF(type);
2669
17
        if (!cond) {
2670
0
            Py_DECREF(Lambda_annotations);
2671
0
            return 0;
2672
0
        }
2673
17
    }
2674
17
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2675
17
                                  Lambda_annotations) == 0;
2676
17
    if (!cond) {
2677
0
        Py_DECREF(Lambda_annotations);
2678
0
        return 0;
2679
0
    }
2680
17
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2681
17
                                  Lambda_annotations) == 0;
2682
17
    if (!cond) {
2683
0
        Py_DECREF(Lambda_annotations);
2684
0
        return 0;
2685
0
    }
2686
17
    Py_DECREF(Lambda_annotations);
2687
17
    PyObject *IfExp_annotations = PyDict_New();
2688
17
    if (!IfExp_annotations) return 0;
2689
17
    {
2690
17
        PyObject *type = state->expr_type;
2691
17
        Py_INCREF(type);
2692
17
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2693
17
        Py_DECREF(type);
2694
17
        if (!cond) {
2695
0
            Py_DECREF(IfExp_annotations);
2696
0
            return 0;
2697
0
        }
2698
17
    }
2699
17
    {
2700
17
        PyObject *type = state->expr_type;
2701
17
        Py_INCREF(type);
2702
17
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2703
17
        Py_DECREF(type);
2704
17
        if (!cond) {
2705
0
            Py_DECREF(IfExp_annotations);
2706
0
            return 0;
2707
0
        }
2708
17
    }
2709
17
    {
2710
17
        PyObject *type = state->expr_type;
2711
17
        Py_INCREF(type);
2712
17
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2713
17
        Py_DECREF(type);
2714
17
        if (!cond) {
2715
0
            Py_DECREF(IfExp_annotations);
2716
0
            return 0;
2717
0
        }
2718
17
    }
2719
17
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2720
17
                                  IfExp_annotations) == 0;
2721
17
    if (!cond) {
2722
0
        Py_DECREF(IfExp_annotations);
2723
0
        return 0;
2724
0
    }
2725
17
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2726
17
                                  IfExp_annotations) == 0;
2727
17
    if (!cond) {
2728
0
        Py_DECREF(IfExp_annotations);
2729
0
        return 0;
2730
0
    }
2731
17
    Py_DECREF(IfExp_annotations);
2732
17
    PyObject *Dict_annotations = PyDict_New();
2733
17
    if (!Dict_annotations) return 0;
2734
17
    {
2735
17
        PyObject *type = state->expr_type;
2736
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2737
17
        cond = type != NULL;
2738
17
        if (!cond) {
2739
0
            Py_DECREF(Dict_annotations);
2740
0
            return 0;
2741
0
        }
2742
17
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2743
17
        Py_DECREF(type);
2744
17
        if (!cond) {
2745
0
            Py_DECREF(Dict_annotations);
2746
0
            return 0;
2747
0
        }
2748
17
    }
2749
17
    {
2750
17
        PyObject *type = state->expr_type;
2751
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2752
17
        cond = type != NULL;
2753
17
        if (!cond) {
2754
0
            Py_DECREF(Dict_annotations);
2755
0
            return 0;
2756
0
        }
2757
17
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2758
17
        Py_DECREF(type);
2759
17
        if (!cond) {
2760
0
            Py_DECREF(Dict_annotations);
2761
0
            return 0;
2762
0
        }
2763
17
    }
2764
17
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2765
17
                                  Dict_annotations) == 0;
2766
17
    if (!cond) {
2767
0
        Py_DECREF(Dict_annotations);
2768
0
        return 0;
2769
0
    }
2770
17
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2771
17
                                  Dict_annotations) == 0;
2772
17
    if (!cond) {
2773
0
        Py_DECREF(Dict_annotations);
2774
0
        return 0;
2775
0
    }
2776
17
    Py_DECREF(Dict_annotations);
2777
17
    PyObject *Set_annotations = PyDict_New();
2778
17
    if (!Set_annotations) return 0;
2779
17
    {
2780
17
        PyObject *type = state->expr_type;
2781
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2782
17
        cond = type != NULL;
2783
17
        if (!cond) {
2784
0
            Py_DECREF(Set_annotations);
2785
0
            return 0;
2786
0
        }
2787
17
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2788
17
        Py_DECREF(type);
2789
17
        if (!cond) {
2790
0
            Py_DECREF(Set_annotations);
2791
0
            return 0;
2792
0
        }
2793
17
    }
2794
17
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2795
17
                                  Set_annotations) == 0;
2796
17
    if (!cond) {
2797
0
        Py_DECREF(Set_annotations);
2798
0
        return 0;
2799
0
    }
2800
17
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2801
17
                                  Set_annotations) == 0;
2802
17
    if (!cond) {
2803
0
        Py_DECREF(Set_annotations);
2804
0
        return 0;
2805
0
    }
2806
17
    Py_DECREF(Set_annotations);
2807
17
    PyObject *ListComp_annotations = PyDict_New();
2808
17
    if (!ListComp_annotations) return 0;
2809
17
    {
2810
17
        PyObject *type = state->expr_type;
2811
17
        Py_INCREF(type);
2812
17
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2813
17
        Py_DECREF(type);
2814
17
        if (!cond) {
2815
0
            Py_DECREF(ListComp_annotations);
2816
0
            return 0;
2817
0
        }
2818
17
    }
2819
17
    {
2820
17
        PyObject *type = state->comprehension_type;
2821
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2822
17
        cond = type != NULL;
2823
17
        if (!cond) {
2824
0
            Py_DECREF(ListComp_annotations);
2825
0
            return 0;
2826
0
        }
2827
17
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2828
17
                                    == 0;
2829
17
        Py_DECREF(type);
2830
17
        if (!cond) {
2831
0
            Py_DECREF(ListComp_annotations);
2832
0
            return 0;
2833
0
        }
2834
17
    }
2835
17
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2836
17
                                  ListComp_annotations) == 0;
2837
17
    if (!cond) {
2838
0
        Py_DECREF(ListComp_annotations);
2839
0
        return 0;
2840
0
    }
2841
17
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2842
17
                                  ListComp_annotations) == 0;
2843
17
    if (!cond) {
2844
0
        Py_DECREF(ListComp_annotations);
2845
0
        return 0;
2846
0
    }
2847
17
    Py_DECREF(ListComp_annotations);
2848
17
    PyObject *SetComp_annotations = PyDict_New();
2849
17
    if (!SetComp_annotations) return 0;
2850
17
    {
2851
17
        PyObject *type = state->expr_type;
2852
17
        Py_INCREF(type);
2853
17
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2854
17
        Py_DECREF(type);
2855
17
        if (!cond) {
2856
0
            Py_DECREF(SetComp_annotations);
2857
0
            return 0;
2858
0
        }
2859
17
    }
2860
17
    {
2861
17
        PyObject *type = state->comprehension_type;
2862
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2863
17
        cond = type != NULL;
2864
17
        if (!cond) {
2865
0
            Py_DECREF(SetComp_annotations);
2866
0
            return 0;
2867
0
        }
2868
17
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2869
17
                                    0;
2870
17
        Py_DECREF(type);
2871
17
        if (!cond) {
2872
0
            Py_DECREF(SetComp_annotations);
2873
0
            return 0;
2874
0
        }
2875
17
    }
2876
17
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2877
17
                                  SetComp_annotations) == 0;
2878
17
    if (!cond) {
2879
0
        Py_DECREF(SetComp_annotations);
2880
0
        return 0;
2881
0
    }
2882
17
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2883
17
                                  SetComp_annotations) == 0;
2884
17
    if (!cond) {
2885
0
        Py_DECREF(SetComp_annotations);
2886
0
        return 0;
2887
0
    }
2888
17
    Py_DECREF(SetComp_annotations);
2889
17
    PyObject *DictComp_annotations = PyDict_New();
2890
17
    if (!DictComp_annotations) return 0;
2891
17
    {
2892
17
        PyObject *type = state->expr_type;
2893
17
        Py_INCREF(type);
2894
17
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2895
17
        Py_DECREF(type);
2896
17
        if (!cond) {
2897
0
            Py_DECREF(DictComp_annotations);
2898
0
            return 0;
2899
0
        }
2900
17
    }
2901
17
    {
2902
17
        PyObject *type = state->expr_type;
2903
17
        type = _Py_union_type_or(type, Py_None);
2904
17
        cond = type != NULL;
2905
17
        if (!cond) {
2906
0
            Py_DECREF(DictComp_annotations);
2907
0
            return 0;
2908
0
        }
2909
17
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2910
17
        Py_DECREF(type);
2911
17
        if (!cond) {
2912
0
            Py_DECREF(DictComp_annotations);
2913
0
            return 0;
2914
0
        }
2915
17
    }
2916
17
    {
2917
17
        PyObject *type = state->comprehension_type;
2918
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2919
17
        cond = type != NULL;
2920
17
        if (!cond) {
2921
0
            Py_DECREF(DictComp_annotations);
2922
0
            return 0;
2923
0
        }
2924
17
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2925
17
                                    == 0;
2926
17
        Py_DECREF(type);
2927
17
        if (!cond) {
2928
0
            Py_DECREF(DictComp_annotations);
2929
0
            return 0;
2930
0
        }
2931
17
    }
2932
17
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2933
17
                                  DictComp_annotations) == 0;
2934
17
    if (!cond) {
2935
0
        Py_DECREF(DictComp_annotations);
2936
0
        return 0;
2937
0
    }
2938
17
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2939
17
                                  DictComp_annotations) == 0;
2940
17
    if (!cond) {
2941
0
        Py_DECREF(DictComp_annotations);
2942
0
        return 0;
2943
0
    }
2944
17
    Py_DECREF(DictComp_annotations);
2945
17
    PyObject *GeneratorExp_annotations = PyDict_New();
2946
17
    if (!GeneratorExp_annotations) return 0;
2947
17
    {
2948
17
        PyObject *type = state->expr_type;
2949
17
        Py_INCREF(type);
2950
17
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2951
17
        Py_DECREF(type);
2952
17
        if (!cond) {
2953
0
            Py_DECREF(GeneratorExp_annotations);
2954
0
            return 0;
2955
0
        }
2956
17
    }
2957
17
    {
2958
17
        PyObject *type = state->comprehension_type;
2959
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2960
17
        cond = type != NULL;
2961
17
        if (!cond) {
2962
0
            Py_DECREF(GeneratorExp_annotations);
2963
0
            return 0;
2964
0
        }
2965
17
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2966
17
                                    type) == 0;
2967
17
        Py_DECREF(type);
2968
17
        if (!cond) {
2969
0
            Py_DECREF(GeneratorExp_annotations);
2970
0
            return 0;
2971
0
        }
2972
17
    }
2973
17
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2974
17
                                  GeneratorExp_annotations) == 0;
2975
17
    if (!cond) {
2976
0
        Py_DECREF(GeneratorExp_annotations);
2977
0
        return 0;
2978
0
    }
2979
17
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2980
17
                                  GeneratorExp_annotations) == 0;
2981
17
    if (!cond) {
2982
0
        Py_DECREF(GeneratorExp_annotations);
2983
0
        return 0;
2984
0
    }
2985
17
    Py_DECREF(GeneratorExp_annotations);
2986
17
    PyObject *Await_annotations = PyDict_New();
2987
17
    if (!Await_annotations) return 0;
2988
17
    {
2989
17
        PyObject *type = state->expr_type;
2990
17
        Py_INCREF(type);
2991
17
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2992
17
        Py_DECREF(type);
2993
17
        if (!cond) {
2994
0
            Py_DECREF(Await_annotations);
2995
0
            return 0;
2996
0
        }
2997
17
    }
2998
17
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2999
17
                                  Await_annotations) == 0;
3000
17
    if (!cond) {
3001
0
        Py_DECREF(Await_annotations);
3002
0
        return 0;
3003
0
    }
3004
17
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
3005
17
                                  Await_annotations) == 0;
3006
17
    if (!cond) {
3007
0
        Py_DECREF(Await_annotations);
3008
0
        return 0;
3009
0
    }
3010
17
    Py_DECREF(Await_annotations);
3011
17
    PyObject *Yield_annotations = PyDict_New();
3012
17
    if (!Yield_annotations) return 0;
3013
17
    {
3014
17
        PyObject *type = state->expr_type;
3015
17
        type = _Py_union_type_or(type, Py_None);
3016
17
        cond = type != NULL;
3017
17
        if (!cond) {
3018
0
            Py_DECREF(Yield_annotations);
3019
0
            return 0;
3020
0
        }
3021
17
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
3022
17
        Py_DECREF(type);
3023
17
        if (!cond) {
3024
0
            Py_DECREF(Yield_annotations);
3025
0
            return 0;
3026
0
        }
3027
17
    }
3028
17
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
3029
17
                                  Yield_annotations) == 0;
3030
17
    if (!cond) {
3031
0
        Py_DECREF(Yield_annotations);
3032
0
        return 0;
3033
0
    }
3034
17
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
3035
17
                                  Yield_annotations) == 0;
3036
17
    if (!cond) {
3037
0
        Py_DECREF(Yield_annotations);
3038
0
        return 0;
3039
0
    }
3040
17
    Py_DECREF(Yield_annotations);
3041
17
    PyObject *YieldFrom_annotations = PyDict_New();
3042
17
    if (!YieldFrom_annotations) return 0;
3043
17
    {
3044
17
        PyObject *type = state->expr_type;
3045
17
        Py_INCREF(type);
3046
17
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3047
17
        Py_DECREF(type);
3048
17
        if (!cond) {
3049
0
            Py_DECREF(YieldFrom_annotations);
3050
0
            return 0;
3051
0
        }
3052
17
    }
3053
17
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3054
17
                                  YieldFrom_annotations) == 0;
3055
17
    if (!cond) {
3056
0
        Py_DECREF(YieldFrom_annotations);
3057
0
        return 0;
3058
0
    }
3059
17
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3060
17
                                  YieldFrom_annotations) == 0;
3061
17
    if (!cond) {
3062
0
        Py_DECREF(YieldFrom_annotations);
3063
0
        return 0;
3064
0
    }
3065
17
    Py_DECREF(YieldFrom_annotations);
3066
17
    PyObject *Compare_annotations = PyDict_New();
3067
17
    if (!Compare_annotations) return 0;
3068
17
    {
3069
17
        PyObject *type = state->expr_type;
3070
17
        Py_INCREF(type);
3071
17
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3072
17
        Py_DECREF(type);
3073
17
        if (!cond) {
3074
0
            Py_DECREF(Compare_annotations);
3075
0
            return 0;
3076
0
        }
3077
17
    }
3078
17
    {
3079
17
        PyObject *type = state->cmpop_type;
3080
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3081
17
        cond = type != NULL;
3082
17
        if (!cond) {
3083
0
            Py_DECREF(Compare_annotations);
3084
0
            return 0;
3085
0
        }
3086
17
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3087
17
        Py_DECREF(type);
3088
17
        if (!cond) {
3089
0
            Py_DECREF(Compare_annotations);
3090
0
            return 0;
3091
0
        }
3092
17
    }
3093
17
    {
3094
17
        PyObject *type = state->expr_type;
3095
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3096
17
        cond = type != NULL;
3097
17
        if (!cond) {
3098
0
            Py_DECREF(Compare_annotations);
3099
0
            return 0;
3100
0
        }
3101
17
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3102
17
                                    == 0;
3103
17
        Py_DECREF(type);
3104
17
        if (!cond) {
3105
0
            Py_DECREF(Compare_annotations);
3106
0
            return 0;
3107
0
        }
3108
17
    }
3109
17
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3110
17
                                  Compare_annotations) == 0;
3111
17
    if (!cond) {
3112
0
        Py_DECREF(Compare_annotations);
3113
0
        return 0;
3114
0
    }
3115
17
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3116
17
                                  Compare_annotations) == 0;
3117
17
    if (!cond) {
3118
0
        Py_DECREF(Compare_annotations);
3119
0
        return 0;
3120
0
    }
3121
17
    Py_DECREF(Compare_annotations);
3122
17
    PyObject *Call_annotations = PyDict_New();
3123
17
    if (!Call_annotations) return 0;
3124
17
    {
3125
17
        PyObject *type = state->expr_type;
3126
17
        Py_INCREF(type);
3127
17
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3128
17
        Py_DECREF(type);
3129
17
        if (!cond) {
3130
0
            Py_DECREF(Call_annotations);
3131
0
            return 0;
3132
0
        }
3133
17
    }
3134
17
    {
3135
17
        PyObject *type = state->expr_type;
3136
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3137
17
        cond = type != NULL;
3138
17
        if (!cond) {
3139
0
            Py_DECREF(Call_annotations);
3140
0
            return 0;
3141
0
        }
3142
17
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3143
17
        Py_DECREF(type);
3144
17
        if (!cond) {
3145
0
            Py_DECREF(Call_annotations);
3146
0
            return 0;
3147
0
        }
3148
17
    }
3149
17
    {
3150
17
        PyObject *type = state->keyword_type;
3151
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3152
17
        cond = type != NULL;
3153
17
        if (!cond) {
3154
0
            Py_DECREF(Call_annotations);
3155
0
            return 0;
3156
0
        }
3157
17
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3158
17
        Py_DECREF(type);
3159
17
        if (!cond) {
3160
0
            Py_DECREF(Call_annotations);
3161
0
            return 0;
3162
0
        }
3163
17
    }
3164
17
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3165
17
                                  Call_annotations) == 0;
3166
17
    if (!cond) {
3167
0
        Py_DECREF(Call_annotations);
3168
0
        return 0;
3169
0
    }
3170
17
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3171
17
                                  Call_annotations) == 0;
3172
17
    if (!cond) {
3173
0
        Py_DECREF(Call_annotations);
3174
0
        return 0;
3175
0
    }
3176
17
    Py_DECREF(Call_annotations);
3177
17
    PyObject *FormattedValue_annotations = PyDict_New();
3178
17
    if (!FormattedValue_annotations) return 0;
3179
17
    {
3180
17
        PyObject *type = state->expr_type;
3181
17
        Py_INCREF(type);
3182
17
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3183
17
                                    == 0;
3184
17
        Py_DECREF(type);
3185
17
        if (!cond) {
3186
0
            Py_DECREF(FormattedValue_annotations);
3187
0
            return 0;
3188
0
        }
3189
17
    }
3190
17
    {
3191
17
        PyObject *type = (PyObject *)&PyLong_Type;
3192
17
        Py_INCREF(type);
3193
17
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3194
17
                                    type) == 0;
3195
17
        Py_DECREF(type);
3196
17
        if (!cond) {
3197
0
            Py_DECREF(FormattedValue_annotations);
3198
0
            return 0;
3199
0
        }
3200
17
    }
3201
17
    {
3202
17
        PyObject *type = state->expr_type;
3203
17
        type = _Py_union_type_or(type, Py_None);
3204
17
        cond = type != NULL;
3205
17
        if (!cond) {
3206
0
            Py_DECREF(FormattedValue_annotations);
3207
0
            return 0;
3208
0
        }
3209
17
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3210
17
                                    type) == 0;
3211
17
        Py_DECREF(type);
3212
17
        if (!cond) {
3213
0
            Py_DECREF(FormattedValue_annotations);
3214
0
            return 0;
3215
0
        }
3216
17
    }
3217
17
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3218
17
                                  FormattedValue_annotations) == 0;
3219
17
    if (!cond) {
3220
0
        Py_DECREF(FormattedValue_annotations);
3221
0
        return 0;
3222
0
    }
3223
17
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3224
17
                                  "__annotations__",
3225
17
                                  FormattedValue_annotations) == 0;
3226
17
    if (!cond) {
3227
0
        Py_DECREF(FormattedValue_annotations);
3228
0
        return 0;
3229
0
    }
3230
17
    Py_DECREF(FormattedValue_annotations);
3231
17
    PyObject *Interpolation_annotations = PyDict_New();
3232
17
    if (!Interpolation_annotations) return 0;
3233
17
    {
3234
17
        PyObject *type = state->expr_type;
3235
17
        Py_INCREF(type);
3236
17
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3237
17
                                    == 0;
3238
17
        Py_DECREF(type);
3239
17
        if (!cond) {
3240
0
            Py_DECREF(Interpolation_annotations);
3241
0
            return 0;
3242
0
        }
3243
17
    }
3244
17
    {
3245
17
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3246
17
        Py_INCREF(type);
3247
17
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3248
17
                                    0;
3249
17
        Py_DECREF(type);
3250
17
        if (!cond) {
3251
0
            Py_DECREF(Interpolation_annotations);
3252
0
            return 0;
3253
0
        }
3254
17
    }
3255
17
    {
3256
17
        PyObject *type = (PyObject *)&PyLong_Type;
3257
17
        Py_INCREF(type);
3258
17
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3259
17
                                    type) == 0;
3260
17
        Py_DECREF(type);
3261
17
        if (!cond) {
3262
0
            Py_DECREF(Interpolation_annotations);
3263
0
            return 0;
3264
0
        }
3265
17
    }
3266
17
    {
3267
17
        PyObject *type = state->expr_type;
3268
17
        type = _Py_union_type_or(type, Py_None);
3269
17
        cond = type != NULL;
3270
17
        if (!cond) {
3271
0
            Py_DECREF(Interpolation_annotations);
3272
0
            return 0;
3273
0
        }
3274
17
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3275
17
                                    type) == 0;
3276
17
        Py_DECREF(type);
3277
17
        if (!cond) {
3278
0
            Py_DECREF(Interpolation_annotations);
3279
0
            return 0;
3280
0
        }
3281
17
    }
3282
17
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3283
17
                                  Interpolation_annotations) == 0;
3284
17
    if (!cond) {
3285
0
        Py_DECREF(Interpolation_annotations);
3286
0
        return 0;
3287
0
    }
3288
17
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3289
17
                                  Interpolation_annotations) == 0;
3290
17
    if (!cond) {
3291
0
        Py_DECREF(Interpolation_annotations);
3292
0
        return 0;
3293
0
    }
3294
17
    Py_DECREF(Interpolation_annotations);
3295
17
    PyObject *JoinedStr_annotations = PyDict_New();
3296
17
    if (!JoinedStr_annotations) return 0;
3297
17
    {
3298
17
        PyObject *type = state->expr_type;
3299
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3300
17
        cond = type != NULL;
3301
17
        if (!cond) {
3302
0
            Py_DECREF(JoinedStr_annotations);
3303
0
            return 0;
3304
0
        }
3305
17
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3306
17
        Py_DECREF(type);
3307
17
        if (!cond) {
3308
0
            Py_DECREF(JoinedStr_annotations);
3309
0
            return 0;
3310
0
        }
3311
17
    }
3312
17
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3313
17
                                  JoinedStr_annotations) == 0;
3314
17
    if (!cond) {
3315
0
        Py_DECREF(JoinedStr_annotations);
3316
0
        return 0;
3317
0
    }
3318
17
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3319
17
                                  JoinedStr_annotations) == 0;
3320
17
    if (!cond) {
3321
0
        Py_DECREF(JoinedStr_annotations);
3322
0
        return 0;
3323
0
    }
3324
17
    Py_DECREF(JoinedStr_annotations);
3325
17
    PyObject *TemplateStr_annotations = PyDict_New();
3326
17
    if (!TemplateStr_annotations) return 0;
3327
17
    {
3328
17
        PyObject *type = state->expr_type;
3329
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3330
17
        cond = type != NULL;
3331
17
        if (!cond) {
3332
0
            Py_DECREF(TemplateStr_annotations);
3333
0
            return 0;
3334
0
        }
3335
17
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3336
17
                                    0;
3337
17
        Py_DECREF(type);
3338
17
        if (!cond) {
3339
0
            Py_DECREF(TemplateStr_annotations);
3340
0
            return 0;
3341
0
        }
3342
17
    }
3343
17
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3344
17
                                  TemplateStr_annotations) == 0;
3345
17
    if (!cond) {
3346
0
        Py_DECREF(TemplateStr_annotations);
3347
0
        return 0;
3348
0
    }
3349
17
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3350
17
                                  TemplateStr_annotations) == 0;
3351
17
    if (!cond) {
3352
0
        Py_DECREF(TemplateStr_annotations);
3353
0
        return 0;
3354
0
    }
3355
17
    Py_DECREF(TemplateStr_annotations);
3356
17
    PyObject *Constant_annotations = PyDict_New();
3357
17
    if (!Constant_annotations) return 0;
3358
17
    {
3359
17
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3360
17
        Py_INCREF(type);
3361
17
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3362
17
        Py_DECREF(type);
3363
17
        if (!cond) {
3364
0
            Py_DECREF(Constant_annotations);
3365
0
            return 0;
3366
0
        }
3367
17
    }
3368
17
    {
3369
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
3370
17
        type = _Py_union_type_or(type, Py_None);
3371
17
        cond = type != NULL;
3372
17
        if (!cond) {
3373
0
            Py_DECREF(Constant_annotations);
3374
0
            return 0;
3375
0
        }
3376
17
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3377
17
        Py_DECREF(type);
3378
17
        if (!cond) {
3379
0
            Py_DECREF(Constant_annotations);
3380
0
            return 0;
3381
0
        }
3382
17
    }
3383
17
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3384
17
                                  Constant_annotations) == 0;
3385
17
    if (!cond) {
3386
0
        Py_DECREF(Constant_annotations);
3387
0
        return 0;
3388
0
    }
3389
17
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3390
17
                                  Constant_annotations) == 0;
3391
17
    if (!cond) {
3392
0
        Py_DECREF(Constant_annotations);
3393
0
        return 0;
3394
0
    }
3395
17
    Py_DECREF(Constant_annotations);
3396
17
    PyObject *Attribute_annotations = PyDict_New();
3397
17
    if (!Attribute_annotations) return 0;
3398
17
    {
3399
17
        PyObject *type = state->expr_type;
3400
17
        Py_INCREF(type);
3401
17
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3402
17
        Py_DECREF(type);
3403
17
        if (!cond) {
3404
0
            Py_DECREF(Attribute_annotations);
3405
0
            return 0;
3406
0
        }
3407
17
    }
3408
17
    {
3409
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
3410
17
        Py_INCREF(type);
3411
17
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3412
17
        Py_DECREF(type);
3413
17
        if (!cond) {
3414
0
            Py_DECREF(Attribute_annotations);
3415
0
            return 0;
3416
0
        }
3417
17
    }
3418
17
    {
3419
17
        PyObject *type = state->expr_context_type;
3420
17
        Py_INCREF(type);
3421
17
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3422
17
        Py_DECREF(type);
3423
17
        if (!cond) {
3424
0
            Py_DECREF(Attribute_annotations);
3425
0
            return 0;
3426
0
        }
3427
17
    }
3428
17
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3429
17
                                  Attribute_annotations) == 0;
3430
17
    if (!cond) {
3431
0
        Py_DECREF(Attribute_annotations);
3432
0
        return 0;
3433
0
    }
3434
17
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3435
17
                                  Attribute_annotations) == 0;
3436
17
    if (!cond) {
3437
0
        Py_DECREF(Attribute_annotations);
3438
0
        return 0;
3439
0
    }
3440
17
    Py_DECREF(Attribute_annotations);
3441
17
    PyObject *Subscript_annotations = PyDict_New();
3442
17
    if (!Subscript_annotations) return 0;
3443
17
    {
3444
17
        PyObject *type = state->expr_type;
3445
17
        Py_INCREF(type);
3446
17
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3447
17
        Py_DECREF(type);
3448
17
        if (!cond) {
3449
0
            Py_DECREF(Subscript_annotations);
3450
0
            return 0;
3451
0
        }
3452
17
    }
3453
17
    {
3454
17
        PyObject *type = state->expr_type;
3455
17
        Py_INCREF(type);
3456
17
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3457
17
        Py_DECREF(type);
3458
17
        if (!cond) {
3459
0
            Py_DECREF(Subscript_annotations);
3460
0
            return 0;
3461
0
        }
3462
17
    }
3463
17
    {
3464
17
        PyObject *type = state->expr_context_type;
3465
17
        Py_INCREF(type);
3466
17
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3467
17
        Py_DECREF(type);
3468
17
        if (!cond) {
3469
0
            Py_DECREF(Subscript_annotations);
3470
0
            return 0;
3471
0
        }
3472
17
    }
3473
17
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3474
17
                                  Subscript_annotations) == 0;
3475
17
    if (!cond) {
3476
0
        Py_DECREF(Subscript_annotations);
3477
0
        return 0;
3478
0
    }
3479
17
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3480
17
                                  Subscript_annotations) == 0;
3481
17
    if (!cond) {
3482
0
        Py_DECREF(Subscript_annotations);
3483
0
        return 0;
3484
0
    }
3485
17
    Py_DECREF(Subscript_annotations);
3486
17
    PyObject *Starred_annotations = PyDict_New();
3487
17
    if (!Starred_annotations) return 0;
3488
17
    {
3489
17
        PyObject *type = state->expr_type;
3490
17
        Py_INCREF(type);
3491
17
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3492
17
        Py_DECREF(type);
3493
17
        if (!cond) {
3494
0
            Py_DECREF(Starred_annotations);
3495
0
            return 0;
3496
0
        }
3497
17
    }
3498
17
    {
3499
17
        PyObject *type = state->expr_context_type;
3500
17
        Py_INCREF(type);
3501
17
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3502
17
        Py_DECREF(type);
3503
17
        if (!cond) {
3504
0
            Py_DECREF(Starred_annotations);
3505
0
            return 0;
3506
0
        }
3507
17
    }
3508
17
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3509
17
                                  Starred_annotations) == 0;
3510
17
    if (!cond) {
3511
0
        Py_DECREF(Starred_annotations);
3512
0
        return 0;
3513
0
    }
3514
17
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3515
17
                                  Starred_annotations) == 0;
3516
17
    if (!cond) {
3517
0
        Py_DECREF(Starred_annotations);
3518
0
        return 0;
3519
0
    }
3520
17
    Py_DECREF(Starred_annotations);
3521
17
    PyObject *Name_annotations = PyDict_New();
3522
17
    if (!Name_annotations) return 0;
3523
17
    {
3524
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
3525
17
        Py_INCREF(type);
3526
17
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3527
17
        Py_DECREF(type);
3528
17
        if (!cond) {
3529
0
            Py_DECREF(Name_annotations);
3530
0
            return 0;
3531
0
        }
3532
17
    }
3533
17
    {
3534
17
        PyObject *type = state->expr_context_type;
3535
17
        Py_INCREF(type);
3536
17
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3537
17
        Py_DECREF(type);
3538
17
        if (!cond) {
3539
0
            Py_DECREF(Name_annotations);
3540
0
            return 0;
3541
0
        }
3542
17
    }
3543
17
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3544
17
                                  Name_annotations) == 0;
3545
17
    if (!cond) {
3546
0
        Py_DECREF(Name_annotations);
3547
0
        return 0;
3548
0
    }
3549
17
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3550
17
                                  Name_annotations) == 0;
3551
17
    if (!cond) {
3552
0
        Py_DECREF(Name_annotations);
3553
0
        return 0;
3554
0
    }
3555
17
    Py_DECREF(Name_annotations);
3556
17
    PyObject *List_annotations = PyDict_New();
3557
17
    if (!List_annotations) return 0;
3558
17
    {
3559
17
        PyObject *type = state->expr_type;
3560
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3561
17
        cond = type != NULL;
3562
17
        if (!cond) {
3563
0
            Py_DECREF(List_annotations);
3564
0
            return 0;
3565
0
        }
3566
17
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3567
17
        Py_DECREF(type);
3568
17
        if (!cond) {
3569
0
            Py_DECREF(List_annotations);
3570
0
            return 0;
3571
0
        }
3572
17
    }
3573
17
    {
3574
17
        PyObject *type = state->expr_context_type;
3575
17
        Py_INCREF(type);
3576
17
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3577
17
        Py_DECREF(type);
3578
17
        if (!cond) {
3579
0
            Py_DECREF(List_annotations);
3580
0
            return 0;
3581
0
        }
3582
17
    }
3583
17
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3584
17
                                  List_annotations) == 0;
3585
17
    if (!cond) {
3586
0
        Py_DECREF(List_annotations);
3587
0
        return 0;
3588
0
    }
3589
17
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3590
17
                                  List_annotations) == 0;
3591
17
    if (!cond) {
3592
0
        Py_DECREF(List_annotations);
3593
0
        return 0;
3594
0
    }
3595
17
    Py_DECREF(List_annotations);
3596
17
    PyObject *Tuple_annotations = PyDict_New();
3597
17
    if (!Tuple_annotations) return 0;
3598
17
    {
3599
17
        PyObject *type = state->expr_type;
3600
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3601
17
        cond = type != NULL;
3602
17
        if (!cond) {
3603
0
            Py_DECREF(Tuple_annotations);
3604
0
            return 0;
3605
0
        }
3606
17
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3607
17
        Py_DECREF(type);
3608
17
        if (!cond) {
3609
0
            Py_DECREF(Tuple_annotations);
3610
0
            return 0;
3611
0
        }
3612
17
    }
3613
17
    {
3614
17
        PyObject *type = state->expr_context_type;
3615
17
        Py_INCREF(type);
3616
17
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3617
17
        Py_DECREF(type);
3618
17
        if (!cond) {
3619
0
            Py_DECREF(Tuple_annotations);
3620
0
            return 0;
3621
0
        }
3622
17
    }
3623
17
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3624
17
                                  Tuple_annotations) == 0;
3625
17
    if (!cond) {
3626
0
        Py_DECREF(Tuple_annotations);
3627
0
        return 0;
3628
0
    }
3629
17
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3630
17
                                  Tuple_annotations) == 0;
3631
17
    if (!cond) {
3632
0
        Py_DECREF(Tuple_annotations);
3633
0
        return 0;
3634
0
    }
3635
17
    Py_DECREF(Tuple_annotations);
3636
17
    PyObject *Slice_annotations = PyDict_New();
3637
17
    if (!Slice_annotations) return 0;
3638
17
    {
3639
17
        PyObject *type = state->expr_type;
3640
17
        type = _Py_union_type_or(type, Py_None);
3641
17
        cond = type != NULL;
3642
17
        if (!cond) {
3643
0
            Py_DECREF(Slice_annotations);
3644
0
            return 0;
3645
0
        }
3646
17
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3647
17
        Py_DECREF(type);
3648
17
        if (!cond) {
3649
0
            Py_DECREF(Slice_annotations);
3650
0
            return 0;
3651
0
        }
3652
17
    }
3653
17
    {
3654
17
        PyObject *type = state->expr_type;
3655
17
        type = _Py_union_type_or(type, Py_None);
3656
17
        cond = type != NULL;
3657
17
        if (!cond) {
3658
0
            Py_DECREF(Slice_annotations);
3659
0
            return 0;
3660
0
        }
3661
17
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3662
17
        Py_DECREF(type);
3663
17
        if (!cond) {
3664
0
            Py_DECREF(Slice_annotations);
3665
0
            return 0;
3666
0
        }
3667
17
    }
3668
17
    {
3669
17
        PyObject *type = state->expr_type;
3670
17
        type = _Py_union_type_or(type, Py_None);
3671
17
        cond = type != NULL;
3672
17
        if (!cond) {
3673
0
            Py_DECREF(Slice_annotations);
3674
0
            return 0;
3675
0
        }
3676
17
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3677
17
        Py_DECREF(type);
3678
17
        if (!cond) {
3679
0
            Py_DECREF(Slice_annotations);
3680
0
            return 0;
3681
0
        }
3682
17
    }
3683
17
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3684
17
                                  Slice_annotations) == 0;
3685
17
    if (!cond) {
3686
0
        Py_DECREF(Slice_annotations);
3687
0
        return 0;
3688
0
    }
3689
17
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3690
17
                                  Slice_annotations) == 0;
3691
17
    if (!cond) {
3692
0
        Py_DECREF(Slice_annotations);
3693
0
        return 0;
3694
0
    }
3695
17
    Py_DECREF(Slice_annotations);
3696
17
    PyObject *Load_annotations = PyDict_New();
3697
17
    if (!Load_annotations) return 0;
3698
17
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3699
17
                                  Load_annotations) == 0;
3700
17
    if (!cond) {
3701
0
        Py_DECREF(Load_annotations);
3702
0
        return 0;
3703
0
    }
3704
17
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3705
17
                                  Load_annotations) == 0;
3706
17
    if (!cond) {
3707
0
        Py_DECREF(Load_annotations);
3708
0
        return 0;
3709
0
    }
3710
17
    Py_DECREF(Load_annotations);
3711
17
    PyObject *Store_annotations = PyDict_New();
3712
17
    if (!Store_annotations) return 0;
3713
17
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3714
17
                                  Store_annotations) == 0;
3715
17
    if (!cond) {
3716
0
        Py_DECREF(Store_annotations);
3717
0
        return 0;
3718
0
    }
3719
17
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3720
17
                                  Store_annotations) == 0;
3721
17
    if (!cond) {
3722
0
        Py_DECREF(Store_annotations);
3723
0
        return 0;
3724
0
    }
3725
17
    Py_DECREF(Store_annotations);
3726
17
    PyObject *Del_annotations = PyDict_New();
3727
17
    if (!Del_annotations) return 0;
3728
17
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3729
17
                                  Del_annotations) == 0;
3730
17
    if (!cond) {
3731
0
        Py_DECREF(Del_annotations);
3732
0
        return 0;
3733
0
    }
3734
17
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3735
17
                                  Del_annotations) == 0;
3736
17
    if (!cond) {
3737
0
        Py_DECREF(Del_annotations);
3738
0
        return 0;
3739
0
    }
3740
17
    Py_DECREF(Del_annotations);
3741
17
    PyObject *And_annotations = PyDict_New();
3742
17
    if (!And_annotations) return 0;
3743
17
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3744
17
                                  And_annotations) == 0;
3745
17
    if (!cond) {
3746
0
        Py_DECREF(And_annotations);
3747
0
        return 0;
3748
0
    }
3749
17
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3750
17
                                  And_annotations) == 0;
3751
17
    if (!cond) {
3752
0
        Py_DECREF(And_annotations);
3753
0
        return 0;
3754
0
    }
3755
17
    Py_DECREF(And_annotations);
3756
17
    PyObject *Or_annotations = PyDict_New();
3757
17
    if (!Or_annotations) return 0;
3758
17
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3759
17
                                  Or_annotations) == 0;
3760
17
    if (!cond) {
3761
0
        Py_DECREF(Or_annotations);
3762
0
        return 0;
3763
0
    }
3764
17
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3765
17
                                  Or_annotations) == 0;
3766
17
    if (!cond) {
3767
0
        Py_DECREF(Or_annotations);
3768
0
        return 0;
3769
0
    }
3770
17
    Py_DECREF(Or_annotations);
3771
17
    PyObject *Add_annotations = PyDict_New();
3772
17
    if (!Add_annotations) return 0;
3773
17
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3774
17
                                  Add_annotations) == 0;
3775
17
    if (!cond) {
3776
0
        Py_DECREF(Add_annotations);
3777
0
        return 0;
3778
0
    }
3779
17
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3780
17
                                  Add_annotations) == 0;
3781
17
    if (!cond) {
3782
0
        Py_DECREF(Add_annotations);
3783
0
        return 0;
3784
0
    }
3785
17
    Py_DECREF(Add_annotations);
3786
17
    PyObject *Sub_annotations = PyDict_New();
3787
17
    if (!Sub_annotations) return 0;
3788
17
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3789
17
                                  Sub_annotations) == 0;
3790
17
    if (!cond) {
3791
0
        Py_DECREF(Sub_annotations);
3792
0
        return 0;
3793
0
    }
3794
17
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3795
17
                                  Sub_annotations) == 0;
3796
17
    if (!cond) {
3797
0
        Py_DECREF(Sub_annotations);
3798
0
        return 0;
3799
0
    }
3800
17
    Py_DECREF(Sub_annotations);
3801
17
    PyObject *Mult_annotations = PyDict_New();
3802
17
    if (!Mult_annotations) return 0;
3803
17
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3804
17
                                  Mult_annotations) == 0;
3805
17
    if (!cond) {
3806
0
        Py_DECREF(Mult_annotations);
3807
0
        return 0;
3808
0
    }
3809
17
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3810
17
                                  Mult_annotations) == 0;
3811
17
    if (!cond) {
3812
0
        Py_DECREF(Mult_annotations);
3813
0
        return 0;
3814
0
    }
3815
17
    Py_DECREF(Mult_annotations);
3816
17
    PyObject *MatMult_annotations = PyDict_New();
3817
17
    if (!MatMult_annotations) return 0;
3818
17
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3819
17
                                  MatMult_annotations) == 0;
3820
17
    if (!cond) {
3821
0
        Py_DECREF(MatMult_annotations);
3822
0
        return 0;
3823
0
    }
3824
17
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3825
17
                                  MatMult_annotations) == 0;
3826
17
    if (!cond) {
3827
0
        Py_DECREF(MatMult_annotations);
3828
0
        return 0;
3829
0
    }
3830
17
    Py_DECREF(MatMult_annotations);
3831
17
    PyObject *Div_annotations = PyDict_New();
3832
17
    if (!Div_annotations) return 0;
3833
17
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3834
17
                                  Div_annotations) == 0;
3835
17
    if (!cond) {
3836
0
        Py_DECREF(Div_annotations);
3837
0
        return 0;
3838
0
    }
3839
17
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3840
17
                                  Div_annotations) == 0;
3841
17
    if (!cond) {
3842
0
        Py_DECREF(Div_annotations);
3843
0
        return 0;
3844
0
    }
3845
17
    Py_DECREF(Div_annotations);
3846
17
    PyObject *Mod_annotations = PyDict_New();
3847
17
    if (!Mod_annotations) return 0;
3848
17
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3849
17
                                  Mod_annotations) == 0;
3850
17
    if (!cond) {
3851
0
        Py_DECREF(Mod_annotations);
3852
0
        return 0;
3853
0
    }
3854
17
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3855
17
                                  Mod_annotations) == 0;
3856
17
    if (!cond) {
3857
0
        Py_DECREF(Mod_annotations);
3858
0
        return 0;
3859
0
    }
3860
17
    Py_DECREF(Mod_annotations);
3861
17
    PyObject *Pow_annotations = PyDict_New();
3862
17
    if (!Pow_annotations) return 0;
3863
17
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3864
17
                                  Pow_annotations) == 0;
3865
17
    if (!cond) {
3866
0
        Py_DECREF(Pow_annotations);
3867
0
        return 0;
3868
0
    }
3869
17
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3870
17
                                  Pow_annotations) == 0;
3871
17
    if (!cond) {
3872
0
        Py_DECREF(Pow_annotations);
3873
0
        return 0;
3874
0
    }
3875
17
    Py_DECREF(Pow_annotations);
3876
17
    PyObject *LShift_annotations = PyDict_New();
3877
17
    if (!LShift_annotations) return 0;
3878
17
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3879
17
                                  LShift_annotations) == 0;
3880
17
    if (!cond) {
3881
0
        Py_DECREF(LShift_annotations);
3882
0
        return 0;
3883
0
    }
3884
17
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3885
17
                                  LShift_annotations) == 0;
3886
17
    if (!cond) {
3887
0
        Py_DECREF(LShift_annotations);
3888
0
        return 0;
3889
0
    }
3890
17
    Py_DECREF(LShift_annotations);
3891
17
    PyObject *RShift_annotations = PyDict_New();
3892
17
    if (!RShift_annotations) return 0;
3893
17
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3894
17
                                  RShift_annotations) == 0;
3895
17
    if (!cond) {
3896
0
        Py_DECREF(RShift_annotations);
3897
0
        return 0;
3898
0
    }
3899
17
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3900
17
                                  RShift_annotations) == 0;
3901
17
    if (!cond) {
3902
0
        Py_DECREF(RShift_annotations);
3903
0
        return 0;
3904
0
    }
3905
17
    Py_DECREF(RShift_annotations);
3906
17
    PyObject *BitOr_annotations = PyDict_New();
3907
17
    if (!BitOr_annotations) return 0;
3908
17
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3909
17
                                  BitOr_annotations) == 0;
3910
17
    if (!cond) {
3911
0
        Py_DECREF(BitOr_annotations);
3912
0
        return 0;
3913
0
    }
3914
17
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3915
17
                                  BitOr_annotations) == 0;
3916
17
    if (!cond) {
3917
0
        Py_DECREF(BitOr_annotations);
3918
0
        return 0;
3919
0
    }
3920
17
    Py_DECREF(BitOr_annotations);
3921
17
    PyObject *BitXor_annotations = PyDict_New();
3922
17
    if (!BitXor_annotations) return 0;
3923
17
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3924
17
                                  BitXor_annotations) == 0;
3925
17
    if (!cond) {
3926
0
        Py_DECREF(BitXor_annotations);
3927
0
        return 0;
3928
0
    }
3929
17
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3930
17
                                  BitXor_annotations) == 0;
3931
17
    if (!cond) {
3932
0
        Py_DECREF(BitXor_annotations);
3933
0
        return 0;
3934
0
    }
3935
17
    Py_DECREF(BitXor_annotations);
3936
17
    PyObject *BitAnd_annotations = PyDict_New();
3937
17
    if (!BitAnd_annotations) return 0;
3938
17
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3939
17
                                  BitAnd_annotations) == 0;
3940
17
    if (!cond) {
3941
0
        Py_DECREF(BitAnd_annotations);
3942
0
        return 0;
3943
0
    }
3944
17
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3945
17
                                  BitAnd_annotations) == 0;
3946
17
    if (!cond) {
3947
0
        Py_DECREF(BitAnd_annotations);
3948
0
        return 0;
3949
0
    }
3950
17
    Py_DECREF(BitAnd_annotations);
3951
17
    PyObject *FloorDiv_annotations = PyDict_New();
3952
17
    if (!FloorDiv_annotations) return 0;
3953
17
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3954
17
                                  FloorDiv_annotations) == 0;
3955
17
    if (!cond) {
3956
0
        Py_DECREF(FloorDiv_annotations);
3957
0
        return 0;
3958
0
    }
3959
17
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3960
17
                                  FloorDiv_annotations) == 0;
3961
17
    if (!cond) {
3962
0
        Py_DECREF(FloorDiv_annotations);
3963
0
        return 0;
3964
0
    }
3965
17
    Py_DECREF(FloorDiv_annotations);
3966
17
    PyObject *Invert_annotations = PyDict_New();
3967
17
    if (!Invert_annotations) return 0;
3968
17
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3969
17
                                  Invert_annotations) == 0;
3970
17
    if (!cond) {
3971
0
        Py_DECREF(Invert_annotations);
3972
0
        return 0;
3973
0
    }
3974
17
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3975
17
                                  Invert_annotations) == 0;
3976
17
    if (!cond) {
3977
0
        Py_DECREF(Invert_annotations);
3978
0
        return 0;
3979
0
    }
3980
17
    Py_DECREF(Invert_annotations);
3981
17
    PyObject *Not_annotations = PyDict_New();
3982
17
    if (!Not_annotations) return 0;
3983
17
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3984
17
                                  Not_annotations) == 0;
3985
17
    if (!cond) {
3986
0
        Py_DECREF(Not_annotations);
3987
0
        return 0;
3988
0
    }
3989
17
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3990
17
                                  Not_annotations) == 0;
3991
17
    if (!cond) {
3992
0
        Py_DECREF(Not_annotations);
3993
0
        return 0;
3994
0
    }
3995
17
    Py_DECREF(Not_annotations);
3996
17
    PyObject *UAdd_annotations = PyDict_New();
3997
17
    if (!UAdd_annotations) return 0;
3998
17
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3999
17
                                  UAdd_annotations) == 0;
4000
17
    if (!cond) {
4001
0
        Py_DECREF(UAdd_annotations);
4002
0
        return 0;
4003
0
    }
4004
17
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
4005
17
                                  UAdd_annotations) == 0;
4006
17
    if (!cond) {
4007
0
        Py_DECREF(UAdd_annotations);
4008
0
        return 0;
4009
0
    }
4010
17
    Py_DECREF(UAdd_annotations);
4011
17
    PyObject *USub_annotations = PyDict_New();
4012
17
    if (!USub_annotations) return 0;
4013
17
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
4014
17
                                  USub_annotations) == 0;
4015
17
    if (!cond) {
4016
0
        Py_DECREF(USub_annotations);
4017
0
        return 0;
4018
0
    }
4019
17
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
4020
17
                                  USub_annotations) == 0;
4021
17
    if (!cond) {
4022
0
        Py_DECREF(USub_annotations);
4023
0
        return 0;
4024
0
    }
4025
17
    Py_DECREF(USub_annotations);
4026
17
    PyObject *Eq_annotations = PyDict_New();
4027
17
    if (!Eq_annotations) return 0;
4028
17
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
4029
17
                                  Eq_annotations) == 0;
4030
17
    if (!cond) {
4031
0
        Py_DECREF(Eq_annotations);
4032
0
        return 0;
4033
0
    }
4034
17
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
4035
17
                                  Eq_annotations) == 0;
4036
17
    if (!cond) {
4037
0
        Py_DECREF(Eq_annotations);
4038
0
        return 0;
4039
0
    }
4040
17
    Py_DECREF(Eq_annotations);
4041
17
    PyObject *NotEq_annotations = PyDict_New();
4042
17
    if (!NotEq_annotations) return 0;
4043
17
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4044
17
                                  NotEq_annotations) == 0;
4045
17
    if (!cond) {
4046
0
        Py_DECREF(NotEq_annotations);
4047
0
        return 0;
4048
0
    }
4049
17
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4050
17
                                  NotEq_annotations) == 0;
4051
17
    if (!cond) {
4052
0
        Py_DECREF(NotEq_annotations);
4053
0
        return 0;
4054
0
    }
4055
17
    Py_DECREF(NotEq_annotations);
4056
17
    PyObject *Lt_annotations = PyDict_New();
4057
17
    if (!Lt_annotations) return 0;
4058
17
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4059
17
                                  Lt_annotations) == 0;
4060
17
    if (!cond) {
4061
0
        Py_DECREF(Lt_annotations);
4062
0
        return 0;
4063
0
    }
4064
17
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4065
17
                                  Lt_annotations) == 0;
4066
17
    if (!cond) {
4067
0
        Py_DECREF(Lt_annotations);
4068
0
        return 0;
4069
0
    }
4070
17
    Py_DECREF(Lt_annotations);
4071
17
    PyObject *LtE_annotations = PyDict_New();
4072
17
    if (!LtE_annotations) return 0;
4073
17
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4074
17
                                  LtE_annotations) == 0;
4075
17
    if (!cond) {
4076
0
        Py_DECREF(LtE_annotations);
4077
0
        return 0;
4078
0
    }
4079
17
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4080
17
                                  LtE_annotations) == 0;
4081
17
    if (!cond) {
4082
0
        Py_DECREF(LtE_annotations);
4083
0
        return 0;
4084
0
    }
4085
17
    Py_DECREF(LtE_annotations);
4086
17
    PyObject *Gt_annotations = PyDict_New();
4087
17
    if (!Gt_annotations) return 0;
4088
17
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4089
17
                                  Gt_annotations) == 0;
4090
17
    if (!cond) {
4091
0
        Py_DECREF(Gt_annotations);
4092
0
        return 0;
4093
0
    }
4094
17
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4095
17
                                  Gt_annotations) == 0;
4096
17
    if (!cond) {
4097
0
        Py_DECREF(Gt_annotations);
4098
0
        return 0;
4099
0
    }
4100
17
    Py_DECREF(Gt_annotations);
4101
17
    PyObject *GtE_annotations = PyDict_New();
4102
17
    if (!GtE_annotations) return 0;
4103
17
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4104
17
                                  GtE_annotations) == 0;
4105
17
    if (!cond) {
4106
0
        Py_DECREF(GtE_annotations);
4107
0
        return 0;
4108
0
    }
4109
17
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4110
17
                                  GtE_annotations) == 0;
4111
17
    if (!cond) {
4112
0
        Py_DECREF(GtE_annotations);
4113
0
        return 0;
4114
0
    }
4115
17
    Py_DECREF(GtE_annotations);
4116
17
    PyObject *Is_annotations = PyDict_New();
4117
17
    if (!Is_annotations) return 0;
4118
17
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4119
17
                                  Is_annotations) == 0;
4120
17
    if (!cond) {
4121
0
        Py_DECREF(Is_annotations);
4122
0
        return 0;
4123
0
    }
4124
17
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4125
17
                                  Is_annotations) == 0;
4126
17
    if (!cond) {
4127
0
        Py_DECREF(Is_annotations);
4128
0
        return 0;
4129
0
    }
4130
17
    Py_DECREF(Is_annotations);
4131
17
    PyObject *IsNot_annotations = PyDict_New();
4132
17
    if (!IsNot_annotations) return 0;
4133
17
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4134
17
                                  IsNot_annotations) == 0;
4135
17
    if (!cond) {
4136
0
        Py_DECREF(IsNot_annotations);
4137
0
        return 0;
4138
0
    }
4139
17
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4140
17
                                  IsNot_annotations) == 0;
4141
17
    if (!cond) {
4142
0
        Py_DECREF(IsNot_annotations);
4143
0
        return 0;
4144
0
    }
4145
17
    Py_DECREF(IsNot_annotations);
4146
17
    PyObject *In_annotations = PyDict_New();
4147
17
    if (!In_annotations) return 0;
4148
17
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4149
17
                                  In_annotations) == 0;
4150
17
    if (!cond) {
4151
0
        Py_DECREF(In_annotations);
4152
0
        return 0;
4153
0
    }
4154
17
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4155
17
                                  In_annotations) == 0;
4156
17
    if (!cond) {
4157
0
        Py_DECREF(In_annotations);
4158
0
        return 0;
4159
0
    }
4160
17
    Py_DECREF(In_annotations);
4161
17
    PyObject *NotIn_annotations = PyDict_New();
4162
17
    if (!NotIn_annotations) return 0;
4163
17
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4164
17
                                  NotIn_annotations) == 0;
4165
17
    if (!cond) {
4166
0
        Py_DECREF(NotIn_annotations);
4167
0
        return 0;
4168
0
    }
4169
17
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4170
17
                                  NotIn_annotations) == 0;
4171
17
    if (!cond) {
4172
0
        Py_DECREF(NotIn_annotations);
4173
0
        return 0;
4174
0
    }
4175
17
    Py_DECREF(NotIn_annotations);
4176
17
    PyObject *comprehension_annotations = PyDict_New();
4177
17
    if (!comprehension_annotations) return 0;
4178
17
    {
4179
17
        PyObject *type = state->expr_type;
4180
17
        Py_INCREF(type);
4181
17
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4182
17
                                    == 0;
4183
17
        Py_DECREF(type);
4184
17
        if (!cond) {
4185
0
            Py_DECREF(comprehension_annotations);
4186
0
            return 0;
4187
0
        }
4188
17
    }
4189
17
    {
4190
17
        PyObject *type = state->expr_type;
4191
17
        Py_INCREF(type);
4192
17
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4193
17
                                    0;
4194
17
        Py_DECREF(type);
4195
17
        if (!cond) {
4196
0
            Py_DECREF(comprehension_annotations);
4197
0
            return 0;
4198
0
        }
4199
17
    }
4200
17
    {
4201
17
        PyObject *type = state->expr_type;
4202
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4203
17
        cond = type != NULL;
4204
17
        if (!cond) {
4205
0
            Py_DECREF(comprehension_annotations);
4206
0
            return 0;
4207
0
        }
4208
17
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4209
17
                                    0;
4210
17
        Py_DECREF(type);
4211
17
        if (!cond) {
4212
0
            Py_DECREF(comprehension_annotations);
4213
0
            return 0;
4214
0
        }
4215
17
    }
4216
17
    {
4217
17
        PyObject *type = (PyObject *)&PyLong_Type;
4218
17
        Py_INCREF(type);
4219
17
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4220
17
                                    type) == 0;
4221
17
        Py_DECREF(type);
4222
17
        if (!cond) {
4223
0
            Py_DECREF(comprehension_annotations);
4224
0
            return 0;
4225
0
        }
4226
17
    }
4227
17
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4228
17
                                  comprehension_annotations) == 0;
4229
17
    if (!cond) {
4230
0
        Py_DECREF(comprehension_annotations);
4231
0
        return 0;
4232
0
    }
4233
17
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4234
17
                                  comprehension_annotations) == 0;
4235
17
    if (!cond) {
4236
0
        Py_DECREF(comprehension_annotations);
4237
0
        return 0;
4238
0
    }
4239
17
    Py_DECREF(comprehension_annotations);
4240
17
    PyObject *ExceptHandler_annotations = PyDict_New();
4241
17
    if (!ExceptHandler_annotations) return 0;
4242
17
    {
4243
17
        PyObject *type = state->expr_type;
4244
17
        type = _Py_union_type_or(type, Py_None);
4245
17
        cond = type != NULL;
4246
17
        if (!cond) {
4247
0
            Py_DECREF(ExceptHandler_annotations);
4248
0
            return 0;
4249
0
        }
4250
17
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4251
17
                                    0;
4252
17
        Py_DECREF(type);
4253
17
        if (!cond) {
4254
0
            Py_DECREF(ExceptHandler_annotations);
4255
0
            return 0;
4256
0
        }
4257
17
    }
4258
17
    {
4259
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4260
17
        type = _Py_union_type_or(type, Py_None);
4261
17
        cond = type != NULL;
4262
17
        if (!cond) {
4263
0
            Py_DECREF(ExceptHandler_annotations);
4264
0
            return 0;
4265
0
        }
4266
17
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4267
17
                                    0;
4268
17
        Py_DECREF(type);
4269
17
        if (!cond) {
4270
0
            Py_DECREF(ExceptHandler_annotations);
4271
0
            return 0;
4272
0
        }
4273
17
    }
4274
17
    {
4275
17
        PyObject *type = state->stmt_type;
4276
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4277
17
        cond = type != NULL;
4278
17
        if (!cond) {
4279
0
            Py_DECREF(ExceptHandler_annotations);
4280
0
            return 0;
4281
0
        }
4282
17
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4283
17
                                    0;
4284
17
        Py_DECREF(type);
4285
17
        if (!cond) {
4286
0
            Py_DECREF(ExceptHandler_annotations);
4287
0
            return 0;
4288
0
        }
4289
17
    }
4290
17
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4291
17
                                  ExceptHandler_annotations) == 0;
4292
17
    if (!cond) {
4293
0
        Py_DECREF(ExceptHandler_annotations);
4294
0
        return 0;
4295
0
    }
4296
17
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4297
17
                                  ExceptHandler_annotations) == 0;
4298
17
    if (!cond) {
4299
0
        Py_DECREF(ExceptHandler_annotations);
4300
0
        return 0;
4301
0
    }
4302
17
    Py_DECREF(ExceptHandler_annotations);
4303
17
    PyObject *arguments_annotations = PyDict_New();
4304
17
    if (!arguments_annotations) return 0;
4305
17
    {
4306
17
        PyObject *type = state->arg_type;
4307
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4308
17
        cond = type != NULL;
4309
17
        if (!cond) {
4310
0
            Py_DECREF(arguments_annotations);
4311
0
            return 0;
4312
0
        }
4313
17
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4314
17
                                    == 0;
4315
17
        Py_DECREF(type);
4316
17
        if (!cond) {
4317
0
            Py_DECREF(arguments_annotations);
4318
0
            return 0;
4319
0
        }
4320
17
    }
4321
17
    {
4322
17
        PyObject *type = state->arg_type;
4323
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4324
17
        cond = type != NULL;
4325
17
        if (!cond) {
4326
0
            Py_DECREF(arguments_annotations);
4327
0
            return 0;
4328
0
        }
4329
17
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4330
17
        Py_DECREF(type);
4331
17
        if (!cond) {
4332
0
            Py_DECREF(arguments_annotations);
4333
0
            return 0;
4334
0
        }
4335
17
    }
4336
17
    {
4337
17
        PyObject *type = state->arg_type;
4338
17
        type = _Py_union_type_or(type, Py_None);
4339
17
        cond = type != NULL;
4340
17
        if (!cond) {
4341
0
            Py_DECREF(arguments_annotations);
4342
0
            return 0;
4343
0
        }
4344
17
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4345
17
        Py_DECREF(type);
4346
17
        if (!cond) {
4347
0
            Py_DECREF(arguments_annotations);
4348
0
            return 0;
4349
0
        }
4350
17
    }
4351
17
    {
4352
17
        PyObject *type = state->arg_type;
4353
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4354
17
        cond = type != NULL;
4355
17
        if (!cond) {
4356
0
            Py_DECREF(arguments_annotations);
4357
0
            return 0;
4358
0
        }
4359
17
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4360
17
                                    == 0;
4361
17
        Py_DECREF(type);
4362
17
        if (!cond) {
4363
0
            Py_DECREF(arguments_annotations);
4364
0
            return 0;
4365
0
        }
4366
17
    }
4367
17
    {
4368
17
        PyObject *type = state->expr_type;
4369
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4370
17
        cond = type != NULL;
4371
17
        if (!cond) {
4372
0
            Py_DECREF(arguments_annotations);
4373
0
            return 0;
4374
0
        }
4375
17
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4376
17
                                    == 0;
4377
17
        Py_DECREF(type);
4378
17
        if (!cond) {
4379
0
            Py_DECREF(arguments_annotations);
4380
0
            return 0;
4381
0
        }
4382
17
    }
4383
17
    {
4384
17
        PyObject *type = state->arg_type;
4385
17
        type = _Py_union_type_or(type, Py_None);
4386
17
        cond = type != NULL;
4387
17
        if (!cond) {
4388
0
            Py_DECREF(arguments_annotations);
4389
0
            return 0;
4390
0
        }
4391
17
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4392
17
        Py_DECREF(type);
4393
17
        if (!cond) {
4394
0
            Py_DECREF(arguments_annotations);
4395
0
            return 0;
4396
0
        }
4397
17
    }
4398
17
    {
4399
17
        PyObject *type = state->expr_type;
4400
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4401
17
        cond = type != NULL;
4402
17
        if (!cond) {
4403
0
            Py_DECREF(arguments_annotations);
4404
0
            return 0;
4405
0
        }
4406
17
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4407
17
                                    0;
4408
17
        Py_DECREF(type);
4409
17
        if (!cond) {
4410
0
            Py_DECREF(arguments_annotations);
4411
0
            return 0;
4412
0
        }
4413
17
    }
4414
17
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4415
17
                                  arguments_annotations) == 0;
4416
17
    if (!cond) {
4417
0
        Py_DECREF(arguments_annotations);
4418
0
        return 0;
4419
0
    }
4420
17
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4421
17
                                  arguments_annotations) == 0;
4422
17
    if (!cond) {
4423
0
        Py_DECREF(arguments_annotations);
4424
0
        return 0;
4425
0
    }
4426
17
    Py_DECREF(arguments_annotations);
4427
17
    PyObject *arg_annotations = PyDict_New();
4428
17
    if (!arg_annotations) return 0;
4429
17
    {
4430
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4431
17
        Py_INCREF(type);
4432
17
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4433
17
        Py_DECREF(type);
4434
17
        if (!cond) {
4435
0
            Py_DECREF(arg_annotations);
4436
0
            return 0;
4437
0
        }
4438
17
    }
4439
17
    {
4440
17
        PyObject *type = state->expr_type;
4441
17
        type = _Py_union_type_or(type, Py_None);
4442
17
        cond = type != NULL;
4443
17
        if (!cond) {
4444
0
            Py_DECREF(arg_annotations);
4445
0
            return 0;
4446
0
        }
4447
17
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4448
17
        Py_DECREF(type);
4449
17
        if (!cond) {
4450
0
            Py_DECREF(arg_annotations);
4451
0
            return 0;
4452
0
        }
4453
17
    }
4454
17
    {
4455
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4456
17
        type = _Py_union_type_or(type, Py_None);
4457
17
        cond = type != NULL;
4458
17
        if (!cond) {
4459
0
            Py_DECREF(arg_annotations);
4460
0
            return 0;
4461
0
        }
4462
17
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4463
17
        Py_DECREF(type);
4464
17
        if (!cond) {
4465
0
            Py_DECREF(arg_annotations);
4466
0
            return 0;
4467
0
        }
4468
17
    }
4469
17
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4470
17
                                  arg_annotations) == 0;
4471
17
    if (!cond) {
4472
0
        Py_DECREF(arg_annotations);
4473
0
        return 0;
4474
0
    }
4475
17
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4476
17
                                  arg_annotations) == 0;
4477
17
    if (!cond) {
4478
0
        Py_DECREF(arg_annotations);
4479
0
        return 0;
4480
0
    }
4481
17
    Py_DECREF(arg_annotations);
4482
17
    PyObject *keyword_annotations = PyDict_New();
4483
17
    if (!keyword_annotations) return 0;
4484
17
    {
4485
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4486
17
        type = _Py_union_type_or(type, Py_None);
4487
17
        cond = type != NULL;
4488
17
        if (!cond) {
4489
0
            Py_DECREF(keyword_annotations);
4490
0
            return 0;
4491
0
        }
4492
17
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4493
17
        Py_DECREF(type);
4494
17
        if (!cond) {
4495
0
            Py_DECREF(keyword_annotations);
4496
0
            return 0;
4497
0
        }
4498
17
    }
4499
17
    {
4500
17
        PyObject *type = state->expr_type;
4501
17
        Py_INCREF(type);
4502
17
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4503
17
        Py_DECREF(type);
4504
17
        if (!cond) {
4505
0
            Py_DECREF(keyword_annotations);
4506
0
            return 0;
4507
0
        }
4508
17
    }
4509
17
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4510
17
                                  keyword_annotations) == 0;
4511
17
    if (!cond) {
4512
0
        Py_DECREF(keyword_annotations);
4513
0
        return 0;
4514
0
    }
4515
17
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4516
17
                                  keyword_annotations) == 0;
4517
17
    if (!cond) {
4518
0
        Py_DECREF(keyword_annotations);
4519
0
        return 0;
4520
0
    }
4521
17
    Py_DECREF(keyword_annotations);
4522
17
    PyObject *alias_annotations = PyDict_New();
4523
17
    if (!alias_annotations) return 0;
4524
17
    {
4525
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4526
17
        Py_INCREF(type);
4527
17
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4528
17
        Py_DECREF(type);
4529
17
        if (!cond) {
4530
0
            Py_DECREF(alias_annotations);
4531
0
            return 0;
4532
0
        }
4533
17
    }
4534
17
    {
4535
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4536
17
        type = _Py_union_type_or(type, Py_None);
4537
17
        cond = type != NULL;
4538
17
        if (!cond) {
4539
0
            Py_DECREF(alias_annotations);
4540
0
            return 0;
4541
0
        }
4542
17
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4543
17
        Py_DECREF(type);
4544
17
        if (!cond) {
4545
0
            Py_DECREF(alias_annotations);
4546
0
            return 0;
4547
0
        }
4548
17
    }
4549
17
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4550
17
                                  alias_annotations) == 0;
4551
17
    if (!cond) {
4552
0
        Py_DECREF(alias_annotations);
4553
0
        return 0;
4554
0
    }
4555
17
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4556
17
                                  alias_annotations) == 0;
4557
17
    if (!cond) {
4558
0
        Py_DECREF(alias_annotations);
4559
0
        return 0;
4560
0
    }
4561
17
    Py_DECREF(alias_annotations);
4562
17
    PyObject *withitem_annotations = PyDict_New();
4563
17
    if (!withitem_annotations) return 0;
4564
17
    {
4565
17
        PyObject *type = state->expr_type;
4566
17
        Py_INCREF(type);
4567
17
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4568
17
                                    == 0;
4569
17
        Py_DECREF(type);
4570
17
        if (!cond) {
4571
0
            Py_DECREF(withitem_annotations);
4572
0
            return 0;
4573
0
        }
4574
17
    }
4575
17
    {
4576
17
        PyObject *type = state->expr_type;
4577
17
        type = _Py_union_type_or(type, Py_None);
4578
17
        cond = type != NULL;
4579
17
        if (!cond) {
4580
0
            Py_DECREF(withitem_annotations);
4581
0
            return 0;
4582
0
        }
4583
17
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4584
17
                                    type) == 0;
4585
17
        Py_DECREF(type);
4586
17
        if (!cond) {
4587
0
            Py_DECREF(withitem_annotations);
4588
0
            return 0;
4589
0
        }
4590
17
    }
4591
17
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4592
17
                                  withitem_annotations) == 0;
4593
17
    if (!cond) {
4594
0
        Py_DECREF(withitem_annotations);
4595
0
        return 0;
4596
0
    }
4597
17
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4598
17
                                  withitem_annotations) == 0;
4599
17
    if (!cond) {
4600
0
        Py_DECREF(withitem_annotations);
4601
0
        return 0;
4602
0
    }
4603
17
    Py_DECREF(withitem_annotations);
4604
17
    PyObject *match_case_annotations = PyDict_New();
4605
17
    if (!match_case_annotations) return 0;
4606
17
    {
4607
17
        PyObject *type = state->pattern_type;
4608
17
        Py_INCREF(type);
4609
17
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4610
17
                                    0;
4611
17
        Py_DECREF(type);
4612
17
        if (!cond) {
4613
0
            Py_DECREF(match_case_annotations);
4614
0
            return 0;
4615
0
        }
4616
17
    }
4617
17
    {
4618
17
        PyObject *type = state->expr_type;
4619
17
        type = _Py_union_type_or(type, Py_None);
4620
17
        cond = type != NULL;
4621
17
        if (!cond) {
4622
0
            Py_DECREF(match_case_annotations);
4623
0
            return 0;
4624
0
        }
4625
17
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4626
17
        Py_DECREF(type);
4627
17
        if (!cond) {
4628
0
            Py_DECREF(match_case_annotations);
4629
0
            return 0;
4630
0
        }
4631
17
    }
4632
17
    {
4633
17
        PyObject *type = state->stmt_type;
4634
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4635
17
        cond = type != NULL;
4636
17
        if (!cond) {
4637
0
            Py_DECREF(match_case_annotations);
4638
0
            return 0;
4639
0
        }
4640
17
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4641
17
        Py_DECREF(type);
4642
17
        if (!cond) {
4643
0
            Py_DECREF(match_case_annotations);
4644
0
            return 0;
4645
0
        }
4646
17
    }
4647
17
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4648
17
                                  match_case_annotations) == 0;
4649
17
    if (!cond) {
4650
0
        Py_DECREF(match_case_annotations);
4651
0
        return 0;
4652
0
    }
4653
17
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4654
17
                                  match_case_annotations) == 0;
4655
17
    if (!cond) {
4656
0
        Py_DECREF(match_case_annotations);
4657
0
        return 0;
4658
0
    }
4659
17
    Py_DECREF(match_case_annotations);
4660
17
    PyObject *MatchValue_annotations = PyDict_New();
4661
17
    if (!MatchValue_annotations) return 0;
4662
17
    {
4663
17
        PyObject *type = state->expr_type;
4664
17
        Py_INCREF(type);
4665
17
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4666
17
        Py_DECREF(type);
4667
17
        if (!cond) {
4668
0
            Py_DECREF(MatchValue_annotations);
4669
0
            return 0;
4670
0
        }
4671
17
    }
4672
17
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4673
17
                                  MatchValue_annotations) == 0;
4674
17
    if (!cond) {
4675
0
        Py_DECREF(MatchValue_annotations);
4676
0
        return 0;
4677
0
    }
4678
17
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4679
17
                                  MatchValue_annotations) == 0;
4680
17
    if (!cond) {
4681
0
        Py_DECREF(MatchValue_annotations);
4682
0
        return 0;
4683
0
    }
4684
17
    Py_DECREF(MatchValue_annotations);
4685
17
    PyObject *MatchSingleton_annotations = PyDict_New();
4686
17
    if (!MatchSingleton_annotations) return 0;
4687
17
    {
4688
17
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4689
17
        Py_INCREF(type);
4690
17
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4691
17
                                    == 0;
4692
17
        Py_DECREF(type);
4693
17
        if (!cond) {
4694
0
            Py_DECREF(MatchSingleton_annotations);
4695
0
            return 0;
4696
0
        }
4697
17
    }
4698
17
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4699
17
                                  MatchSingleton_annotations) == 0;
4700
17
    if (!cond) {
4701
0
        Py_DECREF(MatchSingleton_annotations);
4702
0
        return 0;
4703
0
    }
4704
17
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4705
17
                                  "__annotations__",
4706
17
                                  MatchSingleton_annotations) == 0;
4707
17
    if (!cond) {
4708
0
        Py_DECREF(MatchSingleton_annotations);
4709
0
        return 0;
4710
0
    }
4711
17
    Py_DECREF(MatchSingleton_annotations);
4712
17
    PyObject *MatchSequence_annotations = PyDict_New();
4713
17
    if (!MatchSequence_annotations) return 0;
4714
17
    {
4715
17
        PyObject *type = state->pattern_type;
4716
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4717
17
        cond = type != NULL;
4718
17
        if (!cond) {
4719
0
            Py_DECREF(MatchSequence_annotations);
4720
0
            return 0;
4721
0
        }
4722
17
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4723
17
                                    type) == 0;
4724
17
        Py_DECREF(type);
4725
17
        if (!cond) {
4726
0
            Py_DECREF(MatchSequence_annotations);
4727
0
            return 0;
4728
0
        }
4729
17
    }
4730
17
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4731
17
                                  MatchSequence_annotations) == 0;
4732
17
    if (!cond) {
4733
0
        Py_DECREF(MatchSequence_annotations);
4734
0
        return 0;
4735
0
    }
4736
17
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4737
17
                                  MatchSequence_annotations) == 0;
4738
17
    if (!cond) {
4739
0
        Py_DECREF(MatchSequence_annotations);
4740
0
        return 0;
4741
0
    }
4742
17
    Py_DECREF(MatchSequence_annotations);
4743
17
    PyObject *MatchMapping_annotations = PyDict_New();
4744
17
    if (!MatchMapping_annotations) return 0;
4745
17
    {
4746
17
        PyObject *type = state->expr_type;
4747
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4748
17
        cond = type != NULL;
4749
17
        if (!cond) {
4750
0
            Py_DECREF(MatchMapping_annotations);
4751
0
            return 0;
4752
0
        }
4753
17
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4754
17
                                    0;
4755
17
        Py_DECREF(type);
4756
17
        if (!cond) {
4757
0
            Py_DECREF(MatchMapping_annotations);
4758
0
            return 0;
4759
0
        }
4760
17
    }
4761
17
    {
4762
17
        PyObject *type = state->pattern_type;
4763
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4764
17
        cond = type != NULL;
4765
17
        if (!cond) {
4766
0
            Py_DECREF(MatchMapping_annotations);
4767
0
            return 0;
4768
0
        }
4769
17
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4770
17
                                    == 0;
4771
17
        Py_DECREF(type);
4772
17
        if (!cond) {
4773
0
            Py_DECREF(MatchMapping_annotations);
4774
0
            return 0;
4775
0
        }
4776
17
    }
4777
17
    {
4778
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4779
17
        type = _Py_union_type_or(type, Py_None);
4780
17
        cond = type != NULL;
4781
17
        if (!cond) {
4782
0
            Py_DECREF(MatchMapping_annotations);
4783
0
            return 0;
4784
0
        }
4785
17
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4786
17
                                    0;
4787
17
        Py_DECREF(type);
4788
17
        if (!cond) {
4789
0
            Py_DECREF(MatchMapping_annotations);
4790
0
            return 0;
4791
0
        }
4792
17
    }
4793
17
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4794
17
                                  MatchMapping_annotations) == 0;
4795
17
    if (!cond) {
4796
0
        Py_DECREF(MatchMapping_annotations);
4797
0
        return 0;
4798
0
    }
4799
17
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4800
17
                                  MatchMapping_annotations) == 0;
4801
17
    if (!cond) {
4802
0
        Py_DECREF(MatchMapping_annotations);
4803
0
        return 0;
4804
0
    }
4805
17
    Py_DECREF(MatchMapping_annotations);
4806
17
    PyObject *MatchClass_annotations = PyDict_New();
4807
17
    if (!MatchClass_annotations) return 0;
4808
17
    {
4809
17
        PyObject *type = state->expr_type;
4810
17
        Py_INCREF(type);
4811
17
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4812
17
        Py_DECREF(type);
4813
17
        if (!cond) {
4814
0
            Py_DECREF(MatchClass_annotations);
4815
0
            return 0;
4816
0
        }
4817
17
    }
4818
17
    {
4819
17
        PyObject *type = state->pattern_type;
4820
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4821
17
        cond = type != NULL;
4822
17
        if (!cond) {
4823
0
            Py_DECREF(MatchClass_annotations);
4824
0
            return 0;
4825
0
        }
4826
17
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4827
17
                                    == 0;
4828
17
        Py_DECREF(type);
4829
17
        if (!cond) {
4830
0
            Py_DECREF(MatchClass_annotations);
4831
0
            return 0;
4832
0
        }
4833
17
    }
4834
17
    {
4835
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4836
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4837
17
        cond = type != NULL;
4838
17
        if (!cond) {
4839
0
            Py_DECREF(MatchClass_annotations);
4840
0
            return 0;
4841
0
        }
4842
17
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4843
17
                                    == 0;
4844
17
        Py_DECREF(type);
4845
17
        if (!cond) {
4846
0
            Py_DECREF(MatchClass_annotations);
4847
0
            return 0;
4848
0
        }
4849
17
    }
4850
17
    {
4851
17
        PyObject *type = state->pattern_type;
4852
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4853
17
        cond = type != NULL;
4854
17
        if (!cond) {
4855
0
            Py_DECREF(MatchClass_annotations);
4856
0
            return 0;
4857
0
        }
4858
17
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4859
17
                                    type) == 0;
4860
17
        Py_DECREF(type);
4861
17
        if (!cond) {
4862
0
            Py_DECREF(MatchClass_annotations);
4863
0
            return 0;
4864
0
        }
4865
17
    }
4866
17
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4867
17
                                  MatchClass_annotations) == 0;
4868
17
    if (!cond) {
4869
0
        Py_DECREF(MatchClass_annotations);
4870
0
        return 0;
4871
0
    }
4872
17
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4873
17
                                  MatchClass_annotations) == 0;
4874
17
    if (!cond) {
4875
0
        Py_DECREF(MatchClass_annotations);
4876
0
        return 0;
4877
0
    }
4878
17
    Py_DECREF(MatchClass_annotations);
4879
17
    PyObject *MatchStar_annotations = PyDict_New();
4880
17
    if (!MatchStar_annotations) return 0;
4881
17
    {
4882
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4883
17
        type = _Py_union_type_or(type, Py_None);
4884
17
        cond = type != NULL;
4885
17
        if (!cond) {
4886
0
            Py_DECREF(MatchStar_annotations);
4887
0
            return 0;
4888
0
        }
4889
17
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4890
17
        Py_DECREF(type);
4891
17
        if (!cond) {
4892
0
            Py_DECREF(MatchStar_annotations);
4893
0
            return 0;
4894
0
        }
4895
17
    }
4896
17
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4897
17
                                  MatchStar_annotations) == 0;
4898
17
    if (!cond) {
4899
0
        Py_DECREF(MatchStar_annotations);
4900
0
        return 0;
4901
0
    }
4902
17
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4903
17
                                  MatchStar_annotations) == 0;
4904
17
    if (!cond) {
4905
0
        Py_DECREF(MatchStar_annotations);
4906
0
        return 0;
4907
0
    }
4908
17
    Py_DECREF(MatchStar_annotations);
4909
17
    PyObject *MatchAs_annotations = PyDict_New();
4910
17
    if (!MatchAs_annotations) return 0;
4911
17
    {
4912
17
        PyObject *type = state->pattern_type;
4913
17
        type = _Py_union_type_or(type, Py_None);
4914
17
        cond = type != NULL;
4915
17
        if (!cond) {
4916
0
            Py_DECREF(MatchAs_annotations);
4917
0
            return 0;
4918
0
        }
4919
17
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4920
17
        Py_DECREF(type);
4921
17
        if (!cond) {
4922
0
            Py_DECREF(MatchAs_annotations);
4923
0
            return 0;
4924
0
        }
4925
17
    }
4926
17
    {
4927
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4928
17
        type = _Py_union_type_or(type, Py_None);
4929
17
        cond = type != NULL;
4930
17
        if (!cond) {
4931
0
            Py_DECREF(MatchAs_annotations);
4932
0
            return 0;
4933
0
        }
4934
17
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4935
17
        Py_DECREF(type);
4936
17
        if (!cond) {
4937
0
            Py_DECREF(MatchAs_annotations);
4938
0
            return 0;
4939
0
        }
4940
17
    }
4941
17
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4942
17
                                  MatchAs_annotations) == 0;
4943
17
    if (!cond) {
4944
0
        Py_DECREF(MatchAs_annotations);
4945
0
        return 0;
4946
0
    }
4947
17
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4948
17
                                  MatchAs_annotations) == 0;
4949
17
    if (!cond) {
4950
0
        Py_DECREF(MatchAs_annotations);
4951
0
        return 0;
4952
0
    }
4953
17
    Py_DECREF(MatchAs_annotations);
4954
17
    PyObject *MatchOr_annotations = PyDict_New();
4955
17
    if (!MatchOr_annotations) return 0;
4956
17
    {
4957
17
        PyObject *type = state->pattern_type;
4958
17
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4959
17
        cond = type != NULL;
4960
17
        if (!cond) {
4961
0
            Py_DECREF(MatchOr_annotations);
4962
0
            return 0;
4963
0
        }
4964
17
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4965
17
        Py_DECREF(type);
4966
17
        if (!cond) {
4967
0
            Py_DECREF(MatchOr_annotations);
4968
0
            return 0;
4969
0
        }
4970
17
    }
4971
17
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4972
17
                                  MatchOr_annotations) == 0;
4973
17
    if (!cond) {
4974
0
        Py_DECREF(MatchOr_annotations);
4975
0
        return 0;
4976
0
    }
4977
17
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4978
17
                                  MatchOr_annotations) == 0;
4979
17
    if (!cond) {
4980
0
        Py_DECREF(MatchOr_annotations);
4981
0
        return 0;
4982
0
    }
4983
17
    Py_DECREF(MatchOr_annotations);
4984
17
    PyObject *TypeIgnore_annotations = PyDict_New();
4985
17
    if (!TypeIgnore_annotations) return 0;
4986
17
    {
4987
17
        PyObject *type = (PyObject *)&PyLong_Type;
4988
17
        Py_INCREF(type);
4989
17
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4990
17
                                    0;
4991
17
        Py_DECREF(type);
4992
17
        if (!cond) {
4993
0
            Py_DECREF(TypeIgnore_annotations);
4994
0
            return 0;
4995
0
        }
4996
17
    }
4997
17
    {
4998
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
4999
17
        Py_INCREF(type);
5000
17
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
5001
17
        Py_DECREF(type);
5002
17
        if (!cond) {
5003
0
            Py_DECREF(TypeIgnore_annotations);
5004
0
            return 0;
5005
0
        }
5006
17
    }
5007
17
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
5008
17
                                  TypeIgnore_annotations) == 0;
5009
17
    if (!cond) {
5010
0
        Py_DECREF(TypeIgnore_annotations);
5011
0
        return 0;
5012
0
    }
5013
17
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
5014
17
                                  TypeIgnore_annotations) == 0;
5015
17
    if (!cond) {
5016
0
        Py_DECREF(TypeIgnore_annotations);
5017
0
        return 0;
5018
0
    }
5019
17
    Py_DECREF(TypeIgnore_annotations);
5020
17
    PyObject *TypeVar_annotations = PyDict_New();
5021
17
    if (!TypeVar_annotations) return 0;
5022
17
    {
5023
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
5024
17
        Py_INCREF(type);
5025
17
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
5026
17
        Py_DECREF(type);
5027
17
        if (!cond) {
5028
0
            Py_DECREF(TypeVar_annotations);
5029
0
            return 0;
5030
0
        }
5031
17
    }
5032
17
    {
5033
17
        PyObject *type = state->expr_type;
5034
17
        type = _Py_union_type_or(type, Py_None);
5035
17
        cond = type != NULL;
5036
17
        if (!cond) {
5037
0
            Py_DECREF(TypeVar_annotations);
5038
0
            return 0;
5039
0
        }
5040
17
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5041
17
        Py_DECREF(type);
5042
17
        if (!cond) {
5043
0
            Py_DECREF(TypeVar_annotations);
5044
0
            return 0;
5045
0
        }
5046
17
    }
5047
17
    {
5048
17
        PyObject *type = state->expr_type;
5049
17
        type = _Py_union_type_or(type, Py_None);
5050
17
        cond = type != NULL;
5051
17
        if (!cond) {
5052
0
            Py_DECREF(TypeVar_annotations);
5053
0
            return 0;
5054
0
        }
5055
17
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5056
17
                                    == 0;
5057
17
        Py_DECREF(type);
5058
17
        if (!cond) {
5059
0
            Py_DECREF(TypeVar_annotations);
5060
0
            return 0;
5061
0
        }
5062
17
    }
5063
17
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5064
17
                                  TypeVar_annotations) == 0;
5065
17
    if (!cond) {
5066
0
        Py_DECREF(TypeVar_annotations);
5067
0
        return 0;
5068
0
    }
5069
17
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5070
17
                                  TypeVar_annotations) == 0;
5071
17
    if (!cond) {
5072
0
        Py_DECREF(TypeVar_annotations);
5073
0
        return 0;
5074
0
    }
5075
17
    Py_DECREF(TypeVar_annotations);
5076
17
    PyObject *ParamSpec_annotations = PyDict_New();
5077
17
    if (!ParamSpec_annotations) return 0;
5078
17
    {
5079
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
5080
17
        Py_INCREF(type);
5081
17
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5082
17
        Py_DECREF(type);
5083
17
        if (!cond) {
5084
0
            Py_DECREF(ParamSpec_annotations);
5085
0
            return 0;
5086
0
        }
5087
17
    }
5088
17
    {
5089
17
        PyObject *type = state->expr_type;
5090
17
        type = _Py_union_type_or(type, Py_None);
5091
17
        cond = type != NULL;
5092
17
        if (!cond) {
5093
0
            Py_DECREF(ParamSpec_annotations);
5094
0
            return 0;
5095
0
        }
5096
17
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5097
17
                                    type) == 0;
5098
17
        Py_DECREF(type);
5099
17
        if (!cond) {
5100
0
            Py_DECREF(ParamSpec_annotations);
5101
0
            return 0;
5102
0
        }
5103
17
    }
5104
17
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5105
17
                                  ParamSpec_annotations) == 0;
5106
17
    if (!cond) {
5107
0
        Py_DECREF(ParamSpec_annotations);
5108
0
        return 0;
5109
0
    }
5110
17
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5111
17
                                  ParamSpec_annotations) == 0;
5112
17
    if (!cond) {
5113
0
        Py_DECREF(ParamSpec_annotations);
5114
0
        return 0;
5115
0
    }
5116
17
    Py_DECREF(ParamSpec_annotations);
5117
17
    PyObject *TypeVarTuple_annotations = PyDict_New();
5118
17
    if (!TypeVarTuple_annotations) return 0;
5119
17
    {
5120
17
        PyObject *type = (PyObject *)&PyUnicode_Type;
5121
17
        Py_INCREF(type);
5122
17
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5123
17
                                    0;
5124
17
        Py_DECREF(type);
5125
17
        if (!cond) {
5126
0
            Py_DECREF(TypeVarTuple_annotations);
5127
0
            return 0;
5128
0
        }
5129
17
    }
5130
17
    {
5131
17
        PyObject *type = state->expr_type;
5132
17
        type = _Py_union_type_or(type, Py_None);
5133
17
        cond = type != NULL;
5134
17
        if (!cond) {
5135
0
            Py_DECREF(TypeVarTuple_annotations);
5136
0
            return 0;
5137
0
        }
5138
17
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5139
17
                                    type) == 0;
5140
17
        Py_DECREF(type);
5141
17
        if (!cond) {
5142
0
            Py_DECREF(TypeVarTuple_annotations);
5143
0
            return 0;
5144
0
        }
5145
17
    }
5146
17
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5147
17
                                  TypeVarTuple_annotations) == 0;
5148
17
    if (!cond) {
5149
0
        Py_DECREF(TypeVarTuple_annotations);
5150
0
        return 0;
5151
0
    }
5152
17
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5153
17
                                  TypeVarTuple_annotations) == 0;
5154
17
    if (!cond) {
5155
0
        Py_DECREF(TypeVarTuple_annotations);
5156
0
        return 0;
5157
0
    }
5158
17
    Py_DECREF(TypeVarTuple_annotations);
5159
5160
17
    return 1;
5161
17
}
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
456k
{
5173
456k
    AST_object *self = (AST_object*)op;
5174
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5175
456k
    PyTypeObject *tp = Py_TYPE(self);
5176
456k
    PyObject_GC_UnTrack(self);
5177
456k
    Py_CLEAR(self->dict);
5178
456k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5179
456k
    assert(free_func != NULL);
5180
456k
    free_func(self);
5181
456k
    Py_DECREF(tp);
5182
456k
}
5183
5184
static int
5185
ast_traverse(PyObject *op, visitproc visit, void *arg)
5186
429k
{
5187
429k
    AST_object *self = (AST_object*)op;
5188
429k
    Py_VISIT(Py_TYPE(self));
5189
429k
    Py_VISIT(self->dict);
5190
429k
    return 0;
5191
429k
}
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
250
{
5268
250
    struct ast_state *state = get_ast_state();
5269
250
    if (state == NULL) {
5270
0
        return -1;
5271
0
    }
5272
5273
250
    int contains = PySet_Contains(state->abstract_types, (PyObject *)Py_TYPE(self));
5274
250
    if (contains == -1) {
5275
0
        return -1;
5276
0
    }
5277
250
    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
250
    Py_ssize_t i, numfields = 0;
5287
250
    int res = -1;
5288
250
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5289
5290
250
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5291
250
    if (fields == NULL) {
5292
0
        goto cleanup;
5293
0
    }
5294
5295
250
    numfields = PySequence_Size(fields);
5296
250
    if (numfields == -1) {
5297
0
        goto cleanup;
5298
0
    }
5299
250
    remaining_fields = PySet_New(fields);
5300
250
    if (remaining_fields == NULL) {
5301
0
        goto cleanup;
5302
0
    }
5303
5304
250
    res = 0; /* if no error occurs, this stays 0 to the end */
5305
250
    if (numfields < PyTuple_GET_SIZE(args)) {
5306
0
        PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
5307
0
                     "%zd positional argument%s",
5308
0
                     _PyType_Name(Py_TYPE(self)),
5309
0
                     numfields, numfields == 1 ? "" : "s");
5310
0
        res = -1;
5311
0
        goto cleanup;
5312
0
    }
5313
253
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5314
        /* cannot be reached when fields is NULL */
5315
3
        PyObject *name = PySequence_GetItem(fields, i);
5316
3
        if (!name) {
5317
0
            res = -1;
5318
0
            goto cleanup;
5319
0
        }
5320
3
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5321
3
        if (PySet_Discard(remaining_fields, name) < 0) {
5322
0
            res = -1;
5323
0
            Py_DECREF(name);
5324
0
            goto cleanup;
5325
0
        }
5326
3
        Py_DECREF(name);
5327
3
        if (res < 0) {
5328
0
            goto cleanup;
5329
0
        }
5330
3
    }
5331
250
    if (kw) {
5332
3
        i = 0;  /* needed by PyDict_Next */
5333
6
        while (PyDict_Next(kw, &i, &key, &value)) {
5334
3
            int contains = PySequence_Contains(fields, key);
5335
3
            if (contains == -1) {
5336
0
                res = -1;
5337
0
                goto cleanup;
5338
0
            }
5339
3
            else if (contains == 1) {
5340
3
                int p = PySet_Discard(remaining_fields, key);
5341
3
                if (p == -1) {
5342
0
                    res = -1;
5343
0
                    goto cleanup;
5344
0
                }
5345
3
                if (p == 0) {
5346
0
                    PyErr_Format(PyExc_TypeError,
5347
0
                        "%T got multiple values for argument %R",
5348
0
                        self, key);
5349
0
                    res = -1;
5350
0
                    goto cleanup;
5351
0
                }
5352
3
            }
5353
0
            else {
5354
                // Lazily initialize "attributes"
5355
0
                if (attributes == NULL) {
5356
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5357
0
                    if (attributes == NULL) {
5358
0
                        res = -1;
5359
0
                        goto cleanup;
5360
0
                    }
5361
0
                }
5362
0
                int contains = PySequence_Contains(attributes, key);
5363
0
                if (contains == -1) {
5364
0
                    res = -1;
5365
0
                    goto cleanup;
5366
0
                }
5367
0
                else if (contains == 0) {
5368
0
                    PyErr_Format(PyExc_TypeError,
5369
0
                        "%T.__init__ got an unexpected keyword argument %R",
5370
0
                        self, key);
5371
0
                    res = -1;
5372
0
                    goto cleanup;
5373
0
                }
5374
0
            }
5375
3
            res = PyObject_SetAttr(self, key, value);
5376
3
            if (res < 0) {
5377
0
                goto cleanup;
5378
0
            }
5379
3
        }
5380
3
    }
5381
250
    Py_ssize_t size = PySet_Size(remaining_fields);
5382
250
    PyObject *field_types = NULL, *remaining_list = NULL, *missing_names = NULL;
5383
250
    if (size > 0) {
5384
5
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5385
5
                                     &field_types) < 0) {
5386
0
            res = -1;
5387
0
            goto cleanup;
5388
0
        }
5389
5
        if (field_types == NULL) {
5390
            // Probably a user-defined subclass of AST that lacks _field_types.
5391
            // This will continue to work as it did before 3.13; i.e., attributes
5392
            // that are not passed in simply do not exist on the instance.
5393
0
            goto cleanup;
5394
0
        }
5395
5
        remaining_list = PySequence_List(remaining_fields);
5396
5
        if (!remaining_list) {
5397
0
            goto set_remaining_cleanup;
5398
0
        }
5399
5
        missing_names = PySet_New(NULL);
5400
5
        if (!missing_names) {
5401
0
            goto set_remaining_cleanup;
5402
0
        }
5403
10
        for (Py_ssize_t i = 0; i < size; i++) {
5404
5
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5405
5
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5406
5
            if (!type) {
5407
0
                if (PyErr_Occurred()) {
5408
0
                    goto set_remaining_cleanup;
5409
0
                }
5410
0
                else {
5411
0
                    PyErr_Format(PyExc_TypeError,
5412
0
                        "Field %R is missing from %T._field_types",
5413
0
                        name, self);
5414
0
                    goto set_remaining_cleanup;
5415
0
                }
5416
0
            }
5417
5
            else if (_PyUnion_Check(type)) {
5418
                // optional field
5419
                // do nothing, we'll have set a None default on the class
5420
2
            }
5421
3
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5422
                // list field
5423
0
                PyObject *empty = PyList_New(0);
5424
0
                if (!empty) {
5425
0
                    goto set_remaining_cleanup;
5426
0
                }
5427
0
                res = PyObject_SetAttr(self, name, empty);
5428
0
                Py_DECREF(empty);
5429
0
                if (res < 0) {
5430
0
                    goto set_remaining_cleanup;
5431
0
                }
5432
0
            }
5433
3
            else if (type == state->expr_context_type) {
5434
                // special case for expr_context: default to Load()
5435
3
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5436
3
                if (res < 0) {
5437
0
                    goto set_remaining_cleanup;
5438
0
                }
5439
3
            }
5440
0
            else {
5441
                // simple field (e.g., identifier)
5442
0
                res = PySet_Add(missing_names, name);
5443
0
                if (res < 0) {
5444
0
                    goto set_remaining_cleanup;
5445
0
                }
5446
0
            }
5447
5
        }
5448
5
        Py_ssize_t num_missing = PySet_GET_SIZE(missing_names);
5449
5
        if (num_missing > 0) {
5450
0
            PyObject *name_str = format_missing(missing_names, fields);
5451
0
            if (!name_str) {
5452
0
                goto set_remaining_cleanup;
5453
0
            }
5454
0
            PyErr_Format(PyExc_TypeError,
5455
0
                "%T.__init__ missing %d required positional argument%s: %U",
5456
0
                self, num_missing, num_missing == 1 ? "" : "s", name_str);
5457
0
            Py_DECREF(name_str);
5458
0
            goto set_remaining_cleanup;
5459
0
        }
5460
5
        Py_DECREF(missing_names);
5461
5
        Py_DECREF(remaining_list);
5462
5
        Py_DECREF(field_types);
5463
5
    }
5464
250
  cleanup:
5465
250
    Py_XDECREF(attributes);
5466
250
    Py_XDECREF(fields);
5467
250
    Py_XDECREF(remaining_fields);
5468
250
    return res;
5469
0
  set_remaining_cleanup:
5470
0
    Py_XDECREF(missing_names);
5471
0
    Py_XDECREF(remaining_list);
5472
0
    Py_XDECREF(field_types);
5473
0
    res = -1;
5474
0
    goto cleanup;
5475
250
}
5476
5477
/* Pickling support */
5478
static PyObject *
5479
ast_type_reduce(PyObject *self, PyObject *unused)
5480
0
{
5481
0
    struct ast_state *state = get_ast_state();
5482
0
    if (state == NULL) {
5483
0
        return NULL;
5484
0
    }
5485
5486
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5487
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5488
0
        return NULL;
5489
0
    }
5490
0
    PyObject *result = NULL;
5491
0
    if (dict) {
5492
        // Unpickling (or copying) works as follows:
5493
        // - Construct the object with only positional arguments
5494
        // - Set the fields from the dict
5495
        // We have two constraints:
5496
        // - We must set all the required fields in the initial constructor call,
5497
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5498
        // - We must not include child nodes in the positional args, because
5499
        //   that may trigger runaway recursion during copying (gh-120108).
5500
        // To satisfy both constraints, we set all the fields to None in the
5501
        // initial list of positional args, and then set the fields from the dict.
5502
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5503
0
            goto cleanup;
5504
0
        }
5505
0
        if (fields) {
5506
0
            Py_ssize_t numfields = PySequence_Size(fields);
5507
0
            if (numfields == -1) {
5508
0
                Py_DECREF(dict);
5509
0
                goto cleanup;
5510
0
            }
5511
0
            positional_args = PyList_New(0);
5512
0
            if (!positional_args) {
5513
0
                goto cleanup;
5514
0
            }
5515
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5516
0
                PyObject *name = PySequence_GetItem(fields, i);
5517
0
                if (!name) {
5518
0
                    goto cleanup;
5519
0
                }
5520
0
                PyObject *value;
5521
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5522
0
                Py_DECREF(name);
5523
0
                if (rc < 0) {
5524
0
                    goto cleanup;
5525
0
                }
5526
0
                if (!value) {
5527
0
                    break;
5528
0
                }
5529
0
                rc = PyList_Append(positional_args, Py_None);
5530
0
                Py_DECREF(value);
5531
0
                if (rc < 0) {
5532
0
                    goto cleanup;
5533
0
                }
5534
0
            }
5535
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5536
0
            if (!args_tuple) {
5537
0
                goto cleanup;
5538
0
            }
5539
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5540
0
        }
5541
0
        else {
5542
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5543
0
        }
5544
0
    }
5545
0
    else {
5546
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5547
0
    }
5548
0
cleanup:
5549
0
    Py_XDECREF(fields);
5550
0
    Py_XDECREF(positional_args);
5551
0
    return result;
5552
0
}
5553
5554
/*
5555
 * Python equivalent:
5556
 *
5557
 *   for key in keys:
5558
 *       if hasattr(self, key):
5559
 *           payload[key] = getattr(self, key)
5560
 *
5561
 * The 'keys' argument is a sequence corresponding to
5562
 * the '_fields' or the '_attributes' of an AST node.
5563
 *
5564
 * This returns -1 if an error occurs and 0 otherwise.
5565
 *
5566
 * Parameters
5567
 *
5568
 *      payload   A dictionary to fill.
5569
 *      keys      A sequence of keys or NULL for an empty sequence.
5570
 *      dict      The AST node instance dictionary (must not be NULL).
5571
 */
5572
static inline int
5573
ast_type_replace_update_payload(PyObject *payload,
5574
                                PyObject *keys,
5575
                                PyObject *dict)
5576
0
{
5577
0
    assert(dict != NULL);
5578
0
    if (keys == NULL) {
5579
0
        return 0;
5580
0
    }
5581
0
    Py_ssize_t n = PySequence_Size(keys);
5582
0
    if (n == -1) {
5583
0
        return -1;
5584
0
    }
5585
0
    for (Py_ssize_t i = 0; i < n; i++) {
5586
0
        PyObject *key = PySequence_GetItem(keys, i);
5587
0
        if (key == NULL) {
5588
0
            return -1;
5589
0
        }
5590
0
        PyObject *value;
5591
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5592
0
            Py_DECREF(key);
5593
0
            return -1;
5594
0
        }
5595
0
        if (value == NULL) {
5596
0
            Py_DECREF(key);
5597
            // If a field or attribute is not present at runtime, it should
5598
            // be explicitly given in 'kwargs'. If not, the constructor will
5599
            // issue a warning (which becomes an error in 3.15).
5600
0
            continue;
5601
0
        }
5602
0
        int rc = PyDict_SetItem(payload, key, value);
5603
0
        Py_DECREF(key);
5604
0
        Py_DECREF(value);
5605
0
        if (rc < 0) {
5606
0
            return -1;
5607
0
        }
5608
0
    }
5609
0
    return 0;
5610
0
}
5611
5612
/* copy.replace() support (shallow copy) */
5613
static PyObject *
5614
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5615
0
{
5616
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5617
0
        return NULL;
5618
0
    }
5619
5620
0
    struct ast_state *state = get_ast_state();
5621
0
    if (state == NULL) {
5622
0
        return NULL;
5623
0
    }
5624
5625
0
    PyObject *result = NULL;
5626
    // known AST class fields and attributes
5627
0
    PyObject *fields = NULL, *attributes = NULL;
5628
    // current instance dictionary
5629
0
    PyObject *dict = NULL;
5630
    // constructor positional and keyword arguments
5631
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5632
5633
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5634
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5635
0
        goto cleanup;
5636
0
    }
5637
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5638
0
        goto cleanup;
5639
0
    }
5640
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5641
0
        goto cleanup;
5642
0
    }
5643
0
    empty_tuple = PyTuple_New(0);
5644
0
    if (empty_tuple == NULL) {
5645
0
        goto cleanup;
5646
0
    }
5647
0
    payload = PyDict_New();
5648
0
    if (payload == NULL) {
5649
0
        goto cleanup;
5650
0
    }
5651
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5652
        // copy the instance's fields (possibly NULL)
5653
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5654
0
            goto cleanup;
5655
0
        }
5656
        // copy the instance's attributes (possibly NULL)
5657
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5658
0
            goto cleanup;
5659
0
        }
5660
0
    }
5661
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5662
0
        goto cleanup;
5663
0
    }
5664
0
    result = PyObject_Call(type, empty_tuple, payload);
5665
0
cleanup:
5666
0
    Py_XDECREF(payload);
5667
0
    Py_XDECREF(empty_tuple);
5668
0
    Py_XDECREF(dict);
5669
0
    Py_XDECREF(attributes);
5670
0
    Py_XDECREF(fields);
5671
0
    return result;
5672
0
}
5673
5674
static PyMemberDef ast_type_members[] = {
5675
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5676
    {NULL}  /* Sentinel */
5677
};
5678
5679
static PyMethodDef ast_type_methods[] = {
5680
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5681
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5682
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5683
               "Return a copy of the AST node with new values "
5684
               "for the specified fields.")},
5685
    {NULL}
5686
};
5687
5688
static PyGetSetDef ast_type_getsets[] = {
5689
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5690
    {NULL}
5691
};
5692
5693
static PyObject *
5694
ast_repr_max_depth(AST_object *self, int depth);
5695
5696
/* Format list and tuple properties of AST nodes.
5697
   Note that, only the first and last elements are shown.
5698
   Anything in between is represented with an ellipsis ('...').
5699
   For example, the list [1, 2, 3] is formatted as
5700
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5701
static PyObject *
5702
ast_repr_list(PyObject *list, int depth)
5703
0
{
5704
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5705
5706
0
    struct ast_state *state = get_ast_state();
5707
0
    if (state == NULL) {
5708
0
        return NULL;
5709
0
    }
5710
5711
0
    Py_ssize_t length = PySequence_Size(list);
5712
0
    if (length < 0) {
5713
0
        return NULL;
5714
0
    }
5715
0
    else if (length == 0) {
5716
0
        return PyObject_Repr(list);
5717
0
    }
5718
5719
0
    PyObject *items[2] = {NULL, NULL};
5720
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5721
0
    if (writer == NULL) {
5722
0
        goto error;
5723
0
    }
5724
5725
0
    items[0] = PySequence_GetItem(list, 0);
5726
0
    if (!items[0]) {
5727
0
        goto error;
5728
0
    }
5729
0
    if (length > 1) {
5730
0
        items[1] = PySequence_GetItem(list, length - 1);
5731
0
        if (!items[1]) {
5732
0
            goto error;
5733
0
        }
5734
0
    }
5735
5736
0
    bool is_list = PyList_Check(list);
5737
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5738
0
        goto error;
5739
0
    }
5740
5741
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5742
0
        if (i > 0) {
5743
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5744
0
                goto error;
5745
0
            }
5746
0
        }
5747
5748
0
        PyObject *item = items[i];
5749
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5750
0
            PyObject *item_repr;
5751
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5752
0
            if (!item_repr) {
5753
0
                goto error;
5754
0
            }
5755
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5756
0
                Py_DECREF(item_repr);
5757
0
                goto error;
5758
0
            }
5759
0
            Py_DECREF(item_repr);
5760
0
        } else {
5761
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5762
0
                goto error;
5763
0
            }
5764
0
        }
5765
5766
0
        if (i == 0 && length > 2) {
5767
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5768
0
                goto error;
5769
0
            }
5770
0
        }
5771
0
    }
5772
5773
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5774
0
        goto error;
5775
0
    }
5776
5777
0
    Py_XDECREF(items[0]);
5778
0
    Py_XDECREF(items[1]);
5779
0
    return PyUnicodeWriter_Finish(writer);
5780
5781
0
error:
5782
0
    Py_XDECREF(items[0]);
5783
0
    Py_XDECREF(items[1]);
5784
0
    PyUnicodeWriter_Discard(writer);
5785
0
    return NULL;
5786
0
}
5787
5788
static PyObject *
5789
ast_repr_max_depth(AST_object *self, int depth)
5790
0
{
5791
0
    struct ast_state *state = get_ast_state();
5792
0
    if (state == NULL) {
5793
0
        return NULL;
5794
0
    }
5795
5796
0
    if (depth <= 0) {
5797
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5798
0
    }
5799
5800
0
    int status = Py_ReprEnter((PyObject *)self);
5801
0
    if (status != 0) {
5802
0
        if (status < 0) {
5803
0
            return NULL;
5804
0
        }
5805
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5806
0
    }
5807
5808
0
    PyObject *fields;
5809
0
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5810
0
        Py_ReprLeave((PyObject *)self);
5811
0
        return NULL;
5812
0
    }
5813
5814
0
    Py_ssize_t numfields = PySequence_Size(fields);
5815
0
    if (numfields < 0) {
5816
0
        Py_ReprLeave((PyObject *)self);
5817
0
        Py_DECREF(fields);
5818
0
        return NULL;
5819
0
    }
5820
5821
0
    if (numfields == 0) {
5822
0
        Py_ReprLeave((PyObject *)self);
5823
0
        Py_DECREF(fields);
5824
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5825
0
    }
5826
5827
0
    const char* tp_name = Py_TYPE(self)->tp_name;
5828
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5829
0
    if (writer == NULL) {
5830
0
        goto error;
5831
0
    }
5832
5833
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5834
0
        goto error;
5835
0
    }
5836
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5837
0
        goto error;
5838
0
    }
5839
5840
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
5841
0
        PyObject *name = PySequence_GetItem(fields, i);
5842
0
        if (!name) {
5843
0
            goto error;
5844
0
        }
5845
5846
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5847
0
        if (!value) {
5848
0
            Py_DECREF(name);
5849
0
            goto error;
5850
0
        }
5851
5852
0
        PyObject *value_repr;
5853
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
5854
0
            value_repr = ast_repr_list(value, depth);
5855
0
        }
5856
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5857
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5858
0
        }
5859
0
        else {
5860
0
            value_repr = PyObject_Repr(value);
5861
0
        }
5862
5863
0
        Py_DECREF(value);
5864
5865
0
        if (!value_repr) {
5866
0
            Py_DECREF(name);
5867
0
            goto error;
5868
0
        }
5869
5870
0
        if (i > 0) {
5871
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5872
0
                Py_DECREF(name);
5873
0
                Py_DECREF(value_repr);
5874
0
                goto error;
5875
0
            }
5876
0
        }
5877
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5878
0
            Py_DECREF(name);
5879
0
            Py_DECREF(value_repr);
5880
0
            goto error;
5881
0
        }
5882
5883
0
        Py_DECREF(name);
5884
5885
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5886
0
            Py_DECREF(value_repr);
5887
0
            goto error;
5888
0
        }
5889
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5890
0
            Py_DECREF(value_repr);
5891
0
            goto error;
5892
0
        }
5893
5894
0
        Py_DECREF(value_repr);
5895
0
    }
5896
5897
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5898
0
        goto error;
5899
0
    }
5900
0
    Py_ReprLeave((PyObject *)self);
5901
0
    Py_DECREF(fields);
5902
0
    return PyUnicodeWriter_Finish(writer);
5903
5904
0
error:
5905
0
    Py_ReprLeave((PyObject *)self);
5906
0
    Py_DECREF(fields);
5907
0
    PyUnicodeWriter_Discard(writer);
5908
0
    return NULL;
5909
0
}
5910
5911
static PyObject *
5912
ast_repr(PyObject *self)
5913
0
{
5914
0
    return ast_repr_max_depth((AST_object*)self, 3);
5915
0
}
5916
5917
static PyType_Slot AST_type_slots[] = {
5918
    {Py_tp_dealloc, ast_dealloc},
5919
    {Py_tp_repr, ast_repr},
5920
    {Py_tp_getattro, PyObject_GenericGetAttr},
5921
    {Py_tp_setattro, PyObject_GenericSetAttr},
5922
    {Py_tp_traverse, ast_traverse},
5923
    {Py_tp_clear, ast_clear},
5924
    {Py_tp_members, ast_type_members},
5925
    {Py_tp_methods, ast_type_methods},
5926
    {Py_tp_getset, ast_type_getsets},
5927
    {Py_tp_init, ast_type_init},
5928
    {Py_tp_alloc, PyType_GenericAlloc},
5929
    {Py_tp_new, PyType_GenericNew},
5930
    {Py_tp_free, PyObject_GC_Del},
5931
    {0, 0},
5932
};
5933
5934
static PyType_Spec AST_type_spec = {
5935
    "ast.AST",
5936
    sizeof(AST_object),
5937
    0,
5938
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
5939
    AST_type_slots
5940
};
5941
5942
static PyObject *
5943
make_type(struct ast_state *state, const char *type, PyObject* base,
5944
          const char* const* fields, int num_fields, const char *doc)
5945
2.12k
{
5946
2.12k
    PyObject *fnames, *result;
5947
2.12k
    int i;
5948
2.12k
    fnames = PyTuple_New(num_fields);
5949
2.12k
    if (!fnames) return NULL;
5950
5.49k
    for (i = 0; i < num_fields; i++) {
5951
3.36k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
5952
3.36k
        if (!field) {
5953
0
            Py_DECREF(fnames);
5954
0
            return NULL;
5955
0
        }
5956
3.36k
        PyTuple_SET_ITEM(fnames, i, field);
5957
3.36k
    }
5958
2.12k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
5959
2.12k
                    type, base,
5960
2.12k
                    state->_fields, fnames,
5961
2.12k
                    state->__match_args__, fnames,
5962
2.12k
                    state->__module__,
5963
2.12k
                    state->ast,
5964
2.12k
                    state->__doc__, doc);
5965
2.12k
    Py_DECREF(fnames);
5966
2.12k
    return result;
5967
2.12k
}
5968
5969
static int
5970
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
5971
323
{
5972
323
    int i, result;
5973
323
    PyObject *s, *l = PyTuple_New(num_fields);
5974
323
    if (!l)
5975
0
        return -1;
5976
867
    for (i = 0; i < num_fields; i++) {
5977
544
        s = PyUnicode_InternFromString(attrs[i]);
5978
544
        if (!s) {
5979
0
            Py_DECREF(l);
5980
0
            return -1;
5981
0
        }
5982
544
        PyTuple_SET_ITEM(l, i, s);
5983
544
    }
5984
323
    result = PyObject_SetAttr(type, state->_attributes, l);
5985
323
    Py_DECREF(l);
5986
323
    return result;
5987
323
}
5988
5989
/* Conversion AST -> Python */
5990
5991
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
5992
                              PyObject* (*func)(struct ast_state *state, void*))
5993
97.4k
{
5994
97.4k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
5995
97.4k
    PyObject *result = PyList_New(n);
5996
97.4k
    PyObject *value;
5997
97.4k
    if (!result)
5998
0
        return NULL;
5999
262k
    for (i = 0; i < n; i++) {
6000
165k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6001
165k
        if (!value) {
6002
0
            Py_DECREF(result);
6003
0
            return NULL;
6004
0
        }
6005
165k
        PyList_SET_ITEM(result, i, value);
6006
165k
    }
6007
97.4k
    return result;
6008
97.4k
}
6009
6010
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6011
256k
{
6012
256k
    PyObject *op = (PyObject*)o;
6013
256k
    if (!op) {
6014
87.8k
        op = Py_None;
6015
87.8k
    }
6016
256k
    return Py_NewRef(op);
6017
256k
}
6018
62.6k
#define ast2obj_constant ast2obj_object
6019
116k
#define ast2obj_identifier ast2obj_object
6020
78.0k
#define ast2obj_string ast2obj_object
6021
6022
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6023
1.79M
{
6024
1.79M
    return PyLong_FromLong(b);
6025
1.79M
}
6026
6027
/* Conversion Python -> AST */
6028
6029
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6030
0
{
6031
0
    if (obj == Py_None)
6032
0
        obj = NULL;
6033
0
    if (obj) {
6034
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6035
0
            *out = NULL;
6036
0
            return -1;
6037
0
        }
6038
0
        *out = Py_NewRef(obj);
6039
0
    }
6040
0
    else {
6041
0
        *out = NULL;
6042
0
    }
6043
0
    return 0;
6044
0
}
6045
6046
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6047
0
{
6048
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6049
0
        *out = NULL;
6050
0
        return -1;
6051
0
    }
6052
0
    *out = Py_NewRef(obj);
6053
0
    return 0;
6054
0
}
6055
6056
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6057
0
{
6058
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6059
0
        PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
6060
0
        return -1;
6061
0
    }
6062
0
    return obj2ast_object(state, obj, out, arena);
6063
0
}
6064
6065
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6066
0
{
6067
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6068
0
        PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
6069
0
        return -1;
6070
0
    }
6071
0
    return obj2ast_object(state, obj, out, arena);
6072
0
}
6073
6074
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
6075
0
{
6076
0
    int i;
6077
0
    if (!PyLong_Check(obj)) {
6078
0
        PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
6079
0
        return -1;
6080
0
    }
6081
6082
0
    i = PyLong_AsInt(obj);
6083
0
    if (i == -1 && PyErr_Occurred())
6084
0
        return -1;
6085
0
    *out = i;
6086
0
    return 0;
6087
0
}
6088
6089
static int add_ast_fields(struct ast_state *state)
6090
17
{
6091
17
    PyObject *empty_tuple;
6092
17
    empty_tuple = PyTuple_New(0);
6093
17
    if (!empty_tuple ||
6094
17
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6095
17
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6096
17
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6097
0
        Py_XDECREF(empty_tuple);
6098
0
        return -1;
6099
0
    }
6100
17
    Py_DECREF(empty_tuple);
6101
17
    return 0;
6102
17
}
6103
6104
6105
6106
static int
6107
init_types(void *arg)
6108
17
{
6109
17
    struct ast_state *state = arg;
6110
17
    if (init_identifiers(state) < 0) {
6111
0
        return -1;
6112
0
    }
6113
17
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6114
17
    if (!state->AST_type) {
6115
0
        return -1;
6116
0
    }
6117
17
    state->abstract_types = PySet_New(NULL);
6118
17
    if (!state->abstract_types) {
6119
0
        return -1;
6120
0
    }
6121
17
    if (PySet_Add(state->abstract_types, state->AST_type) < 0) {
6122
0
        return -1;
6123
0
    }
6124
17
    if (add_ast_fields(state) < 0) {
6125
0
        return -1;
6126
0
    }
6127
17
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6128
17
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6129
17
        "    | Interactive(stmt* body)\n"
6130
17
        "    | Expression(expr body)\n"
6131
17
        "    | FunctionType(expr* argtypes, expr returns)");
6132
17
    if (!state->mod_type) return -1;
6133
17
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6134
17
    if (PySet_Add(state->abstract_types, state->mod_type) < 0) return -1;
6135
17
    state->Module_type = make_type(state, "Module", state->mod_type,
6136
17
                                   Module_fields, 2,
6137
17
        "Module(stmt* body, type_ignore* type_ignores)");
6138
17
    if (!state->Module_type) return -1;
6139
17
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6140
17
                                        Interactive_fields, 1,
6141
17
        "Interactive(stmt* body)");
6142
17
    if (!state->Interactive_type) return -1;
6143
17
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6144
17
                                       Expression_fields, 1,
6145
17
        "Expression(expr body)");
6146
17
    if (!state->Expression_type) return -1;
6147
17
    state->FunctionType_type = make_type(state, "FunctionType",
6148
17
                                         state->mod_type, FunctionType_fields,
6149
17
                                         2,
6150
17
        "FunctionType(expr* argtypes, expr returns)");
6151
17
    if (!state->FunctionType_type) return -1;
6152
17
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6153
17
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6154
17
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6155
17
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6156
17
        "     | Return(expr? value)\n"
6157
17
        "     | Delete(expr* targets)\n"
6158
17
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6159
17
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6160
17
        "     | AugAssign(expr target, operator op, expr value)\n"
6161
17
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6162
17
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6163
17
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6164
17
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6165
17
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6166
17
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6167
17
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6168
17
        "     | Match(expr subject, match_case* cases)\n"
6169
17
        "     | Raise(expr? exc, expr? cause)\n"
6170
17
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6171
17
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6172
17
        "     | Assert(expr test, expr? msg)\n"
6173
17
        "     | Import(alias* names, int? is_lazy)\n"
6174
17
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
6175
17
        "     | Global(identifier* names)\n"
6176
17
        "     | Nonlocal(identifier* names)\n"
6177
17
        "     | Expr(expr value)\n"
6178
17
        "     | Pass\n"
6179
17
        "     | Break\n"
6180
17
        "     | Continue");
6181
17
    if (!state->stmt_type) return -1;
6182
17
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6183
0
        -1;
6184
17
    if (PySet_Add(state->abstract_types, state->stmt_type) < 0) return -1;
6185
17
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6186
0
        return -1;
6187
17
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6188
17
        -1)
6189
0
        return -1;
6190
17
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6191
17
                                        FunctionDef_fields, 7,
6192
17
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6193
17
    if (!state->FunctionDef_type) return -1;
6194
17
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6195
17
        -1)
6196
0
        return -1;
6197
17
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6198
17
        == -1)
6199
0
        return -1;
6200
17
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6201
17
                                             state->stmt_type,
6202
17
                                             AsyncFunctionDef_fields, 7,
6203
17
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6204
17
    if (!state->AsyncFunctionDef_type) return -1;
6205
17
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6206
17
        == -1)
6207
0
        return -1;
6208
17
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6209
17
        Py_None) == -1)
6210
0
        return -1;
6211
17
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6212
17
                                     ClassDef_fields, 6,
6213
17
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6214
17
    if (!state->ClassDef_type) return -1;
6215
17
    state->Return_type = make_type(state, "Return", state->stmt_type,
6216
17
                                   Return_fields, 1,
6217
17
        "Return(expr? value)");
6218
17
    if (!state->Return_type) return -1;
6219
17
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6220
0
        return -1;
6221
17
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6222
17
                                   Delete_fields, 1,
6223
17
        "Delete(expr* targets)");
6224
17
    if (!state->Delete_type) return -1;
6225
17
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6226
17
                                   Assign_fields, 3,
6227
17
        "Assign(expr* targets, expr value, string? type_comment)");
6228
17
    if (!state->Assign_type) return -1;
6229
17
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6230
17
        -1)
6231
0
        return -1;
6232
17
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6233
17
                                      TypeAlias_fields, 3,
6234
17
        "TypeAlias(expr name, type_param* type_params, expr value)");
6235
17
    if (!state->TypeAlias_type) return -1;
6236
17
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6237
17
                                      AugAssign_fields, 3,
6238
17
        "AugAssign(expr target, operator op, expr value)");
6239
17
    if (!state->AugAssign_type) return -1;
6240
17
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6241
17
                                      AnnAssign_fields, 4,
6242
17
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6243
17
    if (!state->AnnAssign_type) return -1;
6244
17
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6245
0
        return -1;
6246
17
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6247
17
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6248
17
    if (!state->For_type) return -1;
6249
17
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6250
0
        return -1;
6251
17
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6252
17
                                     AsyncFor_fields, 5,
6253
17
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6254
17
    if (!state->AsyncFor_type) return -1;
6255
17
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6256
17
        -1)
6257
0
        return -1;
6258
17
    state->While_type = make_type(state, "While", state->stmt_type,
6259
17
                                  While_fields, 3,
6260
17
        "While(expr test, stmt* body, stmt* orelse)");
6261
17
    if (!state->While_type) return -1;
6262
17
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6263
17
        "If(expr test, stmt* body, stmt* orelse)");
6264
17
    if (!state->If_type) return -1;
6265
17
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6266
17
                                 3,
6267
17
        "With(withitem* items, stmt* body, string? type_comment)");
6268
17
    if (!state->With_type) return -1;
6269
17
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6270
0
        return -1;
6271
17
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6272
17
                                      AsyncWith_fields, 3,
6273
17
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6274
17
    if (!state->AsyncWith_type) return -1;
6275
17
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6276
17
        == -1)
6277
0
        return -1;
6278
17
    state->Match_type = make_type(state, "Match", state->stmt_type,
6279
17
                                  Match_fields, 2,
6280
17
        "Match(expr subject, match_case* cases)");
6281
17
    if (!state->Match_type) return -1;
6282
17
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6283
17
                                  Raise_fields, 2,
6284
17
        "Raise(expr? exc, expr? cause)");
6285
17
    if (!state->Raise_type) return -1;
6286
17
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6287
0
        return -1;
6288
17
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6289
0
        return -1;
6290
17
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6291
17
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6292
17
    if (!state->Try_type) return -1;
6293
17
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6294
17
                                    TryStar_fields, 4,
6295
17
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6296
17
    if (!state->TryStar_type) return -1;
6297
17
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6298
17
                                   Assert_fields, 2,
6299
17
        "Assert(expr test, expr? msg)");
6300
17
    if (!state->Assert_type) return -1;
6301
17
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6302
0
        return -1;
6303
17
    state->Import_type = make_type(state, "Import", state->stmt_type,
6304
17
                                   Import_fields, 2,
6305
17
        "Import(alias* names, int? is_lazy)");
6306
17
    if (!state->Import_type) return -1;
6307
17
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
6308
0
        return -1;
6309
17
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6310
17
                                       ImportFrom_fields, 4,
6311
17
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
6312
17
    if (!state->ImportFrom_type) return -1;
6313
17
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6314
0
        return -1;
6315
17
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6316
0
        return -1;
6317
17
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
6318
0
        return -1;
6319
17
    state->Global_type = make_type(state, "Global", state->stmt_type,
6320
17
                                   Global_fields, 1,
6321
17
        "Global(identifier* names)");
6322
17
    if (!state->Global_type) return -1;
6323
17
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6324
17
                                     Nonlocal_fields, 1,
6325
17
        "Nonlocal(identifier* names)");
6326
17
    if (!state->Nonlocal_type) return -1;
6327
17
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6328
17
                                 1,
6329
17
        "Expr(expr value)");
6330
17
    if (!state->Expr_type) return -1;
6331
17
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6332
17
        "Pass");
6333
17
    if (!state->Pass_type) return -1;
6334
17
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6335
17
        "Break");
6336
17
    if (!state->Break_type) return -1;
6337
17
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6338
17
                                     0,
6339
17
        "Continue");
6340
17
    if (!state->Continue_type) return -1;
6341
17
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6342
17
        "expr = BoolOp(boolop op, expr* values)\n"
6343
17
        "     | NamedExpr(expr target, expr value)\n"
6344
17
        "     | BinOp(expr left, operator op, expr right)\n"
6345
17
        "     | UnaryOp(unaryop op, expr operand)\n"
6346
17
        "     | Lambda(arguments args, expr body)\n"
6347
17
        "     | IfExp(expr test, expr body, expr orelse)\n"
6348
17
        "     | Dict(expr?* keys, expr* values)\n"
6349
17
        "     | Set(expr* elts)\n"
6350
17
        "     | ListComp(expr elt, comprehension* generators)\n"
6351
17
        "     | SetComp(expr elt, comprehension* generators)\n"
6352
17
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6353
17
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6354
17
        "     | Await(expr value)\n"
6355
17
        "     | Yield(expr? value)\n"
6356
17
        "     | YieldFrom(expr value)\n"
6357
17
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6358
17
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6359
17
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6360
17
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6361
17
        "     | JoinedStr(expr* values)\n"
6362
17
        "     | TemplateStr(expr* values)\n"
6363
17
        "     | Constant(constant value, string? kind)\n"
6364
17
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6365
17
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6366
17
        "     | Starred(expr value, expr_context ctx)\n"
6367
17
        "     | Name(identifier id, expr_context ctx)\n"
6368
17
        "     | List(expr* elts, expr_context ctx)\n"
6369
17
        "     | Tuple(expr* elts, expr_context ctx)\n"
6370
17
        "     | Slice(expr? lower, expr? upper, expr? step)");
6371
17
    if (!state->expr_type) return -1;
6372
17
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6373
0
        -1;
6374
17
    if (PySet_Add(state->abstract_types, state->expr_type) < 0) return -1;
6375
17
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6376
0
        return -1;
6377
17
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6378
17
        -1)
6379
0
        return -1;
6380
17
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6381
17
                                   BoolOp_fields, 2,
6382
17
        "BoolOp(boolop op, expr* values)");
6383
17
    if (!state->BoolOp_type) return -1;
6384
17
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6385
17
                                      NamedExpr_fields, 2,
6386
17
        "NamedExpr(expr target, expr value)");
6387
17
    if (!state->NamedExpr_type) return -1;
6388
17
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6389
17
                                  BinOp_fields, 3,
6390
17
        "BinOp(expr left, operator op, expr right)");
6391
17
    if (!state->BinOp_type) return -1;
6392
17
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6393
17
                                    UnaryOp_fields, 2,
6394
17
        "UnaryOp(unaryop op, expr operand)");
6395
17
    if (!state->UnaryOp_type) return -1;
6396
17
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6397
17
                                   Lambda_fields, 2,
6398
17
        "Lambda(arguments args, expr body)");
6399
17
    if (!state->Lambda_type) return -1;
6400
17
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6401
17
                                  IfExp_fields, 3,
6402
17
        "IfExp(expr test, expr body, expr orelse)");
6403
17
    if (!state->IfExp_type) return -1;
6404
17
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6405
17
                                 2,
6406
17
        "Dict(expr?* keys, expr* values)");
6407
17
    if (!state->Dict_type) return -1;
6408
17
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6409
17
        "Set(expr* elts)");
6410
17
    if (!state->Set_type) return -1;
6411
17
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6412
17
                                     ListComp_fields, 2,
6413
17
        "ListComp(expr elt, comprehension* generators)");
6414
17
    if (!state->ListComp_type) return -1;
6415
17
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6416
17
                                    SetComp_fields, 2,
6417
17
        "SetComp(expr elt, comprehension* generators)");
6418
17
    if (!state->SetComp_type) return -1;
6419
17
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6420
17
                                     DictComp_fields, 3,
6421
17
        "DictComp(expr key, expr? value, comprehension* generators)");
6422
17
    if (!state->DictComp_type) return -1;
6423
17
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6424
0
        return -1;
6425
17
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6426
17
                                         state->expr_type, GeneratorExp_fields,
6427
17
                                         2,
6428
17
        "GeneratorExp(expr elt, comprehension* generators)");
6429
17
    if (!state->GeneratorExp_type) return -1;
6430
17
    state->Await_type = make_type(state, "Await", state->expr_type,
6431
17
                                  Await_fields, 1,
6432
17
        "Await(expr value)");
6433
17
    if (!state->Await_type) return -1;
6434
17
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6435
17
                                  Yield_fields, 1,
6436
17
        "Yield(expr? value)");
6437
17
    if (!state->Yield_type) return -1;
6438
17
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6439
0
        return -1;
6440
17
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6441
17
                                      YieldFrom_fields, 1,
6442
17
        "YieldFrom(expr value)");
6443
17
    if (!state->YieldFrom_type) return -1;
6444
17
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6445
17
                                    Compare_fields, 3,
6446
17
        "Compare(expr left, cmpop* ops, expr* comparators)");
6447
17
    if (!state->Compare_type) return -1;
6448
17
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6449
17
                                 3,
6450
17
        "Call(expr func, expr* args, keyword* keywords)");
6451
17
    if (!state->Call_type) return -1;
6452
17
    state->FormattedValue_type = make_type(state, "FormattedValue",
6453
17
                                           state->expr_type,
6454
17
                                           FormattedValue_fields, 3,
6455
17
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6456
17
    if (!state->FormattedValue_type) return -1;
6457
17
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6458
17
        Py_None) == -1)
6459
0
        return -1;
6460
17
    state->Interpolation_type = make_type(state, "Interpolation",
6461
17
                                          state->expr_type,
6462
17
                                          Interpolation_fields, 4,
6463
17
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6464
17
    if (!state->Interpolation_type) return -1;
6465
17
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6466
17
        Py_None) == -1)
6467
0
        return -1;
6468
17
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6469
17
                                      JoinedStr_fields, 1,
6470
17
        "JoinedStr(expr* values)");
6471
17
    if (!state->JoinedStr_type) return -1;
6472
17
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6473
17
                                        TemplateStr_fields, 1,
6474
17
        "TemplateStr(expr* values)");
6475
17
    if (!state->TemplateStr_type) return -1;
6476
17
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6477
17
                                     Constant_fields, 2,
6478
17
        "Constant(constant value, string? kind)");
6479
17
    if (!state->Constant_type) return -1;
6480
17
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6481
0
        return -1;
6482
17
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6483
17
                                      Attribute_fields, 3,
6484
17
        "Attribute(expr value, identifier attr, expr_context ctx)");
6485
17
    if (!state->Attribute_type) return -1;
6486
17
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6487
17
                                      Subscript_fields, 3,
6488
17
        "Subscript(expr value, expr slice, expr_context ctx)");
6489
17
    if (!state->Subscript_type) return -1;
6490
17
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6491
17
                                    Starred_fields, 2,
6492
17
        "Starred(expr value, expr_context ctx)");
6493
17
    if (!state->Starred_type) return -1;
6494
17
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6495
17
                                 2,
6496
17
        "Name(identifier id, expr_context ctx)");
6497
17
    if (!state->Name_type) return -1;
6498
17
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6499
17
                                 2,
6500
17
        "List(expr* elts, expr_context ctx)");
6501
17
    if (!state->List_type) return -1;
6502
17
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6503
17
                                  Tuple_fields, 2,
6504
17
        "Tuple(expr* elts, expr_context ctx)");
6505
17
    if (!state->Tuple_type) return -1;
6506
17
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6507
17
                                  Slice_fields, 3,
6508
17
        "Slice(expr? lower, expr? upper, expr? step)");
6509
17
    if (!state->Slice_type) return -1;
6510
17
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6511
0
        return -1;
6512
17
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6513
0
        return -1;
6514
17
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6515
0
        return -1;
6516
17
    state->expr_context_type = make_type(state, "expr_context",
6517
17
                                         state->AST_type, NULL, 0,
6518
17
        "expr_context = Load | Store | Del");
6519
17
    if (!state->expr_context_type) return -1;
6520
17
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6521
17
    if (PySet_Add(state->abstract_types, state->expr_context_type) < 0) return
6522
0
        -1;
6523
17
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6524
17
                                 0,
6525
17
        "Load");
6526
17
    if (!state->Load_type) return -1;
6527
17
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6528
17
                                              NULL, NULL);
6529
17
    if (!state->Load_singleton) return -1;
6530
17
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6531
17
                                  NULL, 0,
6532
17
        "Store");
6533
17
    if (!state->Store_type) return -1;
6534
17
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6535
17
                                               *)state->Store_type, NULL, NULL);
6536
17
    if (!state->Store_singleton) return -1;
6537
17
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6538
17
        "Del");
6539
17
    if (!state->Del_type) return -1;
6540
17
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6541
17
                                             NULL, NULL);
6542
17
    if (!state->Del_singleton) return -1;
6543
17
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6544
17
        "boolop = And | Or");
6545
17
    if (!state->boolop_type) return -1;
6546
17
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6547
17
    if (PySet_Add(state->abstract_types, state->boolop_type) < 0) return -1;
6548
17
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6549
17
        "And");
6550
17
    if (!state->And_type) return -1;
6551
17
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6552
17
                                             NULL, NULL);
6553
17
    if (!state->And_singleton) return -1;
6554
17
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6555
17
        "Or");
6556
17
    if (!state->Or_type) return -1;
6557
17
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6558
17
                                            NULL, NULL);
6559
17
    if (!state->Or_singleton) return -1;
6560
17
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6561
17
                                     0,
6562
17
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6563
17
    if (!state->operator_type) return -1;
6564
17
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6565
17
    if (PySet_Add(state->abstract_types, state->operator_type) < 0) return -1;
6566
17
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6567
17
        "Add");
6568
17
    if (!state->Add_type) return -1;
6569
17
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6570
17
                                             NULL, NULL);
6571
17
    if (!state->Add_singleton) return -1;
6572
17
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6573
17
        "Sub");
6574
17
    if (!state->Sub_type) return -1;
6575
17
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6576
17
                                             NULL, NULL);
6577
17
    if (!state->Sub_singleton) return -1;
6578
17
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6579
17
        "Mult");
6580
17
    if (!state->Mult_type) return -1;
6581
17
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6582
17
                                              NULL, NULL);
6583
17
    if (!state->Mult_singleton) return -1;
6584
17
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6585
17
                                    NULL, 0,
6586
17
        "MatMult");
6587
17
    if (!state->MatMult_type) return -1;
6588
17
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6589
17
                                                 *)state->MatMult_type, NULL,
6590
17
                                                 NULL);
6591
17
    if (!state->MatMult_singleton) return -1;
6592
17
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6593
17
        "Div");
6594
17
    if (!state->Div_type) return -1;
6595
17
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6596
17
                                             NULL, NULL);
6597
17
    if (!state->Div_singleton) return -1;
6598
17
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6599
17
        "Mod");
6600
17
    if (!state->Mod_type) return -1;
6601
17
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6602
17
                                             NULL, NULL);
6603
17
    if (!state->Mod_singleton) return -1;
6604
17
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6605
17
        "Pow");
6606
17
    if (!state->Pow_type) return -1;
6607
17
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6608
17
                                             NULL, NULL);
6609
17
    if (!state->Pow_singleton) return -1;
6610
17
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6611
17
                                   0,
6612
17
        "LShift");
6613
17
    if (!state->LShift_type) return -1;
6614
17
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6615
17
                                                *)state->LShift_type, NULL,
6616
17
                                                NULL);
6617
17
    if (!state->LShift_singleton) return -1;
6618
17
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6619
17
                                   0,
6620
17
        "RShift");
6621
17
    if (!state->RShift_type) return -1;
6622
17
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6623
17
                                                *)state->RShift_type, NULL,
6624
17
                                                NULL);
6625
17
    if (!state->RShift_singleton) return -1;
6626
17
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6627
17
        "BitOr");
6628
17
    if (!state->BitOr_type) return -1;
6629
17
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6630
17
                                               *)state->BitOr_type, NULL, NULL);
6631
17
    if (!state->BitOr_singleton) return -1;
6632
17
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6633
17
                                   0,
6634
17
        "BitXor");
6635
17
    if (!state->BitXor_type) return -1;
6636
17
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6637
17
                                                *)state->BitXor_type, NULL,
6638
17
                                                NULL);
6639
17
    if (!state->BitXor_singleton) return -1;
6640
17
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6641
17
                                   0,
6642
17
        "BitAnd");
6643
17
    if (!state->BitAnd_type) return -1;
6644
17
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6645
17
                                                *)state->BitAnd_type, NULL,
6646
17
                                                NULL);
6647
17
    if (!state->BitAnd_singleton) return -1;
6648
17
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6649
17
                                     NULL, 0,
6650
17
        "FloorDiv");
6651
17
    if (!state->FloorDiv_type) return -1;
6652
17
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6653
17
                                                  *)state->FloorDiv_type, NULL,
6654
17
                                                  NULL);
6655
17
    if (!state->FloorDiv_singleton) return -1;
6656
17
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6657
17
        "unaryop = Invert | Not | UAdd | USub");
6658
17
    if (!state->unaryop_type) return -1;
6659
17
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6660
17
    if (PySet_Add(state->abstract_types, state->unaryop_type) < 0) return -1;
6661
17
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6662
17
                                   0,
6663
17
        "Invert");
6664
17
    if (!state->Invert_type) return -1;
6665
17
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6666
17
                                                *)state->Invert_type, NULL,
6667
17
                                                NULL);
6668
17
    if (!state->Invert_singleton) return -1;
6669
17
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6670
17
        "Not");
6671
17
    if (!state->Not_type) return -1;
6672
17
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6673
17
                                             NULL, NULL);
6674
17
    if (!state->Not_singleton) return -1;
6675
17
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6676
17
        "UAdd");
6677
17
    if (!state->UAdd_type) return -1;
6678
17
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6679
17
                                              NULL, NULL);
6680
17
    if (!state->UAdd_singleton) return -1;
6681
17
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6682
17
        "USub");
6683
17
    if (!state->USub_type) return -1;
6684
17
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6685
17
                                              NULL, NULL);
6686
17
    if (!state->USub_singleton) return -1;
6687
17
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6688
17
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6689
17
    if (!state->cmpop_type) return -1;
6690
17
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6691
17
    if (PySet_Add(state->abstract_types, state->cmpop_type) < 0) return -1;
6692
17
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6693
17
        "Eq");
6694
17
    if (!state->Eq_type) return -1;
6695
17
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6696
17
                                            NULL, NULL);
6697
17
    if (!state->Eq_singleton) return -1;
6698
17
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6699
17
        "NotEq");
6700
17
    if (!state->NotEq_type) return -1;
6701
17
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6702
17
                                               *)state->NotEq_type, NULL, NULL);
6703
17
    if (!state->NotEq_singleton) return -1;
6704
17
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6705
17
        "Lt");
6706
17
    if (!state->Lt_type) return -1;
6707
17
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6708
17
                                            NULL, NULL);
6709
17
    if (!state->Lt_singleton) return -1;
6710
17
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6711
17
        "LtE");
6712
17
    if (!state->LtE_type) return -1;
6713
17
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6714
17
                                             NULL, NULL);
6715
17
    if (!state->LtE_singleton) return -1;
6716
17
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6717
17
        "Gt");
6718
17
    if (!state->Gt_type) return -1;
6719
17
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6720
17
                                            NULL, NULL);
6721
17
    if (!state->Gt_singleton) return -1;
6722
17
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6723
17
        "GtE");
6724
17
    if (!state->GtE_type) return -1;
6725
17
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6726
17
                                             NULL, NULL);
6727
17
    if (!state->GtE_singleton) return -1;
6728
17
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6729
17
        "Is");
6730
17
    if (!state->Is_type) return -1;
6731
17
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6732
17
                                            NULL, NULL);
6733
17
    if (!state->Is_singleton) return -1;
6734
17
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6735
17
        "IsNot");
6736
17
    if (!state->IsNot_type) return -1;
6737
17
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6738
17
                                               *)state->IsNot_type, NULL, NULL);
6739
17
    if (!state->IsNot_singleton) return -1;
6740
17
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6741
17
        "In");
6742
17
    if (!state->In_type) return -1;
6743
17
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6744
17
                                            NULL, NULL);
6745
17
    if (!state->In_singleton) return -1;
6746
17
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6747
17
        "NotIn");
6748
17
    if (!state->NotIn_type) return -1;
6749
17
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6750
17
                                               *)state->NotIn_type, NULL, NULL);
6751
17
    if (!state->NotIn_singleton) return -1;
6752
17
    state->comprehension_type = make_type(state, "comprehension",
6753
17
                                          state->AST_type,
6754
17
                                          comprehension_fields, 4,
6755
17
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6756
17
    if (!state->comprehension_type) return -1;
6757
17
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6758
0
        -1;
6759
17
    state->excepthandler_type = make_type(state, "excepthandler",
6760
17
                                          state->AST_type, NULL, 0,
6761
17
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6762
17
    if (!state->excepthandler_type) return -1;
6763
17
    if (add_attributes(state, state->excepthandler_type,
6764
17
        excepthandler_attributes, 4) < 0) return -1;
6765
17
    if (PySet_Add(state->abstract_types, state->excepthandler_type) < 0) return
6766
0
        -1;
6767
17
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6768
17
        == -1)
6769
0
        return -1;
6770
17
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6771
17
        Py_None) == -1)
6772
0
        return -1;
6773
17
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6774
17
                                          state->excepthandler_type,
6775
17
                                          ExceptHandler_fields, 3,
6776
17
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6777
17
    if (!state->ExceptHandler_type) return -1;
6778
17
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6779
0
        return -1;
6780
17
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6781
0
        return -1;
6782
17
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6783
17
                                      arguments_fields, 7,
6784
17
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6785
17
    if (!state->arguments_type) return -1;
6786
17
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6787
17
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6788
0
        return -1;
6789
17
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6790
0
        return -1;
6791
17
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6792
17
        "arg(identifier arg, expr? annotation, string? type_comment)");
6793
17
    if (!state->arg_type) return -1;
6794
17
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6795
0
        -1;
6796
17
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6797
0
        return -1;
6798
17
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6799
0
        return -1;
6800
17
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6801
0
        return -1;
6802
17
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6803
0
        return -1;
6804
17
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6805
17
                                    keyword_fields, 2,
6806
17
        "keyword(identifier? arg, expr value)");
6807
17
    if (!state->keyword_type) return -1;
6808
17
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6809
0
        return -1;
6810
17
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6811
0
        return -1;
6812
17
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6813
0
        return -1;
6814
17
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6815
17
        == -1)
6816
0
        return -1;
6817
17
    state->alias_type = make_type(state, "alias", state->AST_type,
6818
17
                                  alias_fields, 2,
6819
17
        "alias(identifier name, identifier? asname)");
6820
17
    if (!state->alias_type) return -1;
6821
17
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6822
0
        return -1;
6823
17
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6824
0
        return -1;
6825
17
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6826
0
        return -1;
6827
17
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6828
17
        -1)
6829
0
        return -1;
6830
17
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6831
17
                                     withitem_fields, 2,
6832
17
        "withitem(expr context_expr, expr? optional_vars)");
6833
17
    if (!state->withitem_type) return -1;
6834
17
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6835
17
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6836
17
        == -1)
6837
0
        return -1;
6838
17
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6839
17
                                       match_case_fields, 3,
6840
17
        "match_case(pattern pattern, expr? guard, stmt* body)");
6841
17
    if (!state->match_case_type) return -1;
6842
17
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6843
17
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6844
0
        return -1;
6845
17
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6846
17
        "pattern = MatchValue(expr value)\n"
6847
17
        "        | MatchSingleton(constant value)\n"
6848
17
        "        | MatchSequence(pattern* patterns)\n"
6849
17
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6850
17
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6851
17
        "        | MatchStar(identifier? name)\n"
6852
17
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6853
17
        "        | MatchOr(pattern* patterns)");
6854
17
    if (!state->pattern_type) return -1;
6855
17
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6856
0
        return -1;
6857
17
    if (PySet_Add(state->abstract_types, state->pattern_type) < 0) return -1;
6858
17
    state->MatchValue_type = make_type(state, "MatchValue",
6859
17
                                       state->pattern_type, MatchValue_fields,
6860
17
                                       1,
6861
17
        "MatchValue(expr value)");
6862
17
    if (!state->MatchValue_type) return -1;
6863
17
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6864
17
                                           state->pattern_type,
6865
17
                                           MatchSingleton_fields, 1,
6866
17
        "MatchSingleton(constant value)");
6867
17
    if (!state->MatchSingleton_type) return -1;
6868
17
    state->MatchSequence_type = make_type(state, "MatchSequence",
6869
17
                                          state->pattern_type,
6870
17
                                          MatchSequence_fields, 1,
6871
17
        "MatchSequence(pattern* patterns)");
6872
17
    if (!state->MatchSequence_type) return -1;
6873
17
    state->MatchMapping_type = make_type(state, "MatchMapping",
6874
17
                                         state->pattern_type,
6875
17
                                         MatchMapping_fields, 3,
6876
17
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6877
17
    if (!state->MatchMapping_type) return -1;
6878
17
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6879
0
        return -1;
6880
17
    state->MatchClass_type = make_type(state, "MatchClass",
6881
17
                                       state->pattern_type, MatchClass_fields,
6882
17
                                       4,
6883
17
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6884
17
    if (!state->MatchClass_type) return -1;
6885
17
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6886
17
                                      MatchStar_fields, 1,
6887
17
        "MatchStar(identifier? name)");
6888
17
    if (!state->MatchStar_type) return -1;
6889
17
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6890
0
        return -1;
6891
17
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6892
17
                                    MatchAs_fields, 2,
6893
17
        "MatchAs(pattern? pattern, identifier? name)");
6894
17
    if (!state->MatchAs_type) return -1;
6895
17
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6896
0
        return -1;
6897
17
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6898
0
        return -1;
6899
17
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6900
17
                                    MatchOr_fields, 1,
6901
17
        "MatchOr(pattern* patterns)");
6902
17
    if (!state->MatchOr_type) return -1;
6903
17
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6904
17
                                        NULL, 0,
6905
17
        "type_ignore = TypeIgnore(int lineno, string tag)");
6906
17
    if (!state->type_ignore_type) return -1;
6907
17
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6908
17
    if (PySet_Add(state->abstract_types, state->type_ignore_type) < 0) return
6909
0
        -1;
6910
17
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6911
17
                                       state->type_ignore_type,
6912
17
                                       TypeIgnore_fields, 2,
6913
17
        "TypeIgnore(int lineno, string tag)");
6914
17
    if (!state->TypeIgnore_type) return -1;
6915
17
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6916
17
                                       NULL, 0,
6917
17
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6918
17
        "           | ParamSpec(identifier name, expr? default_value)\n"
6919
17
        "           | TypeVarTuple(identifier name, expr? default_value)");
6920
17
    if (!state->type_param_type) return -1;
6921
17
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6922
17
        < 0) return -1;
6923
17
    if (PySet_Add(state->abstract_types, state->type_param_type) < 0) return -1;
6924
17
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6925
17
                                    TypeVar_fields, 3,
6926
17
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6927
17
    if (!state->TypeVar_type) return -1;
6928
17
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6929
0
        return -1;
6930
17
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6931
17
        -1)
6932
0
        return -1;
6933
17
    state->ParamSpec_type = make_type(state, "ParamSpec",
6934
17
                                      state->type_param_type, ParamSpec_fields,
6935
17
                                      2,
6936
17
        "ParamSpec(identifier name, expr? default_value)");
6937
17
    if (!state->ParamSpec_type) return -1;
6938
17
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6939
17
        == -1)
6940
0
        return -1;
6941
17
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6942
17
                                         state->type_param_type,
6943
17
                                         TypeVarTuple_fields, 2,
6944
17
        "TypeVarTuple(identifier name, expr? default_value)");
6945
17
    if (!state->TypeVarTuple_type) return -1;
6946
17
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6947
17
        Py_None) == -1)
6948
0
        return -1;
6949
6950
17
    if (!add_ast_annotations(state)) {
6951
0
        return -1;
6952
0
    }
6953
17
    return 0;
6954
17
}
6955
6956
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6957
                       PyArena* arena);
6958
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6959
                        PyArena* arena);
6960
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6961
                        PyArena* arena);
6962
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6963
                                expr_context_ty* out, PyArena* arena);
6964
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
6965
                          out, PyArena* arena);
6966
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
6967
                            operator_ty* out, PyArena* arena);
6968
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
6969
                           out, PyArena* arena);
6970
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
6971
                         PyArena* arena);
6972
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
6973
                                 comprehension_ty* out, PyArena* arena);
6974
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
6975
                                 excepthandler_ty* out, PyArena* arena);
6976
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
6977
                             arguments_ty* out, PyArena* arena);
6978
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
6979
                       PyArena* arena);
6980
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
6981
                           out, PyArena* arena);
6982
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
6983
                         PyArena* arena);
6984
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
6985
                            withitem_ty* out, PyArena* arena);
6986
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
6987
                              match_case_ty* out, PyArena* arena);
6988
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
6989
                           out, PyArena* arena);
6990
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
6991
                               type_ignore_ty* out, PyArena* arena);
6992
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
6993
                              type_param_ty* out, PyArena* arena);
6994
6995
mod_ty
6996
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
6997
              PyArena *arena)
6998
7.09k
{
6999
7.09k
    mod_ty p;
7000
7.09k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7001
7.09k
    if (!p)
7002
0
        return NULL;
7003
7.09k
    p->kind = Module_kind;
7004
7.09k
    p->v.Module.body = body;
7005
7.09k
    p->v.Module.type_ignores = type_ignores;
7006
7.09k
    return p;
7007
7.09k
}
7008
7009
mod_ty
7010
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7011
0
{
7012
0
    mod_ty p;
7013
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7014
0
    if (!p)
7015
0
        return NULL;
7016
0
    p->kind = Interactive_kind;
7017
0
    p->v.Interactive.body = body;
7018
0
    return p;
7019
0
}
7020
7021
mod_ty
7022
_PyAST_Expression(expr_ty body, PyArena *arena)
7023
229
{
7024
229
    mod_ty p;
7025
229
    if (!body) {
7026
0
        PyErr_SetString(PyExc_ValueError,
7027
0
                        "field 'body' is required for Expression");
7028
0
        return NULL;
7029
0
    }
7030
229
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7031
229
    if (!p)
7032
0
        return NULL;
7033
229
    p->kind = Expression_kind;
7034
229
    p->v.Expression.body = body;
7035
229
    return p;
7036
229
}
7037
7038
mod_ty
7039
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7040
0
{
7041
0
    mod_ty p;
7042
0
    if (!returns) {
7043
0
        PyErr_SetString(PyExc_ValueError,
7044
0
                        "field 'returns' is required for FunctionType");
7045
0
        return NULL;
7046
0
    }
7047
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7048
0
    if (!p)
7049
0
        return NULL;
7050
0
    p->kind = FunctionType_kind;
7051
0
    p->v.FunctionType.argtypes = argtypes;
7052
0
    p->v.FunctionType.returns = returns;
7053
0
    return p;
7054
0
}
7055
7056
stmt_ty
7057
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7058
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7059
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7060
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7061
                   *arena)
7062
6.40k
{
7063
6.40k
    stmt_ty p;
7064
6.40k
    if (!name) {
7065
0
        PyErr_SetString(PyExc_ValueError,
7066
0
                        "field 'name' is required for FunctionDef");
7067
0
        return NULL;
7068
0
    }
7069
6.40k
    if (!args) {
7070
0
        PyErr_SetString(PyExc_ValueError,
7071
0
                        "field 'args' is required for FunctionDef");
7072
0
        return NULL;
7073
0
    }
7074
6.40k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7075
6.40k
    if (!p)
7076
0
        return NULL;
7077
6.40k
    p->kind = FunctionDef_kind;
7078
6.40k
    p->v.FunctionDef.name = name;
7079
6.40k
    p->v.FunctionDef.args = args;
7080
6.40k
    p->v.FunctionDef.body = body;
7081
6.40k
    p->v.FunctionDef.decorator_list = decorator_list;
7082
6.40k
    p->v.FunctionDef.returns = returns;
7083
6.40k
    p->v.FunctionDef.type_comment = type_comment;
7084
6.40k
    p->v.FunctionDef.type_params = type_params;
7085
6.40k
    p->lineno = lineno;
7086
6.40k
    p->col_offset = col_offset;
7087
6.40k
    p->end_lineno = end_lineno;
7088
6.40k
    p->end_col_offset = end_col_offset;
7089
6.40k
    return p;
7090
6.40k
}
7091
7092
stmt_ty
7093
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7094
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7095
                        string type_comment, asdl_type_param_seq * type_params,
7096
                        int lineno, int col_offset, int end_lineno, int
7097
                        end_col_offset, PyArena *arena)
7098
796
{
7099
796
    stmt_ty p;
7100
796
    if (!name) {
7101
0
        PyErr_SetString(PyExc_ValueError,
7102
0
                        "field 'name' is required for AsyncFunctionDef");
7103
0
        return NULL;
7104
0
    }
7105
796
    if (!args) {
7106
0
        PyErr_SetString(PyExc_ValueError,
7107
0
                        "field 'args' is required for AsyncFunctionDef");
7108
0
        return NULL;
7109
0
    }
7110
796
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7111
796
    if (!p)
7112
0
        return NULL;
7113
796
    p->kind = AsyncFunctionDef_kind;
7114
796
    p->v.AsyncFunctionDef.name = name;
7115
796
    p->v.AsyncFunctionDef.args = args;
7116
796
    p->v.AsyncFunctionDef.body = body;
7117
796
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7118
796
    p->v.AsyncFunctionDef.returns = returns;
7119
796
    p->v.AsyncFunctionDef.type_comment = type_comment;
7120
796
    p->v.AsyncFunctionDef.type_params = type_params;
7121
796
    p->lineno = lineno;
7122
796
    p->col_offset = col_offset;
7123
796
    p->end_lineno = end_lineno;
7124
796
    p->end_col_offset = end_col_offset;
7125
796
    return p;
7126
796
}
7127
7128
stmt_ty
7129
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7130
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7131
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7132
                int end_lineno, int end_col_offset, PyArena *arena)
7133
2.71k
{
7134
2.71k
    stmt_ty p;
7135
2.71k
    if (!name) {
7136
0
        PyErr_SetString(PyExc_ValueError,
7137
0
                        "field 'name' is required for ClassDef");
7138
0
        return NULL;
7139
0
    }
7140
2.71k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7141
2.71k
    if (!p)
7142
0
        return NULL;
7143
2.71k
    p->kind = ClassDef_kind;
7144
2.71k
    p->v.ClassDef.name = name;
7145
2.71k
    p->v.ClassDef.bases = bases;
7146
2.71k
    p->v.ClassDef.keywords = keywords;
7147
2.71k
    p->v.ClassDef.body = body;
7148
2.71k
    p->v.ClassDef.decorator_list = decorator_list;
7149
2.71k
    p->v.ClassDef.type_params = type_params;
7150
2.71k
    p->lineno = lineno;
7151
2.71k
    p->col_offset = col_offset;
7152
2.71k
    p->end_lineno = end_lineno;
7153
2.71k
    p->end_col_offset = end_col_offset;
7154
2.71k
    return p;
7155
2.71k
}
7156
7157
stmt_ty
7158
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7159
              end_col_offset, PyArena *arena)
7160
3.29k
{
7161
3.29k
    stmt_ty p;
7162
3.29k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7163
3.29k
    if (!p)
7164
0
        return NULL;
7165
3.29k
    p->kind = Return_kind;
7166
3.29k
    p->v.Return.value = value;
7167
3.29k
    p->lineno = lineno;
7168
3.29k
    p->col_offset = col_offset;
7169
3.29k
    p->end_lineno = end_lineno;
7170
3.29k
    p->end_col_offset = end_col_offset;
7171
3.29k
    return p;
7172
3.29k
}
7173
7174
stmt_ty
7175
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7176
              end_lineno, int end_col_offset, PyArena *arena)
7177
398
{
7178
398
    stmt_ty p;
7179
398
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7180
398
    if (!p)
7181
0
        return NULL;
7182
398
    p->kind = Delete_kind;
7183
398
    p->v.Delete.targets = targets;
7184
398
    p->lineno = lineno;
7185
398
    p->col_offset = col_offset;
7186
398
    p->end_lineno = end_lineno;
7187
398
    p->end_col_offset = end_col_offset;
7188
398
    return p;
7189
398
}
7190
7191
stmt_ty
7192
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7193
              lineno, int col_offset, int end_lineno, int end_col_offset,
7194
              PyArena *arena)
7195
6.27k
{
7196
6.27k
    stmt_ty p;
7197
6.27k
    if (!value) {
7198
0
        PyErr_SetString(PyExc_ValueError,
7199
0
                        "field 'value' is required for Assign");
7200
0
        return NULL;
7201
0
    }
7202
6.27k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7203
6.27k
    if (!p)
7204
0
        return NULL;
7205
6.27k
    p->kind = Assign_kind;
7206
6.27k
    p->v.Assign.targets = targets;
7207
6.27k
    p->v.Assign.value = value;
7208
6.27k
    p->v.Assign.type_comment = type_comment;
7209
6.27k
    p->lineno = lineno;
7210
6.27k
    p->col_offset = col_offset;
7211
6.27k
    p->end_lineno = end_lineno;
7212
6.27k
    p->end_col_offset = end_col_offset;
7213
6.27k
    return p;
7214
6.27k
}
7215
7216
stmt_ty
7217
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7218
                 value, int lineno, int col_offset, int end_lineno, int
7219
                 end_col_offset, PyArena *arena)
7220
269
{
7221
269
    stmt_ty p;
7222
269
    if (!name) {
7223
0
        PyErr_SetString(PyExc_ValueError,
7224
0
                        "field 'name' is required for TypeAlias");
7225
0
        return NULL;
7226
0
    }
7227
269
    if (!value) {
7228
0
        PyErr_SetString(PyExc_ValueError,
7229
0
                        "field 'value' is required for TypeAlias");
7230
0
        return NULL;
7231
0
    }
7232
269
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7233
269
    if (!p)
7234
0
        return NULL;
7235
269
    p->kind = TypeAlias_kind;
7236
269
    p->v.TypeAlias.name = name;
7237
269
    p->v.TypeAlias.type_params = type_params;
7238
269
    p->v.TypeAlias.value = value;
7239
269
    p->lineno = lineno;
7240
269
    p->col_offset = col_offset;
7241
269
    p->end_lineno = end_lineno;
7242
269
    p->end_col_offset = end_col_offset;
7243
269
    return p;
7244
269
}
7245
7246
stmt_ty
7247
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7248
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7249
2.48k
{
7250
2.48k
    stmt_ty p;
7251
2.48k
    if (!target) {
7252
0
        PyErr_SetString(PyExc_ValueError,
7253
0
                        "field 'target' is required for AugAssign");
7254
0
        return NULL;
7255
0
    }
7256
2.48k
    if (!op) {
7257
0
        PyErr_SetString(PyExc_ValueError,
7258
0
                        "field 'op' is required for AugAssign");
7259
0
        return NULL;
7260
0
    }
7261
2.48k
    if (!value) {
7262
0
        PyErr_SetString(PyExc_ValueError,
7263
0
                        "field 'value' is required for AugAssign");
7264
0
        return NULL;
7265
0
    }
7266
2.48k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7267
2.48k
    if (!p)
7268
0
        return NULL;
7269
2.48k
    p->kind = AugAssign_kind;
7270
2.48k
    p->v.AugAssign.target = target;
7271
2.48k
    p->v.AugAssign.op = op;
7272
2.48k
    p->v.AugAssign.value = value;
7273
2.48k
    p->lineno = lineno;
7274
2.48k
    p->col_offset = col_offset;
7275
2.48k
    p->end_lineno = end_lineno;
7276
2.48k
    p->end_col_offset = end_col_offset;
7277
2.48k
    return p;
7278
2.48k
}
7279
7280
stmt_ty
7281
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7282
                 int lineno, int col_offset, int end_lineno, int
7283
                 end_col_offset, PyArena *arena)
7284
2.69k
{
7285
2.69k
    stmt_ty p;
7286
2.69k
    if (!target) {
7287
0
        PyErr_SetString(PyExc_ValueError,
7288
0
                        "field 'target' is required for AnnAssign");
7289
0
        return NULL;
7290
0
    }
7291
2.69k
    if (!annotation) {
7292
0
        PyErr_SetString(PyExc_ValueError,
7293
0
                        "field 'annotation' is required for AnnAssign");
7294
0
        return NULL;
7295
0
    }
7296
2.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7297
2.69k
    if (!p)
7298
0
        return NULL;
7299
2.69k
    p->kind = AnnAssign_kind;
7300
2.69k
    p->v.AnnAssign.target = target;
7301
2.69k
    p->v.AnnAssign.annotation = annotation;
7302
2.69k
    p->v.AnnAssign.value = value;
7303
2.69k
    p->v.AnnAssign.simple = simple;
7304
2.69k
    p->lineno = lineno;
7305
2.69k
    p->col_offset = col_offset;
7306
2.69k
    p->end_lineno = end_lineno;
7307
2.69k
    p->end_col_offset = end_col_offset;
7308
2.69k
    return p;
7309
2.69k
}
7310
7311
stmt_ty
7312
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7313
           orelse, string type_comment, int lineno, int col_offset, int
7314
           end_lineno, int end_col_offset, PyArena *arena)
7315
1.09k
{
7316
1.09k
    stmt_ty p;
7317
1.09k
    if (!target) {
7318
0
        PyErr_SetString(PyExc_ValueError,
7319
0
                        "field 'target' is required for For");
7320
0
        return NULL;
7321
0
    }
7322
1.09k
    if (!iter) {
7323
0
        PyErr_SetString(PyExc_ValueError,
7324
0
                        "field 'iter' is required for For");
7325
0
        return NULL;
7326
0
    }
7327
1.09k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7328
1.09k
    if (!p)
7329
0
        return NULL;
7330
1.09k
    p->kind = For_kind;
7331
1.09k
    p->v.For.target = target;
7332
1.09k
    p->v.For.iter = iter;
7333
1.09k
    p->v.For.body = body;
7334
1.09k
    p->v.For.orelse = orelse;
7335
1.09k
    p->v.For.type_comment = type_comment;
7336
1.09k
    p->lineno = lineno;
7337
1.09k
    p->col_offset = col_offset;
7338
1.09k
    p->end_lineno = end_lineno;
7339
1.09k
    p->end_col_offset = end_col_offset;
7340
1.09k
    return p;
7341
1.09k
}
7342
7343
stmt_ty
7344
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7345
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7346
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7347
447
{
7348
447
    stmt_ty p;
7349
447
    if (!target) {
7350
0
        PyErr_SetString(PyExc_ValueError,
7351
0
                        "field 'target' is required for AsyncFor");
7352
0
        return NULL;
7353
0
    }
7354
447
    if (!iter) {
7355
0
        PyErr_SetString(PyExc_ValueError,
7356
0
                        "field 'iter' is required for AsyncFor");
7357
0
        return NULL;
7358
0
    }
7359
447
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7360
447
    if (!p)
7361
0
        return NULL;
7362
447
    p->kind = AsyncFor_kind;
7363
447
    p->v.AsyncFor.target = target;
7364
447
    p->v.AsyncFor.iter = iter;
7365
447
    p->v.AsyncFor.body = body;
7366
447
    p->v.AsyncFor.orelse = orelse;
7367
447
    p->v.AsyncFor.type_comment = type_comment;
7368
447
    p->lineno = lineno;
7369
447
    p->col_offset = col_offset;
7370
447
    p->end_lineno = end_lineno;
7371
447
    p->end_col_offset = end_col_offset;
7372
447
    return p;
7373
447
}
7374
7375
stmt_ty
7376
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7377
             lineno, int col_offset, int end_lineno, int end_col_offset,
7378
             PyArena *arena)
7379
837
{
7380
837
    stmt_ty p;
7381
837
    if (!test) {
7382
0
        PyErr_SetString(PyExc_ValueError,
7383
0
                        "field 'test' is required for While");
7384
0
        return NULL;
7385
0
    }
7386
837
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7387
837
    if (!p)
7388
0
        return NULL;
7389
837
    p->kind = While_kind;
7390
837
    p->v.While.test = test;
7391
837
    p->v.While.body = body;
7392
837
    p->v.While.orelse = orelse;
7393
837
    p->lineno = lineno;
7394
837
    p->col_offset = col_offset;
7395
837
    p->end_lineno = end_lineno;
7396
837
    p->end_col_offset = end_col_offset;
7397
837
    return p;
7398
837
}
7399
7400
stmt_ty
7401
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7402
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7403
          *arena)
7404
5.03k
{
7405
5.03k
    stmt_ty p;
7406
5.03k
    if (!test) {
7407
0
        PyErr_SetString(PyExc_ValueError,
7408
0
                        "field 'test' is required for If");
7409
0
        return NULL;
7410
0
    }
7411
5.03k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7412
5.03k
    if (!p)
7413
0
        return NULL;
7414
5.03k
    p->kind = If_kind;
7415
5.03k
    p->v.If.test = test;
7416
5.03k
    p->v.If.body = body;
7417
5.03k
    p->v.If.orelse = orelse;
7418
5.03k
    p->lineno = lineno;
7419
5.03k
    p->col_offset = col_offset;
7420
5.03k
    p->end_lineno = end_lineno;
7421
5.03k
    p->end_col_offset = end_col_offset;
7422
5.03k
    return p;
7423
5.03k
}
7424
7425
stmt_ty
7426
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7427
            type_comment, int lineno, int col_offset, int end_lineno, int
7428
            end_col_offset, PyArena *arena)
7429
2.43k
{
7430
2.43k
    stmt_ty p;
7431
2.43k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7432
2.43k
    if (!p)
7433
0
        return NULL;
7434
2.43k
    p->kind = With_kind;
7435
2.43k
    p->v.With.items = items;
7436
2.43k
    p->v.With.body = body;
7437
2.43k
    p->v.With.type_comment = type_comment;
7438
2.43k
    p->lineno = lineno;
7439
2.43k
    p->col_offset = col_offset;
7440
2.43k
    p->end_lineno = end_lineno;
7441
2.43k
    p->end_col_offset = end_col_offset;
7442
2.43k
    return p;
7443
2.43k
}
7444
7445
stmt_ty
7446
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7447
                 type_comment, int lineno, int col_offset, int end_lineno, int
7448
                 end_col_offset, PyArena *arena)
7449
808
{
7450
808
    stmt_ty p;
7451
808
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7452
808
    if (!p)
7453
0
        return NULL;
7454
808
    p->kind = AsyncWith_kind;
7455
808
    p->v.AsyncWith.items = items;
7456
808
    p->v.AsyncWith.body = body;
7457
808
    p->v.AsyncWith.type_comment = type_comment;
7458
808
    p->lineno = lineno;
7459
808
    p->col_offset = col_offset;
7460
808
    p->end_lineno = end_lineno;
7461
808
    p->end_col_offset = end_col_offset;
7462
808
    return p;
7463
808
}
7464
7465
stmt_ty
7466
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7467
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7468
540
{
7469
540
    stmt_ty p;
7470
540
    if (!subject) {
7471
0
        PyErr_SetString(PyExc_ValueError,
7472
0
                        "field 'subject' is required for Match");
7473
0
        return NULL;
7474
0
    }
7475
540
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7476
540
    if (!p)
7477
0
        return NULL;
7478
540
    p->kind = Match_kind;
7479
540
    p->v.Match.subject = subject;
7480
540
    p->v.Match.cases = cases;
7481
540
    p->lineno = lineno;
7482
540
    p->col_offset = col_offset;
7483
540
    p->end_lineno = end_lineno;
7484
540
    p->end_col_offset = end_col_offset;
7485
540
    return p;
7486
540
}
7487
7488
stmt_ty
7489
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7490
             end_lineno, int end_col_offset, PyArena *arena)
7491
2.35k
{
7492
2.35k
    stmt_ty p;
7493
2.35k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7494
2.35k
    if (!p)
7495
0
        return NULL;
7496
2.35k
    p->kind = Raise_kind;
7497
2.35k
    p->v.Raise.exc = exc;
7498
2.35k
    p->v.Raise.cause = cause;
7499
2.35k
    p->lineno = lineno;
7500
2.35k
    p->col_offset = col_offset;
7501
2.35k
    p->end_lineno = end_lineno;
7502
2.35k
    p->end_col_offset = end_col_offset;
7503
2.35k
    return p;
7504
2.35k
}
7505
7506
stmt_ty
7507
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7508
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7509
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7510
2.41k
{
7511
2.41k
    stmt_ty p;
7512
2.41k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7513
2.41k
    if (!p)
7514
0
        return NULL;
7515
2.41k
    p->kind = Try_kind;
7516
2.41k
    p->v.Try.body = body;
7517
2.41k
    p->v.Try.handlers = handlers;
7518
2.41k
    p->v.Try.orelse = orelse;
7519
2.41k
    p->v.Try.finalbody = finalbody;
7520
2.41k
    p->lineno = lineno;
7521
2.41k
    p->col_offset = col_offset;
7522
2.41k
    p->end_lineno = end_lineno;
7523
2.41k
    p->end_col_offset = end_col_offset;
7524
2.41k
    return p;
7525
2.41k
}
7526
7527
stmt_ty
7528
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7529
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7530
               int col_offset, int end_lineno, int end_col_offset, PyArena
7531
               *arena)
7532
1.53k
{
7533
1.53k
    stmt_ty p;
7534
1.53k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7535
1.53k
    if (!p)
7536
0
        return NULL;
7537
1.53k
    p->kind = TryStar_kind;
7538
1.53k
    p->v.TryStar.body = body;
7539
1.53k
    p->v.TryStar.handlers = handlers;
7540
1.53k
    p->v.TryStar.orelse = orelse;
7541
1.53k
    p->v.TryStar.finalbody = finalbody;
7542
1.53k
    p->lineno = lineno;
7543
1.53k
    p->col_offset = col_offset;
7544
1.53k
    p->end_lineno = end_lineno;
7545
1.53k
    p->end_col_offset = end_col_offset;
7546
1.53k
    return p;
7547
1.53k
}
7548
7549
stmt_ty
7550
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7551
              end_lineno, int end_col_offset, PyArena *arena)
7552
756
{
7553
756
    stmt_ty p;
7554
756
    if (!test) {
7555
0
        PyErr_SetString(PyExc_ValueError,
7556
0
                        "field 'test' is required for Assert");
7557
0
        return NULL;
7558
0
    }
7559
756
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7560
756
    if (!p)
7561
0
        return NULL;
7562
756
    p->kind = Assert_kind;
7563
756
    p->v.Assert.test = test;
7564
756
    p->v.Assert.msg = msg;
7565
756
    p->lineno = lineno;
7566
756
    p->col_offset = col_offset;
7567
756
    p->end_lineno = end_lineno;
7568
756
    p->end_col_offset = end_col_offset;
7569
756
    return p;
7570
756
}
7571
7572
stmt_ty
7573
_PyAST_Import(asdl_alias_seq * names, int is_lazy, int lineno, int col_offset,
7574
              int end_lineno, int end_col_offset, PyArena *arena)
7575
2.19k
{
7576
2.19k
    stmt_ty p;
7577
2.19k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7578
2.19k
    if (!p)
7579
0
        return NULL;
7580
2.19k
    p->kind = Import_kind;
7581
2.19k
    p->v.Import.names = names;
7582
2.19k
    p->v.Import.is_lazy = is_lazy;
7583
2.19k
    p->lineno = lineno;
7584
2.19k
    p->col_offset = col_offset;
7585
2.19k
    p->end_lineno = end_lineno;
7586
2.19k
    p->end_col_offset = end_col_offset;
7587
2.19k
    return p;
7588
2.19k
}
7589
7590
stmt_ty
7591
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7592
                  is_lazy, int lineno, int col_offset, int end_lineno, int
7593
                  end_col_offset, PyArena *arena)
7594
3.01k
{
7595
3.01k
    stmt_ty p;
7596
3.01k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7597
3.01k
    if (!p)
7598
0
        return NULL;
7599
3.01k
    p->kind = ImportFrom_kind;
7600
3.01k
    p->v.ImportFrom.module = module;
7601
3.01k
    p->v.ImportFrom.names = names;
7602
3.01k
    p->v.ImportFrom.level = level;
7603
3.01k
    p->v.ImportFrom.is_lazy = is_lazy;
7604
3.01k
    p->lineno = lineno;
7605
3.01k
    p->col_offset = col_offset;
7606
3.01k
    p->end_lineno = end_lineno;
7607
3.01k
    p->end_col_offset = end_col_offset;
7608
3.01k
    return p;
7609
3.01k
}
7610
7611
stmt_ty
7612
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7613
              end_lineno, int end_col_offset, PyArena *arena)
7614
622
{
7615
622
    stmt_ty p;
7616
622
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7617
622
    if (!p)
7618
0
        return NULL;
7619
622
    p->kind = Global_kind;
7620
622
    p->v.Global.names = names;
7621
622
    p->lineno = lineno;
7622
622
    p->col_offset = col_offset;
7623
622
    p->end_lineno = end_lineno;
7624
622
    p->end_col_offset = end_col_offset;
7625
622
    return p;
7626
622
}
7627
7628
stmt_ty
7629
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7630
                end_lineno, int end_col_offset, PyArena *arena)
7631
102
{
7632
102
    stmt_ty p;
7633
102
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7634
102
    if (!p)
7635
0
        return NULL;
7636
102
    p->kind = Nonlocal_kind;
7637
102
    p->v.Nonlocal.names = names;
7638
102
    p->lineno = lineno;
7639
102
    p->col_offset = col_offset;
7640
102
    p->end_lineno = end_lineno;
7641
102
    p->end_col_offset = end_col_offset;
7642
102
    return p;
7643
102
}
7644
7645
stmt_ty
7646
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7647
            end_col_offset, PyArena *arena)
7648
89.8k
{
7649
89.8k
    stmt_ty p;
7650
89.8k
    if (!value) {
7651
0
        PyErr_SetString(PyExc_ValueError,
7652
0
                        "field 'value' is required for Expr");
7653
0
        return NULL;
7654
0
    }
7655
89.8k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7656
89.8k
    if (!p)
7657
0
        return NULL;
7658
89.8k
    p->kind = Expr_kind;
7659
89.8k
    p->v.Expr.value = value;
7660
89.8k
    p->lineno = lineno;
7661
89.8k
    p->col_offset = col_offset;
7662
89.8k
    p->end_lineno = end_lineno;
7663
89.8k
    p->end_col_offset = end_col_offset;
7664
89.8k
    return p;
7665
89.8k
}
7666
7667
stmt_ty
7668
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7669
            PyArena *arena)
7670
1.61k
{
7671
1.61k
    stmt_ty p;
7672
1.61k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7673
1.61k
    if (!p)
7674
0
        return NULL;
7675
1.61k
    p->kind = Pass_kind;
7676
1.61k
    p->lineno = lineno;
7677
1.61k
    p->col_offset = col_offset;
7678
1.61k
    p->end_lineno = end_lineno;
7679
1.61k
    p->end_col_offset = end_col_offset;
7680
1.61k
    return p;
7681
1.61k
}
7682
7683
stmt_ty
7684
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7685
             PyArena *arena)
7686
1.42k
{
7687
1.42k
    stmt_ty p;
7688
1.42k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7689
1.42k
    if (!p)
7690
0
        return NULL;
7691
1.42k
    p->kind = Break_kind;
7692
1.42k
    p->lineno = lineno;
7693
1.42k
    p->col_offset = col_offset;
7694
1.42k
    p->end_lineno = end_lineno;
7695
1.42k
    p->end_col_offset = end_col_offset;
7696
1.42k
    return p;
7697
1.42k
}
7698
7699
stmt_ty
7700
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7701
                PyArena *arena)
7702
3.27k
{
7703
3.27k
    stmt_ty p;
7704
3.27k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7705
3.27k
    if (!p)
7706
0
        return NULL;
7707
3.27k
    p->kind = Continue_kind;
7708
3.27k
    p->lineno = lineno;
7709
3.27k
    p->col_offset = col_offset;
7710
3.27k
    p->end_lineno = end_lineno;
7711
3.27k
    p->end_col_offset = end_col_offset;
7712
3.27k
    return p;
7713
3.27k
}
7714
7715
expr_ty
7716
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7717
              int end_lineno, int end_col_offset, PyArena *arena)
7718
2.21k
{
7719
2.21k
    expr_ty p;
7720
2.21k
    if (!op) {
7721
0
        PyErr_SetString(PyExc_ValueError,
7722
0
                        "field 'op' is required for BoolOp");
7723
0
        return NULL;
7724
0
    }
7725
2.21k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7726
2.21k
    if (!p)
7727
0
        return NULL;
7728
2.21k
    p->kind = BoolOp_kind;
7729
2.21k
    p->v.BoolOp.op = op;
7730
2.21k
    p->v.BoolOp.values = values;
7731
2.21k
    p->lineno = lineno;
7732
2.21k
    p->col_offset = col_offset;
7733
2.21k
    p->end_lineno = end_lineno;
7734
2.21k
    p->end_col_offset = end_col_offset;
7735
2.21k
    return p;
7736
2.21k
}
7737
7738
expr_ty
7739
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7740
                 end_lineno, int end_col_offset, PyArena *arena)
7741
1.63k
{
7742
1.63k
    expr_ty p;
7743
1.63k
    if (!target) {
7744
0
        PyErr_SetString(PyExc_ValueError,
7745
0
                        "field 'target' is required for NamedExpr");
7746
0
        return NULL;
7747
0
    }
7748
1.63k
    if (!value) {
7749
0
        PyErr_SetString(PyExc_ValueError,
7750
0
                        "field 'value' is required for NamedExpr");
7751
0
        return NULL;
7752
0
    }
7753
1.63k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7754
1.63k
    if (!p)
7755
0
        return NULL;
7756
1.63k
    p->kind = NamedExpr_kind;
7757
1.63k
    p->v.NamedExpr.target = target;
7758
1.63k
    p->v.NamedExpr.value = value;
7759
1.63k
    p->lineno = lineno;
7760
1.63k
    p->col_offset = col_offset;
7761
1.63k
    p->end_lineno = end_lineno;
7762
1.63k
    p->end_col_offset = end_col_offset;
7763
1.63k
    return p;
7764
1.63k
}
7765
7766
expr_ty
7767
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7768
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7769
43.0k
{
7770
43.0k
    expr_ty p;
7771
43.0k
    if (!left) {
7772
0
        PyErr_SetString(PyExc_ValueError,
7773
0
                        "field 'left' is required for BinOp");
7774
0
        return NULL;
7775
0
    }
7776
43.0k
    if (!op) {
7777
0
        PyErr_SetString(PyExc_ValueError,
7778
0
                        "field 'op' is required for BinOp");
7779
0
        return NULL;
7780
0
    }
7781
43.0k
    if (!right) {
7782
0
        PyErr_SetString(PyExc_ValueError,
7783
0
                        "field 'right' is required for BinOp");
7784
0
        return NULL;
7785
0
    }
7786
43.0k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7787
43.0k
    if (!p)
7788
0
        return NULL;
7789
43.0k
    p->kind = BinOp_kind;
7790
43.0k
    p->v.BinOp.left = left;
7791
43.0k
    p->v.BinOp.op = op;
7792
43.0k
    p->v.BinOp.right = right;
7793
43.0k
    p->lineno = lineno;
7794
43.0k
    p->col_offset = col_offset;
7795
43.0k
    p->end_lineno = end_lineno;
7796
43.0k
    p->end_col_offset = end_col_offset;
7797
43.0k
    return p;
7798
43.0k
}
7799
7800
expr_ty
7801
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7802
               end_lineno, int end_col_offset, PyArena *arena)
7803
162k
{
7804
162k
    expr_ty p;
7805
162k
    if (!op) {
7806
0
        PyErr_SetString(PyExc_ValueError,
7807
0
                        "field 'op' is required for UnaryOp");
7808
0
        return NULL;
7809
0
    }
7810
162k
    if (!operand) {
7811
0
        PyErr_SetString(PyExc_ValueError,
7812
0
                        "field 'operand' is required for UnaryOp");
7813
0
        return NULL;
7814
0
    }
7815
162k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7816
162k
    if (!p)
7817
0
        return NULL;
7818
162k
    p->kind = UnaryOp_kind;
7819
162k
    p->v.UnaryOp.op = op;
7820
162k
    p->v.UnaryOp.operand = operand;
7821
162k
    p->lineno = lineno;
7822
162k
    p->col_offset = col_offset;
7823
162k
    p->end_lineno = end_lineno;
7824
162k
    p->end_col_offset = end_col_offset;
7825
162k
    return p;
7826
162k
}
7827
7828
expr_ty
7829
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7830
              end_lineno, int end_col_offset, PyArena *arena)
7831
2.86k
{
7832
2.86k
    expr_ty p;
7833
2.86k
    if (!args) {
7834
0
        PyErr_SetString(PyExc_ValueError,
7835
0
                        "field 'args' is required for Lambda");
7836
0
        return NULL;
7837
0
    }
7838
2.86k
    if (!body) {
7839
0
        PyErr_SetString(PyExc_ValueError,
7840
0
                        "field 'body' is required for Lambda");
7841
0
        return NULL;
7842
0
    }
7843
2.86k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7844
2.86k
    if (!p)
7845
0
        return NULL;
7846
2.86k
    p->kind = Lambda_kind;
7847
2.86k
    p->v.Lambda.args = args;
7848
2.86k
    p->v.Lambda.body = body;
7849
2.86k
    p->lineno = lineno;
7850
2.86k
    p->col_offset = col_offset;
7851
2.86k
    p->end_lineno = end_lineno;
7852
2.86k
    p->end_col_offset = end_col_offset;
7853
2.86k
    return p;
7854
2.86k
}
7855
7856
expr_ty
7857
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7858
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7859
989
{
7860
989
    expr_ty p;
7861
989
    if (!test) {
7862
0
        PyErr_SetString(PyExc_ValueError,
7863
0
                        "field 'test' is required for IfExp");
7864
0
        return NULL;
7865
0
    }
7866
989
    if (!body) {
7867
0
        PyErr_SetString(PyExc_ValueError,
7868
0
                        "field 'body' is required for IfExp");
7869
0
        return NULL;
7870
0
    }
7871
989
    if (!orelse) {
7872
0
        PyErr_SetString(PyExc_ValueError,
7873
0
                        "field 'orelse' is required for IfExp");
7874
0
        return NULL;
7875
0
    }
7876
989
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7877
989
    if (!p)
7878
0
        return NULL;
7879
989
    p->kind = IfExp_kind;
7880
989
    p->v.IfExp.test = test;
7881
989
    p->v.IfExp.body = body;
7882
989
    p->v.IfExp.orelse = orelse;
7883
989
    p->lineno = lineno;
7884
989
    p->col_offset = col_offset;
7885
989
    p->end_lineno = end_lineno;
7886
989
    p->end_col_offset = end_col_offset;
7887
989
    return p;
7888
989
}
7889
7890
expr_ty
7891
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7892
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7893
5.24k
{
7894
5.24k
    expr_ty p;
7895
5.24k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7896
5.24k
    if (!p)
7897
0
        return NULL;
7898
5.24k
    p->kind = Dict_kind;
7899
5.24k
    p->v.Dict.keys = keys;
7900
5.24k
    p->v.Dict.values = values;
7901
5.24k
    p->lineno = lineno;
7902
5.24k
    p->col_offset = col_offset;
7903
5.24k
    p->end_lineno = end_lineno;
7904
5.24k
    p->end_col_offset = end_col_offset;
7905
5.24k
    return p;
7906
5.24k
}
7907
7908
expr_ty
7909
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7910
           int end_col_offset, PyArena *arena)
7911
1.05k
{
7912
1.05k
    expr_ty p;
7913
1.05k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7914
1.05k
    if (!p)
7915
0
        return NULL;
7916
1.05k
    p->kind = Set_kind;
7917
1.05k
    p->v.Set.elts = elts;
7918
1.05k
    p->lineno = lineno;
7919
1.05k
    p->col_offset = col_offset;
7920
1.05k
    p->end_lineno = end_lineno;
7921
1.05k
    p->end_col_offset = end_col_offset;
7922
1.05k
    return p;
7923
1.05k
}
7924
7925
expr_ty
7926
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7927
                int col_offset, int end_lineno, int end_col_offset, PyArena
7928
                *arena)
7929
936
{
7930
936
    expr_ty p;
7931
936
    if (!elt) {
7932
0
        PyErr_SetString(PyExc_ValueError,
7933
0
                        "field 'elt' is required for ListComp");
7934
0
        return NULL;
7935
0
    }
7936
936
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7937
936
    if (!p)
7938
0
        return NULL;
7939
936
    p->kind = ListComp_kind;
7940
936
    p->v.ListComp.elt = elt;
7941
936
    p->v.ListComp.generators = generators;
7942
936
    p->lineno = lineno;
7943
936
    p->col_offset = col_offset;
7944
936
    p->end_lineno = end_lineno;
7945
936
    p->end_col_offset = end_col_offset;
7946
936
    return p;
7947
936
}
7948
7949
expr_ty
7950
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7951
               int col_offset, int end_lineno, int end_col_offset, PyArena
7952
               *arena)
7953
898
{
7954
898
    expr_ty p;
7955
898
    if (!elt) {
7956
0
        PyErr_SetString(PyExc_ValueError,
7957
0
                        "field 'elt' is required for SetComp");
7958
0
        return NULL;
7959
0
    }
7960
898
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7961
898
    if (!p)
7962
0
        return NULL;
7963
898
    p->kind = SetComp_kind;
7964
898
    p->v.SetComp.elt = elt;
7965
898
    p->v.SetComp.generators = generators;
7966
898
    p->lineno = lineno;
7967
898
    p->col_offset = col_offset;
7968
898
    p->end_lineno = end_lineno;
7969
898
    p->end_col_offset = end_col_offset;
7970
898
    return p;
7971
898
}
7972
7973
expr_ty
7974
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
7975
                generators, int lineno, int col_offset, int end_lineno, int
7976
                end_col_offset, PyArena *arena)
7977
1.10k
{
7978
1.10k
    expr_ty p;
7979
1.10k
    if (!key) {
7980
0
        PyErr_SetString(PyExc_ValueError,
7981
0
                        "field 'key' is required for DictComp");
7982
0
        return NULL;
7983
0
    }
7984
1.10k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7985
1.10k
    if (!p)
7986
0
        return NULL;
7987
1.10k
    p->kind = DictComp_kind;
7988
1.10k
    p->v.DictComp.key = key;
7989
1.10k
    p->v.DictComp.value = value;
7990
1.10k
    p->v.DictComp.generators = generators;
7991
1.10k
    p->lineno = lineno;
7992
1.10k
    p->col_offset = col_offset;
7993
1.10k
    p->end_lineno = end_lineno;
7994
1.10k
    p->end_col_offset = end_col_offset;
7995
1.10k
    return p;
7996
1.10k
}
7997
7998
expr_ty
7999
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8000
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8001
                    PyArena *arena)
8002
4.41k
{
8003
4.41k
    expr_ty p;
8004
4.41k
    if (!elt) {
8005
0
        PyErr_SetString(PyExc_ValueError,
8006
0
                        "field 'elt' is required for GeneratorExp");
8007
0
        return NULL;
8008
0
    }
8009
4.41k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8010
4.41k
    if (!p)
8011
0
        return NULL;
8012
4.41k
    p->kind = GeneratorExp_kind;
8013
4.41k
    p->v.GeneratorExp.elt = elt;
8014
4.41k
    p->v.GeneratorExp.generators = generators;
8015
4.41k
    p->lineno = lineno;
8016
4.41k
    p->col_offset = col_offset;
8017
4.41k
    p->end_lineno = end_lineno;
8018
4.41k
    p->end_col_offset = end_col_offset;
8019
4.41k
    return p;
8020
4.41k
}
8021
8022
expr_ty
8023
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8024
             end_col_offset, PyArena *arena)
8025
362
{
8026
362
    expr_ty p;
8027
362
    if (!value) {
8028
0
        PyErr_SetString(PyExc_ValueError,
8029
0
                        "field 'value' is required for Await");
8030
0
        return NULL;
8031
0
    }
8032
362
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8033
362
    if (!p)
8034
0
        return NULL;
8035
362
    p->kind = Await_kind;
8036
362
    p->v.Await.value = value;
8037
362
    p->lineno = lineno;
8038
362
    p->col_offset = col_offset;
8039
362
    p->end_lineno = end_lineno;
8040
362
    p->end_col_offset = end_col_offset;
8041
362
    return p;
8042
362
}
8043
8044
expr_ty
8045
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8046
             end_col_offset, PyArena *arena)
8047
2.51k
{
8048
2.51k
    expr_ty p;
8049
2.51k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8050
2.51k
    if (!p)
8051
0
        return NULL;
8052
2.51k
    p->kind = Yield_kind;
8053
2.51k
    p->v.Yield.value = value;
8054
2.51k
    p->lineno = lineno;
8055
2.51k
    p->col_offset = col_offset;
8056
2.51k
    p->end_lineno = end_lineno;
8057
2.51k
    p->end_col_offset = end_col_offset;
8058
2.51k
    return p;
8059
2.51k
}
8060
8061
expr_ty
8062
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8063
                 end_col_offset, PyArena *arena)
8064
269
{
8065
269
    expr_ty p;
8066
269
    if (!value) {
8067
0
        PyErr_SetString(PyExc_ValueError,
8068
0
                        "field 'value' is required for YieldFrom");
8069
0
        return NULL;
8070
0
    }
8071
269
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8072
269
    if (!p)
8073
0
        return NULL;
8074
269
    p->kind = YieldFrom_kind;
8075
269
    p->v.YieldFrom.value = value;
8076
269
    p->lineno = lineno;
8077
269
    p->col_offset = col_offset;
8078
269
    p->end_lineno = end_lineno;
8079
269
    p->end_col_offset = end_col_offset;
8080
269
    return p;
8081
269
}
8082
8083
expr_ty
8084
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8085
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8086
               PyArena *arena)
8087
5.76k
{
8088
5.76k
    expr_ty p;
8089
5.76k
    if (!left) {
8090
0
        PyErr_SetString(PyExc_ValueError,
8091
0
                        "field 'left' is required for Compare");
8092
0
        return NULL;
8093
0
    }
8094
5.76k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8095
5.76k
    if (!p)
8096
0
        return NULL;
8097
5.76k
    p->kind = Compare_kind;
8098
5.76k
    p->v.Compare.left = left;
8099
5.76k
    p->v.Compare.ops = ops;
8100
5.76k
    p->v.Compare.comparators = comparators;
8101
5.76k
    p->lineno = lineno;
8102
5.76k
    p->col_offset = col_offset;
8103
5.76k
    p->end_lineno = end_lineno;
8104
5.76k
    p->end_col_offset = end_col_offset;
8105
5.76k
    return p;
8106
5.76k
}
8107
8108
expr_ty
8109
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8110
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8111
            PyArena *arena)
8112
59.4k
{
8113
59.4k
    expr_ty p;
8114
59.4k
    if (!func) {
8115
0
        PyErr_SetString(PyExc_ValueError,
8116
0
                        "field 'func' is required for Call");
8117
0
        return NULL;
8118
0
    }
8119
59.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8120
59.4k
    if (!p)
8121
0
        return NULL;
8122
59.4k
    p->kind = Call_kind;
8123
59.4k
    p->v.Call.func = func;
8124
59.4k
    p->v.Call.args = args;
8125
59.4k
    p->v.Call.keywords = keywords;
8126
59.4k
    p->lineno = lineno;
8127
59.4k
    p->col_offset = col_offset;
8128
59.4k
    p->end_lineno = end_lineno;
8129
59.4k
    p->end_col_offset = end_col_offset;
8130
59.4k
    return p;
8131
59.4k
}
8132
8133
expr_ty
8134
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8135
                      lineno, int col_offset, int end_lineno, int
8136
                      end_col_offset, PyArena *arena)
8137
22.4k
{
8138
22.4k
    expr_ty p;
8139
22.4k
    if (!value) {
8140
0
        PyErr_SetString(PyExc_ValueError,
8141
0
                        "field 'value' is required for FormattedValue");
8142
0
        return NULL;
8143
0
    }
8144
22.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8145
22.4k
    if (!p)
8146
0
        return NULL;
8147
22.4k
    p->kind = FormattedValue_kind;
8148
22.4k
    p->v.FormattedValue.value = value;
8149
22.4k
    p->v.FormattedValue.conversion = conversion;
8150
22.4k
    p->v.FormattedValue.format_spec = format_spec;
8151
22.4k
    p->lineno = lineno;
8152
22.4k
    p->col_offset = col_offset;
8153
22.4k
    p->end_lineno = end_lineno;
8154
22.4k
    p->end_col_offset = end_col_offset;
8155
22.4k
    return p;
8156
22.4k
}
8157
8158
expr_ty
8159
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8160
                     format_spec, int lineno, int col_offset, int end_lineno,
8161
                     int end_col_offset, PyArena *arena)
8162
6.11k
{
8163
6.11k
    expr_ty p;
8164
6.11k
    if (!value) {
8165
0
        PyErr_SetString(PyExc_ValueError,
8166
0
                        "field 'value' is required for Interpolation");
8167
0
        return NULL;
8168
0
    }
8169
6.11k
    if (!str) {
8170
0
        PyErr_SetString(PyExc_ValueError,
8171
0
                        "field 'str' is required for Interpolation");
8172
0
        return NULL;
8173
0
    }
8174
6.11k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8175
6.11k
    if (!p)
8176
0
        return NULL;
8177
6.11k
    p->kind = Interpolation_kind;
8178
6.11k
    p->v.Interpolation.value = value;
8179
6.11k
    p->v.Interpolation.str = str;
8180
6.11k
    p->v.Interpolation.conversion = conversion;
8181
6.11k
    p->v.Interpolation.format_spec = format_spec;
8182
6.11k
    p->lineno = lineno;
8183
6.11k
    p->col_offset = col_offset;
8184
6.11k
    p->end_lineno = end_lineno;
8185
6.11k
    p->end_col_offset = end_col_offset;
8186
6.11k
    return p;
8187
6.11k
}
8188
8189
expr_ty
8190
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8191
                 end_lineno, int end_col_offset, PyArena *arena)
8192
38.1k
{
8193
38.1k
    expr_ty p;
8194
38.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8195
38.1k
    if (!p)
8196
0
        return NULL;
8197
38.1k
    p->kind = JoinedStr_kind;
8198
38.1k
    p->v.JoinedStr.values = values;
8199
38.1k
    p->lineno = lineno;
8200
38.1k
    p->col_offset = col_offset;
8201
38.1k
    p->end_lineno = end_lineno;
8202
38.1k
    p->end_col_offset = end_col_offset;
8203
38.1k
    return p;
8204
38.1k
}
8205
8206
expr_ty
8207
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8208
                   end_lineno, int end_col_offset, PyArena *arena)
8209
8.39k
{
8210
8.39k
    expr_ty p;
8211
8.39k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8212
8.39k
    if (!p)
8213
0
        return NULL;
8214
8.39k
    p->kind = TemplateStr_kind;
8215
8.39k
    p->v.TemplateStr.values = values;
8216
8.39k
    p->lineno = lineno;
8217
8.39k
    p->col_offset = col_offset;
8218
8.39k
    p->end_lineno = end_lineno;
8219
8.39k
    p->end_col_offset = end_col_offset;
8220
8.39k
    return p;
8221
8.39k
}
8222
8223
expr_ty
8224
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8225
                end_lineno, int end_col_offset, PyArena *arena)
8226
374k
{
8227
374k
    expr_ty p;
8228
374k
    if (!value) {
8229
4
        PyErr_SetString(PyExc_ValueError,
8230
4
                        "field 'value' is required for Constant");
8231
4
        return NULL;
8232
4
    }
8233
374k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8234
374k
    if (!p)
8235
0
        return NULL;
8236
374k
    p->kind = Constant_kind;
8237
374k
    p->v.Constant.value = value;
8238
374k
    p->v.Constant.kind = kind;
8239
374k
    p->lineno = lineno;
8240
374k
    p->col_offset = col_offset;
8241
374k
    p->end_lineno = end_lineno;
8242
374k
    p->end_col_offset = end_col_offset;
8243
374k
    return p;
8244
374k
}
8245
8246
expr_ty
8247
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8248
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8249
                 PyArena *arena)
8250
33.9k
{
8251
33.9k
    expr_ty p;
8252
33.9k
    if (!value) {
8253
0
        PyErr_SetString(PyExc_ValueError,
8254
0
                        "field 'value' is required for Attribute");
8255
0
        return NULL;
8256
0
    }
8257
33.9k
    if (!attr) {
8258
0
        PyErr_SetString(PyExc_ValueError,
8259
0
                        "field 'attr' is required for Attribute");
8260
0
        return NULL;
8261
0
    }
8262
33.9k
    if (!ctx) {
8263
0
        PyErr_SetString(PyExc_ValueError,
8264
0
                        "field 'ctx' is required for Attribute");
8265
0
        return NULL;
8266
0
    }
8267
33.9k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8268
33.9k
    if (!p)
8269
0
        return NULL;
8270
33.9k
    p->kind = Attribute_kind;
8271
33.9k
    p->v.Attribute.value = value;
8272
33.9k
    p->v.Attribute.attr = attr;
8273
33.9k
    p->v.Attribute.ctx = ctx;
8274
33.9k
    p->lineno = lineno;
8275
33.9k
    p->col_offset = col_offset;
8276
33.9k
    p->end_lineno = end_lineno;
8277
33.9k
    p->end_col_offset = end_col_offset;
8278
33.9k
    return p;
8279
33.9k
}
8280
8281
expr_ty
8282
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8283
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8284
                 *arena)
8285
5.05k
{
8286
5.05k
    expr_ty p;
8287
5.05k
    if (!value) {
8288
0
        PyErr_SetString(PyExc_ValueError,
8289
0
                        "field 'value' is required for Subscript");
8290
0
        return NULL;
8291
0
    }
8292
5.05k
    if (!slice) {
8293
0
        PyErr_SetString(PyExc_ValueError,
8294
0
                        "field 'slice' is required for Subscript");
8295
0
        return NULL;
8296
0
    }
8297
5.05k
    if (!ctx) {
8298
0
        PyErr_SetString(PyExc_ValueError,
8299
0
                        "field 'ctx' is required for Subscript");
8300
0
        return NULL;
8301
0
    }
8302
5.05k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8303
5.05k
    if (!p)
8304
0
        return NULL;
8305
5.05k
    p->kind = Subscript_kind;
8306
5.05k
    p->v.Subscript.value = value;
8307
5.05k
    p->v.Subscript.slice = slice;
8308
5.05k
    p->v.Subscript.ctx = ctx;
8309
5.05k
    p->lineno = lineno;
8310
5.05k
    p->col_offset = col_offset;
8311
5.05k
    p->end_lineno = end_lineno;
8312
5.05k
    p->end_col_offset = end_col_offset;
8313
5.05k
    return p;
8314
5.05k
}
8315
8316
expr_ty
8317
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8318
               int end_lineno, int end_col_offset, PyArena *arena)
8319
19.4k
{
8320
19.4k
    expr_ty p;
8321
19.4k
    if (!value) {
8322
0
        PyErr_SetString(PyExc_ValueError,
8323
0
                        "field 'value' is required for Starred");
8324
0
        return NULL;
8325
0
    }
8326
19.4k
    if (!ctx) {
8327
0
        PyErr_SetString(PyExc_ValueError,
8328
0
                        "field 'ctx' is required for Starred");
8329
0
        return NULL;
8330
0
    }
8331
19.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8332
19.4k
    if (!p)
8333
0
        return NULL;
8334
19.4k
    p->kind = Starred_kind;
8335
19.4k
    p->v.Starred.value = value;
8336
19.4k
    p->v.Starred.ctx = ctx;
8337
19.4k
    p->lineno = lineno;
8338
19.4k
    p->col_offset = col_offset;
8339
19.4k
    p->end_lineno = end_lineno;
8340
19.4k
    p->end_col_offset = end_col_offset;
8341
19.4k
    return p;
8342
19.4k
}
8343
8344
expr_ty
8345
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8346
            end_lineno, int end_col_offset, PyArena *arena)
8347
11.9M
{
8348
11.9M
    expr_ty p;
8349
11.9M
    if (!id) {
8350
0
        PyErr_SetString(PyExc_ValueError,
8351
0
                        "field 'id' is required for Name");
8352
0
        return NULL;
8353
0
    }
8354
11.9M
    if (!ctx) {
8355
0
        PyErr_SetString(PyExc_ValueError,
8356
0
                        "field 'ctx' is required for Name");
8357
0
        return NULL;
8358
0
    }
8359
11.9M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8360
11.9M
    if (!p)
8361
0
        return NULL;
8362
11.9M
    p->kind = Name_kind;
8363
11.9M
    p->v.Name.id = id;
8364
11.9M
    p->v.Name.ctx = ctx;
8365
11.9M
    p->lineno = lineno;
8366
11.9M
    p->col_offset = col_offset;
8367
11.9M
    p->end_lineno = end_lineno;
8368
11.9M
    p->end_col_offset = end_col_offset;
8369
11.9M
    return p;
8370
11.9M
}
8371
8372
expr_ty
8373
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8374
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8375
18.7k
{
8376
18.7k
    expr_ty p;
8377
18.7k
    if (!ctx) {
8378
0
        PyErr_SetString(PyExc_ValueError,
8379
0
                        "field 'ctx' is required for List");
8380
0
        return NULL;
8381
0
    }
8382
18.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8383
18.7k
    if (!p)
8384
0
        return NULL;
8385
18.7k
    p->kind = List_kind;
8386
18.7k
    p->v.List.elts = elts;
8387
18.7k
    p->v.List.ctx = ctx;
8388
18.7k
    p->lineno = lineno;
8389
18.7k
    p->col_offset = col_offset;
8390
18.7k
    p->end_lineno = end_lineno;
8391
18.7k
    p->end_col_offset = end_col_offset;
8392
18.7k
    return p;
8393
18.7k
}
8394
8395
expr_ty
8396
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8397
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8398
88.5k
{
8399
88.5k
    expr_ty p;
8400
88.5k
    if (!ctx) {
8401
0
        PyErr_SetString(PyExc_ValueError,
8402
0
                        "field 'ctx' is required for Tuple");
8403
0
        return NULL;
8404
0
    }
8405
88.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8406
88.5k
    if (!p)
8407
0
        return NULL;
8408
88.5k
    p->kind = Tuple_kind;
8409
88.5k
    p->v.Tuple.elts = elts;
8410
88.5k
    p->v.Tuple.ctx = ctx;
8411
88.5k
    p->lineno = lineno;
8412
88.5k
    p->col_offset = col_offset;
8413
88.5k
    p->end_lineno = end_lineno;
8414
88.5k
    p->end_col_offset = end_col_offset;
8415
88.5k
    return p;
8416
88.5k
}
8417
8418
expr_ty
8419
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8420
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8421
13.9k
{
8422
13.9k
    expr_ty p;
8423
13.9k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8424
13.9k
    if (!p)
8425
0
        return NULL;
8426
13.9k
    p->kind = Slice_kind;
8427
13.9k
    p->v.Slice.lower = lower;
8428
13.9k
    p->v.Slice.upper = upper;
8429
13.9k
    p->v.Slice.step = step;
8430
13.9k
    p->lineno = lineno;
8431
13.9k
    p->col_offset = col_offset;
8432
13.9k
    p->end_lineno = end_lineno;
8433
13.9k
    p->end_col_offset = end_col_offset;
8434
13.9k
    return p;
8435
13.9k
}
8436
8437
comprehension_ty
8438
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8439
                     is_async, PyArena *arena)
8440
9.86k
{
8441
9.86k
    comprehension_ty p;
8442
9.86k
    if (!target) {
8443
0
        PyErr_SetString(PyExc_ValueError,
8444
0
                        "field 'target' is required for comprehension");
8445
0
        return NULL;
8446
0
    }
8447
9.86k
    if (!iter) {
8448
0
        PyErr_SetString(PyExc_ValueError,
8449
0
                        "field 'iter' is required for comprehension");
8450
0
        return NULL;
8451
0
    }
8452
9.86k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8453
9.86k
    if (!p)
8454
0
        return NULL;
8455
9.86k
    p->target = target;
8456
9.86k
    p->iter = iter;
8457
9.86k
    p->ifs = ifs;
8458
9.86k
    p->is_async = is_async;
8459
9.86k
    return p;
8460
9.86k
}
8461
8462
excepthandler_ty
8463
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8464
                     lineno, int col_offset, int end_lineno, int
8465
                     end_col_offset, PyArena *arena)
8466
7.33k
{
8467
7.33k
    excepthandler_ty p;
8468
7.33k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8469
7.33k
    if (!p)
8470
0
        return NULL;
8471
7.33k
    p->kind = ExceptHandler_kind;
8472
7.33k
    p->v.ExceptHandler.type = type;
8473
7.33k
    p->v.ExceptHandler.name = name;
8474
7.33k
    p->v.ExceptHandler.body = body;
8475
7.33k
    p->lineno = lineno;
8476
7.33k
    p->col_offset = col_offset;
8477
7.33k
    p->end_lineno = end_lineno;
8478
7.33k
    p->end_col_offset = end_col_offset;
8479
7.33k
    return p;
8480
7.33k
}
8481
8482
arguments_ty
8483
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8484
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8485
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8486
                 *arena)
8487
331k
{
8488
331k
    arguments_ty p;
8489
331k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8490
331k
    if (!p)
8491
0
        return NULL;
8492
331k
    p->posonlyargs = posonlyargs;
8493
331k
    p->args = args;
8494
331k
    p->vararg = vararg;
8495
331k
    p->kwonlyargs = kwonlyargs;
8496
331k
    p->kw_defaults = kw_defaults;
8497
331k
    p->kwarg = kwarg;
8498
331k
    p->defaults = defaults;
8499
331k
    return p;
8500
331k
}
8501
8502
arg_ty
8503
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8504
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8505
10.2M
{
8506
10.2M
    arg_ty p;
8507
10.2M
    if (!arg) {
8508
0
        PyErr_SetString(PyExc_ValueError,
8509
0
                        "field 'arg' is required for arg");
8510
0
        return NULL;
8511
0
    }
8512
10.2M
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8513
10.2M
    if (!p)
8514
0
        return NULL;
8515
10.2M
    p->arg = arg;
8516
10.2M
    p->annotation = annotation;
8517
10.2M
    p->type_comment = type_comment;
8518
10.2M
    p->lineno = lineno;
8519
10.2M
    p->col_offset = col_offset;
8520
10.2M
    p->end_lineno = end_lineno;
8521
10.2M
    p->end_col_offset = end_col_offset;
8522
10.2M
    return p;
8523
10.2M
}
8524
8525
keyword_ty
8526
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8527
               end_lineno, int end_col_offset, PyArena *arena)
8528
33.4k
{
8529
33.4k
    keyword_ty p;
8530
33.4k
    if (!value) {
8531
0
        PyErr_SetString(PyExc_ValueError,
8532
0
                        "field 'value' is required for keyword");
8533
0
        return NULL;
8534
0
    }
8535
33.4k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8536
33.4k
    if (!p)
8537
0
        return NULL;
8538
33.4k
    p->arg = arg;
8539
33.4k
    p->value = value;
8540
33.4k
    p->lineno = lineno;
8541
33.4k
    p->col_offset = col_offset;
8542
33.4k
    p->end_lineno = end_lineno;
8543
33.4k
    p->end_col_offset = end_col_offset;
8544
33.4k
    return p;
8545
33.4k
}
8546
8547
alias_ty
8548
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8549
             int end_lineno, int end_col_offset, PyArena *arena)
8550
12.2k
{
8551
12.2k
    alias_ty p;
8552
12.2k
    if (!name) {
8553
0
        PyErr_SetString(PyExc_ValueError,
8554
0
                        "field 'name' is required for alias");
8555
0
        return NULL;
8556
0
    }
8557
12.2k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8558
12.2k
    if (!p)
8559
0
        return NULL;
8560
12.2k
    p->name = name;
8561
12.2k
    p->asname = asname;
8562
12.2k
    p->lineno = lineno;
8563
12.2k
    p->col_offset = col_offset;
8564
12.2k
    p->end_lineno = end_lineno;
8565
12.2k
    p->end_col_offset = end_col_offset;
8566
12.2k
    return p;
8567
12.2k
}
8568
8569
withitem_ty
8570
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8571
8.36k
{
8572
8.36k
    withitem_ty p;
8573
8.36k
    if (!context_expr) {
8574
0
        PyErr_SetString(PyExc_ValueError,
8575
0
                        "field 'context_expr' is required for withitem");
8576
0
        return NULL;
8577
0
    }
8578
8.36k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8579
8.36k
    if (!p)
8580
0
        return NULL;
8581
8.36k
    p->context_expr = context_expr;
8582
8.36k
    p->optional_vars = optional_vars;
8583
8.36k
    return p;
8584
8.36k
}
8585
8586
match_case_ty
8587
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8588
                  PyArena *arena)
8589
2.91k
{
8590
2.91k
    match_case_ty p;
8591
2.91k
    if (!pattern) {
8592
0
        PyErr_SetString(PyExc_ValueError,
8593
0
                        "field 'pattern' is required for match_case");
8594
0
        return NULL;
8595
0
    }
8596
2.91k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8597
2.91k
    if (!p)
8598
0
        return NULL;
8599
2.91k
    p->pattern = pattern;
8600
2.91k
    p->guard = guard;
8601
2.91k
    p->body = body;
8602
2.91k
    return p;
8603
2.91k
}
8604
8605
pattern_ty
8606
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8607
                  int end_col_offset, PyArena *arena)
8608
6.38k
{
8609
6.38k
    pattern_ty p;
8610
6.38k
    if (!value) {
8611
0
        PyErr_SetString(PyExc_ValueError,
8612
0
                        "field 'value' is required for MatchValue");
8613
0
        return NULL;
8614
0
    }
8615
6.38k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8616
6.38k
    if (!p)
8617
0
        return NULL;
8618
6.38k
    p->kind = MatchValue_kind;
8619
6.38k
    p->v.MatchValue.value = value;
8620
6.38k
    p->lineno = lineno;
8621
6.38k
    p->col_offset = col_offset;
8622
6.38k
    p->end_lineno = end_lineno;
8623
6.38k
    p->end_col_offset = end_col_offset;
8624
6.38k
    return p;
8625
6.38k
}
8626
8627
pattern_ty
8628
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8629
                      end_lineno, int end_col_offset, PyArena *arena)
8630
857
{
8631
857
    pattern_ty p;
8632
857
    if (!value) {
8633
0
        PyErr_SetString(PyExc_ValueError,
8634
0
                        "field 'value' is required for MatchSingleton");
8635
0
        return NULL;
8636
0
    }
8637
857
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8638
857
    if (!p)
8639
0
        return NULL;
8640
857
    p->kind = MatchSingleton_kind;
8641
857
    p->v.MatchSingleton.value = value;
8642
857
    p->lineno = lineno;
8643
857
    p->col_offset = col_offset;
8644
857
    p->end_lineno = end_lineno;
8645
857
    p->end_col_offset = end_col_offset;
8646
857
    return p;
8647
857
}
8648
8649
pattern_ty
8650
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8651
                     int end_lineno, int end_col_offset, PyArena *arena)
8652
3.11k
{
8653
3.11k
    pattern_ty p;
8654
3.11k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8655
3.11k
    if (!p)
8656
0
        return NULL;
8657
3.11k
    p->kind = MatchSequence_kind;
8658
3.11k
    p->v.MatchSequence.patterns = patterns;
8659
3.11k
    p->lineno = lineno;
8660
3.11k
    p->col_offset = col_offset;
8661
3.11k
    p->end_lineno = end_lineno;
8662
3.11k
    p->end_col_offset = end_col_offset;
8663
3.11k
    return p;
8664
3.11k
}
8665
8666
pattern_ty
8667
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8668
                    identifier rest, int lineno, int col_offset, int
8669
                    end_lineno, int end_col_offset, PyArena *arena)
8670
1.16k
{
8671
1.16k
    pattern_ty p;
8672
1.16k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8673
1.16k
    if (!p)
8674
0
        return NULL;
8675
1.16k
    p->kind = MatchMapping_kind;
8676
1.16k
    p->v.MatchMapping.keys = keys;
8677
1.16k
    p->v.MatchMapping.patterns = patterns;
8678
1.16k
    p->v.MatchMapping.rest = rest;
8679
1.16k
    p->lineno = lineno;
8680
1.16k
    p->col_offset = col_offset;
8681
1.16k
    p->end_lineno = end_lineno;
8682
1.16k
    p->end_col_offset = end_col_offset;
8683
1.16k
    return p;
8684
1.16k
}
8685
8686
pattern_ty
8687
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8688
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8689
                  col_offset, int end_lineno, int end_col_offset, PyArena
8690
                  *arena)
8691
2.09k
{
8692
2.09k
    pattern_ty p;
8693
2.09k
    if (!cls) {
8694
0
        PyErr_SetString(PyExc_ValueError,
8695
0
                        "field 'cls' is required for MatchClass");
8696
0
        return NULL;
8697
0
    }
8698
2.09k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8699
2.09k
    if (!p)
8700
0
        return NULL;
8701
2.09k
    p->kind = MatchClass_kind;
8702
2.09k
    p->v.MatchClass.cls = cls;
8703
2.09k
    p->v.MatchClass.patterns = patterns;
8704
2.09k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8705
2.09k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8706
2.09k
    p->lineno = lineno;
8707
2.09k
    p->col_offset = col_offset;
8708
2.09k
    p->end_lineno = end_lineno;
8709
2.09k
    p->end_col_offset = end_col_offset;
8710
2.09k
    return p;
8711
2.09k
}
8712
8713
pattern_ty
8714
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8715
                 int end_col_offset, PyArena *arena)
8716
1.20k
{
8717
1.20k
    pattern_ty p;
8718
1.20k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8719
1.20k
    if (!p)
8720
0
        return NULL;
8721
1.20k
    p->kind = MatchStar_kind;
8722
1.20k
    p->v.MatchStar.name = name;
8723
1.20k
    p->lineno = lineno;
8724
1.20k
    p->col_offset = col_offset;
8725
1.20k
    p->end_lineno = end_lineno;
8726
1.20k
    p->end_col_offset = end_col_offset;
8727
1.20k
    return p;
8728
1.20k
}
8729
8730
pattern_ty
8731
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8732
               int end_lineno, int end_col_offset, PyArena *arena)
8733
21.5k
{
8734
21.5k
    pattern_ty p;
8735
21.5k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8736
21.5k
    if (!p)
8737
0
        return NULL;
8738
21.5k
    p->kind = MatchAs_kind;
8739
21.5k
    p->v.MatchAs.pattern = pattern;
8740
21.5k
    p->v.MatchAs.name = name;
8741
21.5k
    p->lineno = lineno;
8742
21.5k
    p->col_offset = col_offset;
8743
21.5k
    p->end_lineno = end_lineno;
8744
21.5k
    p->end_col_offset = end_col_offset;
8745
21.5k
    return p;
8746
21.5k
}
8747
8748
pattern_ty
8749
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8750
               end_lineno, int end_col_offset, PyArena *arena)
8751
8.31k
{
8752
8.31k
    pattern_ty p;
8753
8.31k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8754
8.31k
    if (!p)
8755
0
        return NULL;
8756
8.31k
    p->kind = MatchOr_kind;
8757
8.31k
    p->v.MatchOr.patterns = patterns;
8758
8.31k
    p->lineno = lineno;
8759
8.31k
    p->col_offset = col_offset;
8760
8.31k
    p->end_lineno = end_lineno;
8761
8.31k
    p->end_col_offset = end_col_offset;
8762
8.31k
    return p;
8763
8.31k
}
8764
8765
type_ignore_ty
8766
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8767
0
{
8768
0
    type_ignore_ty p;
8769
0
    if (!tag) {
8770
0
        PyErr_SetString(PyExc_ValueError,
8771
0
                        "field 'tag' is required for TypeIgnore");
8772
0
        return NULL;
8773
0
    }
8774
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8775
0
    if (!p)
8776
0
        return NULL;
8777
0
    p->kind = TypeIgnore_kind;
8778
0
    p->v.TypeIgnore.lineno = lineno;
8779
0
    p->v.TypeIgnore.tag = tag;
8780
0
    return p;
8781
0
}
8782
8783
type_param_ty
8784
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8785
               lineno, int col_offset, int end_lineno, int end_col_offset,
8786
               PyArena *arena)
8787
7.67k
{
8788
7.67k
    type_param_ty p;
8789
7.67k
    if (!name) {
8790
0
        PyErr_SetString(PyExc_ValueError,
8791
0
                        "field 'name' is required for TypeVar");
8792
0
        return NULL;
8793
0
    }
8794
7.67k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8795
7.67k
    if (!p)
8796
0
        return NULL;
8797
7.67k
    p->kind = TypeVar_kind;
8798
7.67k
    p->v.TypeVar.name = name;
8799
7.67k
    p->v.TypeVar.bound = bound;
8800
7.67k
    p->v.TypeVar.default_value = default_value;
8801
7.67k
    p->lineno = lineno;
8802
7.67k
    p->col_offset = col_offset;
8803
7.67k
    p->end_lineno = end_lineno;
8804
7.67k
    p->end_col_offset = end_col_offset;
8805
7.67k
    return p;
8806
7.67k
}
8807
8808
type_param_ty
8809
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8810
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8811
1.21k
{
8812
1.21k
    type_param_ty p;
8813
1.21k
    if (!name) {
8814
0
        PyErr_SetString(PyExc_ValueError,
8815
0
                        "field 'name' is required for ParamSpec");
8816
0
        return NULL;
8817
0
    }
8818
1.21k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8819
1.21k
    if (!p)
8820
0
        return NULL;
8821
1.21k
    p->kind = ParamSpec_kind;
8822
1.21k
    p->v.ParamSpec.name = name;
8823
1.21k
    p->v.ParamSpec.default_value = default_value;
8824
1.21k
    p->lineno = lineno;
8825
1.21k
    p->col_offset = col_offset;
8826
1.21k
    p->end_lineno = end_lineno;
8827
1.21k
    p->end_col_offset = end_col_offset;
8828
1.21k
    return p;
8829
1.21k
}
8830
8831
type_param_ty
8832
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8833
                    col_offset, int end_lineno, int end_col_offset, PyArena
8834
                    *arena)
8835
2.20k
{
8836
2.20k
    type_param_ty p;
8837
2.20k
    if (!name) {
8838
0
        PyErr_SetString(PyExc_ValueError,
8839
0
                        "field 'name' is required for TypeVarTuple");
8840
0
        return NULL;
8841
0
    }
8842
2.20k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8843
2.20k
    if (!p)
8844
0
        return NULL;
8845
2.20k
    p->kind = TypeVarTuple_kind;
8846
2.20k
    p->v.TypeVarTuple.name = name;
8847
2.20k
    p->v.TypeVarTuple.default_value = default_value;
8848
2.20k
    p->lineno = lineno;
8849
2.20k
    p->col_offset = col_offset;
8850
2.20k
    p->end_lineno = end_lineno;
8851
2.20k
    p->end_col_offset = end_col_offset;
8852
2.20k
    return p;
8853
2.20k
}
8854
8855
8856
PyObject*
8857
ast2obj_mod(struct ast_state *state, void* _o)
8858
6.51k
{
8859
6.51k
    mod_ty o = (mod_ty)_o;
8860
6.51k
    PyObject *result = NULL, *value = NULL;
8861
6.51k
    PyTypeObject *tp;
8862
6.51k
    if (!o) {
8863
0
        Py_RETURN_NONE;
8864
0
    }
8865
6.51k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8866
0
        return NULL;
8867
0
    }
8868
6.51k
    switch (o->kind) {
8869
6.51k
    case Module_kind:
8870
6.51k
        tp = (PyTypeObject *)state->Module_type;
8871
6.51k
        result = PyType_GenericNew(tp, NULL, NULL);
8872
6.51k
        if (!result) goto failed;
8873
6.51k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8874
6.51k
        if (!value) goto failed;
8875
6.51k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8876
0
            goto failed;
8877
6.51k
        Py_DECREF(value);
8878
6.51k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8879
6.51k
                             ast2obj_type_ignore);
8880
6.51k
        if (!value) goto failed;
8881
6.51k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8882
0
            goto failed;
8883
6.51k
        Py_DECREF(value);
8884
6.51k
        break;
8885
0
    case Interactive_kind:
8886
0
        tp = (PyTypeObject *)state->Interactive_type;
8887
0
        result = PyType_GenericNew(tp, NULL, NULL);
8888
0
        if (!result) goto failed;
8889
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8890
0
                             ast2obj_stmt);
8891
0
        if (!value) goto failed;
8892
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8893
0
            goto failed;
8894
0
        Py_DECREF(value);
8895
0
        break;
8896
0
    case Expression_kind:
8897
0
        tp = (PyTypeObject *)state->Expression_type;
8898
0
        result = PyType_GenericNew(tp, NULL, NULL);
8899
0
        if (!result) goto failed;
8900
0
        value = ast2obj_expr(state, o->v.Expression.body);
8901
0
        if (!value) goto failed;
8902
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8903
0
            goto failed;
8904
0
        Py_DECREF(value);
8905
0
        break;
8906
0
    case FunctionType_kind:
8907
0
        tp = (PyTypeObject *)state->FunctionType_type;
8908
0
        result = PyType_GenericNew(tp, NULL, NULL);
8909
0
        if (!result) goto failed;
8910
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8911
0
                             ast2obj_expr);
8912
0
        if (!value) goto failed;
8913
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8914
0
            goto failed;
8915
0
        Py_DECREF(value);
8916
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8917
0
        if (!value) goto failed;
8918
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8919
0
            goto failed;
8920
0
        Py_DECREF(value);
8921
0
        break;
8922
6.51k
    }
8923
6.51k
    Py_LeaveRecursiveCall();
8924
6.51k
    return result;
8925
0
failed:
8926
0
    Py_LeaveRecursiveCall();
8927
0
    Py_XDECREF(value);
8928
0
    Py_XDECREF(result);
8929
0
    return NULL;
8930
6.51k
}
8931
8932
PyObject*
8933
ast2obj_stmt(struct ast_state *state, void* _o)
8934
45.1k
{
8935
45.1k
    stmt_ty o = (stmt_ty)_o;
8936
45.1k
    PyObject *result = NULL, *value = NULL;
8937
45.1k
    PyTypeObject *tp;
8938
45.1k
    if (!o) {
8939
0
        Py_RETURN_NONE;
8940
0
    }
8941
45.1k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8942
0
        return NULL;
8943
0
    }
8944
45.1k
    switch (o->kind) {
8945
1.40k
    case FunctionDef_kind:
8946
1.40k
        tp = (PyTypeObject *)state->FunctionDef_type;
8947
1.40k
        result = PyType_GenericNew(tp, NULL, NULL);
8948
1.40k
        if (!result) goto failed;
8949
1.40k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8950
1.40k
        if (!value) goto failed;
8951
1.40k
        if (PyObject_SetAttr(result, state->name, value) == -1)
8952
0
            goto failed;
8953
1.40k
        Py_DECREF(value);
8954
1.40k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8955
1.40k
        if (!value) goto failed;
8956
1.40k
        if (PyObject_SetAttr(result, state->args, value) == -1)
8957
0
            goto failed;
8958
1.40k
        Py_DECREF(value);
8959
1.40k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8960
1.40k
                             ast2obj_stmt);
8961
1.40k
        if (!value) goto failed;
8962
1.40k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8963
0
            goto failed;
8964
1.40k
        Py_DECREF(value);
8965
1.40k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8966
1.40k
                             ast2obj_expr);
8967
1.40k
        if (!value) goto failed;
8968
1.40k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
8969
0
            goto failed;
8970
1.40k
        Py_DECREF(value);
8971
1.40k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
8972
1.40k
        if (!value) goto failed;
8973
1.40k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8974
0
            goto failed;
8975
1.40k
        Py_DECREF(value);
8976
1.40k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
8977
1.40k
        if (!value) goto failed;
8978
1.40k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
8979
0
            goto failed;
8980
1.40k
        Py_DECREF(value);
8981
1.40k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
8982
1.40k
                             ast2obj_type_param);
8983
1.40k
        if (!value) goto failed;
8984
1.40k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
8985
0
            goto failed;
8986
1.40k
        Py_DECREF(value);
8987
1.40k
        break;
8988
301
    case AsyncFunctionDef_kind:
8989
301
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
8990
301
        result = PyType_GenericNew(tp, NULL, NULL);
8991
301
        if (!result) goto failed;
8992
301
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
8993
301
        if (!value) goto failed;
8994
301
        if (PyObject_SetAttr(result, state->name, value) == -1)
8995
0
            goto failed;
8996
301
        Py_DECREF(value);
8997
301
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
8998
301
        if (!value) goto failed;
8999
301
        if (PyObject_SetAttr(result, state->args, value) == -1)
9000
0
            goto failed;
9001
301
        Py_DECREF(value);
9002
301
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9003
301
                             ast2obj_stmt);
9004
301
        if (!value) goto failed;
9005
301
        if (PyObject_SetAttr(result, state->body, value) == -1)
9006
0
            goto failed;
9007
301
        Py_DECREF(value);
9008
301
        value = ast2obj_list(state,
9009
301
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9010
301
                             ast2obj_expr);
9011
301
        if (!value) goto failed;
9012
301
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9013
0
            goto failed;
9014
301
        Py_DECREF(value);
9015
301
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9016
301
        if (!value) goto failed;
9017
301
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9018
0
            goto failed;
9019
301
        Py_DECREF(value);
9020
301
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9021
301
        if (!value) goto failed;
9022
301
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9023
0
            goto failed;
9024
301
        Py_DECREF(value);
9025
301
        value = ast2obj_list(state,
9026
301
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9027
301
                             ast2obj_type_param);
9028
301
        if (!value) goto failed;
9029
301
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9030
0
            goto failed;
9031
301
        Py_DECREF(value);
9032
301
        break;
9033
495
    case ClassDef_kind:
9034
495
        tp = (PyTypeObject *)state->ClassDef_type;
9035
495
        result = PyType_GenericNew(tp, NULL, NULL);
9036
495
        if (!result) goto failed;
9037
495
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9038
495
        if (!value) goto failed;
9039
495
        if (PyObject_SetAttr(result, state->name, value) == -1)
9040
0
            goto failed;
9041
495
        Py_DECREF(value);
9042
495
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9043
495
                             ast2obj_expr);
9044
495
        if (!value) goto failed;
9045
495
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9046
0
            goto failed;
9047
495
        Py_DECREF(value);
9048
495
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9049
495
                             ast2obj_keyword);
9050
495
        if (!value) goto failed;
9051
495
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9052
0
            goto failed;
9053
495
        Py_DECREF(value);
9054
495
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9055
495
                             ast2obj_stmt);
9056
495
        if (!value) goto failed;
9057
495
        if (PyObject_SetAttr(result, state->body, value) == -1)
9058
0
            goto failed;
9059
495
        Py_DECREF(value);
9060
495
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9061
495
                             ast2obj_expr);
9062
495
        if (!value) goto failed;
9063
495
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9064
0
            goto failed;
9065
495
        Py_DECREF(value);
9066
495
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9067
495
                             ast2obj_type_param);
9068
495
        if (!value) goto failed;
9069
495
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9070
0
            goto failed;
9071
495
        Py_DECREF(value);
9072
495
        break;
9073
308
    case Return_kind:
9074
308
        tp = (PyTypeObject *)state->Return_type;
9075
308
        result = PyType_GenericNew(tp, NULL, NULL);
9076
308
        if (!result) goto failed;
9077
308
        value = ast2obj_expr(state, o->v.Return.value);
9078
308
        if (!value) goto failed;
9079
308
        if (PyObject_SetAttr(result, state->value, value) == -1)
9080
0
            goto failed;
9081
308
        Py_DECREF(value);
9082
308
        break;
9083
230
    case Delete_kind:
9084
230
        tp = (PyTypeObject *)state->Delete_type;
9085
230
        result = PyType_GenericNew(tp, NULL, NULL);
9086
230
        if (!result) goto failed;
9087
230
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9088
230
                             ast2obj_expr);
9089
230
        if (!value) goto failed;
9090
230
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9091
0
            goto failed;
9092
230
        Py_DECREF(value);
9093
230
        break;
9094
628
    case Assign_kind:
9095
628
        tp = (PyTypeObject *)state->Assign_type;
9096
628
        result = PyType_GenericNew(tp, NULL, NULL);
9097
628
        if (!result) goto failed;
9098
628
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9099
628
                             ast2obj_expr);
9100
628
        if (!value) goto failed;
9101
628
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9102
0
            goto failed;
9103
628
        Py_DECREF(value);
9104
628
        value = ast2obj_expr(state, o->v.Assign.value);
9105
628
        if (!value) goto failed;
9106
628
        if (PyObject_SetAttr(result, state->value, value) == -1)
9107
0
            goto failed;
9108
628
        Py_DECREF(value);
9109
628
        value = ast2obj_string(state, o->v.Assign.type_comment);
9110
628
        if (!value) goto failed;
9111
628
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9112
0
            goto failed;
9113
628
        Py_DECREF(value);
9114
628
        break;
9115
79
    case TypeAlias_kind:
9116
79
        tp = (PyTypeObject *)state->TypeAlias_type;
9117
79
        result = PyType_GenericNew(tp, NULL, NULL);
9118
79
        if (!result) goto failed;
9119
79
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9120
79
        if (!value) goto failed;
9121
79
        if (PyObject_SetAttr(result, state->name, value) == -1)
9122
0
            goto failed;
9123
79
        Py_DECREF(value);
9124
79
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9125
79
                             ast2obj_type_param);
9126
79
        if (!value) goto failed;
9127
79
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9128
0
            goto failed;
9129
79
        Py_DECREF(value);
9130
79
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9131
79
        if (!value) goto failed;
9132
79
        if (PyObject_SetAttr(result, state->value, value) == -1)
9133
0
            goto failed;
9134
79
        Py_DECREF(value);
9135
79
        break;
9136
319
    case AugAssign_kind:
9137
319
        tp = (PyTypeObject *)state->AugAssign_type;
9138
319
        result = PyType_GenericNew(tp, NULL, NULL);
9139
319
        if (!result) goto failed;
9140
319
        value = ast2obj_expr(state, o->v.AugAssign.target);
9141
319
        if (!value) goto failed;
9142
319
        if (PyObject_SetAttr(result, state->target, value) == -1)
9143
0
            goto failed;
9144
319
        Py_DECREF(value);
9145
319
        value = ast2obj_operator(state, o->v.AugAssign.op);
9146
319
        if (!value) goto failed;
9147
319
        if (PyObject_SetAttr(result, state->op, value) == -1)
9148
0
            goto failed;
9149
319
        Py_DECREF(value);
9150
319
        value = ast2obj_expr(state, o->v.AugAssign.value);
9151
319
        if (!value) goto failed;
9152
319
        if (PyObject_SetAttr(result, state->value, value) == -1)
9153
0
            goto failed;
9154
319
        Py_DECREF(value);
9155
319
        break;
9156
925
    case AnnAssign_kind:
9157
925
        tp = (PyTypeObject *)state->AnnAssign_type;
9158
925
        result = PyType_GenericNew(tp, NULL, NULL);
9159
925
        if (!result) goto failed;
9160
925
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9161
925
        if (!value) goto failed;
9162
925
        if (PyObject_SetAttr(result, state->target, value) == -1)
9163
0
            goto failed;
9164
925
        Py_DECREF(value);
9165
925
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9166
925
        if (!value) goto failed;
9167
925
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9168
0
            goto failed;
9169
925
        Py_DECREF(value);
9170
925
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9171
925
        if (!value) goto failed;
9172
925
        if (PyObject_SetAttr(result, state->value, value) == -1)
9173
0
            goto failed;
9174
925
        Py_DECREF(value);
9175
925
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9176
925
        if (!value) goto failed;
9177
925
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9178
0
            goto failed;
9179
925
        Py_DECREF(value);
9180
925
        break;
9181
307
    case For_kind:
9182
307
        tp = (PyTypeObject *)state->For_type;
9183
307
        result = PyType_GenericNew(tp, NULL, NULL);
9184
307
        if (!result) goto failed;
9185
307
        value = ast2obj_expr(state, o->v.For.target);
9186
307
        if (!value) goto failed;
9187
307
        if (PyObject_SetAttr(result, state->target, value) == -1)
9188
0
            goto failed;
9189
307
        Py_DECREF(value);
9190
307
        value = ast2obj_expr(state, o->v.For.iter);
9191
307
        if (!value) goto failed;
9192
307
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9193
0
            goto failed;
9194
307
        Py_DECREF(value);
9195
307
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9196
307
        if (!value) goto failed;
9197
307
        if (PyObject_SetAttr(result, state->body, value) == -1)
9198
0
            goto failed;
9199
307
        Py_DECREF(value);
9200
307
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9201
307
        if (!value) goto failed;
9202
307
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9203
0
            goto failed;
9204
307
        Py_DECREF(value);
9205
307
        value = ast2obj_string(state, o->v.For.type_comment);
9206
307
        if (!value) goto failed;
9207
307
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9208
0
            goto failed;
9209
307
        Py_DECREF(value);
9210
307
        break;
9211
145
    case AsyncFor_kind:
9212
145
        tp = (PyTypeObject *)state->AsyncFor_type;
9213
145
        result = PyType_GenericNew(tp, NULL, NULL);
9214
145
        if (!result) goto failed;
9215
145
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9216
145
        if (!value) goto failed;
9217
145
        if (PyObject_SetAttr(result, state->target, value) == -1)
9218
0
            goto failed;
9219
145
        Py_DECREF(value);
9220
145
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9221
145
        if (!value) goto failed;
9222
145
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9223
0
            goto failed;
9224
145
        Py_DECREF(value);
9225
145
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9226
145
                             ast2obj_stmt);
9227
145
        if (!value) goto failed;
9228
145
        if (PyObject_SetAttr(result, state->body, value) == -1)
9229
0
            goto failed;
9230
145
        Py_DECREF(value);
9231
145
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9232
145
                             ast2obj_stmt);
9233
145
        if (!value) goto failed;
9234
145
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9235
0
            goto failed;
9236
145
        Py_DECREF(value);
9237
145
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9238
145
        if (!value) goto failed;
9239
145
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9240
0
            goto failed;
9241
145
        Py_DECREF(value);
9242
145
        break;
9243
210
    case While_kind:
9244
210
        tp = (PyTypeObject *)state->While_type;
9245
210
        result = PyType_GenericNew(tp, NULL, NULL);
9246
210
        if (!result) goto failed;
9247
210
        value = ast2obj_expr(state, o->v.While.test);
9248
210
        if (!value) goto failed;
9249
210
        if (PyObject_SetAttr(result, state->test, value) == -1)
9250
0
            goto failed;
9251
210
        Py_DECREF(value);
9252
210
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9253
210
        if (!value) goto failed;
9254
210
        if (PyObject_SetAttr(result, state->body, value) == -1)
9255
0
            goto failed;
9256
210
        Py_DECREF(value);
9257
210
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9258
210
        if (!value) goto failed;
9259
210
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9260
0
            goto failed;
9261
210
        Py_DECREF(value);
9262
210
        break;
9263
490
    case If_kind:
9264
490
        tp = (PyTypeObject *)state->If_type;
9265
490
        result = PyType_GenericNew(tp, NULL, NULL);
9266
490
        if (!result) goto failed;
9267
490
        value = ast2obj_expr(state, o->v.If.test);
9268
490
        if (!value) goto failed;
9269
490
        if (PyObject_SetAttr(result, state->test, value) == -1)
9270
0
            goto failed;
9271
490
        Py_DECREF(value);
9272
490
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9273
490
        if (!value) goto failed;
9274
490
        if (PyObject_SetAttr(result, state->body, value) == -1)
9275
0
            goto failed;
9276
490
        Py_DECREF(value);
9277
490
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9278
490
        if (!value) goto failed;
9279
490
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9280
0
            goto failed;
9281
490
        Py_DECREF(value);
9282
490
        break;
9283
383
    case With_kind:
9284
383
        tp = (PyTypeObject *)state->With_type;
9285
383
        result = PyType_GenericNew(tp, NULL, NULL);
9286
383
        if (!result) goto failed;
9287
383
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9288
383
                             ast2obj_withitem);
9289
383
        if (!value) goto failed;
9290
383
        if (PyObject_SetAttr(result, state->items, value) == -1)
9291
0
            goto failed;
9292
383
        Py_DECREF(value);
9293
383
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9294
383
        if (!value) goto failed;
9295
383
        if (PyObject_SetAttr(result, state->body, value) == -1)
9296
0
            goto failed;
9297
383
        Py_DECREF(value);
9298
383
        value = ast2obj_string(state, o->v.With.type_comment);
9299
383
        if (!value) goto failed;
9300
383
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9301
0
            goto failed;
9302
383
        Py_DECREF(value);
9303
383
        break;
9304
156
    case AsyncWith_kind:
9305
156
        tp = (PyTypeObject *)state->AsyncWith_type;
9306
156
        result = PyType_GenericNew(tp, NULL, NULL);
9307
156
        if (!result) goto failed;
9308
156
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9309
156
                             ast2obj_withitem);
9310
156
        if (!value) goto failed;
9311
156
        if (PyObject_SetAttr(result, state->items, value) == -1)
9312
0
            goto failed;
9313
156
        Py_DECREF(value);
9314
156
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9315
156
                             ast2obj_stmt);
9316
156
        if (!value) goto failed;
9317
156
        if (PyObject_SetAttr(result, state->body, value) == -1)
9318
0
            goto failed;
9319
156
        Py_DECREF(value);
9320
156
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9321
156
        if (!value) goto failed;
9322
156
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9323
0
            goto failed;
9324
156
        Py_DECREF(value);
9325
156
        break;
9326
233
    case Match_kind:
9327
233
        tp = (PyTypeObject *)state->Match_type;
9328
233
        result = PyType_GenericNew(tp, NULL, NULL);
9329
233
        if (!result) goto failed;
9330
233
        value = ast2obj_expr(state, o->v.Match.subject);
9331
233
        if (!value) goto failed;
9332
233
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9333
0
            goto failed;
9334
233
        Py_DECREF(value);
9335
233
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9336
233
                             ast2obj_match_case);
9337
233
        if (!value) goto failed;
9338
233
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9339
0
            goto failed;
9340
233
        Py_DECREF(value);
9341
233
        break;
9342
470
    case Raise_kind:
9343
470
        tp = (PyTypeObject *)state->Raise_type;
9344
470
        result = PyType_GenericNew(tp, NULL, NULL);
9345
470
        if (!result) goto failed;
9346
470
        value = ast2obj_expr(state, o->v.Raise.exc);
9347
470
        if (!value) goto failed;
9348
470
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9349
0
            goto failed;
9350
470
        Py_DECREF(value);
9351
470
        value = ast2obj_expr(state, o->v.Raise.cause);
9352
470
        if (!value) goto failed;
9353
470
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9354
0
            goto failed;
9355
470
        Py_DECREF(value);
9356
470
        break;
9357
133
    case Try_kind:
9358
133
        tp = (PyTypeObject *)state->Try_type;
9359
133
        result = PyType_GenericNew(tp, NULL, NULL);
9360
133
        if (!result) goto failed;
9361
133
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9362
133
        if (!value) goto failed;
9363
133
        if (PyObject_SetAttr(result, state->body, value) == -1)
9364
0
            goto failed;
9365
133
        Py_DECREF(value);
9366
133
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9367
133
                             ast2obj_excepthandler);
9368
133
        if (!value) goto failed;
9369
133
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9370
0
            goto failed;
9371
133
        Py_DECREF(value);
9372
133
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9373
133
        if (!value) goto failed;
9374
133
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9375
0
            goto failed;
9376
133
        Py_DECREF(value);
9377
133
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9378
133
                             ast2obj_stmt);
9379
133
        if (!value) goto failed;
9380
133
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9381
0
            goto failed;
9382
133
        Py_DECREF(value);
9383
133
        break;
9384
538
    case TryStar_kind:
9385
538
        tp = (PyTypeObject *)state->TryStar_type;
9386
538
        result = PyType_GenericNew(tp, NULL, NULL);
9387
538
        if (!result) goto failed;
9388
538
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9389
538
        if (!value) goto failed;
9390
538
        if (PyObject_SetAttr(result, state->body, value) == -1)
9391
0
            goto failed;
9392
538
        Py_DECREF(value);
9393
538
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9394
538
                             ast2obj_excepthandler);
9395
538
        if (!value) goto failed;
9396
538
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9397
0
            goto failed;
9398
538
        Py_DECREF(value);
9399
538
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9400
538
                             ast2obj_stmt);
9401
538
        if (!value) goto failed;
9402
538
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9403
0
            goto failed;
9404
538
        Py_DECREF(value);
9405
538
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9406
538
                             ast2obj_stmt);
9407
538
        if (!value) goto failed;
9408
538
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9409
0
            goto failed;
9410
538
        Py_DECREF(value);
9411
538
        break;
9412
180
    case Assert_kind:
9413
180
        tp = (PyTypeObject *)state->Assert_type;
9414
180
        result = PyType_GenericNew(tp, NULL, NULL);
9415
180
        if (!result) goto failed;
9416
180
        value = ast2obj_expr(state, o->v.Assert.test);
9417
180
        if (!value) goto failed;
9418
180
        if (PyObject_SetAttr(result, state->test, value) == -1)
9419
0
            goto failed;
9420
180
        Py_DECREF(value);
9421
180
        value = ast2obj_expr(state, o->v.Assert.msg);
9422
180
        if (!value) goto failed;
9423
180
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9424
0
            goto failed;
9425
180
        Py_DECREF(value);
9426
180
        break;
9427
548
    case Import_kind:
9428
548
        tp = (PyTypeObject *)state->Import_type;
9429
548
        result = PyType_GenericNew(tp, NULL, NULL);
9430
548
        if (!result) goto failed;
9431
548
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9432
548
                             ast2obj_alias);
9433
548
        if (!value) goto failed;
9434
548
        if (PyObject_SetAttr(result, state->names, value) == -1)
9435
0
            goto failed;
9436
548
        Py_DECREF(value);
9437
548
        value = ast2obj_int(state, o->v.Import.is_lazy);
9438
548
        if (!value) goto failed;
9439
548
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9440
0
            goto failed;
9441
548
        Py_DECREF(value);
9442
548
        break;
9443
715
    case ImportFrom_kind:
9444
715
        tp = (PyTypeObject *)state->ImportFrom_type;
9445
715
        result = PyType_GenericNew(tp, NULL, NULL);
9446
715
        if (!result) goto failed;
9447
715
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9448
715
        if (!value) goto failed;
9449
715
        if (PyObject_SetAttr(result, state->module, value) == -1)
9450
0
            goto failed;
9451
715
        Py_DECREF(value);
9452
715
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9453
715
                             ast2obj_alias);
9454
715
        if (!value) goto failed;
9455
715
        if (PyObject_SetAttr(result, state->names, value) == -1)
9456
0
            goto failed;
9457
715
        Py_DECREF(value);
9458
715
        value = ast2obj_int(state, o->v.ImportFrom.level);
9459
715
        if (!value) goto failed;
9460
715
        if (PyObject_SetAttr(result, state->level, value) == -1)
9461
0
            goto failed;
9462
715
        Py_DECREF(value);
9463
715
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
9464
715
        if (!value) goto failed;
9465
715
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9466
0
            goto failed;
9467
715
        Py_DECREF(value);
9468
715
        break;
9469
129
    case Global_kind:
9470
129
        tp = (PyTypeObject *)state->Global_type;
9471
129
        result = PyType_GenericNew(tp, NULL, NULL);
9472
129
        if (!result) goto failed;
9473
129
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9474
129
                             ast2obj_identifier);
9475
129
        if (!value) goto failed;
9476
129
        if (PyObject_SetAttr(result, state->names, value) == -1)
9477
0
            goto failed;
9478
129
        Py_DECREF(value);
9479
129
        break;
9480
74
    case Nonlocal_kind:
9481
74
        tp = (PyTypeObject *)state->Nonlocal_type;
9482
74
        result = PyType_GenericNew(tp, NULL, NULL);
9483
74
        if (!result) goto failed;
9484
74
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9485
74
                             ast2obj_identifier);
9486
74
        if (!value) goto failed;
9487
74
        if (PyObject_SetAttr(result, state->names, value) == -1)
9488
0
            goto failed;
9489
74
        Py_DECREF(value);
9490
74
        break;
9491
35.0k
    case Expr_kind:
9492
35.0k
        tp = (PyTypeObject *)state->Expr_type;
9493
35.0k
        result = PyType_GenericNew(tp, NULL, NULL);
9494
35.0k
        if (!result) goto failed;
9495
35.0k
        value = ast2obj_expr(state, o->v.Expr.value);
9496
35.0k
        if (!value) goto failed;
9497
35.0k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9498
0
            goto failed;
9499
35.0k
        Py_DECREF(value);
9500
35.0k
        break;
9501
241
    case Pass_kind:
9502
241
        tp = (PyTypeObject *)state->Pass_type;
9503
241
        result = PyType_GenericNew(tp, NULL, NULL);
9504
241
        if (!result) goto failed;
9505
241
        break;
9506
241
    case Break_kind:
9507
226
        tp = (PyTypeObject *)state->Break_type;
9508
226
        result = PyType_GenericNew(tp, NULL, NULL);
9509
226
        if (!result) goto failed;
9510
226
        break;
9511
245
    case Continue_kind:
9512
245
        tp = (PyTypeObject *)state->Continue_type;
9513
245
        result = PyType_GenericNew(tp, NULL, NULL);
9514
245
        if (!result) goto failed;
9515
245
        break;
9516
45.1k
    }
9517
45.1k
    value = ast2obj_int(state, o->lineno);
9518
45.1k
    if (!value) goto failed;
9519
45.1k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9520
0
        goto failed;
9521
45.1k
    Py_DECREF(value);
9522
45.1k
    value = ast2obj_int(state, o->col_offset);
9523
45.1k
    if (!value) goto failed;
9524
45.1k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9525
0
        goto failed;
9526
45.1k
    Py_DECREF(value);
9527
45.1k
    value = ast2obj_int(state, o->end_lineno);
9528
45.1k
    if (!value) goto failed;
9529
45.1k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9530
0
        goto failed;
9531
45.1k
    Py_DECREF(value);
9532
45.1k
    value = ast2obj_int(state, o->end_col_offset);
9533
45.1k
    if (!value) goto failed;
9534
45.1k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9535
0
        goto failed;
9536
45.1k
    Py_DECREF(value);
9537
45.1k
    Py_LeaveRecursiveCall();
9538
45.1k
    return result;
9539
0
failed:
9540
0
    Py_LeaveRecursiveCall();
9541
0
    Py_XDECREF(value);
9542
0
    Py_XDECREF(result);
9543
0
    return NULL;
9544
45.1k
}
9545
9546
PyObject*
9547
ast2obj_expr(struct ast_state *state, void* _o)
9548
405k
{
9549
405k
    expr_ty o = (expr_ty)_o;
9550
405k
    PyObject *result = NULL, *value = NULL;
9551
405k
    PyTypeObject *tp;
9552
405k
    if (!o) {
9553
51.4k
        Py_RETURN_NONE;
9554
51.4k
    }
9555
354k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9556
0
        return NULL;
9557
0
    }
9558
354k
    switch (o->kind) {
9559
804
    case BoolOp_kind:
9560
804
        tp = (PyTypeObject *)state->BoolOp_type;
9561
804
        result = PyType_GenericNew(tp, NULL, NULL);
9562
804
        if (!result) goto failed;
9563
804
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9564
804
        if (!value) goto failed;
9565
804
        if (PyObject_SetAttr(result, state->op, value) == -1)
9566
0
            goto failed;
9567
804
        Py_DECREF(value);
9568
804
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9569
804
                             ast2obj_expr);
9570
804
        if (!value) goto failed;
9571
804
        if (PyObject_SetAttr(result, state->values, value) == -1)
9572
0
            goto failed;
9573
804
        Py_DECREF(value);
9574
804
        break;
9575
69
    case NamedExpr_kind:
9576
69
        tp = (PyTypeObject *)state->NamedExpr_type;
9577
69
        result = PyType_GenericNew(tp, NULL, NULL);
9578
69
        if (!result) goto failed;
9579
69
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9580
69
        if (!value) goto failed;
9581
69
        if (PyObject_SetAttr(result, state->target, value) == -1)
9582
0
            goto failed;
9583
69
        Py_DECREF(value);
9584
69
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9585
69
        if (!value) goto failed;
9586
69
        if (PyObject_SetAttr(result, state->value, value) == -1)
9587
0
            goto failed;
9588
69
        Py_DECREF(value);
9589
69
        break;
9590
23.5k
    case BinOp_kind:
9591
23.5k
        tp = (PyTypeObject *)state->BinOp_type;
9592
23.5k
        result = PyType_GenericNew(tp, NULL, NULL);
9593
23.5k
        if (!result) goto failed;
9594
23.5k
        value = ast2obj_expr(state, o->v.BinOp.left);
9595
23.5k
        if (!value) goto failed;
9596
23.5k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9597
0
            goto failed;
9598
23.5k
        Py_DECREF(value);
9599
23.5k
        value = ast2obj_operator(state, o->v.BinOp.op);
9600
23.5k
        if (!value) goto failed;
9601
23.5k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9602
0
            goto failed;
9603
23.5k
        Py_DECREF(value);
9604
23.5k
        value = ast2obj_expr(state, o->v.BinOp.right);
9605
23.5k
        if (!value) goto failed;
9606
23.5k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9607
0
            goto failed;
9608
23.5k
        Py_DECREF(value);
9609
23.5k
        break;
9610
144k
    case UnaryOp_kind:
9611
144k
        tp = (PyTypeObject *)state->UnaryOp_type;
9612
144k
        result = PyType_GenericNew(tp, NULL, NULL);
9613
144k
        if (!result) goto failed;
9614
144k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9615
144k
        if (!value) goto failed;
9616
144k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9617
0
            goto failed;
9618
144k
        Py_DECREF(value);
9619
144k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9620
144k
        if (!value) goto failed;
9621
144k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9622
0
            goto failed;
9623
144k
        Py_DECREF(value);
9624
144k
        break;
9625
952
    case Lambda_kind:
9626
952
        tp = (PyTypeObject *)state->Lambda_type;
9627
952
        result = PyType_GenericNew(tp, NULL, NULL);
9628
952
        if (!result) goto failed;
9629
952
        value = ast2obj_arguments(state, o->v.Lambda.args);
9630
952
        if (!value) goto failed;
9631
952
        if (PyObject_SetAttr(result, state->args, value) == -1)
9632
0
            goto failed;
9633
952
        Py_DECREF(value);
9634
952
        value = ast2obj_expr(state, o->v.Lambda.body);
9635
952
        if (!value) goto failed;
9636
952
        if (PyObject_SetAttr(result, state->body, value) == -1)
9637
0
            goto failed;
9638
952
        Py_DECREF(value);
9639
952
        break;
9640
204
    case IfExp_kind:
9641
204
        tp = (PyTypeObject *)state->IfExp_type;
9642
204
        result = PyType_GenericNew(tp, NULL, NULL);
9643
204
        if (!result) goto failed;
9644
204
        value = ast2obj_expr(state, o->v.IfExp.test);
9645
204
        if (!value) goto failed;
9646
204
        if (PyObject_SetAttr(result, state->test, value) == -1)
9647
0
            goto failed;
9648
204
        Py_DECREF(value);
9649
204
        value = ast2obj_expr(state, o->v.IfExp.body);
9650
204
        if (!value) goto failed;
9651
204
        if (PyObject_SetAttr(result, state->body, value) == -1)
9652
0
            goto failed;
9653
204
        Py_DECREF(value);
9654
204
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9655
204
        if (!value) goto failed;
9656
204
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9657
0
            goto failed;
9658
204
        Py_DECREF(value);
9659
204
        break;
9660
1.72k
    case Dict_kind:
9661
1.72k
        tp = (PyTypeObject *)state->Dict_type;
9662
1.72k
        result = PyType_GenericNew(tp, NULL, NULL);
9663
1.72k
        if (!result) goto failed;
9664
1.72k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9665
1.72k
        if (!value) goto failed;
9666
1.72k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9667
0
            goto failed;
9668
1.72k
        Py_DECREF(value);
9669
1.72k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9670
1.72k
        if (!value) goto failed;
9671
1.72k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9672
0
            goto failed;
9673
1.72k
        Py_DECREF(value);
9674
1.72k
        break;
9675
173
    case Set_kind:
9676
173
        tp = (PyTypeObject *)state->Set_type;
9677
173
        result = PyType_GenericNew(tp, NULL, NULL);
9678
173
        if (!result) goto failed;
9679
173
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9680
173
        if (!value) goto failed;
9681
173
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9682
0
            goto failed;
9683
173
        Py_DECREF(value);
9684
173
        break;
9685
320
    case ListComp_kind:
9686
320
        tp = (PyTypeObject *)state->ListComp_type;
9687
320
        result = PyType_GenericNew(tp, NULL, NULL);
9688
320
        if (!result) goto failed;
9689
320
        value = ast2obj_expr(state, o->v.ListComp.elt);
9690
320
        if (!value) goto failed;
9691
320
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9692
0
            goto failed;
9693
320
        Py_DECREF(value);
9694
320
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9695
320
                             ast2obj_comprehension);
9696
320
        if (!value) goto failed;
9697
320
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9698
0
            goto failed;
9699
320
        Py_DECREF(value);
9700
320
        break;
9701
328
    case SetComp_kind:
9702
328
        tp = (PyTypeObject *)state->SetComp_type;
9703
328
        result = PyType_GenericNew(tp, NULL, NULL);
9704
328
        if (!result) goto failed;
9705
328
        value = ast2obj_expr(state, o->v.SetComp.elt);
9706
328
        if (!value) goto failed;
9707
328
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9708
0
            goto failed;
9709
328
        Py_DECREF(value);
9710
328
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9711
328
                             ast2obj_comprehension);
9712
328
        if (!value) goto failed;
9713
328
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9714
0
            goto failed;
9715
328
        Py_DECREF(value);
9716
328
        break;
9717
333
    case DictComp_kind:
9718
333
        tp = (PyTypeObject *)state->DictComp_type;
9719
333
        result = PyType_GenericNew(tp, NULL, NULL);
9720
333
        if (!result) goto failed;
9721
333
        value = ast2obj_expr(state, o->v.DictComp.key);
9722
333
        if (!value) goto failed;
9723
333
        if (PyObject_SetAttr(result, state->key, value) == -1)
9724
0
            goto failed;
9725
333
        Py_DECREF(value);
9726
333
        value = ast2obj_expr(state, o->v.DictComp.value);
9727
333
        if (!value) goto failed;
9728
333
        if (PyObject_SetAttr(result, state->value, value) == -1)
9729
0
            goto failed;
9730
333
        Py_DECREF(value);
9731
333
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9732
333
                             ast2obj_comprehension);
9733
333
        if (!value) goto failed;
9734
333
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9735
0
            goto failed;
9736
333
        Py_DECREF(value);
9737
333
        break;
9738
428
    case GeneratorExp_kind:
9739
428
        tp = (PyTypeObject *)state->GeneratorExp_type;
9740
428
        result = PyType_GenericNew(tp, NULL, NULL);
9741
428
        if (!result) goto failed;
9742
428
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9743
428
        if (!value) goto failed;
9744
428
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9745
0
            goto failed;
9746
428
        Py_DECREF(value);
9747
428
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9748
428
                             ast2obj_comprehension);
9749
428
        if (!value) goto failed;
9750
428
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9751
0
            goto failed;
9752
428
        Py_DECREF(value);
9753
428
        break;
9754
70
    case Await_kind:
9755
70
        tp = (PyTypeObject *)state->Await_type;
9756
70
        result = PyType_GenericNew(tp, NULL, NULL);
9757
70
        if (!result) goto failed;
9758
70
        value = ast2obj_expr(state, o->v.Await.value);
9759
70
        if (!value) goto failed;
9760
70
        if (PyObject_SetAttr(result, state->value, value) == -1)
9761
0
            goto failed;
9762
70
        Py_DECREF(value);
9763
70
        break;
9764
707
    case Yield_kind:
9765
707
        tp = (PyTypeObject *)state->Yield_type;
9766
707
        result = PyType_GenericNew(tp, NULL, NULL);
9767
707
        if (!result) goto failed;
9768
707
        value = ast2obj_expr(state, o->v.Yield.value);
9769
707
        if (!value) goto failed;
9770
707
        if (PyObject_SetAttr(result, state->value, value) == -1)
9771
0
            goto failed;
9772
707
        Py_DECREF(value);
9773
707
        break;
9774
70
    case YieldFrom_kind:
9775
70
        tp = (PyTypeObject *)state->YieldFrom_type;
9776
70
        result = PyType_GenericNew(tp, NULL, NULL);
9777
70
        if (!result) goto failed;
9778
70
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9779
70
        if (!value) goto failed;
9780
70
        if (PyObject_SetAttr(result, state->value, value) == -1)
9781
0
            goto failed;
9782
70
        Py_DECREF(value);
9783
70
        break;
9784
1.46k
    case Compare_kind:
9785
1.46k
        tp = (PyTypeObject *)state->Compare_type;
9786
1.46k
        result = PyType_GenericNew(tp, NULL, NULL);
9787
1.46k
        if (!result) goto failed;
9788
1.46k
        value = ast2obj_expr(state, o->v.Compare.left);
9789
1.46k
        if (!value) goto failed;
9790
1.46k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9791
0
            goto failed;
9792
1.46k
        Py_DECREF(value);
9793
1.46k
        {
9794
1.46k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9795
1.46k
            value = PyList_New(n);
9796
1.46k
            if (!value) goto failed;
9797
8.26k
            for(i = 0; i < n; i++)
9798
6.79k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9799
1.46k
        }
9800
1.46k
        if (!value) goto failed;
9801
1.46k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9802
0
            goto failed;
9803
1.46k
        Py_DECREF(value);
9804
1.46k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9805
1.46k
                             ast2obj_expr);
9806
1.46k
        if (!value) goto failed;
9807
1.46k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9808
0
            goto failed;
9809
1.46k
        Py_DECREF(value);
9810
1.46k
        break;
9811
8.20k
    case Call_kind:
9812
8.20k
        tp = (PyTypeObject *)state->Call_type;
9813
8.20k
        result = PyType_GenericNew(tp, NULL, NULL);
9814
8.20k
        if (!result) goto failed;
9815
8.20k
        value = ast2obj_expr(state, o->v.Call.func);
9816
8.20k
        if (!value) goto failed;
9817
8.20k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9818
0
            goto failed;
9819
8.20k
        Py_DECREF(value);
9820
8.20k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9821
8.20k
        if (!value) goto failed;
9822
8.20k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9823
0
            goto failed;
9824
8.20k
        Py_DECREF(value);
9825
8.20k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9826
8.20k
                             ast2obj_keyword);
9827
8.20k
        if (!value) goto failed;
9828
8.20k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9829
0
            goto failed;
9830
8.20k
        Py_DECREF(value);
9831
8.20k
        break;
9832
13.8k
    case FormattedValue_kind:
9833
13.8k
        tp = (PyTypeObject *)state->FormattedValue_type;
9834
13.8k
        result = PyType_GenericNew(tp, NULL, NULL);
9835
13.8k
        if (!result) goto failed;
9836
13.8k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9837
13.8k
        if (!value) goto failed;
9838
13.8k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9839
0
            goto failed;
9840
13.8k
        Py_DECREF(value);
9841
13.8k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9842
13.8k
        if (!value) goto failed;
9843
13.8k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9844
0
            goto failed;
9845
13.8k
        Py_DECREF(value);
9846
13.8k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9847
13.8k
        if (!value) goto failed;
9848
13.8k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9849
0
            goto failed;
9850
13.8k
        Py_DECREF(value);
9851
13.8k
        break;
9852
2.11k
    case Interpolation_kind:
9853
2.11k
        tp = (PyTypeObject *)state->Interpolation_type;
9854
2.11k
        result = PyType_GenericNew(tp, NULL, NULL);
9855
2.11k
        if (!result) goto failed;
9856
2.11k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9857
2.11k
        if (!value) goto failed;
9858
2.11k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9859
0
            goto failed;
9860
2.11k
        Py_DECREF(value);
9861
2.11k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9862
2.11k
        if (!value) goto failed;
9863
2.11k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9864
0
            goto failed;
9865
2.11k
        Py_DECREF(value);
9866
2.11k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9867
2.11k
        if (!value) goto failed;
9868
2.11k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9869
0
            goto failed;
9870
2.11k
        Py_DECREF(value);
9871
2.11k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9872
2.11k
        if (!value) goto failed;
9873
2.11k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9874
0
            goto failed;
9875
2.11k
        Py_DECREF(value);
9876
2.11k
        break;
9877
7.77k
    case JoinedStr_kind:
9878
7.77k
        tp = (PyTypeObject *)state->JoinedStr_type;
9879
7.77k
        result = PyType_GenericNew(tp, NULL, NULL);
9880
7.77k
        if (!result) goto failed;
9881
7.77k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9882
7.77k
                             ast2obj_expr);
9883
7.77k
        if (!value) goto failed;
9884
7.77k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9885
0
            goto failed;
9886
7.77k
        Py_DECREF(value);
9887
7.77k
        break;
9888
717
    case TemplateStr_kind:
9889
717
        tp = (PyTypeObject *)state->TemplateStr_type;
9890
717
        result = PyType_GenericNew(tp, NULL, NULL);
9891
717
        if (!result) goto failed;
9892
717
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9893
717
                             ast2obj_expr);
9894
717
        if (!value) goto failed;
9895
717
        if (PyObject_SetAttr(result, state->values, value) == -1)
9896
0
            goto failed;
9897
717
        Py_DECREF(value);
9898
717
        break;
9899
60.2k
    case Constant_kind:
9900
60.2k
        tp = (PyTypeObject *)state->Constant_type;
9901
60.2k
        result = PyType_GenericNew(tp, NULL, NULL);
9902
60.2k
        if (!result) goto failed;
9903
60.2k
        value = ast2obj_constant(state, o->v.Constant.value);
9904
60.2k
        if (!value) goto failed;
9905
60.2k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9906
0
            goto failed;
9907
60.2k
        Py_DECREF(value);
9908
60.2k
        value = ast2obj_string(state, o->v.Constant.kind);
9909
60.2k
        if (!value) goto failed;
9910
60.2k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9911
0
            goto failed;
9912
60.2k
        Py_DECREF(value);
9913
60.2k
        break;
9914
1.78k
    case Attribute_kind:
9915
1.78k
        tp = (PyTypeObject *)state->Attribute_type;
9916
1.78k
        result = PyType_GenericNew(tp, NULL, NULL);
9917
1.78k
        if (!result) goto failed;
9918
1.78k
        value = ast2obj_expr(state, o->v.Attribute.value);
9919
1.78k
        if (!value) goto failed;
9920
1.78k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9921
0
            goto failed;
9922
1.78k
        Py_DECREF(value);
9923
1.78k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9924
1.78k
        if (!value) goto failed;
9925
1.78k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9926
0
            goto failed;
9927
1.78k
        Py_DECREF(value);
9928
1.78k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9929
1.78k
        if (!value) goto failed;
9930
1.78k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9931
0
            goto failed;
9932
1.78k
        Py_DECREF(value);
9933
1.78k
        break;
9934
458
    case Subscript_kind:
9935
458
        tp = (PyTypeObject *)state->Subscript_type;
9936
458
        result = PyType_GenericNew(tp, NULL, NULL);
9937
458
        if (!result) goto failed;
9938
458
        value = ast2obj_expr(state, o->v.Subscript.value);
9939
458
        if (!value) goto failed;
9940
458
        if (PyObject_SetAttr(result, state->value, value) == -1)
9941
0
            goto failed;
9942
458
        Py_DECREF(value);
9943
458
        value = ast2obj_expr(state, o->v.Subscript.slice);
9944
458
        if (!value) goto failed;
9945
458
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9946
0
            goto failed;
9947
458
        Py_DECREF(value);
9948
458
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9949
458
        if (!value) goto failed;
9950
458
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9951
0
            goto failed;
9952
458
        Py_DECREF(value);
9953
458
        break;
9954
897
    case Starred_kind:
9955
897
        tp = (PyTypeObject *)state->Starred_type;
9956
897
        result = PyType_GenericNew(tp, NULL, NULL);
9957
897
        if (!result) goto failed;
9958
897
        value = ast2obj_expr(state, o->v.Starred.value);
9959
897
        if (!value) goto failed;
9960
897
        if (PyObject_SetAttr(result, state->value, value) == -1)
9961
0
            goto failed;
9962
897
        Py_DECREF(value);
9963
897
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9964
897
        if (!value) goto failed;
9965
897
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9966
0
            goto failed;
9967
897
        Py_DECREF(value);
9968
897
        break;
9969
67.8k
    case Name_kind:
9970
67.8k
        tp = (PyTypeObject *)state->Name_type;
9971
67.8k
        result = PyType_GenericNew(tp, NULL, NULL);
9972
67.8k
        if (!result) goto failed;
9973
67.8k
        value = ast2obj_identifier(state, o->v.Name.id);
9974
67.8k
        if (!value) goto failed;
9975
67.8k
        if (PyObject_SetAttr(result, state->id, value) == -1)
9976
0
            goto failed;
9977
67.8k
        Py_DECREF(value);
9978
67.8k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
9979
67.8k
        if (!value) goto failed;
9980
67.8k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9981
0
            goto failed;
9982
67.8k
        Py_DECREF(value);
9983
67.8k
        break;
9984
1.48k
    case List_kind:
9985
1.48k
        tp = (PyTypeObject *)state->List_type;
9986
1.48k
        result = PyType_GenericNew(tp, NULL, NULL);
9987
1.48k
        if (!result) goto failed;
9988
1.48k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
9989
1.48k
        if (!value) goto failed;
9990
1.48k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9991
0
            goto failed;
9992
1.48k
        Py_DECREF(value);
9993
1.48k
        value = ast2obj_expr_context(state, o->v.List.ctx);
9994
1.48k
        if (!value) goto failed;
9995
1.48k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9996
0
            goto failed;
9997
1.48k
        Py_DECREF(value);
9998
1.48k
        break;
9999
10.4k
    case Tuple_kind:
10000
10.4k
        tp = (PyTypeObject *)state->Tuple_type;
10001
10.4k
        result = PyType_GenericNew(tp, NULL, NULL);
10002
10.4k
        if (!result) goto failed;
10003
10.4k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10004
10.4k
        if (!value) goto failed;
10005
10.4k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10006
0
            goto failed;
10007
10.4k
        Py_DECREF(value);
10008
10.4k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10009
10.4k
        if (!value) goto failed;
10010
10.4k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10011
0
            goto failed;
10012
10.4k
        Py_DECREF(value);
10013
10.4k
        break;
10014
2.53k
    case Slice_kind:
10015
2.53k
        tp = (PyTypeObject *)state->Slice_type;
10016
2.53k
        result = PyType_GenericNew(tp, NULL, NULL);
10017
2.53k
        if (!result) goto failed;
10018
2.53k
        value = ast2obj_expr(state, o->v.Slice.lower);
10019
2.53k
        if (!value) goto failed;
10020
2.53k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10021
0
            goto failed;
10022
2.53k
        Py_DECREF(value);
10023
2.53k
        value = ast2obj_expr(state, o->v.Slice.upper);
10024
2.53k
        if (!value) goto failed;
10025
2.53k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10026
0
            goto failed;
10027
2.53k
        Py_DECREF(value);
10028
2.53k
        value = ast2obj_expr(state, o->v.Slice.step);
10029
2.53k
        if (!value) goto failed;
10030
2.53k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10031
0
            goto failed;
10032
2.53k
        Py_DECREF(value);
10033
2.53k
        break;
10034
354k
    }
10035
354k
    value = ast2obj_int(state, o->lineno);
10036
354k
    if (!value) goto failed;
10037
354k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10038
0
        goto failed;
10039
354k
    Py_DECREF(value);
10040
354k
    value = ast2obj_int(state, o->col_offset);
10041
354k
    if (!value) goto failed;
10042
354k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10043
0
        goto failed;
10044
354k
    Py_DECREF(value);
10045
354k
    value = ast2obj_int(state, o->end_lineno);
10046
354k
    if (!value) goto failed;
10047
354k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10048
0
        goto failed;
10049
354k
    Py_DECREF(value);
10050
354k
    value = ast2obj_int(state, o->end_col_offset);
10051
354k
    if (!value) goto failed;
10052
354k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10053
0
        goto failed;
10054
354k
    Py_DECREF(value);
10055
354k
    Py_LeaveRecursiveCall();
10056
354k
    return result;
10057
0
failed:
10058
0
    Py_LeaveRecursiveCall();
10059
0
    Py_XDECREF(value);
10060
0
    Py_XDECREF(result);
10061
0
    return NULL;
10062
354k
}
10063
10064
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10065
82.9k
{
10066
82.9k
    switch(o) {
10067
75.2k
        case Load:
10068
75.2k
            return Py_NewRef(state->Load_singleton);
10069
7.25k
        case Store:
10070
7.25k
            return Py_NewRef(state->Store_singleton);
10071
465
        case Del:
10072
465
            return Py_NewRef(state->Del_singleton);
10073
82.9k
    }
10074
82.9k
    Py_UNREACHABLE();
10075
82.9k
}
10076
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10077
804
{
10078
804
    switch(o) {
10079
379
        case And:
10080
379
            return Py_NewRef(state->And_singleton);
10081
425
        case Or:
10082
425
            return Py_NewRef(state->Or_singleton);
10083
804
    }
10084
804
    Py_UNREACHABLE();
10085
804
}
10086
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10087
23.8k
{
10088
23.8k
    switch(o) {
10089
3.64k
        case Add:
10090
3.64k
            return Py_NewRef(state->Add_singleton);
10091
8.25k
        case Sub:
10092
8.25k
            return Py_NewRef(state->Sub_singleton);
10093
4.67k
        case Mult:
10094
4.67k
            return Py_NewRef(state->Mult_singleton);
10095
593
        case MatMult:
10096
593
            return Py_NewRef(state->MatMult_singleton);
10097
898
        case Div:
10098
898
            return Py_NewRef(state->Div_singleton);
10099
1.55k
        case Mod:
10100
1.55k
            return Py_NewRef(state->Mod_singleton);
10101
821
        case Pow:
10102
821
            return Py_NewRef(state->Pow_singleton);
10103
407
        case LShift:
10104
407
            return Py_NewRef(state->LShift_singleton);
10105
265
        case RShift:
10106
265
            return Py_NewRef(state->RShift_singleton);
10107
876
        case BitOr:
10108
876
            return Py_NewRef(state->BitOr_singleton);
10109
709
        case BitXor:
10110
709
            return Py_NewRef(state->BitXor_singleton);
10111
910
        case BitAnd:
10112
910
            return Py_NewRef(state->BitAnd_singleton);
10113
286
        case FloorDiv:
10114
286
            return Py_NewRef(state->FloorDiv_singleton);
10115
23.8k
    }
10116
23.8k
    Py_UNREACHABLE();
10117
23.8k
}
10118
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10119
144k
{
10120
144k
    switch(o) {
10121
23.9k
        case Invert:
10122
23.9k
            return Py_NewRef(state->Invert_singleton);
10123
113
        case Not:
10124
113
            return Py_NewRef(state->Not_singleton);
10125
56.2k
        case UAdd:
10126
56.2k
            return Py_NewRef(state->UAdd_singleton);
10127
64.2k
        case USub:
10128
64.2k
            return Py_NewRef(state->USub_singleton);
10129
144k
    }
10130
144k
    Py_UNREACHABLE();
10131
144k
}
10132
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10133
6.79k
{
10134
6.79k
    switch(o) {
10135
262
        case Eq:
10136
262
            return Py_NewRef(state->Eq_singleton);
10137
306
        case NotEq:
10138
306
            return Py_NewRef(state->NotEq_singleton);
10139
2.05k
        case Lt:
10140
2.05k
            return Py_NewRef(state->Lt_singleton);
10141
195
        case LtE:
10142
195
            return Py_NewRef(state->LtE_singleton);
10143
2.99k
        case Gt:
10144
2.99k
            return Py_NewRef(state->Gt_singleton);
10145
245
        case GtE:
10146
245
            return Py_NewRef(state->GtE_singleton);
10147
268
        case Is:
10148
268
            return Py_NewRef(state->Is_singleton);
10149
76
        case IsNot:
10150
76
            return Py_NewRef(state->IsNot_singleton);
10151
320
        case In:
10152
320
            return Py_NewRef(state->In_singleton);
10153
66
        case NotIn:
10154
66
            return Py_NewRef(state->NotIn_singleton);
10155
6.79k
    }
10156
6.79k
    Py_UNREACHABLE();
10157
6.79k
}
10158
PyObject*
10159
ast2obj_comprehension(struct ast_state *state, void* _o)
10160
1.43k
{
10161
1.43k
    comprehension_ty o = (comprehension_ty)_o;
10162
1.43k
    PyObject *result = NULL, *value = NULL;
10163
1.43k
    PyTypeObject *tp;
10164
1.43k
    if (!o) {
10165
0
        Py_RETURN_NONE;
10166
0
    }
10167
1.43k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10168
0
        return NULL;
10169
0
    }
10170
1.43k
    tp = (PyTypeObject *)state->comprehension_type;
10171
1.43k
    result = PyType_GenericNew(tp, NULL, NULL);
10172
1.43k
    if (!result) return NULL;
10173
1.43k
    value = ast2obj_expr(state, o->target);
10174
1.43k
    if (!value) goto failed;
10175
1.43k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10176
0
        goto failed;
10177
1.43k
    Py_DECREF(value);
10178
1.43k
    value = ast2obj_expr(state, o->iter);
10179
1.43k
    if (!value) goto failed;
10180
1.43k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10181
0
        goto failed;
10182
1.43k
    Py_DECREF(value);
10183
1.43k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10184
1.43k
    if (!value) goto failed;
10185
1.43k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10186
0
        goto failed;
10187
1.43k
    Py_DECREF(value);
10188
1.43k
    value = ast2obj_int(state, o->is_async);
10189
1.43k
    if (!value) goto failed;
10190
1.43k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10191
0
        goto failed;
10192
1.43k
    Py_DECREF(value);
10193
1.43k
    Py_LeaveRecursiveCall();
10194
1.43k
    return result;
10195
0
failed:
10196
0
    Py_LeaveRecursiveCall();
10197
0
    Py_XDECREF(value);
10198
0
    Py_XDECREF(result);
10199
0
    return NULL;
10200
1.43k
}
10201
10202
PyObject*
10203
ast2obj_excepthandler(struct ast_state *state, void* _o)
10204
1.07k
{
10205
1.07k
    excepthandler_ty o = (excepthandler_ty)_o;
10206
1.07k
    PyObject *result = NULL, *value = NULL;
10207
1.07k
    PyTypeObject *tp;
10208
1.07k
    if (!o) {
10209
0
        Py_RETURN_NONE;
10210
0
    }
10211
1.07k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10212
0
        return NULL;
10213
0
    }
10214
1.07k
    switch (o->kind) {
10215
1.07k
    case ExceptHandler_kind:
10216
1.07k
        tp = (PyTypeObject *)state->ExceptHandler_type;
10217
1.07k
        result = PyType_GenericNew(tp, NULL, NULL);
10218
1.07k
        if (!result) goto failed;
10219
1.07k
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10220
1.07k
        if (!value) goto failed;
10221
1.07k
        if (PyObject_SetAttr(result, state->type, value) == -1)
10222
0
            goto failed;
10223
1.07k
        Py_DECREF(value);
10224
1.07k
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10225
1.07k
        if (!value) goto failed;
10226
1.07k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10227
0
            goto failed;
10228
1.07k
        Py_DECREF(value);
10229
1.07k
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10230
1.07k
                             ast2obj_stmt);
10231
1.07k
        if (!value) goto failed;
10232
1.07k
        if (PyObject_SetAttr(result, state->body, value) == -1)
10233
0
            goto failed;
10234
1.07k
        Py_DECREF(value);
10235
1.07k
        break;
10236
1.07k
    }
10237
1.07k
    value = ast2obj_int(state, o->lineno);
10238
1.07k
    if (!value) goto failed;
10239
1.07k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10240
0
        goto failed;
10241
1.07k
    Py_DECREF(value);
10242
1.07k
    value = ast2obj_int(state, o->col_offset);
10243
1.07k
    if (!value) goto failed;
10244
1.07k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10245
0
        goto failed;
10246
1.07k
    Py_DECREF(value);
10247
1.07k
    value = ast2obj_int(state, o->end_lineno);
10248
1.07k
    if (!value) goto failed;
10249
1.07k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10250
0
        goto failed;
10251
1.07k
    Py_DECREF(value);
10252
1.07k
    value = ast2obj_int(state, o->end_col_offset);
10253
1.07k
    if (!value) goto failed;
10254
1.07k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10255
0
        goto failed;
10256
1.07k
    Py_DECREF(value);
10257
1.07k
    Py_LeaveRecursiveCall();
10258
1.07k
    return result;
10259
0
failed:
10260
0
    Py_LeaveRecursiveCall();
10261
0
    Py_XDECREF(value);
10262
0
    Py_XDECREF(result);
10263
0
    return NULL;
10264
1.07k
}
10265
10266
PyObject*
10267
ast2obj_arguments(struct ast_state *state, void* _o)
10268
2.65k
{
10269
2.65k
    arguments_ty o = (arguments_ty)_o;
10270
2.65k
    PyObject *result = NULL, *value = NULL;
10271
2.65k
    PyTypeObject *tp;
10272
2.65k
    if (!o) {
10273
0
        Py_RETURN_NONE;
10274
0
    }
10275
2.65k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10276
0
        return NULL;
10277
0
    }
10278
2.65k
    tp = (PyTypeObject *)state->arguments_type;
10279
2.65k
    result = PyType_GenericNew(tp, NULL, NULL);
10280
2.65k
    if (!result) return NULL;
10281
2.65k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10282
2.65k
    if (!value) goto failed;
10283
2.65k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10284
0
        goto failed;
10285
2.65k
    Py_DECREF(value);
10286
2.65k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10287
2.65k
    if (!value) goto failed;
10288
2.65k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10289
0
        goto failed;
10290
2.65k
    Py_DECREF(value);
10291
2.65k
    value = ast2obj_arg(state, o->vararg);
10292
2.65k
    if (!value) goto failed;
10293
2.65k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10294
0
        goto failed;
10295
2.65k
    Py_DECREF(value);
10296
2.65k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10297
2.65k
    if (!value) goto failed;
10298
2.65k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10299
0
        goto failed;
10300
2.65k
    Py_DECREF(value);
10301
2.65k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10302
2.65k
    if (!value) goto failed;
10303
2.65k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10304
0
        goto failed;
10305
2.65k
    Py_DECREF(value);
10306
2.65k
    value = ast2obj_arg(state, o->kwarg);
10307
2.65k
    if (!value) goto failed;
10308
2.65k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10309
0
        goto failed;
10310
2.65k
    Py_DECREF(value);
10311
2.65k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10312
2.65k
    if (!value) goto failed;
10313
2.65k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10314
0
        goto failed;
10315
2.65k
    Py_DECREF(value);
10316
2.65k
    Py_LeaveRecursiveCall();
10317
2.65k
    return result;
10318
0
failed:
10319
0
    Py_LeaveRecursiveCall();
10320
0
    Py_XDECREF(value);
10321
0
    Py_XDECREF(result);
10322
0
    return NULL;
10323
2.65k
}
10324
10325
PyObject*
10326
ast2obj_arg(struct ast_state *state, void* _o)
10327
19.1k
{
10328
19.1k
    arg_ty o = (arg_ty)_o;
10329
19.1k
    PyObject *result = NULL, *value = NULL;
10330
19.1k
    PyTypeObject *tp;
10331
19.1k
    if (!o) {
10332
4.61k
        Py_RETURN_NONE;
10333
4.61k
    }
10334
14.4k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10335
0
        return NULL;
10336
0
    }
10337
14.4k
    tp = (PyTypeObject *)state->arg_type;
10338
14.4k
    result = PyType_GenericNew(tp, NULL, NULL);
10339
14.4k
    if (!result) return NULL;
10340
14.4k
    value = ast2obj_identifier(state, o->arg);
10341
14.4k
    if (!value) goto failed;
10342
14.4k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10343
0
        goto failed;
10344
14.4k
    Py_DECREF(value);
10345
14.4k
    value = ast2obj_expr(state, o->annotation);
10346
14.4k
    if (!value) goto failed;
10347
14.4k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10348
0
        goto failed;
10349
14.4k
    Py_DECREF(value);
10350
14.4k
    value = ast2obj_string(state, o->type_comment);
10351
14.4k
    if (!value) goto failed;
10352
14.4k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10353
0
        goto failed;
10354
14.4k
    Py_DECREF(value);
10355
14.4k
    value = ast2obj_int(state, o->lineno);
10356
14.4k
    if (!value) goto failed;
10357
14.4k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10358
0
        goto failed;
10359
14.4k
    Py_DECREF(value);
10360
14.4k
    value = ast2obj_int(state, o->col_offset);
10361
14.4k
    if (!value) goto failed;
10362
14.4k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10363
0
        goto failed;
10364
14.4k
    Py_DECREF(value);
10365
14.4k
    value = ast2obj_int(state, o->end_lineno);
10366
14.4k
    if (!value) goto failed;
10367
14.4k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10368
0
        goto failed;
10369
14.4k
    Py_DECREF(value);
10370
14.4k
    value = ast2obj_int(state, o->end_col_offset);
10371
14.4k
    if (!value) goto failed;
10372
14.4k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10373
0
        goto failed;
10374
14.4k
    Py_DECREF(value);
10375
14.4k
    Py_LeaveRecursiveCall();
10376
14.4k
    return result;
10377
0
failed:
10378
0
    Py_LeaveRecursiveCall();
10379
0
    Py_XDECREF(value);
10380
0
    Py_XDECREF(result);
10381
0
    return NULL;
10382
14.4k
}
10383
10384
PyObject*
10385
ast2obj_keyword(struct ast_state *state, void* _o)
10386
1.85k
{
10387
1.85k
    keyword_ty o = (keyword_ty)_o;
10388
1.85k
    PyObject *result = NULL, *value = NULL;
10389
1.85k
    PyTypeObject *tp;
10390
1.85k
    if (!o) {
10391
0
        Py_RETURN_NONE;
10392
0
    }
10393
1.85k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10394
0
        return NULL;
10395
0
    }
10396
1.85k
    tp = (PyTypeObject *)state->keyword_type;
10397
1.85k
    result = PyType_GenericNew(tp, NULL, NULL);
10398
1.85k
    if (!result) return NULL;
10399
1.85k
    value = ast2obj_identifier(state, o->arg);
10400
1.85k
    if (!value) goto failed;
10401
1.85k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10402
0
        goto failed;
10403
1.85k
    Py_DECREF(value);
10404
1.85k
    value = ast2obj_expr(state, o->value);
10405
1.85k
    if (!value) goto failed;
10406
1.85k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10407
0
        goto failed;
10408
1.85k
    Py_DECREF(value);
10409
1.85k
    value = ast2obj_int(state, o->lineno);
10410
1.85k
    if (!value) goto failed;
10411
1.85k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10412
0
        goto failed;
10413
1.85k
    Py_DECREF(value);
10414
1.85k
    value = ast2obj_int(state, o->col_offset);
10415
1.85k
    if (!value) goto failed;
10416
1.85k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10417
0
        goto failed;
10418
1.85k
    Py_DECREF(value);
10419
1.85k
    value = ast2obj_int(state, o->end_lineno);
10420
1.85k
    if (!value) goto failed;
10421
1.85k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10422
0
        goto failed;
10423
1.85k
    Py_DECREF(value);
10424
1.85k
    value = ast2obj_int(state, o->end_col_offset);
10425
1.85k
    if (!value) goto failed;
10426
1.85k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10427
0
        goto failed;
10428
1.85k
    Py_DECREF(value);
10429
1.85k
    Py_LeaveRecursiveCall();
10430
1.85k
    return result;
10431
0
failed:
10432
0
    Py_LeaveRecursiveCall();
10433
0
    Py_XDECREF(value);
10434
0
    Py_XDECREF(result);
10435
0
    return NULL;
10436
1.85k
}
10437
10438
PyObject*
10439
ast2obj_alias(struct ast_state *state, void* _o)
10440
3.20k
{
10441
3.20k
    alias_ty o = (alias_ty)_o;
10442
3.20k
    PyObject *result = NULL, *value = NULL;
10443
3.20k
    PyTypeObject *tp;
10444
3.20k
    if (!o) {
10445
0
        Py_RETURN_NONE;
10446
0
    }
10447
3.20k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10448
0
        return NULL;
10449
0
    }
10450
3.20k
    tp = (PyTypeObject *)state->alias_type;
10451
3.20k
    result = PyType_GenericNew(tp, NULL, NULL);
10452
3.20k
    if (!result) return NULL;
10453
3.20k
    value = ast2obj_identifier(state, o->name);
10454
3.20k
    if (!value) goto failed;
10455
3.20k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10456
0
        goto failed;
10457
3.20k
    Py_DECREF(value);
10458
3.20k
    value = ast2obj_identifier(state, o->asname);
10459
3.20k
    if (!value) goto failed;
10460
3.20k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10461
0
        goto failed;
10462
3.20k
    Py_DECREF(value);
10463
3.20k
    value = ast2obj_int(state, o->lineno);
10464
3.20k
    if (!value) goto failed;
10465
3.20k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10466
0
        goto failed;
10467
3.20k
    Py_DECREF(value);
10468
3.20k
    value = ast2obj_int(state, o->col_offset);
10469
3.20k
    if (!value) goto failed;
10470
3.20k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10471
0
        goto failed;
10472
3.20k
    Py_DECREF(value);
10473
3.20k
    value = ast2obj_int(state, o->end_lineno);
10474
3.20k
    if (!value) goto failed;
10475
3.20k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10476
0
        goto failed;
10477
3.20k
    Py_DECREF(value);
10478
3.20k
    value = ast2obj_int(state, o->end_col_offset);
10479
3.20k
    if (!value) goto failed;
10480
3.20k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10481
0
        goto failed;
10482
3.20k
    Py_DECREF(value);
10483
3.20k
    Py_LeaveRecursiveCall();
10484
3.20k
    return result;
10485
0
failed:
10486
0
    Py_LeaveRecursiveCall();
10487
0
    Py_XDECREF(value);
10488
0
    Py_XDECREF(result);
10489
0
    return NULL;
10490
3.20k
}
10491
10492
PyObject*
10493
ast2obj_withitem(struct ast_state *state, void* _o)
10494
1.37k
{
10495
1.37k
    withitem_ty o = (withitem_ty)_o;
10496
1.37k
    PyObject *result = NULL, *value = NULL;
10497
1.37k
    PyTypeObject *tp;
10498
1.37k
    if (!o) {
10499
0
        Py_RETURN_NONE;
10500
0
    }
10501
1.37k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10502
0
        return NULL;
10503
0
    }
10504
1.37k
    tp = (PyTypeObject *)state->withitem_type;
10505
1.37k
    result = PyType_GenericNew(tp, NULL, NULL);
10506
1.37k
    if (!result) return NULL;
10507
1.37k
    value = ast2obj_expr(state, o->context_expr);
10508
1.37k
    if (!value) goto failed;
10509
1.37k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10510
0
        goto failed;
10511
1.37k
    Py_DECREF(value);
10512
1.37k
    value = ast2obj_expr(state, o->optional_vars);
10513
1.37k
    if (!value) goto failed;
10514
1.37k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10515
0
        goto failed;
10516
1.37k
    Py_DECREF(value);
10517
1.37k
    Py_LeaveRecursiveCall();
10518
1.37k
    return result;
10519
0
failed:
10520
0
    Py_LeaveRecursiveCall();
10521
0
    Py_XDECREF(value);
10522
0
    Py_XDECREF(result);
10523
0
    return NULL;
10524
1.37k
}
10525
10526
PyObject*
10527
ast2obj_match_case(struct ast_state *state, void* _o)
10528
696
{
10529
696
    match_case_ty o = (match_case_ty)_o;
10530
696
    PyObject *result = NULL, *value = NULL;
10531
696
    PyTypeObject *tp;
10532
696
    if (!o) {
10533
0
        Py_RETURN_NONE;
10534
0
    }
10535
696
    if (Py_EnterRecursiveCall("during  ast construction")) {
10536
0
        return NULL;
10537
0
    }
10538
696
    tp = (PyTypeObject *)state->match_case_type;
10539
696
    result = PyType_GenericNew(tp, NULL, NULL);
10540
696
    if (!result) return NULL;
10541
696
    value = ast2obj_pattern(state, o->pattern);
10542
696
    if (!value) goto failed;
10543
696
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10544
0
        goto failed;
10545
696
    Py_DECREF(value);
10546
696
    value = ast2obj_expr(state, o->guard);
10547
696
    if (!value) goto failed;
10548
696
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10549
0
        goto failed;
10550
696
    Py_DECREF(value);
10551
696
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10552
696
    if (!value) goto failed;
10553
696
    if (PyObject_SetAttr(result, state->body, value) == -1)
10554
0
        goto failed;
10555
696
    Py_DECREF(value);
10556
696
    Py_LeaveRecursiveCall();
10557
696
    return result;
10558
0
failed:
10559
0
    Py_LeaveRecursiveCall();
10560
0
    Py_XDECREF(value);
10561
0
    Py_XDECREF(result);
10562
0
    return NULL;
10563
696
}
10564
10565
PyObject*
10566
ast2obj_pattern(struct ast_state *state, void* _o)
10567
24.4k
{
10568
24.4k
    pattern_ty o = (pattern_ty)_o;
10569
24.4k
    PyObject *result = NULL, *value = NULL;
10570
24.4k
    PyTypeObject *tp;
10571
24.4k
    if (!o) {
10572
9.07k
        Py_RETURN_NONE;
10573
9.07k
    }
10574
15.4k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10575
0
        return NULL;
10576
0
    }
10577
15.4k
    switch (o->kind) {
10578
777
    case MatchValue_kind:
10579
777
        tp = (PyTypeObject *)state->MatchValue_type;
10580
777
        result = PyType_GenericNew(tp, NULL, NULL);
10581
777
        if (!result) goto failed;
10582
777
        value = ast2obj_expr(state, o->v.MatchValue.value);
10583
777
        if (!value) goto failed;
10584
777
        if (PyObject_SetAttr(result, state->value, value) == -1)
10585
0
            goto failed;
10586
777
        Py_DECREF(value);
10587
777
        break;
10588
273
    case MatchSingleton_kind:
10589
273
        tp = (PyTypeObject *)state->MatchSingleton_type;
10590
273
        result = PyType_GenericNew(tp, NULL, NULL);
10591
273
        if (!result) goto failed;
10592
273
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10593
273
        if (!value) goto failed;
10594
273
        if (PyObject_SetAttr(result, state->value, value) == -1)
10595
0
            goto failed;
10596
273
        Py_DECREF(value);
10597
273
        break;
10598
455
    case MatchSequence_kind:
10599
455
        tp = (PyTypeObject *)state->MatchSequence_type;
10600
455
        result = PyType_GenericNew(tp, NULL, NULL);
10601
455
        if (!result) goto failed;
10602
455
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10603
455
                             ast2obj_pattern);
10604
455
        if (!value) goto failed;
10605
455
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10606
0
            goto failed;
10607
455
        Py_DECREF(value);
10608
455
        break;
10609
237
    case MatchMapping_kind:
10610
237
        tp = (PyTypeObject *)state->MatchMapping_type;
10611
237
        result = PyType_GenericNew(tp, NULL, NULL);
10612
237
        if (!result) goto failed;
10613
237
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10614
237
                             ast2obj_expr);
10615
237
        if (!value) goto failed;
10616
237
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10617
0
            goto failed;
10618
237
        Py_DECREF(value);
10619
237
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10620
237
                             ast2obj_pattern);
10621
237
        if (!value) goto failed;
10622
237
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10623
0
            goto failed;
10624
237
        Py_DECREF(value);
10625
237
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10626
237
        if (!value) goto failed;
10627
237
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10628
0
            goto failed;
10629
237
        Py_DECREF(value);
10630
237
        break;
10631
1.13k
    case MatchClass_kind:
10632
1.13k
        tp = (PyTypeObject *)state->MatchClass_type;
10633
1.13k
        result = PyType_GenericNew(tp, NULL, NULL);
10634
1.13k
        if (!result) goto failed;
10635
1.13k
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10636
1.13k
        if (!value) goto failed;
10637
1.13k
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10638
0
            goto failed;
10639
1.13k
        Py_DECREF(value);
10640
1.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10641
1.13k
                             ast2obj_pattern);
10642
1.13k
        if (!value) goto failed;
10643
1.13k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10644
0
            goto failed;
10645
1.13k
        Py_DECREF(value);
10646
1.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10647
1.13k
                             ast2obj_identifier);
10648
1.13k
        if (!value) goto failed;
10649
1.13k
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10650
0
            goto failed;
10651
1.13k
        Py_DECREF(value);
10652
1.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10653
1.13k
                             ast2obj_pattern);
10654
1.13k
        if (!value) goto failed;
10655
1.13k
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10656
0
            goto failed;
10657
1.13k
        Py_DECREF(value);
10658
1.13k
        break;
10659
257
    case MatchStar_kind:
10660
257
        tp = (PyTypeObject *)state->MatchStar_type;
10661
257
        result = PyType_GenericNew(tp, NULL, NULL);
10662
257
        if (!result) goto failed;
10663
257
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10664
257
        if (!value) goto failed;
10665
257
        if (PyObject_SetAttr(result, state->name, value) == -1)
10666
0
            goto failed;
10667
257
        Py_DECREF(value);
10668
257
        break;
10669
9.14k
    case MatchAs_kind:
10670
9.14k
        tp = (PyTypeObject *)state->MatchAs_type;
10671
9.14k
        result = PyType_GenericNew(tp, NULL, NULL);
10672
9.14k
        if (!result) goto failed;
10673
9.14k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10674
9.14k
        if (!value) goto failed;
10675
9.14k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10676
0
            goto failed;
10677
9.14k
        Py_DECREF(value);
10678
9.14k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10679
9.14k
        if (!value) goto failed;
10680
9.14k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10681
0
            goto failed;
10682
9.14k
        Py_DECREF(value);
10683
9.14k
        break;
10684
3.13k
    case MatchOr_kind:
10685
3.13k
        tp = (PyTypeObject *)state->MatchOr_type;
10686
3.13k
        result = PyType_GenericNew(tp, NULL, NULL);
10687
3.13k
        if (!result) goto failed;
10688
3.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10689
3.13k
                             ast2obj_pattern);
10690
3.13k
        if (!value) goto failed;
10691
3.13k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10692
0
            goto failed;
10693
3.13k
        Py_DECREF(value);
10694
3.13k
        break;
10695
15.4k
    }
10696
15.4k
    value = ast2obj_int(state, o->lineno);
10697
15.4k
    if (!value) goto failed;
10698
15.4k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10699
0
        goto failed;
10700
15.4k
    Py_DECREF(value);
10701
15.4k
    value = ast2obj_int(state, o->col_offset);
10702
15.4k
    if (!value) goto failed;
10703
15.4k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10704
0
        goto failed;
10705
15.4k
    Py_DECREF(value);
10706
15.4k
    value = ast2obj_int(state, o->end_lineno);
10707
15.4k
    if (!value) goto failed;
10708
15.4k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10709
0
        goto failed;
10710
15.4k
    Py_DECREF(value);
10711
15.4k
    value = ast2obj_int(state, o->end_col_offset);
10712
15.4k
    if (!value) goto failed;
10713
15.4k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10714
0
        goto failed;
10715
15.4k
    Py_DECREF(value);
10716
15.4k
    Py_LeaveRecursiveCall();
10717
15.4k
    return result;
10718
0
failed:
10719
0
    Py_LeaveRecursiveCall();
10720
0
    Py_XDECREF(value);
10721
0
    Py_XDECREF(result);
10722
0
    return NULL;
10723
15.4k
}
10724
10725
PyObject*
10726
ast2obj_type_ignore(struct ast_state *state, void* _o)
10727
0
{
10728
0
    type_ignore_ty o = (type_ignore_ty)_o;
10729
0
    PyObject *result = NULL, *value = NULL;
10730
0
    PyTypeObject *tp;
10731
0
    if (!o) {
10732
0
        Py_RETURN_NONE;
10733
0
    }
10734
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10735
0
        return NULL;
10736
0
    }
10737
0
    switch (o->kind) {
10738
0
    case TypeIgnore_kind:
10739
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10740
0
        result = PyType_GenericNew(tp, NULL, NULL);
10741
0
        if (!result) goto failed;
10742
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10743
0
        if (!value) goto failed;
10744
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10745
0
            goto failed;
10746
0
        Py_DECREF(value);
10747
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10748
0
        if (!value) goto failed;
10749
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10750
0
            goto failed;
10751
0
        Py_DECREF(value);
10752
0
        break;
10753
0
    }
10754
0
    Py_LeaveRecursiveCall();
10755
0
    return result;
10756
0
failed:
10757
0
    Py_LeaveRecursiveCall();
10758
0
    Py_XDECREF(value);
10759
0
    Py_XDECREF(result);
10760
0
    return NULL;
10761
0
}
10762
10763
PyObject*
10764
ast2obj_type_param(struct ast_state *state, void* _o)
10765
8.77k
{
10766
8.77k
    type_param_ty o = (type_param_ty)_o;
10767
8.77k
    PyObject *result = NULL, *value = NULL;
10768
8.77k
    PyTypeObject *tp;
10769
8.77k
    if (!o) {
10770
0
        Py_RETURN_NONE;
10771
0
    }
10772
8.77k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10773
0
        return NULL;
10774
0
    }
10775
8.77k
    switch (o->kind) {
10776
6.43k
    case TypeVar_kind:
10777
6.43k
        tp = (PyTypeObject *)state->TypeVar_type;
10778
6.43k
        result = PyType_GenericNew(tp, NULL, NULL);
10779
6.43k
        if (!result) goto failed;
10780
6.43k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10781
6.43k
        if (!value) goto failed;
10782
6.43k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10783
0
            goto failed;
10784
6.43k
        Py_DECREF(value);
10785
6.43k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10786
6.43k
        if (!value) goto failed;
10787
6.43k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10788
0
            goto failed;
10789
6.43k
        Py_DECREF(value);
10790
6.43k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10791
6.43k
        if (!value) goto failed;
10792
6.43k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10793
0
            goto failed;
10794
6.43k
        Py_DECREF(value);
10795
6.43k
        break;
10796
790
    case ParamSpec_kind:
10797
790
        tp = (PyTypeObject *)state->ParamSpec_type;
10798
790
        result = PyType_GenericNew(tp, NULL, NULL);
10799
790
        if (!result) goto failed;
10800
790
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10801
790
        if (!value) goto failed;
10802
790
        if (PyObject_SetAttr(result, state->name, value) == -1)
10803
0
            goto failed;
10804
790
        Py_DECREF(value);
10805
790
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10806
790
        if (!value) goto failed;
10807
790
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10808
0
            goto failed;
10809
790
        Py_DECREF(value);
10810
790
        break;
10811
1.55k
    case TypeVarTuple_kind:
10812
1.55k
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10813
1.55k
        result = PyType_GenericNew(tp, NULL, NULL);
10814
1.55k
        if (!result) goto failed;
10815
1.55k
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10816
1.55k
        if (!value) goto failed;
10817
1.55k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10818
0
            goto failed;
10819
1.55k
        Py_DECREF(value);
10820
1.55k
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10821
1.55k
        if (!value) goto failed;
10822
1.55k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10823
0
            goto failed;
10824
1.55k
        Py_DECREF(value);
10825
1.55k
        break;
10826
8.77k
    }
10827
8.77k
    value = ast2obj_int(state, o->lineno);
10828
8.77k
    if (!value) goto failed;
10829
8.77k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10830
0
        goto failed;
10831
8.77k
    Py_DECREF(value);
10832
8.77k
    value = ast2obj_int(state, o->col_offset);
10833
8.77k
    if (!value) goto failed;
10834
8.77k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10835
0
        goto failed;
10836
8.77k
    Py_DECREF(value);
10837
8.77k
    value = ast2obj_int(state, o->end_lineno);
10838
8.77k
    if (!value) goto failed;
10839
8.77k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10840
0
        goto failed;
10841
8.77k
    Py_DECREF(value);
10842
8.77k
    value = ast2obj_int(state, o->end_col_offset);
10843
8.77k
    if (!value) goto failed;
10844
8.77k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10845
0
        goto failed;
10846
8.77k
    Py_DECREF(value);
10847
8.77k
    Py_LeaveRecursiveCall();
10848
8.77k
    return result;
10849
0
failed:
10850
0
    Py_LeaveRecursiveCall();
10851
0
    Py_XDECREF(value);
10852
0
    Py_XDECREF(result);
10853
0
    return NULL;
10854
8.77k
}
10855
10856
10857
int
10858
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
10859
0
{
10860
0
    int isinstance;
10861
10862
0
    PyObject *tmp = NULL;
10863
0
    PyObject *tp;
10864
10865
0
    if (obj == Py_None) {
10866
0
        *out = NULL;
10867
0
        return 0;
10868
0
    }
10869
0
    tp = state->Module_type;
10870
0
    isinstance = PyObject_IsInstance(obj, tp);
10871
0
    if (isinstance == -1) {
10872
0
        return -1;
10873
0
    }
10874
0
    if (isinstance) {
10875
0
        asdl_stmt_seq* body;
10876
0
        asdl_type_ignore_seq* type_ignores;
10877
10878
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10879
0
            return -1;
10880
0
        }
10881
0
        if (tmp == NULL) {
10882
0
            tmp = PyList_New(0);
10883
0
            if (tmp == NULL) {
10884
0
                return -1;
10885
0
            }
10886
0
        }
10887
0
        {
10888
0
            int res;
10889
0
            Py_ssize_t len;
10890
0
            Py_ssize_t i;
10891
0
            if (!PyList_Check(tmp)) {
10892
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10893
0
                goto failed;
10894
0
            }
10895
0
            len = PyList_GET_SIZE(tmp);
10896
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10897
0
            if (body == NULL) goto failed;
10898
0
            for (i = 0; i < len; i++) {
10899
0
                stmt_ty val;
10900
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10901
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10902
0
                    goto failed;
10903
0
                }
10904
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10905
0
                _Py_LeaveRecursiveCall();
10906
0
                Py_DECREF(tmp2);
10907
0
                if (res != 0) goto failed;
10908
0
                if (len != PyList_GET_SIZE(tmp)) {
10909
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10910
0
                    goto failed;
10911
0
                }
10912
0
                asdl_seq_SET(body, i, val);
10913
0
            }
10914
0
            Py_CLEAR(tmp);
10915
0
        }
10916
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10917
0
            return -1;
10918
0
        }
10919
0
        if (tmp == NULL) {
10920
0
            tmp = PyList_New(0);
10921
0
            if (tmp == NULL) {
10922
0
                return -1;
10923
0
            }
10924
0
        }
10925
0
        {
10926
0
            int res;
10927
0
            Py_ssize_t len;
10928
0
            Py_ssize_t i;
10929
0
            if (!PyList_Check(tmp)) {
10930
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10931
0
                goto failed;
10932
0
            }
10933
0
            len = PyList_GET_SIZE(tmp);
10934
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
10935
0
            if (type_ignores == NULL) goto failed;
10936
0
            for (i = 0; i < len; i++) {
10937
0
                type_ignore_ty val;
10938
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10939
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10940
0
                    goto failed;
10941
0
                }
10942
0
                res = obj2ast_type_ignore(state, tmp2, &val, arena);
10943
0
                _Py_LeaveRecursiveCall();
10944
0
                Py_DECREF(tmp2);
10945
0
                if (res != 0) goto failed;
10946
0
                if (len != PyList_GET_SIZE(tmp)) {
10947
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
10948
0
                    goto failed;
10949
0
                }
10950
0
                asdl_seq_SET(type_ignores, i, val);
10951
0
            }
10952
0
            Py_CLEAR(tmp);
10953
0
        }
10954
0
        *out = _PyAST_Module(body, type_ignores, arena);
10955
0
        if (*out == NULL) goto failed;
10956
0
        return 0;
10957
0
    }
10958
0
    tp = state->Interactive_type;
10959
0
    isinstance = PyObject_IsInstance(obj, tp);
10960
0
    if (isinstance == -1) {
10961
0
        return -1;
10962
0
    }
10963
0
    if (isinstance) {
10964
0
        asdl_stmt_seq* body;
10965
10966
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10967
0
            return -1;
10968
0
        }
10969
0
        if (tmp == NULL) {
10970
0
            tmp = PyList_New(0);
10971
0
            if (tmp == NULL) {
10972
0
                return -1;
10973
0
            }
10974
0
        }
10975
0
        {
10976
0
            int res;
10977
0
            Py_ssize_t len;
10978
0
            Py_ssize_t i;
10979
0
            if (!PyList_Check(tmp)) {
10980
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10981
0
                goto failed;
10982
0
            }
10983
0
            len = PyList_GET_SIZE(tmp);
10984
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10985
0
            if (body == NULL) goto failed;
10986
0
            for (i = 0; i < len; i++) {
10987
0
                stmt_ty val;
10988
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10989
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
10990
0
                    goto failed;
10991
0
                }
10992
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10993
0
                _Py_LeaveRecursiveCall();
10994
0
                Py_DECREF(tmp2);
10995
0
                if (res != 0) goto failed;
10996
0
                if (len != PyList_GET_SIZE(tmp)) {
10997
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
10998
0
                    goto failed;
10999
0
                }
11000
0
                asdl_seq_SET(body, i, val);
11001
0
            }
11002
0
            Py_CLEAR(tmp);
11003
0
        }
11004
0
        *out = _PyAST_Interactive(body, arena);
11005
0
        if (*out == NULL) goto failed;
11006
0
        return 0;
11007
0
    }
11008
0
    tp = state->Expression_type;
11009
0
    isinstance = PyObject_IsInstance(obj, tp);
11010
0
    if (isinstance == -1) {
11011
0
        return -1;
11012
0
    }
11013
0
    if (isinstance) {
11014
0
        expr_ty body;
11015
11016
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11017
0
            return -1;
11018
0
        }
11019
0
        if (tmp == NULL) {
11020
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11021
0
            return -1;
11022
0
        }
11023
0
        else {
11024
0
            int res;
11025
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11026
0
                goto failed;
11027
0
            }
11028
0
            res = obj2ast_expr(state, tmp, &body, arena);
11029
0
            _Py_LeaveRecursiveCall();
11030
0
            if (res != 0) goto failed;
11031
0
            Py_CLEAR(tmp);
11032
0
        }
11033
0
        *out = _PyAST_Expression(body, arena);
11034
0
        if (*out == NULL) goto failed;
11035
0
        return 0;
11036
0
    }
11037
0
    tp = state->FunctionType_type;
11038
0
    isinstance = PyObject_IsInstance(obj, tp);
11039
0
    if (isinstance == -1) {
11040
0
        return -1;
11041
0
    }
11042
0
    if (isinstance) {
11043
0
        asdl_expr_seq* argtypes;
11044
0
        expr_ty returns;
11045
11046
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11047
0
            return -1;
11048
0
        }
11049
0
        if (tmp == NULL) {
11050
0
            tmp = PyList_New(0);
11051
0
            if (tmp == NULL) {
11052
0
                return -1;
11053
0
            }
11054
0
        }
11055
0
        {
11056
0
            int res;
11057
0
            Py_ssize_t len;
11058
0
            Py_ssize_t i;
11059
0
            if (!PyList_Check(tmp)) {
11060
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11061
0
                goto failed;
11062
0
            }
11063
0
            len = PyList_GET_SIZE(tmp);
11064
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11065
0
            if (argtypes == NULL) goto failed;
11066
0
            for (i = 0; i < len; i++) {
11067
0
                expr_ty val;
11068
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11069
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11070
0
                    goto failed;
11071
0
                }
11072
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11073
0
                _Py_LeaveRecursiveCall();
11074
0
                Py_DECREF(tmp2);
11075
0
                if (res != 0) goto failed;
11076
0
                if (len != PyList_GET_SIZE(tmp)) {
11077
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11078
0
                    goto failed;
11079
0
                }
11080
0
                asdl_seq_SET(argtypes, i, val);
11081
0
            }
11082
0
            Py_CLEAR(tmp);
11083
0
        }
11084
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11085
0
            return -1;
11086
0
        }
11087
0
        if (tmp == NULL) {
11088
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11089
0
            return -1;
11090
0
        }
11091
0
        else {
11092
0
            int res;
11093
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11094
0
                goto failed;
11095
0
            }
11096
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11097
0
            _Py_LeaveRecursiveCall();
11098
0
            if (res != 0) goto failed;
11099
0
            Py_CLEAR(tmp);
11100
0
        }
11101
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11102
0
        if (*out == NULL) goto failed;
11103
0
        return 0;
11104
0
    }
11105
11106
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11107
0
    failed:
11108
0
    Py_XDECREF(tmp);
11109
0
    return -1;
11110
0
}
11111
11112
int
11113
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
11114
             arena)
11115
0
{
11116
0
    int isinstance;
11117
11118
0
    PyObject *tmp = NULL;
11119
0
    PyObject *tp;
11120
0
    int lineno;
11121
0
    int col_offset;
11122
0
    int end_lineno;
11123
0
    int end_col_offset;
11124
11125
0
    if (obj == Py_None) {
11126
0
        *out = NULL;
11127
0
        return 0;
11128
0
    }
11129
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11130
0
        return -1;
11131
0
    }
11132
0
    if (tmp == NULL) {
11133
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11134
0
        return -1;
11135
0
    }
11136
0
    else {
11137
0
        int res;
11138
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11139
0
            goto failed;
11140
0
        }
11141
0
        res = obj2ast_int(state, tmp, &lineno, arena);
11142
0
        _Py_LeaveRecursiveCall();
11143
0
        if (res != 0) goto failed;
11144
0
        Py_CLEAR(tmp);
11145
0
    }
11146
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11147
0
        return -1;
11148
0
    }
11149
0
    if (tmp == NULL) {
11150
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11151
0
        return -1;
11152
0
    }
11153
0
    else {
11154
0
        int res;
11155
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11156
0
            goto failed;
11157
0
        }
11158
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
11159
0
        _Py_LeaveRecursiveCall();
11160
0
        if (res != 0) goto failed;
11161
0
        Py_CLEAR(tmp);
11162
0
    }
11163
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11164
0
        return -1;
11165
0
    }
11166
0
    if (tmp == NULL || tmp == Py_None) {
11167
0
        Py_CLEAR(tmp);
11168
0
        end_lineno = lineno;
11169
0
    }
11170
0
    else {
11171
0
        int res;
11172
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11173
0
            goto failed;
11174
0
        }
11175
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
11176
0
        _Py_LeaveRecursiveCall();
11177
0
        if (res != 0) goto failed;
11178
0
        Py_CLEAR(tmp);
11179
0
    }
11180
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11181
0
        return -1;
11182
0
    }
11183
0
    if (tmp == NULL || tmp == Py_None) {
11184
0
        Py_CLEAR(tmp);
11185
0
        end_col_offset = col_offset;
11186
0
    }
11187
0
    else {
11188
0
        int res;
11189
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11190
0
            goto failed;
11191
0
        }
11192
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
11193
0
        _Py_LeaveRecursiveCall();
11194
0
        if (res != 0) goto failed;
11195
0
        Py_CLEAR(tmp);
11196
0
    }
11197
0
    tp = state->FunctionDef_type;
11198
0
    isinstance = PyObject_IsInstance(obj, tp);
11199
0
    if (isinstance == -1) {
11200
0
        return -1;
11201
0
    }
11202
0
    if (isinstance) {
11203
0
        identifier name;
11204
0
        arguments_ty args;
11205
0
        asdl_stmt_seq* body;
11206
0
        asdl_expr_seq* decorator_list;
11207
0
        expr_ty returns;
11208
0
        string type_comment;
11209
0
        asdl_type_param_seq* type_params;
11210
11211
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11212
0
            return -1;
11213
0
        }
11214
0
        if (tmp == NULL) {
11215
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11216
0
            return -1;
11217
0
        }
11218
0
        else {
11219
0
            int res;
11220
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11221
0
                goto failed;
11222
0
            }
11223
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11224
0
            _Py_LeaveRecursiveCall();
11225
0
            if (res != 0) goto failed;
11226
0
            Py_CLEAR(tmp);
11227
0
        }
11228
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11229
0
            return -1;
11230
0
        }
11231
0
        if (tmp == NULL) {
11232
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11233
0
            return -1;
11234
0
        }
11235
0
        else {
11236
0
            int res;
11237
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11238
0
                goto failed;
11239
0
            }
11240
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11241
0
            _Py_LeaveRecursiveCall();
11242
0
            if (res != 0) goto failed;
11243
0
            Py_CLEAR(tmp);
11244
0
        }
11245
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11246
0
            return -1;
11247
0
        }
11248
0
        if (tmp == NULL) {
11249
0
            tmp = PyList_New(0);
11250
0
            if (tmp == NULL) {
11251
0
                return -1;
11252
0
            }
11253
0
        }
11254
0
        {
11255
0
            int res;
11256
0
            Py_ssize_t len;
11257
0
            Py_ssize_t i;
11258
0
            if (!PyList_Check(tmp)) {
11259
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11260
0
                goto failed;
11261
0
            }
11262
0
            len = PyList_GET_SIZE(tmp);
11263
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11264
0
            if (body == NULL) goto failed;
11265
0
            for (i = 0; i < len; i++) {
11266
0
                stmt_ty val;
11267
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11268
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11269
0
                    goto failed;
11270
0
                }
11271
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11272
0
                _Py_LeaveRecursiveCall();
11273
0
                Py_DECREF(tmp2);
11274
0
                if (res != 0) goto failed;
11275
0
                if (len != PyList_GET_SIZE(tmp)) {
11276
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11277
0
                    goto failed;
11278
0
                }
11279
0
                asdl_seq_SET(body, i, val);
11280
0
            }
11281
0
            Py_CLEAR(tmp);
11282
0
        }
11283
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11284
0
            return -1;
11285
0
        }
11286
0
        if (tmp == NULL) {
11287
0
            tmp = PyList_New(0);
11288
0
            if (tmp == NULL) {
11289
0
                return -1;
11290
0
            }
11291
0
        }
11292
0
        {
11293
0
            int res;
11294
0
            Py_ssize_t len;
11295
0
            Py_ssize_t i;
11296
0
            if (!PyList_Check(tmp)) {
11297
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11298
0
                goto failed;
11299
0
            }
11300
0
            len = PyList_GET_SIZE(tmp);
11301
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11302
0
            if (decorator_list == NULL) goto failed;
11303
0
            for (i = 0; i < len; i++) {
11304
0
                expr_ty val;
11305
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11306
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11307
0
                    goto failed;
11308
0
                }
11309
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11310
0
                _Py_LeaveRecursiveCall();
11311
0
                Py_DECREF(tmp2);
11312
0
                if (res != 0) goto failed;
11313
0
                if (len != PyList_GET_SIZE(tmp)) {
11314
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11315
0
                    goto failed;
11316
0
                }
11317
0
                asdl_seq_SET(decorator_list, i, val);
11318
0
            }
11319
0
            Py_CLEAR(tmp);
11320
0
        }
11321
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11322
0
            return -1;
11323
0
        }
11324
0
        if (tmp == NULL || tmp == Py_None) {
11325
0
            Py_CLEAR(tmp);
11326
0
            returns = NULL;
11327
0
        }
11328
0
        else {
11329
0
            int res;
11330
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11331
0
                goto failed;
11332
0
            }
11333
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11334
0
            _Py_LeaveRecursiveCall();
11335
0
            if (res != 0) goto failed;
11336
0
            Py_CLEAR(tmp);
11337
0
        }
11338
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11339
0
            return -1;
11340
0
        }
11341
0
        if (tmp == NULL || tmp == Py_None) {
11342
0
            Py_CLEAR(tmp);
11343
0
            type_comment = NULL;
11344
0
        }
11345
0
        else {
11346
0
            int res;
11347
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11348
0
                goto failed;
11349
0
            }
11350
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11351
0
            _Py_LeaveRecursiveCall();
11352
0
            if (res != 0) goto failed;
11353
0
            Py_CLEAR(tmp);
11354
0
        }
11355
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11356
0
            return -1;
11357
0
        }
11358
0
        if (tmp == NULL) {
11359
0
            tmp = PyList_New(0);
11360
0
            if (tmp == NULL) {
11361
0
                return -1;
11362
0
            }
11363
0
        }
11364
0
        {
11365
0
            int res;
11366
0
            Py_ssize_t len;
11367
0
            Py_ssize_t i;
11368
0
            if (!PyList_Check(tmp)) {
11369
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11370
0
                goto failed;
11371
0
            }
11372
0
            len = PyList_GET_SIZE(tmp);
11373
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11374
0
            if (type_params == NULL) goto failed;
11375
0
            for (i = 0; i < len; i++) {
11376
0
                type_param_ty val;
11377
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11378
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11379
0
                    goto failed;
11380
0
                }
11381
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11382
0
                _Py_LeaveRecursiveCall();
11383
0
                Py_DECREF(tmp2);
11384
0
                if (res != 0) goto failed;
11385
0
                if (len != PyList_GET_SIZE(tmp)) {
11386
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11387
0
                    goto failed;
11388
0
                }
11389
0
                asdl_seq_SET(type_params, i, val);
11390
0
            }
11391
0
            Py_CLEAR(tmp);
11392
0
        }
11393
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11394
0
                                  type_comment, type_params, lineno,
11395
0
                                  col_offset, end_lineno, end_col_offset,
11396
0
                                  arena);
11397
0
        if (*out == NULL) goto failed;
11398
0
        return 0;
11399
0
    }
11400
0
    tp = state->AsyncFunctionDef_type;
11401
0
    isinstance = PyObject_IsInstance(obj, tp);
11402
0
    if (isinstance == -1) {
11403
0
        return -1;
11404
0
    }
11405
0
    if (isinstance) {
11406
0
        identifier name;
11407
0
        arguments_ty args;
11408
0
        asdl_stmt_seq* body;
11409
0
        asdl_expr_seq* decorator_list;
11410
0
        expr_ty returns;
11411
0
        string type_comment;
11412
0
        asdl_type_param_seq* type_params;
11413
11414
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11415
0
            return -1;
11416
0
        }
11417
0
        if (tmp == NULL) {
11418
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11419
0
            return -1;
11420
0
        }
11421
0
        else {
11422
0
            int res;
11423
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11424
0
                goto failed;
11425
0
            }
11426
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11427
0
            _Py_LeaveRecursiveCall();
11428
0
            if (res != 0) goto failed;
11429
0
            Py_CLEAR(tmp);
11430
0
        }
11431
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11432
0
            return -1;
11433
0
        }
11434
0
        if (tmp == NULL) {
11435
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11436
0
            return -1;
11437
0
        }
11438
0
        else {
11439
0
            int res;
11440
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11441
0
                goto failed;
11442
0
            }
11443
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11444
0
            _Py_LeaveRecursiveCall();
11445
0
            if (res != 0) goto failed;
11446
0
            Py_CLEAR(tmp);
11447
0
        }
11448
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11449
0
            return -1;
11450
0
        }
11451
0
        if (tmp == NULL) {
11452
0
            tmp = PyList_New(0);
11453
0
            if (tmp == NULL) {
11454
0
                return -1;
11455
0
            }
11456
0
        }
11457
0
        {
11458
0
            int res;
11459
0
            Py_ssize_t len;
11460
0
            Py_ssize_t i;
11461
0
            if (!PyList_Check(tmp)) {
11462
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11463
0
                goto failed;
11464
0
            }
11465
0
            len = PyList_GET_SIZE(tmp);
11466
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11467
0
            if (body == NULL) goto failed;
11468
0
            for (i = 0; i < len; i++) {
11469
0
                stmt_ty val;
11470
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11471
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11472
0
                    goto failed;
11473
0
                }
11474
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11475
0
                _Py_LeaveRecursiveCall();
11476
0
                Py_DECREF(tmp2);
11477
0
                if (res != 0) goto failed;
11478
0
                if (len != PyList_GET_SIZE(tmp)) {
11479
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11480
0
                    goto failed;
11481
0
                }
11482
0
                asdl_seq_SET(body, i, val);
11483
0
            }
11484
0
            Py_CLEAR(tmp);
11485
0
        }
11486
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11487
0
            return -1;
11488
0
        }
11489
0
        if (tmp == NULL) {
11490
0
            tmp = PyList_New(0);
11491
0
            if (tmp == NULL) {
11492
0
                return -1;
11493
0
            }
11494
0
        }
11495
0
        {
11496
0
            int res;
11497
0
            Py_ssize_t len;
11498
0
            Py_ssize_t i;
11499
0
            if (!PyList_Check(tmp)) {
11500
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11501
0
                goto failed;
11502
0
            }
11503
0
            len = PyList_GET_SIZE(tmp);
11504
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11505
0
            if (decorator_list == NULL) goto failed;
11506
0
            for (i = 0; i < len; i++) {
11507
0
                expr_ty val;
11508
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11509
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11510
0
                    goto failed;
11511
0
                }
11512
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11513
0
                _Py_LeaveRecursiveCall();
11514
0
                Py_DECREF(tmp2);
11515
0
                if (res != 0) goto failed;
11516
0
                if (len != PyList_GET_SIZE(tmp)) {
11517
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11518
0
                    goto failed;
11519
0
                }
11520
0
                asdl_seq_SET(decorator_list, i, val);
11521
0
            }
11522
0
            Py_CLEAR(tmp);
11523
0
        }
11524
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11525
0
            return -1;
11526
0
        }
11527
0
        if (tmp == NULL || tmp == Py_None) {
11528
0
            Py_CLEAR(tmp);
11529
0
            returns = NULL;
11530
0
        }
11531
0
        else {
11532
0
            int res;
11533
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11534
0
                goto failed;
11535
0
            }
11536
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11537
0
            _Py_LeaveRecursiveCall();
11538
0
            if (res != 0) goto failed;
11539
0
            Py_CLEAR(tmp);
11540
0
        }
11541
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11542
0
            return -1;
11543
0
        }
11544
0
        if (tmp == NULL || tmp == Py_None) {
11545
0
            Py_CLEAR(tmp);
11546
0
            type_comment = NULL;
11547
0
        }
11548
0
        else {
11549
0
            int res;
11550
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11551
0
                goto failed;
11552
0
            }
11553
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11554
0
            _Py_LeaveRecursiveCall();
11555
0
            if (res != 0) goto failed;
11556
0
            Py_CLEAR(tmp);
11557
0
        }
11558
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11559
0
            return -1;
11560
0
        }
11561
0
        if (tmp == NULL) {
11562
0
            tmp = PyList_New(0);
11563
0
            if (tmp == NULL) {
11564
0
                return -1;
11565
0
            }
11566
0
        }
11567
0
        {
11568
0
            int res;
11569
0
            Py_ssize_t len;
11570
0
            Py_ssize_t i;
11571
0
            if (!PyList_Check(tmp)) {
11572
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11573
0
                goto failed;
11574
0
            }
11575
0
            len = PyList_GET_SIZE(tmp);
11576
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11577
0
            if (type_params == NULL) goto failed;
11578
0
            for (i = 0; i < len; i++) {
11579
0
                type_param_ty val;
11580
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11581
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11582
0
                    goto failed;
11583
0
                }
11584
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11585
0
                _Py_LeaveRecursiveCall();
11586
0
                Py_DECREF(tmp2);
11587
0
                if (res != 0) goto failed;
11588
0
                if (len != PyList_GET_SIZE(tmp)) {
11589
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11590
0
                    goto failed;
11591
0
                }
11592
0
                asdl_seq_SET(type_params, i, val);
11593
0
            }
11594
0
            Py_CLEAR(tmp);
11595
0
        }
11596
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11597
0
                                       returns, type_comment, type_params,
11598
0
                                       lineno, col_offset, end_lineno,
11599
0
                                       end_col_offset, arena);
11600
0
        if (*out == NULL) goto failed;
11601
0
        return 0;
11602
0
    }
11603
0
    tp = state->ClassDef_type;
11604
0
    isinstance = PyObject_IsInstance(obj, tp);
11605
0
    if (isinstance == -1) {
11606
0
        return -1;
11607
0
    }
11608
0
    if (isinstance) {
11609
0
        identifier name;
11610
0
        asdl_expr_seq* bases;
11611
0
        asdl_keyword_seq* keywords;
11612
0
        asdl_stmt_seq* body;
11613
0
        asdl_expr_seq* decorator_list;
11614
0
        asdl_type_param_seq* type_params;
11615
11616
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11617
0
            return -1;
11618
0
        }
11619
0
        if (tmp == NULL) {
11620
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11621
0
            return -1;
11622
0
        }
11623
0
        else {
11624
0
            int res;
11625
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11626
0
                goto failed;
11627
0
            }
11628
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11629
0
            _Py_LeaveRecursiveCall();
11630
0
            if (res != 0) goto failed;
11631
0
            Py_CLEAR(tmp);
11632
0
        }
11633
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11634
0
            return -1;
11635
0
        }
11636
0
        if (tmp == NULL) {
11637
0
            tmp = PyList_New(0);
11638
0
            if (tmp == NULL) {
11639
0
                return -1;
11640
0
            }
11641
0
        }
11642
0
        {
11643
0
            int res;
11644
0
            Py_ssize_t len;
11645
0
            Py_ssize_t i;
11646
0
            if (!PyList_Check(tmp)) {
11647
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11648
0
                goto failed;
11649
0
            }
11650
0
            len = PyList_GET_SIZE(tmp);
11651
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11652
0
            if (bases == NULL) goto failed;
11653
0
            for (i = 0; i < len; i++) {
11654
0
                expr_ty val;
11655
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11656
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11657
0
                    goto failed;
11658
0
                }
11659
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11660
0
                _Py_LeaveRecursiveCall();
11661
0
                Py_DECREF(tmp2);
11662
0
                if (res != 0) goto failed;
11663
0
                if (len != PyList_GET_SIZE(tmp)) {
11664
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11665
0
                    goto failed;
11666
0
                }
11667
0
                asdl_seq_SET(bases, i, val);
11668
0
            }
11669
0
            Py_CLEAR(tmp);
11670
0
        }
11671
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11672
0
            return -1;
11673
0
        }
11674
0
        if (tmp == NULL) {
11675
0
            tmp = PyList_New(0);
11676
0
            if (tmp == NULL) {
11677
0
                return -1;
11678
0
            }
11679
0
        }
11680
0
        {
11681
0
            int res;
11682
0
            Py_ssize_t len;
11683
0
            Py_ssize_t i;
11684
0
            if (!PyList_Check(tmp)) {
11685
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11686
0
                goto failed;
11687
0
            }
11688
0
            len = PyList_GET_SIZE(tmp);
11689
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11690
0
            if (keywords == NULL) goto failed;
11691
0
            for (i = 0; i < len; i++) {
11692
0
                keyword_ty val;
11693
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11694
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11695
0
                    goto failed;
11696
0
                }
11697
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
11698
0
                _Py_LeaveRecursiveCall();
11699
0
                Py_DECREF(tmp2);
11700
0
                if (res != 0) goto failed;
11701
0
                if (len != PyList_GET_SIZE(tmp)) {
11702
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11703
0
                    goto failed;
11704
0
                }
11705
0
                asdl_seq_SET(keywords, i, val);
11706
0
            }
11707
0
            Py_CLEAR(tmp);
11708
0
        }
11709
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11710
0
            return -1;
11711
0
        }
11712
0
        if (tmp == NULL) {
11713
0
            tmp = PyList_New(0);
11714
0
            if (tmp == NULL) {
11715
0
                return -1;
11716
0
            }
11717
0
        }
11718
0
        {
11719
0
            int res;
11720
0
            Py_ssize_t len;
11721
0
            Py_ssize_t i;
11722
0
            if (!PyList_Check(tmp)) {
11723
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11724
0
                goto failed;
11725
0
            }
11726
0
            len = PyList_GET_SIZE(tmp);
11727
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11728
0
            if (body == NULL) goto failed;
11729
0
            for (i = 0; i < len; i++) {
11730
0
                stmt_ty val;
11731
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11732
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11733
0
                    goto failed;
11734
0
                }
11735
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11736
0
                _Py_LeaveRecursiveCall();
11737
0
                Py_DECREF(tmp2);
11738
0
                if (res != 0) goto failed;
11739
0
                if (len != PyList_GET_SIZE(tmp)) {
11740
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11741
0
                    goto failed;
11742
0
                }
11743
0
                asdl_seq_SET(body, i, val);
11744
0
            }
11745
0
            Py_CLEAR(tmp);
11746
0
        }
11747
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11748
0
            return -1;
11749
0
        }
11750
0
        if (tmp == NULL) {
11751
0
            tmp = PyList_New(0);
11752
0
            if (tmp == NULL) {
11753
0
                return -1;
11754
0
            }
11755
0
        }
11756
0
        {
11757
0
            int res;
11758
0
            Py_ssize_t len;
11759
0
            Py_ssize_t i;
11760
0
            if (!PyList_Check(tmp)) {
11761
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11762
0
                goto failed;
11763
0
            }
11764
0
            len = PyList_GET_SIZE(tmp);
11765
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11766
0
            if (decorator_list == NULL) goto failed;
11767
0
            for (i = 0; i < len; i++) {
11768
0
                expr_ty val;
11769
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11770
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11771
0
                    goto failed;
11772
0
                }
11773
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11774
0
                _Py_LeaveRecursiveCall();
11775
0
                Py_DECREF(tmp2);
11776
0
                if (res != 0) goto failed;
11777
0
                if (len != PyList_GET_SIZE(tmp)) {
11778
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11779
0
                    goto failed;
11780
0
                }
11781
0
                asdl_seq_SET(decorator_list, i, val);
11782
0
            }
11783
0
            Py_CLEAR(tmp);
11784
0
        }
11785
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11786
0
            return -1;
11787
0
        }
11788
0
        if (tmp == NULL) {
11789
0
            tmp = PyList_New(0);
11790
0
            if (tmp == NULL) {
11791
0
                return -1;
11792
0
            }
11793
0
        }
11794
0
        {
11795
0
            int res;
11796
0
            Py_ssize_t len;
11797
0
            Py_ssize_t i;
11798
0
            if (!PyList_Check(tmp)) {
11799
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11800
0
                goto failed;
11801
0
            }
11802
0
            len = PyList_GET_SIZE(tmp);
11803
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11804
0
            if (type_params == NULL) goto failed;
11805
0
            for (i = 0; i < len; i++) {
11806
0
                type_param_ty val;
11807
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11808
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11809
0
                    goto failed;
11810
0
                }
11811
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11812
0
                _Py_LeaveRecursiveCall();
11813
0
                Py_DECREF(tmp2);
11814
0
                if (res != 0) goto failed;
11815
0
                if (len != PyList_GET_SIZE(tmp)) {
11816
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11817
0
                    goto failed;
11818
0
                }
11819
0
                asdl_seq_SET(type_params, i, val);
11820
0
            }
11821
0
            Py_CLEAR(tmp);
11822
0
        }
11823
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11824
0
                               type_params, lineno, col_offset, end_lineno,
11825
0
                               end_col_offset, arena);
11826
0
        if (*out == NULL) goto failed;
11827
0
        return 0;
11828
0
    }
11829
0
    tp = state->Return_type;
11830
0
    isinstance = PyObject_IsInstance(obj, tp);
11831
0
    if (isinstance == -1) {
11832
0
        return -1;
11833
0
    }
11834
0
    if (isinstance) {
11835
0
        expr_ty value;
11836
11837
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11838
0
            return -1;
11839
0
        }
11840
0
        if (tmp == NULL || tmp == Py_None) {
11841
0
            Py_CLEAR(tmp);
11842
0
            value = NULL;
11843
0
        }
11844
0
        else {
11845
0
            int res;
11846
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11847
0
                goto failed;
11848
0
            }
11849
0
            res = obj2ast_expr(state, tmp, &value, arena);
11850
0
            _Py_LeaveRecursiveCall();
11851
0
            if (res != 0) goto failed;
11852
0
            Py_CLEAR(tmp);
11853
0
        }
11854
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11855
0
                             end_col_offset, arena);
11856
0
        if (*out == NULL) goto failed;
11857
0
        return 0;
11858
0
    }
11859
0
    tp = state->Delete_type;
11860
0
    isinstance = PyObject_IsInstance(obj, tp);
11861
0
    if (isinstance == -1) {
11862
0
        return -1;
11863
0
    }
11864
0
    if (isinstance) {
11865
0
        asdl_expr_seq* targets;
11866
11867
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11868
0
            return -1;
11869
0
        }
11870
0
        if (tmp == NULL) {
11871
0
            tmp = PyList_New(0);
11872
0
            if (tmp == NULL) {
11873
0
                return -1;
11874
0
            }
11875
0
        }
11876
0
        {
11877
0
            int res;
11878
0
            Py_ssize_t len;
11879
0
            Py_ssize_t i;
11880
0
            if (!PyList_Check(tmp)) {
11881
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11882
0
                goto failed;
11883
0
            }
11884
0
            len = PyList_GET_SIZE(tmp);
11885
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11886
0
            if (targets == NULL) goto failed;
11887
0
            for (i = 0; i < len; i++) {
11888
0
                expr_ty val;
11889
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11890
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11891
0
                    goto failed;
11892
0
                }
11893
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11894
0
                _Py_LeaveRecursiveCall();
11895
0
                Py_DECREF(tmp2);
11896
0
                if (res != 0) goto failed;
11897
0
                if (len != PyList_GET_SIZE(tmp)) {
11898
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11899
0
                    goto failed;
11900
0
                }
11901
0
                asdl_seq_SET(targets, i, val);
11902
0
            }
11903
0
            Py_CLEAR(tmp);
11904
0
        }
11905
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11906
0
                             end_col_offset, arena);
11907
0
        if (*out == NULL) goto failed;
11908
0
        return 0;
11909
0
    }
11910
0
    tp = state->Assign_type;
11911
0
    isinstance = PyObject_IsInstance(obj, tp);
11912
0
    if (isinstance == -1) {
11913
0
        return -1;
11914
0
    }
11915
0
    if (isinstance) {
11916
0
        asdl_expr_seq* targets;
11917
0
        expr_ty value;
11918
0
        string type_comment;
11919
11920
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11921
0
            return -1;
11922
0
        }
11923
0
        if (tmp == NULL) {
11924
0
            tmp = PyList_New(0);
11925
0
            if (tmp == NULL) {
11926
0
                return -1;
11927
0
            }
11928
0
        }
11929
0
        {
11930
0
            int res;
11931
0
            Py_ssize_t len;
11932
0
            Py_ssize_t i;
11933
0
            if (!PyList_Check(tmp)) {
11934
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11935
0
                goto failed;
11936
0
            }
11937
0
            len = PyList_GET_SIZE(tmp);
11938
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11939
0
            if (targets == NULL) goto failed;
11940
0
            for (i = 0; i < len; i++) {
11941
0
                expr_ty val;
11942
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11943
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11944
0
                    goto failed;
11945
0
                }
11946
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11947
0
                _Py_LeaveRecursiveCall();
11948
0
                Py_DECREF(tmp2);
11949
0
                if (res != 0) goto failed;
11950
0
                if (len != PyList_GET_SIZE(tmp)) {
11951
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
11952
0
                    goto failed;
11953
0
                }
11954
0
                asdl_seq_SET(targets, i, val);
11955
0
            }
11956
0
            Py_CLEAR(tmp);
11957
0
        }
11958
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11959
0
            return -1;
11960
0
        }
11961
0
        if (tmp == NULL) {
11962
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11963
0
            return -1;
11964
0
        }
11965
0
        else {
11966
0
            int res;
11967
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11968
0
                goto failed;
11969
0
            }
11970
0
            res = obj2ast_expr(state, tmp, &value, arena);
11971
0
            _Py_LeaveRecursiveCall();
11972
0
            if (res != 0) goto failed;
11973
0
            Py_CLEAR(tmp);
11974
0
        }
11975
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11976
0
            return -1;
11977
0
        }
11978
0
        if (tmp == NULL || tmp == Py_None) {
11979
0
            Py_CLEAR(tmp);
11980
0
            type_comment = NULL;
11981
0
        }
11982
0
        else {
11983
0
            int res;
11984
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11985
0
                goto failed;
11986
0
            }
11987
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11988
0
            _Py_LeaveRecursiveCall();
11989
0
            if (res != 0) goto failed;
11990
0
            Py_CLEAR(tmp);
11991
0
        }
11992
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
11993
0
                             end_lineno, end_col_offset, arena);
11994
0
        if (*out == NULL) goto failed;
11995
0
        return 0;
11996
0
    }
11997
0
    tp = state->TypeAlias_type;
11998
0
    isinstance = PyObject_IsInstance(obj, tp);
11999
0
    if (isinstance == -1) {
12000
0
        return -1;
12001
0
    }
12002
0
    if (isinstance) {
12003
0
        expr_ty name;
12004
0
        asdl_type_param_seq* type_params;
12005
0
        expr_ty value;
12006
12007
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12008
0
            return -1;
12009
0
        }
12010
0
        if (tmp == NULL) {
12011
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12012
0
            return -1;
12013
0
        }
12014
0
        else {
12015
0
            int res;
12016
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12017
0
                goto failed;
12018
0
            }
12019
0
            res = obj2ast_expr(state, tmp, &name, arena);
12020
0
            _Py_LeaveRecursiveCall();
12021
0
            if (res != 0) goto failed;
12022
0
            Py_CLEAR(tmp);
12023
0
        }
12024
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12025
0
            return -1;
12026
0
        }
12027
0
        if (tmp == NULL) {
12028
0
            tmp = PyList_New(0);
12029
0
            if (tmp == NULL) {
12030
0
                return -1;
12031
0
            }
12032
0
        }
12033
0
        {
12034
0
            int res;
12035
0
            Py_ssize_t len;
12036
0
            Py_ssize_t i;
12037
0
            if (!PyList_Check(tmp)) {
12038
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12039
0
                goto failed;
12040
0
            }
12041
0
            len = PyList_GET_SIZE(tmp);
12042
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12043
0
            if (type_params == NULL) goto failed;
12044
0
            for (i = 0; i < len; i++) {
12045
0
                type_param_ty val;
12046
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12047
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12048
0
                    goto failed;
12049
0
                }
12050
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
12051
0
                _Py_LeaveRecursiveCall();
12052
0
                Py_DECREF(tmp2);
12053
0
                if (res != 0) goto failed;
12054
0
                if (len != PyList_GET_SIZE(tmp)) {
12055
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12056
0
                    goto failed;
12057
0
                }
12058
0
                asdl_seq_SET(type_params, i, val);
12059
0
            }
12060
0
            Py_CLEAR(tmp);
12061
0
        }
12062
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12063
0
            return -1;
12064
0
        }
12065
0
        if (tmp == NULL) {
12066
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12067
0
            return -1;
12068
0
        }
12069
0
        else {
12070
0
            int res;
12071
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12072
0
                goto failed;
12073
0
            }
12074
0
            res = obj2ast_expr(state, tmp, &value, arena);
12075
0
            _Py_LeaveRecursiveCall();
12076
0
            if (res != 0) goto failed;
12077
0
            Py_CLEAR(tmp);
12078
0
        }
12079
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12080
0
                                end_lineno, end_col_offset, arena);
12081
0
        if (*out == NULL) goto failed;
12082
0
        return 0;
12083
0
    }
12084
0
    tp = state->AugAssign_type;
12085
0
    isinstance = PyObject_IsInstance(obj, tp);
12086
0
    if (isinstance == -1) {
12087
0
        return -1;
12088
0
    }
12089
0
    if (isinstance) {
12090
0
        expr_ty target;
12091
0
        operator_ty op;
12092
0
        expr_ty value;
12093
12094
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12095
0
            return -1;
12096
0
        }
12097
0
        if (tmp == NULL) {
12098
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12099
0
            return -1;
12100
0
        }
12101
0
        else {
12102
0
            int res;
12103
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12104
0
                goto failed;
12105
0
            }
12106
0
            res = obj2ast_expr(state, tmp, &target, arena);
12107
0
            _Py_LeaveRecursiveCall();
12108
0
            if (res != 0) goto failed;
12109
0
            Py_CLEAR(tmp);
12110
0
        }
12111
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12112
0
            return -1;
12113
0
        }
12114
0
        if (tmp == NULL) {
12115
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12116
0
            return -1;
12117
0
        }
12118
0
        else {
12119
0
            int res;
12120
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12121
0
                goto failed;
12122
0
            }
12123
0
            res = obj2ast_operator(state, tmp, &op, arena);
12124
0
            _Py_LeaveRecursiveCall();
12125
0
            if (res != 0) goto failed;
12126
0
            Py_CLEAR(tmp);
12127
0
        }
12128
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12129
0
            return -1;
12130
0
        }
12131
0
        if (tmp == NULL) {
12132
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" 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, &value, arena);
12141
0
            _Py_LeaveRecursiveCall();
12142
0
            if (res != 0) goto failed;
12143
0
            Py_CLEAR(tmp);
12144
0
        }
12145
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12146
0
                                end_lineno, end_col_offset, arena);
12147
0
        if (*out == NULL) goto failed;
12148
0
        return 0;
12149
0
    }
12150
0
    tp = state->AnnAssign_type;
12151
0
    isinstance = PyObject_IsInstance(obj, tp);
12152
0
    if (isinstance == -1) {
12153
0
        return -1;
12154
0
    }
12155
0
    if (isinstance) {
12156
0
        expr_ty target;
12157
0
        expr_ty annotation;
12158
0
        expr_ty value;
12159
0
        int simple;
12160
12161
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12162
0
            return -1;
12163
0
        }
12164
0
        if (tmp == NULL) {
12165
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12166
0
            return -1;
12167
0
        }
12168
0
        else {
12169
0
            int res;
12170
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12171
0
                goto failed;
12172
0
            }
12173
0
            res = obj2ast_expr(state, tmp, &target, arena);
12174
0
            _Py_LeaveRecursiveCall();
12175
0
            if (res != 0) goto failed;
12176
0
            Py_CLEAR(tmp);
12177
0
        }
12178
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12179
0
            return -1;
12180
0
        }
12181
0
        if (tmp == NULL) {
12182
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12183
0
            return -1;
12184
0
        }
12185
0
        else {
12186
0
            int res;
12187
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12188
0
                goto failed;
12189
0
            }
12190
0
            res = obj2ast_expr(state, tmp, &annotation, arena);
12191
0
            _Py_LeaveRecursiveCall();
12192
0
            if (res != 0) goto failed;
12193
0
            Py_CLEAR(tmp);
12194
0
        }
12195
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12196
0
            return -1;
12197
0
        }
12198
0
        if (tmp == NULL || tmp == Py_None) {
12199
0
            Py_CLEAR(tmp);
12200
0
            value = NULL;
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, &value, 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->simple, &tmp) < 0) {
12213
0
            return -1;
12214
0
        }
12215
0
        if (tmp == NULL) {
12216
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" 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_int(state, tmp, &simple, arena);
12225
0
            _Py_LeaveRecursiveCall();
12226
0
            if (res != 0) goto failed;
12227
0
            Py_CLEAR(tmp);
12228
0
        }
12229
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12230
0
                                col_offset, end_lineno, end_col_offset, arena);
12231
0
        if (*out == NULL) goto failed;
12232
0
        return 0;
12233
0
    }
12234
0
    tp = state->For_type;
12235
0
    isinstance = PyObject_IsInstance(obj, tp);
12236
0
    if (isinstance == -1) {
12237
0
        return -1;
12238
0
    }
12239
0
    if (isinstance) {
12240
0
        expr_ty target;
12241
0
        expr_ty iter;
12242
0
        asdl_stmt_seq* body;
12243
0
        asdl_stmt_seq* orelse;
12244
0
        string type_comment;
12245
12246
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12247
0
            return -1;
12248
0
        }
12249
0
        if (tmp == NULL) {
12250
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12251
0
            return -1;
12252
0
        }
12253
0
        else {
12254
0
            int res;
12255
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12256
0
                goto failed;
12257
0
            }
12258
0
            res = obj2ast_expr(state, tmp, &target, arena);
12259
0
            _Py_LeaveRecursiveCall();
12260
0
            if (res != 0) goto failed;
12261
0
            Py_CLEAR(tmp);
12262
0
        }
12263
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12264
0
            return -1;
12265
0
        }
12266
0
        if (tmp == NULL) {
12267
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12268
0
            return -1;
12269
0
        }
12270
0
        else {
12271
0
            int res;
12272
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12273
0
                goto failed;
12274
0
            }
12275
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12276
0
            _Py_LeaveRecursiveCall();
12277
0
            if (res != 0) goto failed;
12278
0
            Py_CLEAR(tmp);
12279
0
        }
12280
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12281
0
            return -1;
12282
0
        }
12283
0
        if (tmp == NULL) {
12284
0
            tmp = PyList_New(0);
12285
0
            if (tmp == NULL) {
12286
0
                return -1;
12287
0
            }
12288
0
        }
12289
0
        {
12290
0
            int res;
12291
0
            Py_ssize_t len;
12292
0
            Py_ssize_t i;
12293
0
            if (!PyList_Check(tmp)) {
12294
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12295
0
                goto failed;
12296
0
            }
12297
0
            len = PyList_GET_SIZE(tmp);
12298
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12299
0
            if (body == NULL) goto failed;
12300
0
            for (i = 0; i < len; i++) {
12301
0
                stmt_ty val;
12302
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12303
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12304
0
                    goto failed;
12305
0
                }
12306
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12307
0
                _Py_LeaveRecursiveCall();
12308
0
                Py_DECREF(tmp2);
12309
0
                if (res != 0) goto failed;
12310
0
                if (len != PyList_GET_SIZE(tmp)) {
12311
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12312
0
                    goto failed;
12313
0
                }
12314
0
                asdl_seq_SET(body, i, val);
12315
0
            }
12316
0
            Py_CLEAR(tmp);
12317
0
        }
12318
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12319
0
            return -1;
12320
0
        }
12321
0
        if (tmp == NULL) {
12322
0
            tmp = PyList_New(0);
12323
0
            if (tmp == NULL) {
12324
0
                return -1;
12325
0
            }
12326
0
        }
12327
0
        {
12328
0
            int res;
12329
0
            Py_ssize_t len;
12330
0
            Py_ssize_t i;
12331
0
            if (!PyList_Check(tmp)) {
12332
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12333
0
                goto failed;
12334
0
            }
12335
0
            len = PyList_GET_SIZE(tmp);
12336
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12337
0
            if (orelse == NULL) goto failed;
12338
0
            for (i = 0; i < len; i++) {
12339
0
                stmt_ty val;
12340
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12341
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12342
0
                    goto failed;
12343
0
                }
12344
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12345
0
                _Py_LeaveRecursiveCall();
12346
0
                Py_DECREF(tmp2);
12347
0
                if (res != 0) goto failed;
12348
0
                if (len != PyList_GET_SIZE(tmp)) {
12349
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12350
0
                    goto failed;
12351
0
                }
12352
0
                asdl_seq_SET(orelse, i, val);
12353
0
            }
12354
0
            Py_CLEAR(tmp);
12355
0
        }
12356
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12357
0
            return -1;
12358
0
        }
12359
0
        if (tmp == NULL || tmp == Py_None) {
12360
0
            Py_CLEAR(tmp);
12361
0
            type_comment = NULL;
12362
0
        }
12363
0
        else {
12364
0
            int res;
12365
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12366
0
                goto failed;
12367
0
            }
12368
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12369
0
            _Py_LeaveRecursiveCall();
12370
0
            if (res != 0) goto failed;
12371
0
            Py_CLEAR(tmp);
12372
0
        }
12373
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12374
0
                          col_offset, end_lineno, end_col_offset, arena);
12375
0
        if (*out == NULL) goto failed;
12376
0
        return 0;
12377
0
    }
12378
0
    tp = state->AsyncFor_type;
12379
0
    isinstance = PyObject_IsInstance(obj, tp);
12380
0
    if (isinstance == -1) {
12381
0
        return -1;
12382
0
    }
12383
0
    if (isinstance) {
12384
0
        expr_ty target;
12385
0
        expr_ty iter;
12386
0
        asdl_stmt_seq* body;
12387
0
        asdl_stmt_seq* orelse;
12388
0
        string type_comment;
12389
12390
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12391
0
            return -1;
12392
0
        }
12393
0
        if (tmp == NULL) {
12394
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12395
0
            return -1;
12396
0
        }
12397
0
        else {
12398
0
            int res;
12399
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12400
0
                goto failed;
12401
0
            }
12402
0
            res = obj2ast_expr(state, tmp, &target, arena);
12403
0
            _Py_LeaveRecursiveCall();
12404
0
            if (res != 0) goto failed;
12405
0
            Py_CLEAR(tmp);
12406
0
        }
12407
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12408
0
            return -1;
12409
0
        }
12410
0
        if (tmp == NULL) {
12411
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12412
0
            return -1;
12413
0
        }
12414
0
        else {
12415
0
            int res;
12416
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12417
0
                goto failed;
12418
0
            }
12419
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12420
0
            _Py_LeaveRecursiveCall();
12421
0
            if (res != 0) goto failed;
12422
0
            Py_CLEAR(tmp);
12423
0
        }
12424
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12425
0
            return -1;
12426
0
        }
12427
0
        if (tmp == NULL) {
12428
0
            tmp = PyList_New(0);
12429
0
            if (tmp == NULL) {
12430
0
                return -1;
12431
0
            }
12432
0
        }
12433
0
        {
12434
0
            int res;
12435
0
            Py_ssize_t len;
12436
0
            Py_ssize_t i;
12437
0
            if (!PyList_Check(tmp)) {
12438
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12439
0
                goto failed;
12440
0
            }
12441
0
            len = PyList_GET_SIZE(tmp);
12442
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12443
0
            if (body == NULL) goto failed;
12444
0
            for (i = 0; i < len; i++) {
12445
0
                stmt_ty val;
12446
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12447
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12448
0
                    goto failed;
12449
0
                }
12450
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12451
0
                _Py_LeaveRecursiveCall();
12452
0
                Py_DECREF(tmp2);
12453
0
                if (res != 0) goto failed;
12454
0
                if (len != PyList_GET_SIZE(tmp)) {
12455
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12456
0
                    goto failed;
12457
0
                }
12458
0
                asdl_seq_SET(body, i, val);
12459
0
            }
12460
0
            Py_CLEAR(tmp);
12461
0
        }
12462
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12463
0
            return -1;
12464
0
        }
12465
0
        if (tmp == NULL) {
12466
0
            tmp = PyList_New(0);
12467
0
            if (tmp == NULL) {
12468
0
                return -1;
12469
0
            }
12470
0
        }
12471
0
        {
12472
0
            int res;
12473
0
            Py_ssize_t len;
12474
0
            Py_ssize_t i;
12475
0
            if (!PyList_Check(tmp)) {
12476
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12477
0
                goto failed;
12478
0
            }
12479
0
            len = PyList_GET_SIZE(tmp);
12480
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12481
0
            if (orelse == NULL) goto failed;
12482
0
            for (i = 0; i < len; i++) {
12483
0
                stmt_ty val;
12484
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12485
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12486
0
                    goto failed;
12487
0
                }
12488
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12489
0
                _Py_LeaveRecursiveCall();
12490
0
                Py_DECREF(tmp2);
12491
0
                if (res != 0) goto failed;
12492
0
                if (len != PyList_GET_SIZE(tmp)) {
12493
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12494
0
                    goto failed;
12495
0
                }
12496
0
                asdl_seq_SET(orelse, i, val);
12497
0
            }
12498
0
            Py_CLEAR(tmp);
12499
0
        }
12500
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12501
0
            return -1;
12502
0
        }
12503
0
        if (tmp == NULL || tmp == Py_None) {
12504
0
            Py_CLEAR(tmp);
12505
0
            type_comment = NULL;
12506
0
        }
12507
0
        else {
12508
0
            int res;
12509
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12510
0
                goto failed;
12511
0
            }
12512
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12513
0
            _Py_LeaveRecursiveCall();
12514
0
            if (res != 0) goto failed;
12515
0
            Py_CLEAR(tmp);
12516
0
        }
12517
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12518
0
                               lineno, col_offset, end_lineno, end_col_offset,
12519
0
                               arena);
12520
0
        if (*out == NULL) goto failed;
12521
0
        return 0;
12522
0
    }
12523
0
    tp = state->While_type;
12524
0
    isinstance = PyObject_IsInstance(obj, tp);
12525
0
    if (isinstance == -1) {
12526
0
        return -1;
12527
0
    }
12528
0
    if (isinstance) {
12529
0
        expr_ty test;
12530
0
        asdl_stmt_seq* body;
12531
0
        asdl_stmt_seq* orelse;
12532
12533
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12534
0
            return -1;
12535
0
        }
12536
0
        if (tmp == NULL) {
12537
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12538
0
            return -1;
12539
0
        }
12540
0
        else {
12541
0
            int res;
12542
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12543
0
                goto failed;
12544
0
            }
12545
0
            res = obj2ast_expr(state, tmp, &test, arena);
12546
0
            _Py_LeaveRecursiveCall();
12547
0
            if (res != 0) goto failed;
12548
0
            Py_CLEAR(tmp);
12549
0
        }
12550
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12551
0
            return -1;
12552
0
        }
12553
0
        if (tmp == NULL) {
12554
0
            tmp = PyList_New(0);
12555
0
            if (tmp == NULL) {
12556
0
                return -1;
12557
0
            }
12558
0
        }
12559
0
        {
12560
0
            int res;
12561
0
            Py_ssize_t len;
12562
0
            Py_ssize_t i;
12563
0
            if (!PyList_Check(tmp)) {
12564
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12565
0
                goto failed;
12566
0
            }
12567
0
            len = PyList_GET_SIZE(tmp);
12568
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12569
0
            if (body == NULL) goto failed;
12570
0
            for (i = 0; i < len; i++) {
12571
0
                stmt_ty val;
12572
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12573
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12574
0
                    goto failed;
12575
0
                }
12576
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12577
0
                _Py_LeaveRecursiveCall();
12578
0
                Py_DECREF(tmp2);
12579
0
                if (res != 0) goto failed;
12580
0
                if (len != PyList_GET_SIZE(tmp)) {
12581
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12582
0
                    goto failed;
12583
0
                }
12584
0
                asdl_seq_SET(body, i, val);
12585
0
            }
12586
0
            Py_CLEAR(tmp);
12587
0
        }
12588
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12589
0
            return -1;
12590
0
        }
12591
0
        if (tmp == NULL) {
12592
0
            tmp = PyList_New(0);
12593
0
            if (tmp == NULL) {
12594
0
                return -1;
12595
0
            }
12596
0
        }
12597
0
        {
12598
0
            int res;
12599
0
            Py_ssize_t len;
12600
0
            Py_ssize_t i;
12601
0
            if (!PyList_Check(tmp)) {
12602
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12603
0
                goto failed;
12604
0
            }
12605
0
            len = PyList_GET_SIZE(tmp);
12606
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12607
0
            if (orelse == NULL) goto failed;
12608
0
            for (i = 0; i < len; i++) {
12609
0
                stmt_ty val;
12610
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12611
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12612
0
                    goto failed;
12613
0
                }
12614
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12615
0
                _Py_LeaveRecursiveCall();
12616
0
                Py_DECREF(tmp2);
12617
0
                if (res != 0) goto failed;
12618
0
                if (len != PyList_GET_SIZE(tmp)) {
12619
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12620
0
                    goto failed;
12621
0
                }
12622
0
                asdl_seq_SET(orelse, i, val);
12623
0
            }
12624
0
            Py_CLEAR(tmp);
12625
0
        }
12626
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12627
0
                            end_col_offset, arena);
12628
0
        if (*out == NULL) goto failed;
12629
0
        return 0;
12630
0
    }
12631
0
    tp = state->If_type;
12632
0
    isinstance = PyObject_IsInstance(obj, tp);
12633
0
    if (isinstance == -1) {
12634
0
        return -1;
12635
0
    }
12636
0
    if (isinstance) {
12637
0
        expr_ty test;
12638
0
        asdl_stmt_seq* body;
12639
0
        asdl_stmt_seq* orelse;
12640
12641
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12642
0
            return -1;
12643
0
        }
12644
0
        if (tmp == NULL) {
12645
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12646
0
            return -1;
12647
0
        }
12648
0
        else {
12649
0
            int res;
12650
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12651
0
                goto failed;
12652
0
            }
12653
0
            res = obj2ast_expr(state, tmp, &test, arena);
12654
0
            _Py_LeaveRecursiveCall();
12655
0
            if (res != 0) goto failed;
12656
0
            Py_CLEAR(tmp);
12657
0
        }
12658
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12659
0
            return -1;
12660
0
        }
12661
0
        if (tmp == NULL) {
12662
0
            tmp = PyList_New(0);
12663
0
            if (tmp == NULL) {
12664
0
                return -1;
12665
0
            }
12666
0
        }
12667
0
        {
12668
0
            int res;
12669
0
            Py_ssize_t len;
12670
0
            Py_ssize_t i;
12671
0
            if (!PyList_Check(tmp)) {
12672
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12673
0
                goto failed;
12674
0
            }
12675
0
            len = PyList_GET_SIZE(tmp);
12676
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12677
0
            if (body == NULL) goto failed;
12678
0
            for (i = 0; i < len; i++) {
12679
0
                stmt_ty val;
12680
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12681
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12682
0
                    goto failed;
12683
0
                }
12684
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12685
0
                _Py_LeaveRecursiveCall();
12686
0
                Py_DECREF(tmp2);
12687
0
                if (res != 0) goto failed;
12688
0
                if (len != PyList_GET_SIZE(tmp)) {
12689
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12690
0
                    goto failed;
12691
0
                }
12692
0
                asdl_seq_SET(body, i, val);
12693
0
            }
12694
0
            Py_CLEAR(tmp);
12695
0
        }
12696
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12697
0
            return -1;
12698
0
        }
12699
0
        if (tmp == NULL) {
12700
0
            tmp = PyList_New(0);
12701
0
            if (tmp == NULL) {
12702
0
                return -1;
12703
0
            }
12704
0
        }
12705
0
        {
12706
0
            int res;
12707
0
            Py_ssize_t len;
12708
0
            Py_ssize_t i;
12709
0
            if (!PyList_Check(tmp)) {
12710
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12711
0
                goto failed;
12712
0
            }
12713
0
            len = PyList_GET_SIZE(tmp);
12714
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12715
0
            if (orelse == NULL) goto failed;
12716
0
            for (i = 0; i < len; i++) {
12717
0
                stmt_ty val;
12718
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12719
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12720
0
                    goto failed;
12721
0
                }
12722
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12723
0
                _Py_LeaveRecursiveCall();
12724
0
                Py_DECREF(tmp2);
12725
0
                if (res != 0) goto failed;
12726
0
                if (len != PyList_GET_SIZE(tmp)) {
12727
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12728
0
                    goto failed;
12729
0
                }
12730
0
                asdl_seq_SET(orelse, i, val);
12731
0
            }
12732
0
            Py_CLEAR(tmp);
12733
0
        }
12734
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12735
0
                         end_col_offset, arena);
12736
0
        if (*out == NULL) goto failed;
12737
0
        return 0;
12738
0
    }
12739
0
    tp = state->With_type;
12740
0
    isinstance = PyObject_IsInstance(obj, tp);
12741
0
    if (isinstance == -1) {
12742
0
        return -1;
12743
0
    }
12744
0
    if (isinstance) {
12745
0
        asdl_withitem_seq* items;
12746
0
        asdl_stmt_seq* body;
12747
0
        string type_comment;
12748
12749
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12750
0
            return -1;
12751
0
        }
12752
0
        if (tmp == NULL) {
12753
0
            tmp = PyList_New(0);
12754
0
            if (tmp == NULL) {
12755
0
                return -1;
12756
0
            }
12757
0
        }
12758
0
        {
12759
0
            int res;
12760
0
            Py_ssize_t len;
12761
0
            Py_ssize_t i;
12762
0
            if (!PyList_Check(tmp)) {
12763
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12764
0
                goto failed;
12765
0
            }
12766
0
            len = PyList_GET_SIZE(tmp);
12767
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12768
0
            if (items == NULL) goto failed;
12769
0
            for (i = 0; i < len; i++) {
12770
0
                withitem_ty val;
12771
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12772
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12773
0
                    goto failed;
12774
0
                }
12775
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12776
0
                _Py_LeaveRecursiveCall();
12777
0
                Py_DECREF(tmp2);
12778
0
                if (res != 0) goto failed;
12779
0
                if (len != PyList_GET_SIZE(tmp)) {
12780
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12781
0
                    goto failed;
12782
0
                }
12783
0
                asdl_seq_SET(items, i, val);
12784
0
            }
12785
0
            Py_CLEAR(tmp);
12786
0
        }
12787
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12788
0
            return -1;
12789
0
        }
12790
0
        if (tmp == NULL) {
12791
0
            tmp = PyList_New(0);
12792
0
            if (tmp == NULL) {
12793
0
                return -1;
12794
0
            }
12795
0
        }
12796
0
        {
12797
0
            int res;
12798
0
            Py_ssize_t len;
12799
0
            Py_ssize_t i;
12800
0
            if (!PyList_Check(tmp)) {
12801
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12802
0
                goto failed;
12803
0
            }
12804
0
            len = PyList_GET_SIZE(tmp);
12805
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12806
0
            if (body == NULL) goto failed;
12807
0
            for (i = 0; i < len; i++) {
12808
0
                stmt_ty val;
12809
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12810
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12811
0
                    goto failed;
12812
0
                }
12813
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12814
0
                _Py_LeaveRecursiveCall();
12815
0
                Py_DECREF(tmp2);
12816
0
                if (res != 0) goto failed;
12817
0
                if (len != PyList_GET_SIZE(tmp)) {
12818
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12819
0
                    goto failed;
12820
0
                }
12821
0
                asdl_seq_SET(body, i, val);
12822
0
            }
12823
0
            Py_CLEAR(tmp);
12824
0
        }
12825
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12826
0
            return -1;
12827
0
        }
12828
0
        if (tmp == NULL || tmp == Py_None) {
12829
0
            Py_CLEAR(tmp);
12830
0
            type_comment = NULL;
12831
0
        }
12832
0
        else {
12833
0
            int res;
12834
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12835
0
                goto failed;
12836
0
            }
12837
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12838
0
            _Py_LeaveRecursiveCall();
12839
0
            if (res != 0) goto failed;
12840
0
            Py_CLEAR(tmp);
12841
0
        }
12842
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12843
0
                           end_lineno, end_col_offset, arena);
12844
0
        if (*out == NULL) goto failed;
12845
0
        return 0;
12846
0
    }
12847
0
    tp = state->AsyncWith_type;
12848
0
    isinstance = PyObject_IsInstance(obj, tp);
12849
0
    if (isinstance == -1) {
12850
0
        return -1;
12851
0
    }
12852
0
    if (isinstance) {
12853
0
        asdl_withitem_seq* items;
12854
0
        asdl_stmt_seq* body;
12855
0
        string type_comment;
12856
12857
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12858
0
            return -1;
12859
0
        }
12860
0
        if (tmp == NULL) {
12861
0
            tmp = PyList_New(0);
12862
0
            if (tmp == NULL) {
12863
0
                return -1;
12864
0
            }
12865
0
        }
12866
0
        {
12867
0
            int res;
12868
0
            Py_ssize_t len;
12869
0
            Py_ssize_t i;
12870
0
            if (!PyList_Check(tmp)) {
12871
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12872
0
                goto failed;
12873
0
            }
12874
0
            len = PyList_GET_SIZE(tmp);
12875
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12876
0
            if (items == NULL) goto failed;
12877
0
            for (i = 0; i < len; i++) {
12878
0
                withitem_ty val;
12879
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12880
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12881
0
                    goto failed;
12882
0
                }
12883
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12884
0
                _Py_LeaveRecursiveCall();
12885
0
                Py_DECREF(tmp2);
12886
0
                if (res != 0) goto failed;
12887
0
                if (len != PyList_GET_SIZE(tmp)) {
12888
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12889
0
                    goto failed;
12890
0
                }
12891
0
                asdl_seq_SET(items, i, val);
12892
0
            }
12893
0
            Py_CLEAR(tmp);
12894
0
        }
12895
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12896
0
            return -1;
12897
0
        }
12898
0
        if (tmp == NULL) {
12899
0
            tmp = PyList_New(0);
12900
0
            if (tmp == NULL) {
12901
0
                return -1;
12902
0
            }
12903
0
        }
12904
0
        {
12905
0
            int res;
12906
0
            Py_ssize_t len;
12907
0
            Py_ssize_t i;
12908
0
            if (!PyList_Check(tmp)) {
12909
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12910
0
                goto failed;
12911
0
            }
12912
0
            len = PyList_GET_SIZE(tmp);
12913
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12914
0
            if (body == NULL) goto failed;
12915
0
            for (i = 0; i < len; i++) {
12916
0
                stmt_ty val;
12917
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12918
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12919
0
                    goto failed;
12920
0
                }
12921
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12922
0
                _Py_LeaveRecursiveCall();
12923
0
                Py_DECREF(tmp2);
12924
0
                if (res != 0) goto failed;
12925
0
                if (len != PyList_GET_SIZE(tmp)) {
12926
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12927
0
                    goto failed;
12928
0
                }
12929
0
                asdl_seq_SET(body, i, val);
12930
0
            }
12931
0
            Py_CLEAR(tmp);
12932
0
        }
12933
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12934
0
            return -1;
12935
0
        }
12936
0
        if (tmp == NULL || tmp == Py_None) {
12937
0
            Py_CLEAR(tmp);
12938
0
            type_comment = NULL;
12939
0
        }
12940
0
        else {
12941
0
            int res;
12942
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12943
0
                goto failed;
12944
0
            }
12945
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12946
0
            _Py_LeaveRecursiveCall();
12947
0
            if (res != 0) goto failed;
12948
0
            Py_CLEAR(tmp);
12949
0
        }
12950
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12951
0
                                end_lineno, end_col_offset, arena);
12952
0
        if (*out == NULL) goto failed;
12953
0
        return 0;
12954
0
    }
12955
0
    tp = state->Match_type;
12956
0
    isinstance = PyObject_IsInstance(obj, tp);
12957
0
    if (isinstance == -1) {
12958
0
        return -1;
12959
0
    }
12960
0
    if (isinstance) {
12961
0
        expr_ty subject;
12962
0
        asdl_match_case_seq* cases;
12963
12964
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
12965
0
            return -1;
12966
0
        }
12967
0
        if (tmp == NULL) {
12968
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
12969
0
            return -1;
12970
0
        }
12971
0
        else {
12972
0
            int res;
12973
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
12974
0
                goto failed;
12975
0
            }
12976
0
            res = obj2ast_expr(state, tmp, &subject, arena);
12977
0
            _Py_LeaveRecursiveCall();
12978
0
            if (res != 0) goto failed;
12979
0
            Py_CLEAR(tmp);
12980
0
        }
12981
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
12982
0
            return -1;
12983
0
        }
12984
0
        if (tmp == NULL) {
12985
0
            tmp = PyList_New(0);
12986
0
            if (tmp == NULL) {
12987
0
                return -1;
12988
0
            }
12989
0
        }
12990
0
        {
12991
0
            int res;
12992
0
            Py_ssize_t len;
12993
0
            Py_ssize_t i;
12994
0
            if (!PyList_Check(tmp)) {
12995
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12996
0
                goto failed;
12997
0
            }
12998
0
            len = PyList_GET_SIZE(tmp);
12999
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13000
0
            if (cases == NULL) goto failed;
13001
0
            for (i = 0; i < len; i++) {
13002
0
                match_case_ty val;
13003
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13004
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13005
0
                    goto failed;
13006
0
                }
13007
0
                res = obj2ast_match_case(state, tmp2, &val, arena);
13008
0
                _Py_LeaveRecursiveCall();
13009
0
                Py_DECREF(tmp2);
13010
0
                if (res != 0) goto failed;
13011
0
                if (len != PyList_GET_SIZE(tmp)) {
13012
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13013
0
                    goto failed;
13014
0
                }
13015
0
                asdl_seq_SET(cases, i, val);
13016
0
            }
13017
0
            Py_CLEAR(tmp);
13018
0
        }
13019
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13020
0
                            end_col_offset, arena);
13021
0
        if (*out == NULL) goto failed;
13022
0
        return 0;
13023
0
    }
13024
0
    tp = state->Raise_type;
13025
0
    isinstance = PyObject_IsInstance(obj, tp);
13026
0
    if (isinstance == -1) {
13027
0
        return -1;
13028
0
    }
13029
0
    if (isinstance) {
13030
0
        expr_ty exc;
13031
0
        expr_ty cause;
13032
13033
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13034
0
            return -1;
13035
0
        }
13036
0
        if (tmp == NULL || tmp == Py_None) {
13037
0
            Py_CLEAR(tmp);
13038
0
            exc = NULL;
13039
0
        }
13040
0
        else {
13041
0
            int res;
13042
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13043
0
                goto failed;
13044
0
            }
13045
0
            res = obj2ast_expr(state, tmp, &exc, arena);
13046
0
            _Py_LeaveRecursiveCall();
13047
0
            if (res != 0) goto failed;
13048
0
            Py_CLEAR(tmp);
13049
0
        }
13050
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13051
0
            return -1;
13052
0
        }
13053
0
        if (tmp == NULL || tmp == Py_None) {
13054
0
            Py_CLEAR(tmp);
13055
0
            cause = NULL;
13056
0
        }
13057
0
        else {
13058
0
            int res;
13059
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13060
0
                goto failed;
13061
0
            }
13062
0
            res = obj2ast_expr(state, tmp, &cause, arena);
13063
0
            _Py_LeaveRecursiveCall();
13064
0
            if (res != 0) goto failed;
13065
0
            Py_CLEAR(tmp);
13066
0
        }
13067
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13068
0
                            end_col_offset, arena);
13069
0
        if (*out == NULL) goto failed;
13070
0
        return 0;
13071
0
    }
13072
0
    tp = state->Try_type;
13073
0
    isinstance = PyObject_IsInstance(obj, tp);
13074
0
    if (isinstance == -1) {
13075
0
        return -1;
13076
0
    }
13077
0
    if (isinstance) {
13078
0
        asdl_stmt_seq* body;
13079
0
        asdl_excepthandler_seq* handlers;
13080
0
        asdl_stmt_seq* orelse;
13081
0
        asdl_stmt_seq* finalbody;
13082
13083
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13084
0
            return -1;
13085
0
        }
13086
0
        if (tmp == NULL) {
13087
0
            tmp = PyList_New(0);
13088
0
            if (tmp == NULL) {
13089
0
                return -1;
13090
0
            }
13091
0
        }
13092
0
        {
13093
0
            int res;
13094
0
            Py_ssize_t len;
13095
0
            Py_ssize_t i;
13096
0
            if (!PyList_Check(tmp)) {
13097
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13098
0
                goto failed;
13099
0
            }
13100
0
            len = PyList_GET_SIZE(tmp);
13101
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13102
0
            if (body == NULL) goto failed;
13103
0
            for (i = 0; i < len; i++) {
13104
0
                stmt_ty val;
13105
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13106
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13107
0
                    goto failed;
13108
0
                }
13109
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13110
0
                _Py_LeaveRecursiveCall();
13111
0
                Py_DECREF(tmp2);
13112
0
                if (res != 0) goto failed;
13113
0
                if (len != PyList_GET_SIZE(tmp)) {
13114
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13115
0
                    goto failed;
13116
0
                }
13117
0
                asdl_seq_SET(body, i, val);
13118
0
            }
13119
0
            Py_CLEAR(tmp);
13120
0
        }
13121
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &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 \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13136
0
                goto failed;
13137
0
            }
13138
0
            len = PyList_GET_SIZE(tmp);
13139
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13140
0
            if (handlers == NULL) goto failed;
13141
0
            for (i = 0; i < len; i++) {
13142
0
                excepthandler_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_excepthandler(state, tmp2, &val, 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 \"handlers\" changed size during iteration");
13153
0
                    goto failed;
13154
0
                }
13155
0
                asdl_seq_SET(handlers, i, val);
13156
0
            }
13157
0
            Py_CLEAR(tmp);
13158
0
        }
13159
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &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 \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13174
0
                goto failed;
13175
0
            }
13176
0
            len = PyList_GET_SIZE(tmp);
13177
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13178
0
            if (orelse == NULL) goto failed;
13179
0
            for (i = 0; i < len; i++) {
13180
0
                stmt_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_stmt(state, tmp2, &val, 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 \"orelse\" changed size during iteration");
13191
0
                    goto failed;
13192
0
                }
13193
0
                asdl_seq_SET(orelse, i, val);
13194
0
            }
13195
0
            Py_CLEAR(tmp);
13196
0
        }
13197
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &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 \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13212
0
                goto failed;
13213
0
            }
13214
0
            len = PyList_GET_SIZE(tmp);
13215
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13216
0
            if (finalbody == 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, 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 \"finalbody\" changed size during iteration");
13229
0
                    goto failed;
13230
0
                }
13231
0
                asdl_seq_SET(finalbody, i, val);
13232
0
            }
13233
0
            Py_CLEAR(tmp);
13234
0
        }
13235
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13236
0
                          col_offset, end_lineno, end_col_offset, arena);
13237
0
        if (*out == NULL) goto failed;
13238
0
        return 0;
13239
0
    }
13240
0
    tp = state->TryStar_type;
13241
0
    isinstance = PyObject_IsInstance(obj, tp);
13242
0
    if (isinstance == -1) {
13243
0
        return -1;
13244
0
    }
13245
0
    if (isinstance) {
13246
0
        asdl_stmt_seq* body;
13247
0
        asdl_excepthandler_seq* handlers;
13248
0
        asdl_stmt_seq* orelse;
13249
0
        asdl_stmt_seq* finalbody;
13250
13251
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13252
0
            return -1;
13253
0
        }
13254
0
        if (tmp == NULL) {
13255
0
            tmp = PyList_New(0);
13256
0
            if (tmp == NULL) {
13257
0
                return -1;
13258
0
            }
13259
0
        }
13260
0
        {
13261
0
            int res;
13262
0
            Py_ssize_t len;
13263
0
            Py_ssize_t i;
13264
0
            if (!PyList_Check(tmp)) {
13265
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13266
0
                goto failed;
13267
0
            }
13268
0
            len = PyList_GET_SIZE(tmp);
13269
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13270
0
            if (body == NULL) goto failed;
13271
0
            for (i = 0; i < len; i++) {
13272
0
                stmt_ty val;
13273
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13274
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13275
0
                    goto failed;
13276
0
                }
13277
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13278
0
                _Py_LeaveRecursiveCall();
13279
0
                Py_DECREF(tmp2);
13280
0
                if (res != 0) goto failed;
13281
0
                if (len != PyList_GET_SIZE(tmp)) {
13282
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13283
0
                    goto failed;
13284
0
                }
13285
0
                asdl_seq_SET(body, i, val);
13286
0
            }
13287
0
            Py_CLEAR(tmp);
13288
0
        }
13289
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &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 \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13304
0
                goto failed;
13305
0
            }
13306
0
            len = PyList_GET_SIZE(tmp);
13307
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13308
0
            if (handlers == NULL) goto failed;
13309
0
            for (i = 0; i < len; i++) {
13310
0
                excepthandler_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_excepthandler(state, tmp2, &val, 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 \"handlers\" changed size during iteration");
13321
0
                    goto failed;
13322
0
                }
13323
0
                asdl_seq_SET(handlers, i, val);
13324
0
            }
13325
0
            Py_CLEAR(tmp);
13326
0
        }
13327
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &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 \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13342
0
                goto failed;
13343
0
            }
13344
0
            len = PyList_GET_SIZE(tmp);
13345
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13346
0
            if (orelse == NULL) goto failed;
13347
0
            for (i = 0; i < len; i++) {
13348
0
                stmt_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_stmt(state, tmp2, &val, 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 \"orelse\" changed size during iteration");
13359
0
                    goto failed;
13360
0
                }
13361
0
                asdl_seq_SET(orelse, i, val);
13362
0
            }
13363
0
            Py_CLEAR(tmp);
13364
0
        }
13365
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &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 \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13380
0
                goto failed;
13381
0
            }
13382
0
            len = PyList_GET_SIZE(tmp);
13383
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13384
0
            if (finalbody == 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, 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 \"finalbody\" changed size during iteration");
13397
0
                    goto failed;
13398
0
                }
13399
0
                asdl_seq_SET(finalbody, i, val);
13400
0
            }
13401
0
            Py_CLEAR(tmp);
13402
0
        }
13403
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13404
0
                              col_offset, end_lineno, end_col_offset, arena);
13405
0
        if (*out == NULL) goto failed;
13406
0
        return 0;
13407
0
    }
13408
0
    tp = state->Assert_type;
13409
0
    isinstance = PyObject_IsInstance(obj, tp);
13410
0
    if (isinstance == -1) {
13411
0
        return -1;
13412
0
    }
13413
0
    if (isinstance) {
13414
0
        expr_ty test;
13415
0
        expr_ty msg;
13416
13417
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13418
0
            return -1;
13419
0
        }
13420
0
        if (tmp == NULL) {
13421
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13422
0
            return -1;
13423
0
        }
13424
0
        else {
13425
0
            int res;
13426
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13427
0
                goto failed;
13428
0
            }
13429
0
            res = obj2ast_expr(state, tmp, &test, arena);
13430
0
            _Py_LeaveRecursiveCall();
13431
0
            if (res != 0) goto failed;
13432
0
            Py_CLEAR(tmp);
13433
0
        }
13434
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13435
0
            return -1;
13436
0
        }
13437
0
        if (tmp == NULL || tmp == Py_None) {
13438
0
            Py_CLEAR(tmp);
13439
0
            msg = NULL;
13440
0
        }
13441
0
        else {
13442
0
            int res;
13443
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13444
0
                goto failed;
13445
0
            }
13446
0
            res = obj2ast_expr(state, tmp, &msg, arena);
13447
0
            _Py_LeaveRecursiveCall();
13448
0
            if (res != 0) goto failed;
13449
0
            Py_CLEAR(tmp);
13450
0
        }
13451
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13452
0
                             end_col_offset, arena);
13453
0
        if (*out == NULL) goto failed;
13454
0
        return 0;
13455
0
    }
13456
0
    tp = state->Import_type;
13457
0
    isinstance = PyObject_IsInstance(obj, tp);
13458
0
    if (isinstance == -1) {
13459
0
        return -1;
13460
0
    }
13461
0
    if (isinstance) {
13462
0
        asdl_alias_seq* names;
13463
0
        int is_lazy;
13464
13465
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13466
0
            return -1;
13467
0
        }
13468
0
        if (tmp == NULL) {
13469
0
            tmp = PyList_New(0);
13470
0
            if (tmp == NULL) {
13471
0
                return -1;
13472
0
            }
13473
0
        }
13474
0
        {
13475
0
            int res;
13476
0
            Py_ssize_t len;
13477
0
            Py_ssize_t i;
13478
0
            if (!PyList_Check(tmp)) {
13479
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13480
0
                goto failed;
13481
0
            }
13482
0
            len = PyList_GET_SIZE(tmp);
13483
0
            names = _Py_asdl_alias_seq_new(len, arena);
13484
0
            if (names == NULL) goto failed;
13485
0
            for (i = 0; i < len; i++) {
13486
0
                alias_ty val;
13487
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13488
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13489
0
                    goto failed;
13490
0
                }
13491
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13492
0
                _Py_LeaveRecursiveCall();
13493
0
                Py_DECREF(tmp2);
13494
0
                if (res != 0) goto failed;
13495
0
                if (len != PyList_GET_SIZE(tmp)) {
13496
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13497
0
                    goto failed;
13498
0
                }
13499
0
                asdl_seq_SET(names, i, val);
13500
0
            }
13501
0
            Py_CLEAR(tmp);
13502
0
        }
13503
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13504
0
            return -1;
13505
0
        }
13506
0
        if (tmp == NULL || tmp == Py_None) {
13507
0
            Py_CLEAR(tmp);
13508
0
            is_lazy = 0;
13509
0
        }
13510
0
        else {
13511
0
            int res;
13512
0
            if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13513
0
                goto failed;
13514
0
            }
13515
0
            res = obj2ast_int(state, tmp, &is_lazy, arena);
13516
0
            _Py_LeaveRecursiveCall();
13517
0
            if (res != 0) goto failed;
13518
0
            Py_CLEAR(tmp);
13519
0
        }
13520
0
        *out = _PyAST_Import(names, is_lazy, lineno, col_offset, end_lineno,
13521
0
                             end_col_offset, arena);
13522
0
        if (*out == NULL) goto failed;
13523
0
        return 0;
13524
0
    }
13525
0
    tp = state->ImportFrom_type;
13526
0
    isinstance = PyObject_IsInstance(obj, tp);
13527
0
    if (isinstance == -1) {
13528
0
        return -1;
13529
0
    }
13530
0
    if (isinstance) {
13531
0
        identifier module;
13532
0
        asdl_alias_seq* names;
13533
0
        int level;
13534
0
        int is_lazy;
13535
13536
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13537
0
            return -1;
13538
0
        }
13539
0
        if (tmp == NULL || tmp == Py_None) {
13540
0
            Py_CLEAR(tmp);
13541
0
            module = NULL;
13542
0
        }
13543
0
        else {
13544
0
            int res;
13545
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13546
0
                goto failed;
13547
0
            }
13548
0
            res = obj2ast_identifier(state, tmp, &module, arena);
13549
0
            _Py_LeaveRecursiveCall();
13550
0
            if (res != 0) goto failed;
13551
0
            Py_CLEAR(tmp);
13552
0
        }
13553
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13554
0
            return -1;
13555
0
        }
13556
0
        if (tmp == NULL) {
13557
0
            tmp = PyList_New(0);
13558
0
            if (tmp == NULL) {
13559
0
                return -1;
13560
0
            }
13561
0
        }
13562
0
        {
13563
0
            int res;
13564
0
            Py_ssize_t len;
13565
0
            Py_ssize_t i;
13566
0
            if (!PyList_Check(tmp)) {
13567
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13568
0
                goto failed;
13569
0
            }
13570
0
            len = PyList_GET_SIZE(tmp);
13571
0
            names = _Py_asdl_alias_seq_new(len, arena);
13572
0
            if (names == NULL) goto failed;
13573
0
            for (i = 0; i < len; i++) {
13574
0
                alias_ty val;
13575
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13576
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13577
0
                    goto failed;
13578
0
                }
13579
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13580
0
                _Py_LeaveRecursiveCall();
13581
0
                Py_DECREF(tmp2);
13582
0
                if (res != 0) goto failed;
13583
0
                if (len != PyList_GET_SIZE(tmp)) {
13584
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13585
0
                    goto failed;
13586
0
                }
13587
0
                asdl_seq_SET(names, i, val);
13588
0
            }
13589
0
            Py_CLEAR(tmp);
13590
0
        }
13591
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13592
0
            return -1;
13593
0
        }
13594
0
        if (tmp == NULL || tmp == Py_None) {
13595
0
            Py_CLEAR(tmp);
13596
0
            level = 0;
13597
0
        }
13598
0
        else {
13599
0
            int res;
13600
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13601
0
                goto failed;
13602
0
            }
13603
0
            res = obj2ast_int(state, tmp, &level, arena);
13604
0
            _Py_LeaveRecursiveCall();
13605
0
            if (res != 0) goto failed;
13606
0
            Py_CLEAR(tmp);
13607
0
        }
13608
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13609
0
            return -1;
13610
0
        }
13611
0
        if (tmp == NULL || tmp == Py_None) {
13612
0
            Py_CLEAR(tmp);
13613
0
            is_lazy = 0;
13614
0
        }
13615
0
        else {
13616
0
            int res;
13617
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13618
0
                goto failed;
13619
0
            }
13620
0
            res = obj2ast_int(state, tmp, &is_lazy, arena);
13621
0
            _Py_LeaveRecursiveCall();
13622
0
            if (res != 0) goto failed;
13623
0
            Py_CLEAR(tmp);
13624
0
        }
13625
0
        *out = _PyAST_ImportFrom(module, names, level, is_lazy, lineno,
13626
0
                                 col_offset, end_lineno, end_col_offset, arena);
13627
0
        if (*out == NULL) goto failed;
13628
0
        return 0;
13629
0
    }
13630
0
    tp = state->Global_type;
13631
0
    isinstance = PyObject_IsInstance(obj, tp);
13632
0
    if (isinstance == -1) {
13633
0
        return -1;
13634
0
    }
13635
0
    if (isinstance) {
13636
0
        asdl_identifier_seq* names;
13637
13638
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13639
0
            return -1;
13640
0
        }
13641
0
        if (tmp == NULL) {
13642
0
            tmp = PyList_New(0);
13643
0
            if (tmp == NULL) {
13644
0
                return -1;
13645
0
            }
13646
0
        }
13647
0
        {
13648
0
            int res;
13649
0
            Py_ssize_t len;
13650
0
            Py_ssize_t i;
13651
0
            if (!PyList_Check(tmp)) {
13652
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13653
0
                goto failed;
13654
0
            }
13655
0
            len = PyList_GET_SIZE(tmp);
13656
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13657
0
            if (names == NULL) goto failed;
13658
0
            for (i = 0; i < len; i++) {
13659
0
                identifier val;
13660
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13661
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13662
0
                    goto failed;
13663
0
                }
13664
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13665
0
                _Py_LeaveRecursiveCall();
13666
0
                Py_DECREF(tmp2);
13667
0
                if (res != 0) goto failed;
13668
0
                if (len != PyList_GET_SIZE(tmp)) {
13669
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13670
0
                    goto failed;
13671
0
                }
13672
0
                asdl_seq_SET(names, i, val);
13673
0
            }
13674
0
            Py_CLEAR(tmp);
13675
0
        }
13676
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13677
0
                             end_col_offset, arena);
13678
0
        if (*out == NULL) goto failed;
13679
0
        return 0;
13680
0
    }
13681
0
    tp = state->Nonlocal_type;
13682
0
    isinstance = PyObject_IsInstance(obj, tp);
13683
0
    if (isinstance == -1) {
13684
0
        return -1;
13685
0
    }
13686
0
    if (isinstance) {
13687
0
        asdl_identifier_seq* names;
13688
13689
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13690
0
            return -1;
13691
0
        }
13692
0
        if (tmp == NULL) {
13693
0
            tmp = PyList_New(0);
13694
0
            if (tmp == NULL) {
13695
0
                return -1;
13696
0
            }
13697
0
        }
13698
0
        {
13699
0
            int res;
13700
0
            Py_ssize_t len;
13701
0
            Py_ssize_t i;
13702
0
            if (!PyList_Check(tmp)) {
13703
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13704
0
                goto failed;
13705
0
            }
13706
0
            len = PyList_GET_SIZE(tmp);
13707
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13708
0
            if (names == NULL) goto failed;
13709
0
            for (i = 0; i < len; i++) {
13710
0
                identifier val;
13711
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13712
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13713
0
                    goto failed;
13714
0
                }
13715
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13716
0
                _Py_LeaveRecursiveCall();
13717
0
                Py_DECREF(tmp2);
13718
0
                if (res != 0) goto failed;
13719
0
                if (len != PyList_GET_SIZE(tmp)) {
13720
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13721
0
                    goto failed;
13722
0
                }
13723
0
                asdl_seq_SET(names, i, val);
13724
0
            }
13725
0
            Py_CLEAR(tmp);
13726
0
        }
13727
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13728
0
                               end_col_offset, arena);
13729
0
        if (*out == NULL) goto failed;
13730
0
        return 0;
13731
0
    }
13732
0
    tp = state->Expr_type;
13733
0
    isinstance = PyObject_IsInstance(obj, tp);
13734
0
    if (isinstance == -1) {
13735
0
        return -1;
13736
0
    }
13737
0
    if (isinstance) {
13738
0
        expr_ty value;
13739
13740
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13741
0
            return -1;
13742
0
        }
13743
0
        if (tmp == NULL) {
13744
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13745
0
            return -1;
13746
0
        }
13747
0
        else {
13748
0
            int res;
13749
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13750
0
                goto failed;
13751
0
            }
13752
0
            res = obj2ast_expr(state, tmp, &value, arena);
13753
0
            _Py_LeaveRecursiveCall();
13754
0
            if (res != 0) goto failed;
13755
0
            Py_CLEAR(tmp);
13756
0
        }
13757
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13758
0
                           end_col_offset, arena);
13759
0
        if (*out == NULL) goto failed;
13760
0
        return 0;
13761
0
    }
13762
0
    tp = state->Pass_type;
13763
0
    isinstance = PyObject_IsInstance(obj, tp);
13764
0
    if (isinstance == -1) {
13765
0
        return -1;
13766
0
    }
13767
0
    if (isinstance) {
13768
13769
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13770
0
                           arena);
13771
0
        if (*out == NULL) goto failed;
13772
0
        return 0;
13773
0
    }
13774
0
    tp = state->Break_type;
13775
0
    isinstance = PyObject_IsInstance(obj, tp);
13776
0
    if (isinstance == -1) {
13777
0
        return -1;
13778
0
    }
13779
0
    if (isinstance) {
13780
13781
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13782
0
                            arena);
13783
0
        if (*out == NULL) goto failed;
13784
0
        return 0;
13785
0
    }
13786
0
    tp = state->Continue_type;
13787
0
    isinstance = PyObject_IsInstance(obj, tp);
13788
0
    if (isinstance == -1) {
13789
0
        return -1;
13790
0
    }
13791
0
    if (isinstance) {
13792
13793
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13794
0
                               arena);
13795
0
        if (*out == NULL) goto failed;
13796
0
        return 0;
13797
0
    }
13798
13799
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13800
0
    failed:
13801
0
    Py_XDECREF(tmp);
13802
0
    return -1;
13803
0
}
13804
13805
int
13806
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
13807
             arena)
13808
0
{
13809
0
    int isinstance;
13810
13811
0
    PyObject *tmp = NULL;
13812
0
    PyObject *tp;
13813
0
    int lineno;
13814
0
    int col_offset;
13815
0
    int end_lineno;
13816
0
    int end_col_offset;
13817
13818
0
    if (obj == Py_None) {
13819
0
        *out = NULL;
13820
0
        return 0;
13821
0
    }
13822
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13823
0
        return -1;
13824
0
    }
13825
0
    if (tmp == NULL) {
13826
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13827
0
        return -1;
13828
0
    }
13829
0
    else {
13830
0
        int res;
13831
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13832
0
            goto failed;
13833
0
        }
13834
0
        res = obj2ast_int(state, tmp, &lineno, arena);
13835
0
        _Py_LeaveRecursiveCall();
13836
0
        if (res != 0) goto failed;
13837
0
        Py_CLEAR(tmp);
13838
0
    }
13839
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13840
0
        return -1;
13841
0
    }
13842
0
    if (tmp == NULL) {
13843
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13844
0
        return -1;
13845
0
    }
13846
0
    else {
13847
0
        int res;
13848
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13849
0
            goto failed;
13850
0
        }
13851
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
13852
0
        _Py_LeaveRecursiveCall();
13853
0
        if (res != 0) goto failed;
13854
0
        Py_CLEAR(tmp);
13855
0
    }
13856
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13857
0
        return -1;
13858
0
    }
13859
0
    if (tmp == NULL || tmp == Py_None) {
13860
0
        Py_CLEAR(tmp);
13861
0
        end_lineno = lineno;
13862
0
    }
13863
0
    else {
13864
0
        int res;
13865
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13866
0
            goto failed;
13867
0
        }
13868
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
13869
0
        _Py_LeaveRecursiveCall();
13870
0
        if (res != 0) goto failed;
13871
0
        Py_CLEAR(tmp);
13872
0
    }
13873
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13874
0
        return -1;
13875
0
    }
13876
0
    if (tmp == NULL || tmp == Py_None) {
13877
0
        Py_CLEAR(tmp);
13878
0
        end_col_offset = col_offset;
13879
0
    }
13880
0
    else {
13881
0
        int res;
13882
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13883
0
            goto failed;
13884
0
        }
13885
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
13886
0
        _Py_LeaveRecursiveCall();
13887
0
        if (res != 0) goto failed;
13888
0
        Py_CLEAR(tmp);
13889
0
    }
13890
0
    tp = state->BoolOp_type;
13891
0
    isinstance = PyObject_IsInstance(obj, tp);
13892
0
    if (isinstance == -1) {
13893
0
        return -1;
13894
0
    }
13895
0
    if (isinstance) {
13896
0
        boolop_ty op;
13897
0
        asdl_expr_seq* values;
13898
13899
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13900
0
            return -1;
13901
0
        }
13902
0
        if (tmp == NULL) {
13903
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13904
0
            return -1;
13905
0
        }
13906
0
        else {
13907
0
            int res;
13908
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13909
0
                goto failed;
13910
0
            }
13911
0
            res = obj2ast_boolop(state, tmp, &op, arena);
13912
0
            _Py_LeaveRecursiveCall();
13913
0
            if (res != 0) goto failed;
13914
0
            Py_CLEAR(tmp);
13915
0
        }
13916
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13917
0
            return -1;
13918
0
        }
13919
0
        if (tmp == NULL) {
13920
0
            tmp = PyList_New(0);
13921
0
            if (tmp == NULL) {
13922
0
                return -1;
13923
0
            }
13924
0
        }
13925
0
        {
13926
0
            int res;
13927
0
            Py_ssize_t len;
13928
0
            Py_ssize_t i;
13929
0
            if (!PyList_Check(tmp)) {
13930
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13931
0
                goto failed;
13932
0
            }
13933
0
            len = PyList_GET_SIZE(tmp);
13934
0
            values = _Py_asdl_expr_seq_new(len, arena);
13935
0
            if (values == NULL) goto failed;
13936
0
            for (i = 0; i < len; i++) {
13937
0
                expr_ty val;
13938
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13939
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13940
0
                    goto failed;
13941
0
                }
13942
0
                res = obj2ast_expr(state, tmp2, &val, arena);
13943
0
                _Py_LeaveRecursiveCall();
13944
0
                Py_DECREF(tmp2);
13945
0
                if (res != 0) goto failed;
13946
0
                if (len != PyList_GET_SIZE(tmp)) {
13947
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13948
0
                    goto failed;
13949
0
                }
13950
0
                asdl_seq_SET(values, i, val);
13951
0
            }
13952
0
            Py_CLEAR(tmp);
13953
0
        }
13954
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
13955
0
                             end_col_offset, arena);
13956
0
        if (*out == NULL) goto failed;
13957
0
        return 0;
13958
0
    }
13959
0
    tp = state->NamedExpr_type;
13960
0
    isinstance = PyObject_IsInstance(obj, tp);
13961
0
    if (isinstance == -1) {
13962
0
        return -1;
13963
0
    }
13964
0
    if (isinstance) {
13965
0
        expr_ty target;
13966
0
        expr_ty value;
13967
13968
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
13969
0
            return -1;
13970
0
        }
13971
0
        if (tmp == NULL) {
13972
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
13973
0
            return -1;
13974
0
        }
13975
0
        else {
13976
0
            int res;
13977
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13978
0
                goto failed;
13979
0
            }
13980
0
            res = obj2ast_expr(state, tmp, &target, arena);
13981
0
            _Py_LeaveRecursiveCall();
13982
0
            if (res != 0) goto failed;
13983
0
            Py_CLEAR(tmp);
13984
0
        }
13985
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13986
0
            return -1;
13987
0
        }
13988
0
        if (tmp == NULL) {
13989
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
13990
0
            return -1;
13991
0
        }
13992
0
        else {
13993
0
            int res;
13994
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13995
0
                goto failed;
13996
0
            }
13997
0
            res = obj2ast_expr(state, tmp, &value, arena);
13998
0
            _Py_LeaveRecursiveCall();
13999
0
            if (res != 0) goto failed;
14000
0
            Py_CLEAR(tmp);
14001
0
        }
14002
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
14003
0
                                end_col_offset, arena);
14004
0
        if (*out == NULL) goto failed;
14005
0
        return 0;
14006
0
    }
14007
0
    tp = state->BinOp_type;
14008
0
    isinstance = PyObject_IsInstance(obj, tp);
14009
0
    if (isinstance == -1) {
14010
0
        return -1;
14011
0
    }
14012
0
    if (isinstance) {
14013
0
        expr_ty left;
14014
0
        operator_ty op;
14015
0
        expr_ty right;
14016
14017
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14018
0
            return -1;
14019
0
        }
14020
0
        if (tmp == NULL) {
14021
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14022
0
            return -1;
14023
0
        }
14024
0
        else {
14025
0
            int res;
14026
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14027
0
                goto failed;
14028
0
            }
14029
0
            res = obj2ast_expr(state, tmp, &left, arena);
14030
0
            _Py_LeaveRecursiveCall();
14031
0
            if (res != 0) goto failed;
14032
0
            Py_CLEAR(tmp);
14033
0
        }
14034
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14035
0
            return -1;
14036
0
        }
14037
0
        if (tmp == NULL) {
14038
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14039
0
            return -1;
14040
0
        }
14041
0
        else {
14042
0
            int res;
14043
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14044
0
                goto failed;
14045
0
            }
14046
0
            res = obj2ast_operator(state, tmp, &op, arena);
14047
0
            _Py_LeaveRecursiveCall();
14048
0
            if (res != 0) goto failed;
14049
0
            Py_CLEAR(tmp);
14050
0
        }
14051
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14052
0
            return -1;
14053
0
        }
14054
0
        if (tmp == NULL) {
14055
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14056
0
            return -1;
14057
0
        }
14058
0
        else {
14059
0
            int res;
14060
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14061
0
                goto failed;
14062
0
            }
14063
0
            res = obj2ast_expr(state, tmp, &right, arena);
14064
0
            _Py_LeaveRecursiveCall();
14065
0
            if (res != 0) goto failed;
14066
0
            Py_CLEAR(tmp);
14067
0
        }
14068
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14069
0
                            end_col_offset, arena);
14070
0
        if (*out == NULL) goto failed;
14071
0
        return 0;
14072
0
    }
14073
0
    tp = state->UnaryOp_type;
14074
0
    isinstance = PyObject_IsInstance(obj, tp);
14075
0
    if (isinstance == -1) {
14076
0
        return -1;
14077
0
    }
14078
0
    if (isinstance) {
14079
0
        unaryop_ty op;
14080
0
        expr_ty operand;
14081
14082
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14083
0
            return -1;
14084
0
        }
14085
0
        if (tmp == NULL) {
14086
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14087
0
            return -1;
14088
0
        }
14089
0
        else {
14090
0
            int res;
14091
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14092
0
                goto failed;
14093
0
            }
14094
0
            res = obj2ast_unaryop(state, tmp, &op, arena);
14095
0
            _Py_LeaveRecursiveCall();
14096
0
            if (res != 0) goto failed;
14097
0
            Py_CLEAR(tmp);
14098
0
        }
14099
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
14100
0
            return -1;
14101
0
        }
14102
0
        if (tmp == NULL) {
14103
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14104
0
            return -1;
14105
0
        }
14106
0
        else {
14107
0
            int res;
14108
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14109
0
                goto failed;
14110
0
            }
14111
0
            res = obj2ast_expr(state, tmp, &operand, arena);
14112
0
            _Py_LeaveRecursiveCall();
14113
0
            if (res != 0) goto failed;
14114
0
            Py_CLEAR(tmp);
14115
0
        }
14116
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14117
0
                              end_col_offset, arena);
14118
0
        if (*out == NULL) goto failed;
14119
0
        return 0;
14120
0
    }
14121
0
    tp = state->Lambda_type;
14122
0
    isinstance = PyObject_IsInstance(obj, tp);
14123
0
    if (isinstance == -1) {
14124
0
        return -1;
14125
0
    }
14126
0
    if (isinstance) {
14127
0
        arguments_ty args;
14128
0
        expr_ty body;
14129
14130
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14131
0
            return -1;
14132
0
        }
14133
0
        if (tmp == NULL) {
14134
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14135
0
            return -1;
14136
0
        }
14137
0
        else {
14138
0
            int res;
14139
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14140
0
                goto failed;
14141
0
            }
14142
0
            res = obj2ast_arguments(state, tmp, &args, arena);
14143
0
            _Py_LeaveRecursiveCall();
14144
0
            if (res != 0) goto failed;
14145
0
            Py_CLEAR(tmp);
14146
0
        }
14147
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14148
0
            return -1;
14149
0
        }
14150
0
        if (tmp == NULL) {
14151
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14152
0
            return -1;
14153
0
        }
14154
0
        else {
14155
0
            int res;
14156
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14157
0
                goto failed;
14158
0
            }
14159
0
            res = obj2ast_expr(state, tmp, &body, arena);
14160
0
            _Py_LeaveRecursiveCall();
14161
0
            if (res != 0) goto failed;
14162
0
            Py_CLEAR(tmp);
14163
0
        }
14164
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14165
0
                             end_col_offset, arena);
14166
0
        if (*out == NULL) goto failed;
14167
0
        return 0;
14168
0
    }
14169
0
    tp = state->IfExp_type;
14170
0
    isinstance = PyObject_IsInstance(obj, tp);
14171
0
    if (isinstance == -1) {
14172
0
        return -1;
14173
0
    }
14174
0
    if (isinstance) {
14175
0
        expr_ty test;
14176
0
        expr_ty body;
14177
0
        expr_ty orelse;
14178
14179
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14180
0
            return -1;
14181
0
        }
14182
0
        if (tmp == NULL) {
14183
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14184
0
            return -1;
14185
0
        }
14186
0
        else {
14187
0
            int res;
14188
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14189
0
                goto failed;
14190
0
            }
14191
0
            res = obj2ast_expr(state, tmp, &test, arena);
14192
0
            _Py_LeaveRecursiveCall();
14193
0
            if (res != 0) goto failed;
14194
0
            Py_CLEAR(tmp);
14195
0
        }
14196
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14197
0
            return -1;
14198
0
        }
14199
0
        if (tmp == NULL) {
14200
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14201
0
            return -1;
14202
0
        }
14203
0
        else {
14204
0
            int res;
14205
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14206
0
                goto failed;
14207
0
            }
14208
0
            res = obj2ast_expr(state, tmp, &body, arena);
14209
0
            _Py_LeaveRecursiveCall();
14210
0
            if (res != 0) goto failed;
14211
0
            Py_CLEAR(tmp);
14212
0
        }
14213
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14214
0
            return -1;
14215
0
        }
14216
0
        if (tmp == NULL) {
14217
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14218
0
            return -1;
14219
0
        }
14220
0
        else {
14221
0
            int res;
14222
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14223
0
                goto failed;
14224
0
            }
14225
0
            res = obj2ast_expr(state, tmp, &orelse, arena);
14226
0
            _Py_LeaveRecursiveCall();
14227
0
            if (res != 0) goto failed;
14228
0
            Py_CLEAR(tmp);
14229
0
        }
14230
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14231
0
                            end_col_offset, arena);
14232
0
        if (*out == NULL) goto failed;
14233
0
        return 0;
14234
0
    }
14235
0
    tp = state->Dict_type;
14236
0
    isinstance = PyObject_IsInstance(obj, tp);
14237
0
    if (isinstance == -1) {
14238
0
        return -1;
14239
0
    }
14240
0
    if (isinstance) {
14241
0
        asdl_expr_seq* keys;
14242
0
        asdl_expr_seq* values;
14243
14244
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14245
0
            return -1;
14246
0
        }
14247
0
        if (tmp == NULL) {
14248
0
            tmp = PyList_New(0);
14249
0
            if (tmp == NULL) {
14250
0
                return -1;
14251
0
            }
14252
0
        }
14253
0
        {
14254
0
            int res;
14255
0
            Py_ssize_t len;
14256
0
            Py_ssize_t i;
14257
0
            if (!PyList_Check(tmp)) {
14258
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14259
0
                goto failed;
14260
0
            }
14261
0
            len = PyList_GET_SIZE(tmp);
14262
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14263
0
            if (keys == NULL) goto failed;
14264
0
            for (i = 0; i < len; i++) {
14265
0
                expr_ty val;
14266
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14267
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14268
0
                    goto failed;
14269
0
                }
14270
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14271
0
                _Py_LeaveRecursiveCall();
14272
0
                Py_DECREF(tmp2);
14273
0
                if (res != 0) goto failed;
14274
0
                if (len != PyList_GET_SIZE(tmp)) {
14275
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14276
0
                    goto failed;
14277
0
                }
14278
0
                asdl_seq_SET(keys, i, val);
14279
0
            }
14280
0
            Py_CLEAR(tmp);
14281
0
        }
14282
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14283
0
            return -1;
14284
0
        }
14285
0
        if (tmp == NULL) {
14286
0
            tmp = PyList_New(0);
14287
0
            if (tmp == NULL) {
14288
0
                return -1;
14289
0
            }
14290
0
        }
14291
0
        {
14292
0
            int res;
14293
0
            Py_ssize_t len;
14294
0
            Py_ssize_t i;
14295
0
            if (!PyList_Check(tmp)) {
14296
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14297
0
                goto failed;
14298
0
            }
14299
0
            len = PyList_GET_SIZE(tmp);
14300
0
            values = _Py_asdl_expr_seq_new(len, arena);
14301
0
            if (values == NULL) goto failed;
14302
0
            for (i = 0; i < len; i++) {
14303
0
                expr_ty val;
14304
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14305
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14306
0
                    goto failed;
14307
0
                }
14308
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14309
0
                _Py_LeaveRecursiveCall();
14310
0
                Py_DECREF(tmp2);
14311
0
                if (res != 0) goto failed;
14312
0
                if (len != PyList_GET_SIZE(tmp)) {
14313
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14314
0
                    goto failed;
14315
0
                }
14316
0
                asdl_seq_SET(values, i, val);
14317
0
            }
14318
0
            Py_CLEAR(tmp);
14319
0
        }
14320
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14321
0
                           end_col_offset, arena);
14322
0
        if (*out == NULL) goto failed;
14323
0
        return 0;
14324
0
    }
14325
0
    tp = state->Set_type;
14326
0
    isinstance = PyObject_IsInstance(obj, tp);
14327
0
    if (isinstance == -1) {
14328
0
        return -1;
14329
0
    }
14330
0
    if (isinstance) {
14331
0
        asdl_expr_seq* elts;
14332
14333
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14334
0
            return -1;
14335
0
        }
14336
0
        if (tmp == NULL) {
14337
0
            tmp = PyList_New(0);
14338
0
            if (tmp == NULL) {
14339
0
                return -1;
14340
0
            }
14341
0
        }
14342
0
        {
14343
0
            int res;
14344
0
            Py_ssize_t len;
14345
0
            Py_ssize_t i;
14346
0
            if (!PyList_Check(tmp)) {
14347
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14348
0
                goto failed;
14349
0
            }
14350
0
            len = PyList_GET_SIZE(tmp);
14351
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14352
0
            if (elts == NULL) goto failed;
14353
0
            for (i = 0; i < len; i++) {
14354
0
                expr_ty val;
14355
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14356
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14357
0
                    goto failed;
14358
0
                }
14359
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14360
0
                _Py_LeaveRecursiveCall();
14361
0
                Py_DECREF(tmp2);
14362
0
                if (res != 0) goto failed;
14363
0
                if (len != PyList_GET_SIZE(tmp)) {
14364
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14365
0
                    goto failed;
14366
0
                }
14367
0
                asdl_seq_SET(elts, i, val);
14368
0
            }
14369
0
            Py_CLEAR(tmp);
14370
0
        }
14371
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14372
0
                          arena);
14373
0
        if (*out == NULL) goto failed;
14374
0
        return 0;
14375
0
    }
14376
0
    tp = state->ListComp_type;
14377
0
    isinstance = PyObject_IsInstance(obj, tp);
14378
0
    if (isinstance == -1) {
14379
0
        return -1;
14380
0
    }
14381
0
    if (isinstance) {
14382
0
        expr_ty elt;
14383
0
        asdl_comprehension_seq* generators;
14384
14385
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14386
0
            return -1;
14387
0
        }
14388
0
        if (tmp == NULL) {
14389
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14390
0
            return -1;
14391
0
        }
14392
0
        else {
14393
0
            int res;
14394
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14395
0
                goto failed;
14396
0
            }
14397
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14398
0
            _Py_LeaveRecursiveCall();
14399
0
            if (res != 0) goto failed;
14400
0
            Py_CLEAR(tmp);
14401
0
        }
14402
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14403
0
            return -1;
14404
0
        }
14405
0
        if (tmp == NULL) {
14406
0
            tmp = PyList_New(0);
14407
0
            if (tmp == NULL) {
14408
0
                return -1;
14409
0
            }
14410
0
        }
14411
0
        {
14412
0
            int res;
14413
0
            Py_ssize_t len;
14414
0
            Py_ssize_t i;
14415
0
            if (!PyList_Check(tmp)) {
14416
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14417
0
                goto failed;
14418
0
            }
14419
0
            len = PyList_GET_SIZE(tmp);
14420
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14421
0
            if (generators == NULL) goto failed;
14422
0
            for (i = 0; i < len; i++) {
14423
0
                comprehension_ty val;
14424
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14425
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14426
0
                    goto failed;
14427
0
                }
14428
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14429
0
                _Py_LeaveRecursiveCall();
14430
0
                Py_DECREF(tmp2);
14431
0
                if (res != 0) goto failed;
14432
0
                if (len != PyList_GET_SIZE(tmp)) {
14433
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14434
0
                    goto failed;
14435
0
                }
14436
0
                asdl_seq_SET(generators, i, val);
14437
0
            }
14438
0
            Py_CLEAR(tmp);
14439
0
        }
14440
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14441
0
                               end_col_offset, arena);
14442
0
        if (*out == NULL) goto failed;
14443
0
        return 0;
14444
0
    }
14445
0
    tp = state->SetComp_type;
14446
0
    isinstance = PyObject_IsInstance(obj, tp);
14447
0
    if (isinstance == -1) {
14448
0
        return -1;
14449
0
    }
14450
0
    if (isinstance) {
14451
0
        expr_ty elt;
14452
0
        asdl_comprehension_seq* generators;
14453
14454
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14455
0
            return -1;
14456
0
        }
14457
0
        if (tmp == NULL) {
14458
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14459
0
            return -1;
14460
0
        }
14461
0
        else {
14462
0
            int res;
14463
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14464
0
                goto failed;
14465
0
            }
14466
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14467
0
            _Py_LeaveRecursiveCall();
14468
0
            if (res != 0) goto failed;
14469
0
            Py_CLEAR(tmp);
14470
0
        }
14471
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14472
0
            return -1;
14473
0
        }
14474
0
        if (tmp == NULL) {
14475
0
            tmp = PyList_New(0);
14476
0
            if (tmp == NULL) {
14477
0
                return -1;
14478
0
            }
14479
0
        }
14480
0
        {
14481
0
            int res;
14482
0
            Py_ssize_t len;
14483
0
            Py_ssize_t i;
14484
0
            if (!PyList_Check(tmp)) {
14485
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14486
0
                goto failed;
14487
0
            }
14488
0
            len = PyList_GET_SIZE(tmp);
14489
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14490
0
            if (generators == NULL) goto failed;
14491
0
            for (i = 0; i < len; i++) {
14492
0
                comprehension_ty val;
14493
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14494
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14495
0
                    goto failed;
14496
0
                }
14497
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14498
0
                _Py_LeaveRecursiveCall();
14499
0
                Py_DECREF(tmp2);
14500
0
                if (res != 0) goto failed;
14501
0
                if (len != PyList_GET_SIZE(tmp)) {
14502
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14503
0
                    goto failed;
14504
0
                }
14505
0
                asdl_seq_SET(generators, i, val);
14506
0
            }
14507
0
            Py_CLEAR(tmp);
14508
0
        }
14509
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14510
0
                              end_col_offset, arena);
14511
0
        if (*out == NULL) goto failed;
14512
0
        return 0;
14513
0
    }
14514
0
    tp = state->DictComp_type;
14515
0
    isinstance = PyObject_IsInstance(obj, tp);
14516
0
    if (isinstance == -1) {
14517
0
        return -1;
14518
0
    }
14519
0
    if (isinstance) {
14520
0
        expr_ty key;
14521
0
        expr_ty value;
14522
0
        asdl_comprehension_seq* generators;
14523
14524
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14525
0
            return -1;
14526
0
        }
14527
0
        if (tmp == NULL) {
14528
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14529
0
            return -1;
14530
0
        }
14531
0
        else {
14532
0
            int res;
14533
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14534
0
                goto failed;
14535
0
            }
14536
0
            res = obj2ast_expr(state, tmp, &key, arena);
14537
0
            _Py_LeaveRecursiveCall();
14538
0
            if (res != 0) goto failed;
14539
0
            Py_CLEAR(tmp);
14540
0
        }
14541
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14542
0
            return -1;
14543
0
        }
14544
0
        if (tmp == NULL || tmp == Py_None) {
14545
0
            Py_CLEAR(tmp);
14546
0
            value = NULL;
14547
0
        }
14548
0
        else {
14549
0
            int res;
14550
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14551
0
                goto failed;
14552
0
            }
14553
0
            res = obj2ast_expr(state, tmp, &value, arena);
14554
0
            _Py_LeaveRecursiveCall();
14555
0
            if (res != 0) goto failed;
14556
0
            Py_CLEAR(tmp);
14557
0
        }
14558
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14559
0
            return -1;
14560
0
        }
14561
0
        if (tmp == NULL) {
14562
0
            tmp = PyList_New(0);
14563
0
            if (tmp == NULL) {
14564
0
                return -1;
14565
0
            }
14566
0
        }
14567
0
        {
14568
0
            int res;
14569
0
            Py_ssize_t len;
14570
0
            Py_ssize_t i;
14571
0
            if (!PyList_Check(tmp)) {
14572
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14573
0
                goto failed;
14574
0
            }
14575
0
            len = PyList_GET_SIZE(tmp);
14576
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14577
0
            if (generators == NULL) goto failed;
14578
0
            for (i = 0; i < len; i++) {
14579
0
                comprehension_ty val;
14580
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14581
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14582
0
                    goto failed;
14583
0
                }
14584
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14585
0
                _Py_LeaveRecursiveCall();
14586
0
                Py_DECREF(tmp2);
14587
0
                if (res != 0) goto failed;
14588
0
                if (len != PyList_GET_SIZE(tmp)) {
14589
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14590
0
                    goto failed;
14591
0
                }
14592
0
                asdl_seq_SET(generators, i, val);
14593
0
            }
14594
0
            Py_CLEAR(tmp);
14595
0
        }
14596
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14597
0
                               end_lineno, end_col_offset, arena);
14598
0
        if (*out == NULL) goto failed;
14599
0
        return 0;
14600
0
    }
14601
0
    tp = state->GeneratorExp_type;
14602
0
    isinstance = PyObject_IsInstance(obj, tp);
14603
0
    if (isinstance == -1) {
14604
0
        return -1;
14605
0
    }
14606
0
    if (isinstance) {
14607
0
        expr_ty elt;
14608
0
        asdl_comprehension_seq* generators;
14609
14610
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14611
0
            return -1;
14612
0
        }
14613
0
        if (tmp == NULL) {
14614
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14615
0
            return -1;
14616
0
        }
14617
0
        else {
14618
0
            int res;
14619
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14620
0
                goto failed;
14621
0
            }
14622
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14623
0
            _Py_LeaveRecursiveCall();
14624
0
            if (res != 0) goto failed;
14625
0
            Py_CLEAR(tmp);
14626
0
        }
14627
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14628
0
            return -1;
14629
0
        }
14630
0
        if (tmp == NULL) {
14631
0
            tmp = PyList_New(0);
14632
0
            if (tmp == NULL) {
14633
0
                return -1;
14634
0
            }
14635
0
        }
14636
0
        {
14637
0
            int res;
14638
0
            Py_ssize_t len;
14639
0
            Py_ssize_t i;
14640
0
            if (!PyList_Check(tmp)) {
14641
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14642
0
                goto failed;
14643
0
            }
14644
0
            len = PyList_GET_SIZE(tmp);
14645
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14646
0
            if (generators == NULL) goto failed;
14647
0
            for (i = 0; i < len; i++) {
14648
0
                comprehension_ty val;
14649
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14650
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14651
0
                    goto failed;
14652
0
                }
14653
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14654
0
                _Py_LeaveRecursiveCall();
14655
0
                Py_DECREF(tmp2);
14656
0
                if (res != 0) goto failed;
14657
0
                if (len != PyList_GET_SIZE(tmp)) {
14658
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14659
0
                    goto failed;
14660
0
                }
14661
0
                asdl_seq_SET(generators, i, val);
14662
0
            }
14663
0
            Py_CLEAR(tmp);
14664
0
        }
14665
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14666
0
                                   end_lineno, end_col_offset, arena);
14667
0
        if (*out == NULL) goto failed;
14668
0
        return 0;
14669
0
    }
14670
0
    tp = state->Await_type;
14671
0
    isinstance = PyObject_IsInstance(obj, tp);
14672
0
    if (isinstance == -1) {
14673
0
        return -1;
14674
0
    }
14675
0
    if (isinstance) {
14676
0
        expr_ty value;
14677
14678
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14679
0
            return -1;
14680
0
        }
14681
0
        if (tmp == NULL) {
14682
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14683
0
            return -1;
14684
0
        }
14685
0
        else {
14686
0
            int res;
14687
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14688
0
                goto failed;
14689
0
            }
14690
0
            res = obj2ast_expr(state, tmp, &value, arena);
14691
0
            _Py_LeaveRecursiveCall();
14692
0
            if (res != 0) goto failed;
14693
0
            Py_CLEAR(tmp);
14694
0
        }
14695
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14696
0
                            end_col_offset, arena);
14697
0
        if (*out == NULL) goto failed;
14698
0
        return 0;
14699
0
    }
14700
0
    tp = state->Yield_type;
14701
0
    isinstance = PyObject_IsInstance(obj, tp);
14702
0
    if (isinstance == -1) {
14703
0
        return -1;
14704
0
    }
14705
0
    if (isinstance) {
14706
0
        expr_ty value;
14707
14708
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14709
0
            return -1;
14710
0
        }
14711
0
        if (tmp == NULL || tmp == Py_None) {
14712
0
            Py_CLEAR(tmp);
14713
0
            value = NULL;
14714
0
        }
14715
0
        else {
14716
0
            int res;
14717
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14718
0
                goto failed;
14719
0
            }
14720
0
            res = obj2ast_expr(state, tmp, &value, arena);
14721
0
            _Py_LeaveRecursiveCall();
14722
0
            if (res != 0) goto failed;
14723
0
            Py_CLEAR(tmp);
14724
0
        }
14725
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14726
0
                            end_col_offset, arena);
14727
0
        if (*out == NULL) goto failed;
14728
0
        return 0;
14729
0
    }
14730
0
    tp = state->YieldFrom_type;
14731
0
    isinstance = PyObject_IsInstance(obj, tp);
14732
0
    if (isinstance == -1) {
14733
0
        return -1;
14734
0
    }
14735
0
    if (isinstance) {
14736
0
        expr_ty value;
14737
14738
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14739
0
            return -1;
14740
0
        }
14741
0
        if (tmp == NULL) {
14742
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14743
0
            return -1;
14744
0
        }
14745
0
        else {
14746
0
            int res;
14747
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14748
0
                goto failed;
14749
0
            }
14750
0
            res = obj2ast_expr(state, tmp, &value, arena);
14751
0
            _Py_LeaveRecursiveCall();
14752
0
            if (res != 0) goto failed;
14753
0
            Py_CLEAR(tmp);
14754
0
        }
14755
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14756
0
                                end_col_offset, arena);
14757
0
        if (*out == NULL) goto failed;
14758
0
        return 0;
14759
0
    }
14760
0
    tp = state->Compare_type;
14761
0
    isinstance = PyObject_IsInstance(obj, tp);
14762
0
    if (isinstance == -1) {
14763
0
        return -1;
14764
0
    }
14765
0
    if (isinstance) {
14766
0
        expr_ty left;
14767
0
        asdl_int_seq* ops;
14768
0
        asdl_expr_seq* comparators;
14769
14770
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14771
0
            return -1;
14772
0
        }
14773
0
        if (tmp == NULL) {
14774
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14775
0
            return -1;
14776
0
        }
14777
0
        else {
14778
0
            int res;
14779
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14780
0
                goto failed;
14781
0
            }
14782
0
            res = obj2ast_expr(state, tmp, &left, arena);
14783
0
            _Py_LeaveRecursiveCall();
14784
0
            if (res != 0) goto failed;
14785
0
            Py_CLEAR(tmp);
14786
0
        }
14787
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14788
0
            return -1;
14789
0
        }
14790
0
        if (tmp == NULL) {
14791
0
            tmp = PyList_New(0);
14792
0
            if (tmp == NULL) {
14793
0
                return -1;
14794
0
            }
14795
0
        }
14796
0
        {
14797
0
            int res;
14798
0
            Py_ssize_t len;
14799
0
            Py_ssize_t i;
14800
0
            if (!PyList_Check(tmp)) {
14801
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14802
0
                goto failed;
14803
0
            }
14804
0
            len = PyList_GET_SIZE(tmp);
14805
0
            ops = _Py_asdl_int_seq_new(len, arena);
14806
0
            if (ops == NULL) goto failed;
14807
0
            for (i = 0; i < len; i++) {
14808
0
                cmpop_ty val;
14809
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14810
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14811
0
                    goto failed;
14812
0
                }
14813
0
                res = obj2ast_cmpop(state, tmp2, &val, arena);
14814
0
                _Py_LeaveRecursiveCall();
14815
0
                Py_DECREF(tmp2);
14816
0
                if (res != 0) goto failed;
14817
0
                if (len != PyList_GET_SIZE(tmp)) {
14818
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14819
0
                    goto failed;
14820
0
                }
14821
0
                asdl_seq_SET(ops, i, val);
14822
0
            }
14823
0
            Py_CLEAR(tmp);
14824
0
        }
14825
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14826
0
            return -1;
14827
0
        }
14828
0
        if (tmp == NULL) {
14829
0
            tmp = PyList_New(0);
14830
0
            if (tmp == NULL) {
14831
0
                return -1;
14832
0
            }
14833
0
        }
14834
0
        {
14835
0
            int res;
14836
0
            Py_ssize_t len;
14837
0
            Py_ssize_t i;
14838
0
            if (!PyList_Check(tmp)) {
14839
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14840
0
                goto failed;
14841
0
            }
14842
0
            len = PyList_GET_SIZE(tmp);
14843
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14844
0
            if (comparators == NULL) goto failed;
14845
0
            for (i = 0; i < len; i++) {
14846
0
                expr_ty val;
14847
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14848
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14849
0
                    goto failed;
14850
0
                }
14851
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14852
0
                _Py_LeaveRecursiveCall();
14853
0
                Py_DECREF(tmp2);
14854
0
                if (res != 0) goto failed;
14855
0
                if (len != PyList_GET_SIZE(tmp)) {
14856
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14857
0
                    goto failed;
14858
0
                }
14859
0
                asdl_seq_SET(comparators, i, val);
14860
0
            }
14861
0
            Py_CLEAR(tmp);
14862
0
        }
14863
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14864
0
                              end_lineno, end_col_offset, arena);
14865
0
        if (*out == NULL) goto failed;
14866
0
        return 0;
14867
0
    }
14868
0
    tp = state->Call_type;
14869
0
    isinstance = PyObject_IsInstance(obj, tp);
14870
0
    if (isinstance == -1) {
14871
0
        return -1;
14872
0
    }
14873
0
    if (isinstance) {
14874
0
        expr_ty func;
14875
0
        asdl_expr_seq* args;
14876
0
        asdl_keyword_seq* keywords;
14877
14878
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14879
0
            return -1;
14880
0
        }
14881
0
        if (tmp == NULL) {
14882
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14883
0
            return -1;
14884
0
        }
14885
0
        else {
14886
0
            int res;
14887
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14888
0
                goto failed;
14889
0
            }
14890
0
            res = obj2ast_expr(state, tmp, &func, arena);
14891
0
            _Py_LeaveRecursiveCall();
14892
0
            if (res != 0) goto failed;
14893
0
            Py_CLEAR(tmp);
14894
0
        }
14895
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14896
0
            return -1;
14897
0
        }
14898
0
        if (tmp == NULL) {
14899
0
            tmp = PyList_New(0);
14900
0
            if (tmp == NULL) {
14901
0
                return -1;
14902
0
            }
14903
0
        }
14904
0
        {
14905
0
            int res;
14906
0
            Py_ssize_t len;
14907
0
            Py_ssize_t i;
14908
0
            if (!PyList_Check(tmp)) {
14909
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14910
0
                goto failed;
14911
0
            }
14912
0
            len = PyList_GET_SIZE(tmp);
14913
0
            args = _Py_asdl_expr_seq_new(len, arena);
14914
0
            if (args == NULL) goto failed;
14915
0
            for (i = 0; i < len; i++) {
14916
0
                expr_ty val;
14917
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14918
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14919
0
                    goto failed;
14920
0
                }
14921
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14922
0
                _Py_LeaveRecursiveCall();
14923
0
                Py_DECREF(tmp2);
14924
0
                if (res != 0) goto failed;
14925
0
                if (len != PyList_GET_SIZE(tmp)) {
14926
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14927
0
                    goto failed;
14928
0
                }
14929
0
                asdl_seq_SET(args, i, val);
14930
0
            }
14931
0
            Py_CLEAR(tmp);
14932
0
        }
14933
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14934
0
            return -1;
14935
0
        }
14936
0
        if (tmp == NULL) {
14937
0
            tmp = PyList_New(0);
14938
0
            if (tmp == NULL) {
14939
0
                return -1;
14940
0
            }
14941
0
        }
14942
0
        {
14943
0
            int res;
14944
0
            Py_ssize_t len;
14945
0
            Py_ssize_t i;
14946
0
            if (!PyList_Check(tmp)) {
14947
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14948
0
                goto failed;
14949
0
            }
14950
0
            len = PyList_GET_SIZE(tmp);
14951
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
14952
0
            if (keywords == NULL) goto failed;
14953
0
            for (i = 0; i < len; i++) {
14954
0
                keyword_ty val;
14955
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14956
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14957
0
                    goto failed;
14958
0
                }
14959
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
14960
0
                _Py_LeaveRecursiveCall();
14961
0
                Py_DECREF(tmp2);
14962
0
                if (res != 0) goto failed;
14963
0
                if (len != PyList_GET_SIZE(tmp)) {
14964
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
14965
0
                    goto failed;
14966
0
                }
14967
0
                asdl_seq_SET(keywords, i, val);
14968
0
            }
14969
0
            Py_CLEAR(tmp);
14970
0
        }
14971
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
14972
0
                           end_lineno, end_col_offset, arena);
14973
0
        if (*out == NULL) goto failed;
14974
0
        return 0;
14975
0
    }
14976
0
    tp = state->FormattedValue_type;
14977
0
    isinstance = PyObject_IsInstance(obj, tp);
14978
0
    if (isinstance == -1) {
14979
0
        return -1;
14980
0
    }
14981
0
    if (isinstance) {
14982
0
        expr_ty value;
14983
0
        int conversion;
14984
0
        expr_ty format_spec;
14985
14986
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14987
0
            return -1;
14988
0
        }
14989
0
        if (tmp == NULL) {
14990
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
14991
0
            return -1;
14992
0
        }
14993
0
        else {
14994
0
            int res;
14995
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14996
0
                goto failed;
14997
0
            }
14998
0
            res = obj2ast_expr(state, tmp, &value, arena);
14999
0
            _Py_LeaveRecursiveCall();
15000
0
            if (res != 0) goto failed;
15001
0
            Py_CLEAR(tmp);
15002
0
        }
15003
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15004
0
            return -1;
15005
0
        }
15006
0
        if (tmp == NULL) {
15007
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
15008
0
            return -1;
15009
0
        }
15010
0
        else {
15011
0
            int res;
15012
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15013
0
                goto failed;
15014
0
            }
15015
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15016
0
            _Py_LeaveRecursiveCall();
15017
0
            if (res != 0) goto failed;
15018
0
            Py_CLEAR(tmp);
15019
0
        }
15020
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15021
0
            return -1;
15022
0
        }
15023
0
        if (tmp == NULL || tmp == Py_None) {
15024
0
            Py_CLEAR(tmp);
15025
0
            format_spec = NULL;
15026
0
        }
15027
0
        else {
15028
0
            int res;
15029
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15030
0
                goto failed;
15031
0
            }
15032
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15033
0
            _Py_LeaveRecursiveCall();
15034
0
            if (res != 0) goto failed;
15035
0
            Py_CLEAR(tmp);
15036
0
        }
15037
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15038
0
                                     col_offset, end_lineno, end_col_offset,
15039
0
                                     arena);
15040
0
        if (*out == NULL) goto failed;
15041
0
        return 0;
15042
0
    }
15043
0
    tp = state->Interpolation_type;
15044
0
    isinstance = PyObject_IsInstance(obj, tp);
15045
0
    if (isinstance == -1) {
15046
0
        return -1;
15047
0
    }
15048
0
    if (isinstance) {
15049
0
        expr_ty value;
15050
0
        constant str;
15051
0
        int conversion;
15052
0
        expr_ty format_spec;
15053
15054
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15055
0
            return -1;
15056
0
        }
15057
0
        if (tmp == NULL) {
15058
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15059
0
            return -1;
15060
0
        }
15061
0
        else {
15062
0
            int res;
15063
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15064
0
                goto failed;
15065
0
            }
15066
0
            res = obj2ast_expr(state, tmp, &value, arena);
15067
0
            _Py_LeaveRecursiveCall();
15068
0
            if (res != 0) goto failed;
15069
0
            Py_CLEAR(tmp);
15070
0
        }
15071
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15072
0
            return -1;
15073
0
        }
15074
0
        if (tmp == NULL) {
15075
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15076
0
            return -1;
15077
0
        }
15078
0
        else {
15079
0
            int res;
15080
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15081
0
                goto failed;
15082
0
            }
15083
0
            res = obj2ast_constant(state, tmp, &str, arena);
15084
0
            _Py_LeaveRecursiveCall();
15085
0
            if (res != 0) goto failed;
15086
0
            Py_CLEAR(tmp);
15087
0
        }
15088
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15089
0
            return -1;
15090
0
        }
15091
0
        if (tmp == NULL) {
15092
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15093
0
            return -1;
15094
0
        }
15095
0
        else {
15096
0
            int res;
15097
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15098
0
                goto failed;
15099
0
            }
15100
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15101
0
            _Py_LeaveRecursiveCall();
15102
0
            if (res != 0) goto failed;
15103
0
            Py_CLEAR(tmp);
15104
0
        }
15105
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15106
0
            return -1;
15107
0
        }
15108
0
        if (tmp == NULL || tmp == Py_None) {
15109
0
            Py_CLEAR(tmp);
15110
0
            format_spec = NULL;
15111
0
        }
15112
0
        else {
15113
0
            int res;
15114
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15115
0
                goto failed;
15116
0
            }
15117
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15118
0
            _Py_LeaveRecursiveCall();
15119
0
            if (res != 0) goto failed;
15120
0
            Py_CLEAR(tmp);
15121
0
        }
15122
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15123
0
                                    lineno, col_offset, end_lineno,
15124
0
                                    end_col_offset, arena);
15125
0
        if (*out == NULL) goto failed;
15126
0
        return 0;
15127
0
    }
15128
0
    tp = state->JoinedStr_type;
15129
0
    isinstance = PyObject_IsInstance(obj, tp);
15130
0
    if (isinstance == -1) {
15131
0
        return -1;
15132
0
    }
15133
0
    if (isinstance) {
15134
0
        asdl_expr_seq* values;
15135
15136
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15137
0
            return -1;
15138
0
        }
15139
0
        if (tmp == NULL) {
15140
0
            tmp = PyList_New(0);
15141
0
            if (tmp == NULL) {
15142
0
                return -1;
15143
0
            }
15144
0
        }
15145
0
        {
15146
0
            int res;
15147
0
            Py_ssize_t len;
15148
0
            Py_ssize_t i;
15149
0
            if (!PyList_Check(tmp)) {
15150
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15151
0
                goto failed;
15152
0
            }
15153
0
            len = PyList_GET_SIZE(tmp);
15154
0
            values = _Py_asdl_expr_seq_new(len, arena);
15155
0
            if (values == NULL) goto failed;
15156
0
            for (i = 0; i < len; i++) {
15157
0
                expr_ty val;
15158
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15159
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15160
0
                    goto failed;
15161
0
                }
15162
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15163
0
                _Py_LeaveRecursiveCall();
15164
0
                Py_DECREF(tmp2);
15165
0
                if (res != 0) goto failed;
15166
0
                if (len != PyList_GET_SIZE(tmp)) {
15167
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15168
0
                    goto failed;
15169
0
                }
15170
0
                asdl_seq_SET(values, i, val);
15171
0
            }
15172
0
            Py_CLEAR(tmp);
15173
0
        }
15174
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15175
0
                                end_col_offset, arena);
15176
0
        if (*out == NULL) goto failed;
15177
0
        return 0;
15178
0
    }
15179
0
    tp = state->TemplateStr_type;
15180
0
    isinstance = PyObject_IsInstance(obj, tp);
15181
0
    if (isinstance == -1) {
15182
0
        return -1;
15183
0
    }
15184
0
    if (isinstance) {
15185
0
        asdl_expr_seq* values;
15186
15187
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15188
0
            return -1;
15189
0
        }
15190
0
        if (tmp == NULL) {
15191
0
            tmp = PyList_New(0);
15192
0
            if (tmp == NULL) {
15193
0
                return -1;
15194
0
            }
15195
0
        }
15196
0
        {
15197
0
            int res;
15198
0
            Py_ssize_t len;
15199
0
            Py_ssize_t i;
15200
0
            if (!PyList_Check(tmp)) {
15201
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15202
0
                goto failed;
15203
0
            }
15204
0
            len = PyList_GET_SIZE(tmp);
15205
0
            values = _Py_asdl_expr_seq_new(len, arena);
15206
0
            if (values == NULL) goto failed;
15207
0
            for (i = 0; i < len; i++) {
15208
0
                expr_ty val;
15209
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15210
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15211
0
                    goto failed;
15212
0
                }
15213
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15214
0
                _Py_LeaveRecursiveCall();
15215
0
                Py_DECREF(tmp2);
15216
0
                if (res != 0) goto failed;
15217
0
                if (len != PyList_GET_SIZE(tmp)) {
15218
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15219
0
                    goto failed;
15220
0
                }
15221
0
                asdl_seq_SET(values, i, val);
15222
0
            }
15223
0
            Py_CLEAR(tmp);
15224
0
        }
15225
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15226
0
                                  end_col_offset, arena);
15227
0
        if (*out == NULL) goto failed;
15228
0
        return 0;
15229
0
    }
15230
0
    tp = state->Constant_type;
15231
0
    isinstance = PyObject_IsInstance(obj, tp);
15232
0
    if (isinstance == -1) {
15233
0
        return -1;
15234
0
    }
15235
0
    if (isinstance) {
15236
0
        constant value;
15237
0
        string kind;
15238
15239
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15240
0
            return -1;
15241
0
        }
15242
0
        if (tmp == NULL) {
15243
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15244
0
            return -1;
15245
0
        }
15246
0
        else {
15247
0
            int res;
15248
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15249
0
                goto failed;
15250
0
            }
15251
0
            res = obj2ast_constant(state, tmp, &value, arena);
15252
0
            _Py_LeaveRecursiveCall();
15253
0
            if (res != 0) goto failed;
15254
0
            Py_CLEAR(tmp);
15255
0
        }
15256
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15257
0
            return -1;
15258
0
        }
15259
0
        if (tmp == NULL || tmp == Py_None) {
15260
0
            Py_CLEAR(tmp);
15261
0
            kind = NULL;
15262
0
        }
15263
0
        else {
15264
0
            int res;
15265
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15266
0
                goto failed;
15267
0
            }
15268
0
            res = obj2ast_string(state, tmp, &kind, arena);
15269
0
            _Py_LeaveRecursiveCall();
15270
0
            if (res != 0) goto failed;
15271
0
            Py_CLEAR(tmp);
15272
0
        }
15273
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15274
0
                               end_col_offset, arena);
15275
0
        if (*out == NULL) goto failed;
15276
0
        return 0;
15277
0
    }
15278
0
    tp = state->Attribute_type;
15279
0
    isinstance = PyObject_IsInstance(obj, tp);
15280
0
    if (isinstance == -1) {
15281
0
        return -1;
15282
0
    }
15283
0
    if (isinstance) {
15284
0
        expr_ty value;
15285
0
        identifier attr;
15286
0
        expr_context_ty ctx;
15287
15288
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15289
0
            return -1;
15290
0
        }
15291
0
        if (tmp == NULL) {
15292
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15293
0
            return -1;
15294
0
        }
15295
0
        else {
15296
0
            int res;
15297
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15298
0
                goto failed;
15299
0
            }
15300
0
            res = obj2ast_expr(state, tmp, &value, arena);
15301
0
            _Py_LeaveRecursiveCall();
15302
0
            if (res != 0) goto failed;
15303
0
            Py_CLEAR(tmp);
15304
0
        }
15305
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15306
0
            return -1;
15307
0
        }
15308
0
        if (tmp == NULL) {
15309
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15310
0
            return -1;
15311
0
        }
15312
0
        else {
15313
0
            int res;
15314
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15315
0
                goto failed;
15316
0
            }
15317
0
            res = obj2ast_identifier(state, tmp, &attr, arena);
15318
0
            _Py_LeaveRecursiveCall();
15319
0
            if (res != 0) goto failed;
15320
0
            Py_CLEAR(tmp);
15321
0
        }
15322
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15323
0
            return -1;
15324
0
        }
15325
0
        if (tmp == NULL) {
15326
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15327
0
            return -1;
15328
0
        }
15329
0
        else {
15330
0
            int res;
15331
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15332
0
                goto failed;
15333
0
            }
15334
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15335
0
            _Py_LeaveRecursiveCall();
15336
0
            if (res != 0) goto failed;
15337
0
            Py_CLEAR(tmp);
15338
0
        }
15339
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15340
0
                                end_lineno, end_col_offset, arena);
15341
0
        if (*out == NULL) goto failed;
15342
0
        return 0;
15343
0
    }
15344
0
    tp = state->Subscript_type;
15345
0
    isinstance = PyObject_IsInstance(obj, tp);
15346
0
    if (isinstance == -1) {
15347
0
        return -1;
15348
0
    }
15349
0
    if (isinstance) {
15350
0
        expr_ty value;
15351
0
        expr_ty slice;
15352
0
        expr_context_ty ctx;
15353
15354
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15355
0
            return -1;
15356
0
        }
15357
0
        if (tmp == NULL) {
15358
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15359
0
            return -1;
15360
0
        }
15361
0
        else {
15362
0
            int res;
15363
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15364
0
                goto failed;
15365
0
            }
15366
0
            res = obj2ast_expr(state, tmp, &value, arena);
15367
0
            _Py_LeaveRecursiveCall();
15368
0
            if (res != 0) goto failed;
15369
0
            Py_CLEAR(tmp);
15370
0
        }
15371
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15372
0
            return -1;
15373
0
        }
15374
0
        if (tmp == NULL) {
15375
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15376
0
            return -1;
15377
0
        }
15378
0
        else {
15379
0
            int res;
15380
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15381
0
                goto failed;
15382
0
            }
15383
0
            res = obj2ast_expr(state, tmp, &slice, arena);
15384
0
            _Py_LeaveRecursiveCall();
15385
0
            if (res != 0) goto failed;
15386
0
            Py_CLEAR(tmp);
15387
0
        }
15388
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15389
0
            return -1;
15390
0
        }
15391
0
        if (tmp == NULL) {
15392
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15393
0
            return -1;
15394
0
        }
15395
0
        else {
15396
0
            int res;
15397
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15398
0
                goto failed;
15399
0
            }
15400
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15401
0
            _Py_LeaveRecursiveCall();
15402
0
            if (res != 0) goto failed;
15403
0
            Py_CLEAR(tmp);
15404
0
        }
15405
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15406
0
                                end_lineno, end_col_offset, arena);
15407
0
        if (*out == NULL) goto failed;
15408
0
        return 0;
15409
0
    }
15410
0
    tp = state->Starred_type;
15411
0
    isinstance = PyObject_IsInstance(obj, tp);
15412
0
    if (isinstance == -1) {
15413
0
        return -1;
15414
0
    }
15415
0
    if (isinstance) {
15416
0
        expr_ty value;
15417
0
        expr_context_ty ctx;
15418
15419
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15420
0
            return -1;
15421
0
        }
15422
0
        if (tmp == NULL) {
15423
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15424
0
            return -1;
15425
0
        }
15426
0
        else {
15427
0
            int res;
15428
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15429
0
                goto failed;
15430
0
            }
15431
0
            res = obj2ast_expr(state, tmp, &value, arena);
15432
0
            _Py_LeaveRecursiveCall();
15433
0
            if (res != 0) goto failed;
15434
0
            Py_CLEAR(tmp);
15435
0
        }
15436
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15437
0
            return -1;
15438
0
        }
15439
0
        if (tmp == NULL) {
15440
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15441
0
            return -1;
15442
0
        }
15443
0
        else {
15444
0
            int res;
15445
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15446
0
                goto failed;
15447
0
            }
15448
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15449
0
            _Py_LeaveRecursiveCall();
15450
0
            if (res != 0) goto failed;
15451
0
            Py_CLEAR(tmp);
15452
0
        }
15453
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15454
0
                              end_col_offset, arena);
15455
0
        if (*out == NULL) goto failed;
15456
0
        return 0;
15457
0
    }
15458
0
    tp = state->Name_type;
15459
0
    isinstance = PyObject_IsInstance(obj, tp);
15460
0
    if (isinstance == -1) {
15461
0
        return -1;
15462
0
    }
15463
0
    if (isinstance) {
15464
0
        identifier id;
15465
0
        expr_context_ty ctx;
15466
15467
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15468
0
            return -1;
15469
0
        }
15470
0
        if (tmp == NULL) {
15471
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15472
0
            return -1;
15473
0
        }
15474
0
        else {
15475
0
            int res;
15476
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15477
0
                goto failed;
15478
0
            }
15479
0
            res = obj2ast_identifier(state, tmp, &id, arena);
15480
0
            _Py_LeaveRecursiveCall();
15481
0
            if (res != 0) goto failed;
15482
0
            Py_CLEAR(tmp);
15483
0
        }
15484
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15485
0
            return -1;
15486
0
        }
15487
0
        if (tmp == NULL) {
15488
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15489
0
            return -1;
15490
0
        }
15491
0
        else {
15492
0
            int res;
15493
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15494
0
                goto failed;
15495
0
            }
15496
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15497
0
            _Py_LeaveRecursiveCall();
15498
0
            if (res != 0) goto failed;
15499
0
            Py_CLEAR(tmp);
15500
0
        }
15501
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15502
0
                           end_col_offset, arena);
15503
0
        if (*out == NULL) goto failed;
15504
0
        return 0;
15505
0
    }
15506
0
    tp = state->List_type;
15507
0
    isinstance = PyObject_IsInstance(obj, tp);
15508
0
    if (isinstance == -1) {
15509
0
        return -1;
15510
0
    }
15511
0
    if (isinstance) {
15512
0
        asdl_expr_seq* elts;
15513
0
        expr_context_ty ctx;
15514
15515
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15516
0
            return -1;
15517
0
        }
15518
0
        if (tmp == NULL) {
15519
0
            tmp = PyList_New(0);
15520
0
            if (tmp == NULL) {
15521
0
                return -1;
15522
0
            }
15523
0
        }
15524
0
        {
15525
0
            int res;
15526
0
            Py_ssize_t len;
15527
0
            Py_ssize_t i;
15528
0
            if (!PyList_Check(tmp)) {
15529
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15530
0
                goto failed;
15531
0
            }
15532
0
            len = PyList_GET_SIZE(tmp);
15533
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15534
0
            if (elts == NULL) goto failed;
15535
0
            for (i = 0; i < len; i++) {
15536
0
                expr_ty val;
15537
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15538
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15539
0
                    goto failed;
15540
0
                }
15541
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15542
0
                _Py_LeaveRecursiveCall();
15543
0
                Py_DECREF(tmp2);
15544
0
                if (res != 0) goto failed;
15545
0
                if (len != PyList_GET_SIZE(tmp)) {
15546
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15547
0
                    goto failed;
15548
0
                }
15549
0
                asdl_seq_SET(elts, i, val);
15550
0
            }
15551
0
            Py_CLEAR(tmp);
15552
0
        }
15553
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15554
0
            return -1;
15555
0
        }
15556
0
        if (tmp == NULL) {
15557
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15558
0
            return -1;
15559
0
        }
15560
0
        else {
15561
0
            int res;
15562
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15563
0
                goto failed;
15564
0
            }
15565
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15566
0
            _Py_LeaveRecursiveCall();
15567
0
            if (res != 0) goto failed;
15568
0
            Py_CLEAR(tmp);
15569
0
        }
15570
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15571
0
                           end_col_offset, arena);
15572
0
        if (*out == NULL) goto failed;
15573
0
        return 0;
15574
0
    }
15575
0
    tp = state->Tuple_type;
15576
0
    isinstance = PyObject_IsInstance(obj, tp);
15577
0
    if (isinstance == -1) {
15578
0
        return -1;
15579
0
    }
15580
0
    if (isinstance) {
15581
0
        asdl_expr_seq* elts;
15582
0
        expr_context_ty ctx;
15583
15584
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15585
0
            return -1;
15586
0
        }
15587
0
        if (tmp == NULL) {
15588
0
            tmp = PyList_New(0);
15589
0
            if (tmp == NULL) {
15590
0
                return -1;
15591
0
            }
15592
0
        }
15593
0
        {
15594
0
            int res;
15595
0
            Py_ssize_t len;
15596
0
            Py_ssize_t i;
15597
0
            if (!PyList_Check(tmp)) {
15598
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15599
0
                goto failed;
15600
0
            }
15601
0
            len = PyList_GET_SIZE(tmp);
15602
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15603
0
            if (elts == NULL) goto failed;
15604
0
            for (i = 0; i < len; i++) {
15605
0
                expr_ty val;
15606
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15607
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15608
0
                    goto failed;
15609
0
                }
15610
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15611
0
                _Py_LeaveRecursiveCall();
15612
0
                Py_DECREF(tmp2);
15613
0
                if (res != 0) goto failed;
15614
0
                if (len != PyList_GET_SIZE(tmp)) {
15615
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15616
0
                    goto failed;
15617
0
                }
15618
0
                asdl_seq_SET(elts, i, val);
15619
0
            }
15620
0
            Py_CLEAR(tmp);
15621
0
        }
15622
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15623
0
            return -1;
15624
0
        }
15625
0
        if (tmp == NULL) {
15626
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15627
0
            return -1;
15628
0
        }
15629
0
        else {
15630
0
            int res;
15631
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15632
0
                goto failed;
15633
0
            }
15634
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15635
0
            _Py_LeaveRecursiveCall();
15636
0
            if (res != 0) goto failed;
15637
0
            Py_CLEAR(tmp);
15638
0
        }
15639
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15640
0
                            end_col_offset, arena);
15641
0
        if (*out == NULL) goto failed;
15642
0
        return 0;
15643
0
    }
15644
0
    tp = state->Slice_type;
15645
0
    isinstance = PyObject_IsInstance(obj, tp);
15646
0
    if (isinstance == -1) {
15647
0
        return -1;
15648
0
    }
15649
0
    if (isinstance) {
15650
0
        expr_ty lower;
15651
0
        expr_ty upper;
15652
0
        expr_ty step;
15653
15654
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15655
0
            return -1;
15656
0
        }
15657
0
        if (tmp == NULL || tmp == Py_None) {
15658
0
            Py_CLEAR(tmp);
15659
0
            lower = NULL;
15660
0
        }
15661
0
        else {
15662
0
            int res;
15663
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15664
0
                goto failed;
15665
0
            }
15666
0
            res = obj2ast_expr(state, tmp, &lower, arena);
15667
0
            _Py_LeaveRecursiveCall();
15668
0
            if (res != 0) goto failed;
15669
0
            Py_CLEAR(tmp);
15670
0
        }
15671
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15672
0
            return -1;
15673
0
        }
15674
0
        if (tmp == NULL || tmp == Py_None) {
15675
0
            Py_CLEAR(tmp);
15676
0
            upper = NULL;
15677
0
        }
15678
0
        else {
15679
0
            int res;
15680
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15681
0
                goto failed;
15682
0
            }
15683
0
            res = obj2ast_expr(state, tmp, &upper, arena);
15684
0
            _Py_LeaveRecursiveCall();
15685
0
            if (res != 0) goto failed;
15686
0
            Py_CLEAR(tmp);
15687
0
        }
15688
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15689
0
            return -1;
15690
0
        }
15691
0
        if (tmp == NULL || tmp == Py_None) {
15692
0
            Py_CLEAR(tmp);
15693
0
            step = NULL;
15694
0
        }
15695
0
        else {
15696
0
            int res;
15697
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15698
0
                goto failed;
15699
0
            }
15700
0
            res = obj2ast_expr(state, tmp, &step, arena);
15701
0
            _Py_LeaveRecursiveCall();
15702
0
            if (res != 0) goto failed;
15703
0
            Py_CLEAR(tmp);
15704
0
        }
15705
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15706
0
                            end_col_offset, arena);
15707
0
        if (*out == NULL) goto failed;
15708
0
        return 0;
15709
0
    }
15710
15711
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15712
0
    failed:
15713
0
    Py_XDECREF(tmp);
15714
0
    return -1;
15715
0
}
15716
15717
int
15718
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15719
                     out, PyArena* arena)
15720
0
{
15721
0
    int isinstance;
15722
15723
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15724
0
    if (isinstance == -1) {
15725
0
        return -1;
15726
0
    }
15727
0
    if (isinstance) {
15728
0
        *out = Load;
15729
0
        return 0;
15730
0
    }
15731
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15732
0
    if (isinstance == -1) {
15733
0
        return -1;
15734
0
    }
15735
0
    if (isinstance) {
15736
0
        *out = Store;
15737
0
        return 0;
15738
0
    }
15739
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15740
0
    if (isinstance == -1) {
15741
0
        return -1;
15742
0
    }
15743
0
    if (isinstance) {
15744
0
        *out = Del;
15745
0
        return 0;
15746
0
    }
15747
15748
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15749
0
    return -1;
15750
0
}
15751
15752
int
15753
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
15754
               arena)
15755
0
{
15756
0
    int isinstance;
15757
15758
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15759
0
    if (isinstance == -1) {
15760
0
        return -1;
15761
0
    }
15762
0
    if (isinstance) {
15763
0
        *out = And;
15764
0
        return 0;
15765
0
    }
15766
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15767
0
    if (isinstance == -1) {
15768
0
        return -1;
15769
0
    }
15770
0
    if (isinstance) {
15771
0
        *out = Or;
15772
0
        return 0;
15773
0
    }
15774
15775
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15776
0
    return -1;
15777
0
}
15778
15779
int
15780
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15781
                 PyArena* arena)
15782
0
{
15783
0
    int isinstance;
15784
15785
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15786
0
    if (isinstance == -1) {
15787
0
        return -1;
15788
0
    }
15789
0
    if (isinstance) {
15790
0
        *out = Add;
15791
0
        return 0;
15792
0
    }
15793
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15794
0
    if (isinstance == -1) {
15795
0
        return -1;
15796
0
    }
15797
0
    if (isinstance) {
15798
0
        *out = Sub;
15799
0
        return 0;
15800
0
    }
15801
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15802
0
    if (isinstance == -1) {
15803
0
        return -1;
15804
0
    }
15805
0
    if (isinstance) {
15806
0
        *out = Mult;
15807
0
        return 0;
15808
0
    }
15809
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15810
0
    if (isinstance == -1) {
15811
0
        return -1;
15812
0
    }
15813
0
    if (isinstance) {
15814
0
        *out = MatMult;
15815
0
        return 0;
15816
0
    }
15817
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15818
0
    if (isinstance == -1) {
15819
0
        return -1;
15820
0
    }
15821
0
    if (isinstance) {
15822
0
        *out = Div;
15823
0
        return 0;
15824
0
    }
15825
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15826
0
    if (isinstance == -1) {
15827
0
        return -1;
15828
0
    }
15829
0
    if (isinstance) {
15830
0
        *out = Mod;
15831
0
        return 0;
15832
0
    }
15833
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15834
0
    if (isinstance == -1) {
15835
0
        return -1;
15836
0
    }
15837
0
    if (isinstance) {
15838
0
        *out = Pow;
15839
0
        return 0;
15840
0
    }
15841
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15842
0
    if (isinstance == -1) {
15843
0
        return -1;
15844
0
    }
15845
0
    if (isinstance) {
15846
0
        *out = LShift;
15847
0
        return 0;
15848
0
    }
15849
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15850
0
    if (isinstance == -1) {
15851
0
        return -1;
15852
0
    }
15853
0
    if (isinstance) {
15854
0
        *out = RShift;
15855
0
        return 0;
15856
0
    }
15857
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15858
0
    if (isinstance == -1) {
15859
0
        return -1;
15860
0
    }
15861
0
    if (isinstance) {
15862
0
        *out = BitOr;
15863
0
        return 0;
15864
0
    }
15865
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15866
0
    if (isinstance == -1) {
15867
0
        return -1;
15868
0
    }
15869
0
    if (isinstance) {
15870
0
        *out = BitXor;
15871
0
        return 0;
15872
0
    }
15873
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15874
0
    if (isinstance == -1) {
15875
0
        return -1;
15876
0
    }
15877
0
    if (isinstance) {
15878
0
        *out = BitAnd;
15879
0
        return 0;
15880
0
    }
15881
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15882
0
    if (isinstance == -1) {
15883
0
        return -1;
15884
0
    }
15885
0
    if (isinstance) {
15886
0
        *out = FloorDiv;
15887
0
        return 0;
15888
0
    }
15889
15890
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15891
0
    return -1;
15892
0
}
15893
15894
int
15895
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
15896
                PyArena* arena)
15897
0
{
15898
0
    int isinstance;
15899
15900
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15901
0
    if (isinstance == -1) {
15902
0
        return -1;
15903
0
    }
15904
0
    if (isinstance) {
15905
0
        *out = Invert;
15906
0
        return 0;
15907
0
    }
15908
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15909
0
    if (isinstance == -1) {
15910
0
        return -1;
15911
0
    }
15912
0
    if (isinstance) {
15913
0
        *out = Not;
15914
0
        return 0;
15915
0
    }
15916
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15917
0
    if (isinstance == -1) {
15918
0
        return -1;
15919
0
    }
15920
0
    if (isinstance) {
15921
0
        *out = UAdd;
15922
0
        return 0;
15923
0
    }
15924
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15925
0
    if (isinstance == -1) {
15926
0
        return -1;
15927
0
    }
15928
0
    if (isinstance) {
15929
0
        *out = USub;
15930
0
        return 0;
15931
0
    }
15932
15933
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15934
0
    return -1;
15935
0
}
15936
15937
int
15938
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
15939
              arena)
15940
0
{
15941
0
    int isinstance;
15942
15943
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15944
0
    if (isinstance == -1) {
15945
0
        return -1;
15946
0
    }
15947
0
    if (isinstance) {
15948
0
        *out = Eq;
15949
0
        return 0;
15950
0
    }
15951
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
15952
0
    if (isinstance == -1) {
15953
0
        return -1;
15954
0
    }
15955
0
    if (isinstance) {
15956
0
        *out = NotEq;
15957
0
        return 0;
15958
0
    }
15959
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
15960
0
    if (isinstance == -1) {
15961
0
        return -1;
15962
0
    }
15963
0
    if (isinstance) {
15964
0
        *out = Lt;
15965
0
        return 0;
15966
0
    }
15967
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
15968
0
    if (isinstance == -1) {
15969
0
        return -1;
15970
0
    }
15971
0
    if (isinstance) {
15972
0
        *out = LtE;
15973
0
        return 0;
15974
0
    }
15975
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
15976
0
    if (isinstance == -1) {
15977
0
        return -1;
15978
0
    }
15979
0
    if (isinstance) {
15980
0
        *out = Gt;
15981
0
        return 0;
15982
0
    }
15983
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
15984
0
    if (isinstance == -1) {
15985
0
        return -1;
15986
0
    }
15987
0
    if (isinstance) {
15988
0
        *out = GtE;
15989
0
        return 0;
15990
0
    }
15991
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
15992
0
    if (isinstance == -1) {
15993
0
        return -1;
15994
0
    }
15995
0
    if (isinstance) {
15996
0
        *out = Is;
15997
0
        return 0;
15998
0
    }
15999
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
16000
0
    if (isinstance == -1) {
16001
0
        return -1;
16002
0
    }
16003
0
    if (isinstance) {
16004
0
        *out = IsNot;
16005
0
        return 0;
16006
0
    }
16007
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
16008
0
    if (isinstance == -1) {
16009
0
        return -1;
16010
0
    }
16011
0
    if (isinstance) {
16012
0
        *out = In;
16013
0
        return 0;
16014
0
    }
16015
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16016
0
    if (isinstance == -1) {
16017
0
        return -1;
16018
0
    }
16019
0
    if (isinstance) {
16020
0
        *out = NotIn;
16021
0
        return 0;
16022
0
    }
16023
16024
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16025
0
    return -1;
16026
0
}
16027
16028
int
16029
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16030
                      out, PyArena* arena)
16031
0
{
16032
0
    PyObject* tmp = NULL;
16033
0
    expr_ty target;
16034
0
    expr_ty iter;
16035
0
    asdl_expr_seq* ifs;
16036
0
    int is_async;
16037
16038
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16039
0
        return -1;
16040
0
    }
16041
0
    if (tmp == NULL) {
16042
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16043
0
        return -1;
16044
0
    }
16045
0
    else {
16046
0
        int res;
16047
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16048
0
            goto failed;
16049
0
        }
16050
0
        res = obj2ast_expr(state, tmp, &target, arena);
16051
0
        _Py_LeaveRecursiveCall();
16052
0
        if (res != 0) goto failed;
16053
0
        Py_CLEAR(tmp);
16054
0
    }
16055
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16056
0
        return -1;
16057
0
    }
16058
0
    if (tmp == NULL) {
16059
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16060
0
        return -1;
16061
0
    }
16062
0
    else {
16063
0
        int res;
16064
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16065
0
            goto failed;
16066
0
        }
16067
0
        res = obj2ast_expr(state, tmp, &iter, arena);
16068
0
        _Py_LeaveRecursiveCall();
16069
0
        if (res != 0) goto failed;
16070
0
        Py_CLEAR(tmp);
16071
0
    }
16072
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16073
0
        return -1;
16074
0
    }
16075
0
    if (tmp == NULL) {
16076
0
        tmp = PyList_New(0);
16077
0
        if (tmp == NULL) {
16078
0
            return -1;
16079
0
        }
16080
0
    }
16081
0
    {
16082
0
        int res;
16083
0
        Py_ssize_t len;
16084
0
        Py_ssize_t i;
16085
0
        if (!PyList_Check(tmp)) {
16086
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16087
0
            goto failed;
16088
0
        }
16089
0
        len = PyList_GET_SIZE(tmp);
16090
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16091
0
        if (ifs == NULL) goto failed;
16092
0
        for (i = 0; i < len; i++) {
16093
0
            expr_ty val;
16094
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16095
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16096
0
                goto failed;
16097
0
            }
16098
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16099
0
            _Py_LeaveRecursiveCall();
16100
0
            Py_DECREF(tmp2);
16101
0
            if (res != 0) goto failed;
16102
0
            if (len != PyList_GET_SIZE(tmp)) {
16103
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16104
0
                goto failed;
16105
0
            }
16106
0
            asdl_seq_SET(ifs, i, val);
16107
0
        }
16108
0
        Py_CLEAR(tmp);
16109
0
    }
16110
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16111
0
        return -1;
16112
0
    }
16113
0
    if (tmp == NULL) {
16114
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16115
0
        return -1;
16116
0
    }
16117
0
    else {
16118
0
        int res;
16119
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16120
0
            goto failed;
16121
0
        }
16122
0
        res = obj2ast_int(state, tmp, &is_async, arena);
16123
0
        _Py_LeaveRecursiveCall();
16124
0
        if (res != 0) goto failed;
16125
0
        Py_CLEAR(tmp);
16126
0
    }
16127
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16128
0
    if (*out == NULL) goto failed;
16129
0
    return 0;
16130
0
failed:
16131
0
    Py_XDECREF(tmp);
16132
0
    return -1;
16133
0
}
16134
16135
int
16136
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16137
                      out, PyArena* arena)
16138
0
{
16139
0
    int isinstance;
16140
16141
0
    PyObject *tmp = NULL;
16142
0
    PyObject *tp;
16143
0
    int lineno;
16144
0
    int col_offset;
16145
0
    int end_lineno;
16146
0
    int end_col_offset;
16147
16148
0
    if (obj == Py_None) {
16149
0
        *out = NULL;
16150
0
        return 0;
16151
0
    }
16152
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16153
0
        return -1;
16154
0
    }
16155
0
    if (tmp == NULL) {
16156
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16157
0
        return -1;
16158
0
    }
16159
0
    else {
16160
0
        int res;
16161
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16162
0
            goto failed;
16163
0
        }
16164
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16165
0
        _Py_LeaveRecursiveCall();
16166
0
        if (res != 0) goto failed;
16167
0
        Py_CLEAR(tmp);
16168
0
    }
16169
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16170
0
        return -1;
16171
0
    }
16172
0
    if (tmp == NULL) {
16173
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16174
0
        return -1;
16175
0
    }
16176
0
    else {
16177
0
        int res;
16178
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16179
0
            goto failed;
16180
0
        }
16181
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16182
0
        _Py_LeaveRecursiveCall();
16183
0
        if (res != 0) goto failed;
16184
0
        Py_CLEAR(tmp);
16185
0
    }
16186
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16187
0
        return -1;
16188
0
    }
16189
0
    if (tmp == NULL || tmp == Py_None) {
16190
0
        Py_CLEAR(tmp);
16191
0
        end_lineno = lineno;
16192
0
    }
16193
0
    else {
16194
0
        int res;
16195
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16196
0
            goto failed;
16197
0
        }
16198
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16199
0
        _Py_LeaveRecursiveCall();
16200
0
        if (res != 0) goto failed;
16201
0
        Py_CLEAR(tmp);
16202
0
    }
16203
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16204
0
        return -1;
16205
0
    }
16206
0
    if (tmp == NULL || tmp == Py_None) {
16207
0
        Py_CLEAR(tmp);
16208
0
        end_col_offset = col_offset;
16209
0
    }
16210
0
    else {
16211
0
        int res;
16212
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16213
0
            goto failed;
16214
0
        }
16215
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16216
0
        _Py_LeaveRecursiveCall();
16217
0
        if (res != 0) goto failed;
16218
0
        Py_CLEAR(tmp);
16219
0
    }
16220
0
    tp = state->ExceptHandler_type;
16221
0
    isinstance = PyObject_IsInstance(obj, tp);
16222
0
    if (isinstance == -1) {
16223
0
        return -1;
16224
0
    }
16225
0
    if (isinstance) {
16226
0
        expr_ty type;
16227
0
        identifier name;
16228
0
        asdl_stmt_seq* body;
16229
16230
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16231
0
            return -1;
16232
0
        }
16233
0
        if (tmp == NULL || tmp == Py_None) {
16234
0
            Py_CLEAR(tmp);
16235
0
            type = NULL;
16236
0
        }
16237
0
        else {
16238
0
            int res;
16239
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16240
0
                goto failed;
16241
0
            }
16242
0
            res = obj2ast_expr(state, tmp, &type, arena);
16243
0
            _Py_LeaveRecursiveCall();
16244
0
            if (res != 0) goto failed;
16245
0
            Py_CLEAR(tmp);
16246
0
        }
16247
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16248
0
            return -1;
16249
0
        }
16250
0
        if (tmp == NULL || tmp == Py_None) {
16251
0
            Py_CLEAR(tmp);
16252
0
            name = NULL;
16253
0
        }
16254
0
        else {
16255
0
            int res;
16256
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16257
0
                goto failed;
16258
0
            }
16259
0
            res = obj2ast_identifier(state, tmp, &name, arena);
16260
0
            _Py_LeaveRecursiveCall();
16261
0
            if (res != 0) goto failed;
16262
0
            Py_CLEAR(tmp);
16263
0
        }
16264
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16265
0
            return -1;
16266
0
        }
16267
0
        if (tmp == NULL) {
16268
0
            tmp = PyList_New(0);
16269
0
            if (tmp == NULL) {
16270
0
                return -1;
16271
0
            }
16272
0
        }
16273
0
        {
16274
0
            int res;
16275
0
            Py_ssize_t len;
16276
0
            Py_ssize_t i;
16277
0
            if (!PyList_Check(tmp)) {
16278
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16279
0
                goto failed;
16280
0
            }
16281
0
            len = PyList_GET_SIZE(tmp);
16282
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16283
0
            if (body == NULL) goto failed;
16284
0
            for (i = 0; i < len; i++) {
16285
0
                stmt_ty val;
16286
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16287
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16288
0
                    goto failed;
16289
0
                }
16290
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
16291
0
                _Py_LeaveRecursiveCall();
16292
0
                Py_DECREF(tmp2);
16293
0
                if (res != 0) goto failed;
16294
0
                if (len != PyList_GET_SIZE(tmp)) {
16295
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16296
0
                    goto failed;
16297
0
                }
16298
0
                asdl_seq_SET(body, i, val);
16299
0
            }
16300
0
            Py_CLEAR(tmp);
16301
0
        }
16302
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16303
0
                                    end_lineno, end_col_offset, arena);
16304
0
        if (*out == NULL) goto failed;
16305
0
        return 0;
16306
0
    }
16307
16308
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16309
0
    failed:
16310
0
    Py_XDECREF(tmp);
16311
0
    return -1;
16312
0
}
16313
16314
int
16315
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16316
                  PyArena* arena)
16317
0
{
16318
0
    PyObject* tmp = NULL;
16319
0
    asdl_arg_seq* posonlyargs;
16320
0
    asdl_arg_seq* args;
16321
0
    arg_ty vararg;
16322
0
    asdl_arg_seq* kwonlyargs;
16323
0
    asdl_expr_seq* kw_defaults;
16324
0
    arg_ty kwarg;
16325
0
    asdl_expr_seq* defaults;
16326
16327
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16328
0
        return -1;
16329
0
    }
16330
0
    if (tmp == NULL) {
16331
0
        tmp = PyList_New(0);
16332
0
        if (tmp == NULL) {
16333
0
            return -1;
16334
0
        }
16335
0
    }
16336
0
    {
16337
0
        int res;
16338
0
        Py_ssize_t len;
16339
0
        Py_ssize_t i;
16340
0
        if (!PyList_Check(tmp)) {
16341
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16342
0
            goto failed;
16343
0
        }
16344
0
        len = PyList_GET_SIZE(tmp);
16345
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16346
0
        if (posonlyargs == NULL) goto failed;
16347
0
        for (i = 0; i < len; i++) {
16348
0
            arg_ty val;
16349
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16350
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16351
0
                goto failed;
16352
0
            }
16353
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16354
0
            _Py_LeaveRecursiveCall();
16355
0
            Py_DECREF(tmp2);
16356
0
            if (res != 0) goto failed;
16357
0
            if (len != PyList_GET_SIZE(tmp)) {
16358
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16359
0
                goto failed;
16360
0
            }
16361
0
            asdl_seq_SET(posonlyargs, i, val);
16362
0
        }
16363
0
        Py_CLEAR(tmp);
16364
0
    }
16365
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16366
0
        return -1;
16367
0
    }
16368
0
    if (tmp == NULL) {
16369
0
        tmp = PyList_New(0);
16370
0
        if (tmp == NULL) {
16371
0
            return -1;
16372
0
        }
16373
0
    }
16374
0
    {
16375
0
        int res;
16376
0
        Py_ssize_t len;
16377
0
        Py_ssize_t i;
16378
0
        if (!PyList_Check(tmp)) {
16379
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16380
0
            goto failed;
16381
0
        }
16382
0
        len = PyList_GET_SIZE(tmp);
16383
0
        args = _Py_asdl_arg_seq_new(len, arena);
16384
0
        if (args == NULL) goto failed;
16385
0
        for (i = 0; i < len; i++) {
16386
0
            arg_ty val;
16387
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16388
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16389
0
                goto failed;
16390
0
            }
16391
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16392
0
            _Py_LeaveRecursiveCall();
16393
0
            Py_DECREF(tmp2);
16394
0
            if (res != 0) goto failed;
16395
0
            if (len != PyList_GET_SIZE(tmp)) {
16396
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16397
0
                goto failed;
16398
0
            }
16399
0
            asdl_seq_SET(args, i, val);
16400
0
        }
16401
0
        Py_CLEAR(tmp);
16402
0
    }
16403
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16404
0
        return -1;
16405
0
    }
16406
0
    if (tmp == NULL || tmp == Py_None) {
16407
0
        Py_CLEAR(tmp);
16408
0
        vararg = NULL;
16409
0
    }
16410
0
    else {
16411
0
        int res;
16412
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16413
0
            goto failed;
16414
0
        }
16415
0
        res = obj2ast_arg(state, tmp, &vararg, arena);
16416
0
        _Py_LeaveRecursiveCall();
16417
0
        if (res != 0) goto failed;
16418
0
        Py_CLEAR(tmp);
16419
0
    }
16420
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16421
0
        return -1;
16422
0
    }
16423
0
    if (tmp == NULL) {
16424
0
        tmp = PyList_New(0);
16425
0
        if (tmp == NULL) {
16426
0
            return -1;
16427
0
        }
16428
0
    }
16429
0
    {
16430
0
        int res;
16431
0
        Py_ssize_t len;
16432
0
        Py_ssize_t i;
16433
0
        if (!PyList_Check(tmp)) {
16434
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16435
0
            goto failed;
16436
0
        }
16437
0
        len = PyList_GET_SIZE(tmp);
16438
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16439
0
        if (kwonlyargs == NULL) goto failed;
16440
0
        for (i = 0; i < len; i++) {
16441
0
            arg_ty val;
16442
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16443
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16444
0
                goto failed;
16445
0
            }
16446
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16447
0
            _Py_LeaveRecursiveCall();
16448
0
            Py_DECREF(tmp2);
16449
0
            if (res != 0) goto failed;
16450
0
            if (len != PyList_GET_SIZE(tmp)) {
16451
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16452
0
                goto failed;
16453
0
            }
16454
0
            asdl_seq_SET(kwonlyargs, i, val);
16455
0
        }
16456
0
        Py_CLEAR(tmp);
16457
0
    }
16458
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16459
0
        return -1;
16460
0
    }
16461
0
    if (tmp == NULL) {
16462
0
        tmp = PyList_New(0);
16463
0
        if (tmp == NULL) {
16464
0
            return -1;
16465
0
        }
16466
0
    }
16467
0
    {
16468
0
        int res;
16469
0
        Py_ssize_t len;
16470
0
        Py_ssize_t i;
16471
0
        if (!PyList_Check(tmp)) {
16472
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16473
0
            goto failed;
16474
0
        }
16475
0
        len = PyList_GET_SIZE(tmp);
16476
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16477
0
        if (kw_defaults == NULL) goto failed;
16478
0
        for (i = 0; i < len; i++) {
16479
0
            expr_ty val;
16480
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16481
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16482
0
                goto failed;
16483
0
            }
16484
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16485
0
            _Py_LeaveRecursiveCall();
16486
0
            Py_DECREF(tmp2);
16487
0
            if (res != 0) goto failed;
16488
0
            if (len != PyList_GET_SIZE(tmp)) {
16489
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16490
0
                goto failed;
16491
0
            }
16492
0
            asdl_seq_SET(kw_defaults, i, val);
16493
0
        }
16494
0
        Py_CLEAR(tmp);
16495
0
    }
16496
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16497
0
        return -1;
16498
0
    }
16499
0
    if (tmp == NULL || tmp == Py_None) {
16500
0
        Py_CLEAR(tmp);
16501
0
        kwarg = NULL;
16502
0
    }
16503
0
    else {
16504
0
        int res;
16505
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16506
0
            goto failed;
16507
0
        }
16508
0
        res = obj2ast_arg(state, tmp, &kwarg, arena);
16509
0
        _Py_LeaveRecursiveCall();
16510
0
        if (res != 0) goto failed;
16511
0
        Py_CLEAR(tmp);
16512
0
    }
16513
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16514
0
        return -1;
16515
0
    }
16516
0
    if (tmp == NULL) {
16517
0
        tmp = PyList_New(0);
16518
0
        if (tmp == NULL) {
16519
0
            return -1;
16520
0
        }
16521
0
    }
16522
0
    {
16523
0
        int res;
16524
0
        Py_ssize_t len;
16525
0
        Py_ssize_t i;
16526
0
        if (!PyList_Check(tmp)) {
16527
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16528
0
            goto failed;
16529
0
        }
16530
0
        len = PyList_GET_SIZE(tmp);
16531
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16532
0
        if (defaults == NULL) goto failed;
16533
0
        for (i = 0; i < len; i++) {
16534
0
            expr_ty val;
16535
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16536
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16537
0
                goto failed;
16538
0
            }
16539
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16540
0
            _Py_LeaveRecursiveCall();
16541
0
            Py_DECREF(tmp2);
16542
0
            if (res != 0) goto failed;
16543
0
            if (len != PyList_GET_SIZE(tmp)) {
16544
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16545
0
                goto failed;
16546
0
            }
16547
0
            asdl_seq_SET(defaults, i, val);
16548
0
        }
16549
0
        Py_CLEAR(tmp);
16550
0
    }
16551
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16552
0
                            kwarg, defaults, arena);
16553
0
    if (*out == NULL) goto failed;
16554
0
    return 0;
16555
0
failed:
16556
0
    Py_XDECREF(tmp);
16557
0
    return -1;
16558
0
}
16559
16560
int
16561
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
16562
0
{
16563
0
    PyObject* tmp = NULL;
16564
0
    identifier arg;
16565
0
    expr_ty annotation;
16566
0
    string type_comment;
16567
0
    int lineno;
16568
0
    int col_offset;
16569
0
    int end_lineno;
16570
0
    int end_col_offset;
16571
16572
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16573
0
        return -1;
16574
0
    }
16575
0
    if (tmp == NULL) {
16576
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16577
0
        return -1;
16578
0
    }
16579
0
    else {
16580
0
        int res;
16581
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16582
0
            goto failed;
16583
0
        }
16584
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16585
0
        _Py_LeaveRecursiveCall();
16586
0
        if (res != 0) goto failed;
16587
0
        Py_CLEAR(tmp);
16588
0
    }
16589
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16590
0
        return -1;
16591
0
    }
16592
0
    if (tmp == NULL || tmp == Py_None) {
16593
0
        Py_CLEAR(tmp);
16594
0
        annotation = NULL;
16595
0
    }
16596
0
    else {
16597
0
        int res;
16598
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16599
0
            goto failed;
16600
0
        }
16601
0
        res = obj2ast_expr(state, tmp, &annotation, arena);
16602
0
        _Py_LeaveRecursiveCall();
16603
0
        if (res != 0) goto failed;
16604
0
        Py_CLEAR(tmp);
16605
0
    }
16606
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16607
0
        return -1;
16608
0
    }
16609
0
    if (tmp == NULL || tmp == Py_None) {
16610
0
        Py_CLEAR(tmp);
16611
0
        type_comment = NULL;
16612
0
    }
16613
0
    else {
16614
0
        int res;
16615
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16616
0
            goto failed;
16617
0
        }
16618
0
        res = obj2ast_string(state, tmp, &type_comment, arena);
16619
0
        _Py_LeaveRecursiveCall();
16620
0
        if (res != 0) goto failed;
16621
0
        Py_CLEAR(tmp);
16622
0
    }
16623
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16624
0
        return -1;
16625
0
    }
16626
0
    if (tmp == NULL) {
16627
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16628
0
        return -1;
16629
0
    }
16630
0
    else {
16631
0
        int res;
16632
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16633
0
            goto failed;
16634
0
        }
16635
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16636
0
        _Py_LeaveRecursiveCall();
16637
0
        if (res != 0) goto failed;
16638
0
        Py_CLEAR(tmp);
16639
0
    }
16640
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16641
0
        return -1;
16642
0
    }
16643
0
    if (tmp == NULL) {
16644
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16645
0
        return -1;
16646
0
    }
16647
0
    else {
16648
0
        int res;
16649
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16650
0
            goto failed;
16651
0
        }
16652
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16653
0
        _Py_LeaveRecursiveCall();
16654
0
        if (res != 0) goto failed;
16655
0
        Py_CLEAR(tmp);
16656
0
    }
16657
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16658
0
        return -1;
16659
0
    }
16660
0
    if (tmp == NULL || tmp == Py_None) {
16661
0
        Py_CLEAR(tmp);
16662
0
        end_lineno = lineno;
16663
0
    }
16664
0
    else {
16665
0
        int res;
16666
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16667
0
            goto failed;
16668
0
        }
16669
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16670
0
        _Py_LeaveRecursiveCall();
16671
0
        if (res != 0) goto failed;
16672
0
        Py_CLEAR(tmp);
16673
0
    }
16674
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16675
0
        return -1;
16676
0
    }
16677
0
    if (tmp == NULL || tmp == Py_None) {
16678
0
        Py_CLEAR(tmp);
16679
0
        end_col_offset = col_offset;
16680
0
    }
16681
0
    else {
16682
0
        int res;
16683
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16684
0
            goto failed;
16685
0
        }
16686
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16687
0
        _Py_LeaveRecursiveCall();
16688
0
        if (res != 0) goto failed;
16689
0
        Py_CLEAR(tmp);
16690
0
    }
16691
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16692
0
                      end_lineno, end_col_offset, arena);
16693
0
    if (*out == NULL) goto failed;
16694
0
    return 0;
16695
0
failed:
16696
0
    Py_XDECREF(tmp);
16697
0
    return -1;
16698
0
}
16699
16700
int
16701
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
16702
                PyArena* arena)
16703
0
{
16704
0
    PyObject* tmp = NULL;
16705
0
    identifier arg;
16706
0
    expr_ty value;
16707
0
    int lineno;
16708
0
    int col_offset;
16709
0
    int end_lineno;
16710
0
    int end_col_offset;
16711
16712
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16713
0
        return -1;
16714
0
    }
16715
0
    if (tmp == NULL || tmp == Py_None) {
16716
0
        Py_CLEAR(tmp);
16717
0
        arg = NULL;
16718
0
    }
16719
0
    else {
16720
0
        int res;
16721
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16722
0
            goto failed;
16723
0
        }
16724
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16725
0
        _Py_LeaveRecursiveCall();
16726
0
        if (res != 0) goto failed;
16727
0
        Py_CLEAR(tmp);
16728
0
    }
16729
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16730
0
        return -1;
16731
0
    }
16732
0
    if (tmp == NULL) {
16733
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16734
0
        return -1;
16735
0
    }
16736
0
    else {
16737
0
        int res;
16738
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16739
0
            goto failed;
16740
0
        }
16741
0
        res = obj2ast_expr(state, tmp, &value, arena);
16742
0
        _Py_LeaveRecursiveCall();
16743
0
        if (res != 0) goto failed;
16744
0
        Py_CLEAR(tmp);
16745
0
    }
16746
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16747
0
        return -1;
16748
0
    }
16749
0
    if (tmp == NULL) {
16750
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16751
0
        return -1;
16752
0
    }
16753
0
    else {
16754
0
        int res;
16755
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16756
0
            goto failed;
16757
0
        }
16758
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16759
0
        _Py_LeaveRecursiveCall();
16760
0
        if (res != 0) goto failed;
16761
0
        Py_CLEAR(tmp);
16762
0
    }
16763
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16764
0
        return -1;
16765
0
    }
16766
0
    if (tmp == NULL) {
16767
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16768
0
        return -1;
16769
0
    }
16770
0
    else {
16771
0
        int res;
16772
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16773
0
            goto failed;
16774
0
        }
16775
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16776
0
        _Py_LeaveRecursiveCall();
16777
0
        if (res != 0) goto failed;
16778
0
        Py_CLEAR(tmp);
16779
0
    }
16780
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16781
0
        return -1;
16782
0
    }
16783
0
    if (tmp == NULL || tmp == Py_None) {
16784
0
        Py_CLEAR(tmp);
16785
0
        end_lineno = lineno;
16786
0
    }
16787
0
    else {
16788
0
        int res;
16789
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16790
0
            goto failed;
16791
0
        }
16792
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16793
0
        _Py_LeaveRecursiveCall();
16794
0
        if (res != 0) goto failed;
16795
0
        Py_CLEAR(tmp);
16796
0
    }
16797
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16798
0
        return -1;
16799
0
    }
16800
0
    if (tmp == NULL || tmp == Py_None) {
16801
0
        Py_CLEAR(tmp);
16802
0
        end_col_offset = col_offset;
16803
0
    }
16804
0
    else {
16805
0
        int res;
16806
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16807
0
            goto failed;
16808
0
        }
16809
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16810
0
        _Py_LeaveRecursiveCall();
16811
0
        if (res != 0) goto failed;
16812
0
        Py_CLEAR(tmp);
16813
0
    }
16814
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16815
0
                          end_col_offset, arena);
16816
0
    if (*out == NULL) goto failed;
16817
0
    return 0;
16818
0
failed:
16819
0
    Py_XDECREF(tmp);
16820
0
    return -1;
16821
0
}
16822
16823
int
16824
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
16825
              arena)
16826
0
{
16827
0
    PyObject* tmp = NULL;
16828
0
    identifier name;
16829
0
    identifier asname;
16830
0
    int lineno;
16831
0
    int col_offset;
16832
0
    int end_lineno;
16833
0
    int end_col_offset;
16834
16835
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16836
0
        return -1;
16837
0
    }
16838
0
    if (tmp == NULL) {
16839
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16840
0
        return -1;
16841
0
    }
16842
0
    else {
16843
0
        int res;
16844
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16845
0
            goto failed;
16846
0
        }
16847
0
        res = obj2ast_identifier(state, tmp, &name, arena);
16848
0
        _Py_LeaveRecursiveCall();
16849
0
        if (res != 0) goto failed;
16850
0
        Py_CLEAR(tmp);
16851
0
    }
16852
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16853
0
        return -1;
16854
0
    }
16855
0
    if (tmp == NULL || tmp == Py_None) {
16856
0
        Py_CLEAR(tmp);
16857
0
        asname = NULL;
16858
0
    }
16859
0
    else {
16860
0
        int res;
16861
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16862
0
            goto failed;
16863
0
        }
16864
0
        res = obj2ast_identifier(state, tmp, &asname, arena);
16865
0
        _Py_LeaveRecursiveCall();
16866
0
        if (res != 0) goto failed;
16867
0
        Py_CLEAR(tmp);
16868
0
    }
16869
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16870
0
        return -1;
16871
0
    }
16872
0
    if (tmp == NULL) {
16873
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16874
0
        return -1;
16875
0
    }
16876
0
    else {
16877
0
        int res;
16878
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16879
0
            goto failed;
16880
0
        }
16881
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16882
0
        _Py_LeaveRecursiveCall();
16883
0
        if (res != 0) goto failed;
16884
0
        Py_CLEAR(tmp);
16885
0
    }
16886
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16887
0
        return -1;
16888
0
    }
16889
0
    if (tmp == NULL) {
16890
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16891
0
        return -1;
16892
0
    }
16893
0
    else {
16894
0
        int res;
16895
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16896
0
            goto failed;
16897
0
        }
16898
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16899
0
        _Py_LeaveRecursiveCall();
16900
0
        if (res != 0) goto failed;
16901
0
        Py_CLEAR(tmp);
16902
0
    }
16903
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16904
0
        return -1;
16905
0
    }
16906
0
    if (tmp == NULL || tmp == Py_None) {
16907
0
        Py_CLEAR(tmp);
16908
0
        end_lineno = lineno;
16909
0
    }
16910
0
    else {
16911
0
        int res;
16912
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16913
0
            goto failed;
16914
0
        }
16915
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16916
0
        _Py_LeaveRecursiveCall();
16917
0
        if (res != 0) goto failed;
16918
0
        Py_CLEAR(tmp);
16919
0
    }
16920
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16921
0
        return -1;
16922
0
    }
16923
0
    if (tmp == NULL || tmp == Py_None) {
16924
0
        Py_CLEAR(tmp);
16925
0
        end_col_offset = col_offset;
16926
0
    }
16927
0
    else {
16928
0
        int res;
16929
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16930
0
            goto failed;
16931
0
        }
16932
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16933
0
        _Py_LeaveRecursiveCall();
16934
0
        if (res != 0) goto failed;
16935
0
        Py_CLEAR(tmp);
16936
0
    }
16937
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16938
0
                        end_col_offset, arena);
16939
0
    if (*out == NULL) goto failed;
16940
0
    return 0;
16941
0
failed:
16942
0
    Py_XDECREF(tmp);
16943
0
    return -1;
16944
0
}
16945
16946
int
16947
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
16948
                 PyArena* arena)
16949
0
{
16950
0
    PyObject* tmp = NULL;
16951
0
    expr_ty context_expr;
16952
0
    expr_ty optional_vars;
16953
16954
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
16955
0
        return -1;
16956
0
    }
16957
0
    if (tmp == NULL) {
16958
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
16959
0
        return -1;
16960
0
    }
16961
0
    else {
16962
0
        int res;
16963
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16964
0
            goto failed;
16965
0
        }
16966
0
        res = obj2ast_expr(state, tmp, &context_expr, arena);
16967
0
        _Py_LeaveRecursiveCall();
16968
0
        if (res != 0) goto failed;
16969
0
        Py_CLEAR(tmp);
16970
0
    }
16971
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
16972
0
        return -1;
16973
0
    }
16974
0
    if (tmp == NULL || tmp == Py_None) {
16975
0
        Py_CLEAR(tmp);
16976
0
        optional_vars = NULL;
16977
0
    }
16978
0
    else {
16979
0
        int res;
16980
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16981
0
            goto failed;
16982
0
        }
16983
0
        res = obj2ast_expr(state, tmp, &optional_vars, arena);
16984
0
        _Py_LeaveRecursiveCall();
16985
0
        if (res != 0) goto failed;
16986
0
        Py_CLEAR(tmp);
16987
0
    }
16988
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
16989
0
    if (*out == NULL) goto failed;
16990
0
    return 0;
16991
0
failed:
16992
0
    Py_XDECREF(tmp);
16993
0
    return -1;
16994
0
}
16995
16996
int
16997
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
16998
                   PyArena* arena)
16999
0
{
17000
0
    PyObject* tmp = NULL;
17001
0
    pattern_ty pattern;
17002
0
    expr_ty guard;
17003
0
    asdl_stmt_seq* body;
17004
17005
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17006
0
        return -1;
17007
0
    }
17008
0
    if (tmp == NULL) {
17009
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
17010
0
        return -1;
17011
0
    }
17012
0
    else {
17013
0
        int res;
17014
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17015
0
            goto failed;
17016
0
        }
17017
0
        res = obj2ast_pattern(state, tmp, &pattern, arena);
17018
0
        _Py_LeaveRecursiveCall();
17019
0
        if (res != 0) goto failed;
17020
0
        Py_CLEAR(tmp);
17021
0
    }
17022
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17023
0
        return -1;
17024
0
    }
17025
0
    if (tmp == NULL || tmp == Py_None) {
17026
0
        Py_CLEAR(tmp);
17027
0
        guard = NULL;
17028
0
    }
17029
0
    else {
17030
0
        int res;
17031
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17032
0
            goto failed;
17033
0
        }
17034
0
        res = obj2ast_expr(state, tmp, &guard, arena);
17035
0
        _Py_LeaveRecursiveCall();
17036
0
        if (res != 0) goto failed;
17037
0
        Py_CLEAR(tmp);
17038
0
    }
17039
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17040
0
        return -1;
17041
0
    }
17042
0
    if (tmp == NULL) {
17043
0
        tmp = PyList_New(0);
17044
0
        if (tmp == NULL) {
17045
0
            return -1;
17046
0
        }
17047
0
    }
17048
0
    {
17049
0
        int res;
17050
0
        Py_ssize_t len;
17051
0
        Py_ssize_t i;
17052
0
        if (!PyList_Check(tmp)) {
17053
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17054
0
            goto failed;
17055
0
        }
17056
0
        len = PyList_GET_SIZE(tmp);
17057
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17058
0
        if (body == NULL) goto failed;
17059
0
        for (i = 0; i < len; i++) {
17060
0
            stmt_ty val;
17061
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17062
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17063
0
                goto failed;
17064
0
            }
17065
0
            res = obj2ast_stmt(state, tmp2, &val, arena);
17066
0
            _Py_LeaveRecursiveCall();
17067
0
            Py_DECREF(tmp2);
17068
0
            if (res != 0) goto failed;
17069
0
            if (len != PyList_GET_SIZE(tmp)) {
17070
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17071
0
                goto failed;
17072
0
            }
17073
0
            asdl_seq_SET(body, i, val);
17074
0
        }
17075
0
        Py_CLEAR(tmp);
17076
0
    }
17077
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17078
0
    if (*out == NULL) goto failed;
17079
0
    return 0;
17080
0
failed:
17081
0
    Py_XDECREF(tmp);
17082
0
    return -1;
17083
0
}
17084
17085
int
17086
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
17087
                PyArena* arena)
17088
0
{
17089
0
    int isinstance;
17090
17091
0
    PyObject *tmp = NULL;
17092
0
    PyObject *tp;
17093
0
    int lineno;
17094
0
    int col_offset;
17095
0
    int end_lineno;
17096
0
    int end_col_offset;
17097
17098
0
    if (obj == Py_None) {
17099
0
        *out = NULL;
17100
0
        return 0;
17101
0
    }
17102
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17103
0
        return -1;
17104
0
    }
17105
0
    if (tmp == NULL) {
17106
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17107
0
        return -1;
17108
0
    }
17109
0
    else {
17110
0
        int res;
17111
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17112
0
            goto failed;
17113
0
        }
17114
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17115
0
        _Py_LeaveRecursiveCall();
17116
0
        if (res != 0) goto failed;
17117
0
        Py_CLEAR(tmp);
17118
0
    }
17119
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17120
0
        return -1;
17121
0
    }
17122
0
    if (tmp == NULL) {
17123
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17124
0
        return -1;
17125
0
    }
17126
0
    else {
17127
0
        int res;
17128
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17129
0
            goto failed;
17130
0
        }
17131
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17132
0
        _Py_LeaveRecursiveCall();
17133
0
        if (res != 0) goto failed;
17134
0
        Py_CLEAR(tmp);
17135
0
    }
17136
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17137
0
        return -1;
17138
0
    }
17139
0
    if (tmp == NULL) {
17140
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17141
0
        return -1;
17142
0
    }
17143
0
    else {
17144
0
        int res;
17145
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17146
0
            goto failed;
17147
0
        }
17148
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17149
0
        _Py_LeaveRecursiveCall();
17150
0
        if (res != 0) goto failed;
17151
0
        Py_CLEAR(tmp);
17152
0
    }
17153
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17154
0
        return -1;
17155
0
    }
17156
0
    if (tmp == NULL) {
17157
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17158
0
        return -1;
17159
0
    }
17160
0
    else {
17161
0
        int res;
17162
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17163
0
            goto failed;
17164
0
        }
17165
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17166
0
        _Py_LeaveRecursiveCall();
17167
0
        if (res != 0) goto failed;
17168
0
        Py_CLEAR(tmp);
17169
0
    }
17170
0
    tp = state->MatchValue_type;
17171
0
    isinstance = PyObject_IsInstance(obj, tp);
17172
0
    if (isinstance == -1) {
17173
0
        return -1;
17174
0
    }
17175
0
    if (isinstance) {
17176
0
        expr_ty value;
17177
17178
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17179
0
            return -1;
17180
0
        }
17181
0
        if (tmp == NULL) {
17182
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17183
0
            return -1;
17184
0
        }
17185
0
        else {
17186
0
            int res;
17187
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17188
0
                goto failed;
17189
0
            }
17190
0
            res = obj2ast_expr(state, tmp, &value, arena);
17191
0
            _Py_LeaveRecursiveCall();
17192
0
            if (res != 0) goto failed;
17193
0
            Py_CLEAR(tmp);
17194
0
        }
17195
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17196
0
                                 end_col_offset, arena);
17197
0
        if (*out == NULL) goto failed;
17198
0
        return 0;
17199
0
    }
17200
0
    tp = state->MatchSingleton_type;
17201
0
    isinstance = PyObject_IsInstance(obj, tp);
17202
0
    if (isinstance == -1) {
17203
0
        return -1;
17204
0
    }
17205
0
    if (isinstance) {
17206
0
        constant value;
17207
17208
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17209
0
            return -1;
17210
0
        }
17211
0
        if (tmp == NULL) {
17212
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17213
0
            return -1;
17214
0
        }
17215
0
        else {
17216
0
            int res;
17217
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17218
0
                goto failed;
17219
0
            }
17220
0
            res = obj2ast_constant(state, tmp, &value, arena);
17221
0
            _Py_LeaveRecursiveCall();
17222
0
            if (res != 0) goto failed;
17223
0
            Py_CLEAR(tmp);
17224
0
        }
17225
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17226
0
                                     end_col_offset, arena);
17227
0
        if (*out == NULL) goto failed;
17228
0
        return 0;
17229
0
    }
17230
0
    tp = state->MatchSequence_type;
17231
0
    isinstance = PyObject_IsInstance(obj, tp);
17232
0
    if (isinstance == -1) {
17233
0
        return -1;
17234
0
    }
17235
0
    if (isinstance) {
17236
0
        asdl_pattern_seq* patterns;
17237
17238
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17239
0
            return -1;
17240
0
        }
17241
0
        if (tmp == NULL) {
17242
0
            tmp = PyList_New(0);
17243
0
            if (tmp == NULL) {
17244
0
                return -1;
17245
0
            }
17246
0
        }
17247
0
        {
17248
0
            int res;
17249
0
            Py_ssize_t len;
17250
0
            Py_ssize_t i;
17251
0
            if (!PyList_Check(tmp)) {
17252
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17253
0
                goto failed;
17254
0
            }
17255
0
            len = PyList_GET_SIZE(tmp);
17256
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17257
0
            if (patterns == NULL) goto failed;
17258
0
            for (i = 0; i < len; i++) {
17259
0
                pattern_ty val;
17260
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17261
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17262
0
                    goto failed;
17263
0
                }
17264
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17265
0
                _Py_LeaveRecursiveCall();
17266
0
                Py_DECREF(tmp2);
17267
0
                if (res != 0) goto failed;
17268
0
                if (len != PyList_GET_SIZE(tmp)) {
17269
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17270
0
                    goto failed;
17271
0
                }
17272
0
                asdl_seq_SET(patterns, i, val);
17273
0
            }
17274
0
            Py_CLEAR(tmp);
17275
0
        }
17276
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17277
0
                                    end_col_offset, arena);
17278
0
        if (*out == NULL) goto failed;
17279
0
        return 0;
17280
0
    }
17281
0
    tp = state->MatchMapping_type;
17282
0
    isinstance = PyObject_IsInstance(obj, tp);
17283
0
    if (isinstance == -1) {
17284
0
        return -1;
17285
0
    }
17286
0
    if (isinstance) {
17287
0
        asdl_expr_seq* keys;
17288
0
        asdl_pattern_seq* patterns;
17289
0
        identifier rest;
17290
17291
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17292
0
            return -1;
17293
0
        }
17294
0
        if (tmp == NULL) {
17295
0
            tmp = PyList_New(0);
17296
0
            if (tmp == NULL) {
17297
0
                return -1;
17298
0
            }
17299
0
        }
17300
0
        {
17301
0
            int res;
17302
0
            Py_ssize_t len;
17303
0
            Py_ssize_t i;
17304
0
            if (!PyList_Check(tmp)) {
17305
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17306
0
                goto failed;
17307
0
            }
17308
0
            len = PyList_GET_SIZE(tmp);
17309
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17310
0
            if (keys == NULL) goto failed;
17311
0
            for (i = 0; i < len; i++) {
17312
0
                expr_ty val;
17313
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17314
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17315
0
                    goto failed;
17316
0
                }
17317
0
                res = obj2ast_expr(state, tmp2, &val, arena);
17318
0
                _Py_LeaveRecursiveCall();
17319
0
                Py_DECREF(tmp2);
17320
0
                if (res != 0) goto failed;
17321
0
                if (len != PyList_GET_SIZE(tmp)) {
17322
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17323
0
                    goto failed;
17324
0
                }
17325
0
                asdl_seq_SET(keys, i, val);
17326
0
            }
17327
0
            Py_CLEAR(tmp);
17328
0
        }
17329
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17330
0
            return -1;
17331
0
        }
17332
0
        if (tmp == NULL) {
17333
0
            tmp = PyList_New(0);
17334
0
            if (tmp == NULL) {
17335
0
                return -1;
17336
0
            }
17337
0
        }
17338
0
        {
17339
0
            int res;
17340
0
            Py_ssize_t len;
17341
0
            Py_ssize_t i;
17342
0
            if (!PyList_Check(tmp)) {
17343
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17344
0
                goto failed;
17345
0
            }
17346
0
            len = PyList_GET_SIZE(tmp);
17347
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17348
0
            if (patterns == NULL) goto failed;
17349
0
            for (i = 0; i < len; i++) {
17350
0
                pattern_ty val;
17351
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17352
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17353
0
                    goto failed;
17354
0
                }
17355
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17356
0
                _Py_LeaveRecursiveCall();
17357
0
                Py_DECREF(tmp2);
17358
0
                if (res != 0) goto failed;
17359
0
                if (len != PyList_GET_SIZE(tmp)) {
17360
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17361
0
                    goto failed;
17362
0
                }
17363
0
                asdl_seq_SET(patterns, i, val);
17364
0
            }
17365
0
            Py_CLEAR(tmp);
17366
0
        }
17367
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17368
0
            return -1;
17369
0
        }
17370
0
        if (tmp == NULL || tmp == Py_None) {
17371
0
            Py_CLEAR(tmp);
17372
0
            rest = NULL;
17373
0
        }
17374
0
        else {
17375
0
            int res;
17376
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17377
0
                goto failed;
17378
0
            }
17379
0
            res = obj2ast_identifier(state, tmp, &rest, arena);
17380
0
            _Py_LeaveRecursiveCall();
17381
0
            if (res != 0) goto failed;
17382
0
            Py_CLEAR(tmp);
17383
0
        }
17384
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17385
0
                                   end_lineno, end_col_offset, arena);
17386
0
        if (*out == NULL) goto failed;
17387
0
        return 0;
17388
0
    }
17389
0
    tp = state->MatchClass_type;
17390
0
    isinstance = PyObject_IsInstance(obj, tp);
17391
0
    if (isinstance == -1) {
17392
0
        return -1;
17393
0
    }
17394
0
    if (isinstance) {
17395
0
        expr_ty cls;
17396
0
        asdl_pattern_seq* patterns;
17397
0
        asdl_identifier_seq* kwd_attrs;
17398
0
        asdl_pattern_seq* kwd_patterns;
17399
17400
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17401
0
            return -1;
17402
0
        }
17403
0
        if (tmp == NULL) {
17404
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17405
0
            return -1;
17406
0
        }
17407
0
        else {
17408
0
            int res;
17409
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17410
0
                goto failed;
17411
0
            }
17412
0
            res = obj2ast_expr(state, tmp, &cls, arena);
17413
0
            _Py_LeaveRecursiveCall();
17414
0
            if (res != 0) goto failed;
17415
0
            Py_CLEAR(tmp);
17416
0
        }
17417
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17418
0
            return -1;
17419
0
        }
17420
0
        if (tmp == NULL) {
17421
0
            tmp = PyList_New(0);
17422
0
            if (tmp == NULL) {
17423
0
                return -1;
17424
0
            }
17425
0
        }
17426
0
        {
17427
0
            int res;
17428
0
            Py_ssize_t len;
17429
0
            Py_ssize_t i;
17430
0
            if (!PyList_Check(tmp)) {
17431
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17432
0
                goto failed;
17433
0
            }
17434
0
            len = PyList_GET_SIZE(tmp);
17435
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17436
0
            if (patterns == NULL) goto failed;
17437
0
            for (i = 0; i < len; i++) {
17438
0
                pattern_ty val;
17439
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17440
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17441
0
                    goto failed;
17442
0
                }
17443
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17444
0
                _Py_LeaveRecursiveCall();
17445
0
                Py_DECREF(tmp2);
17446
0
                if (res != 0) goto failed;
17447
0
                if (len != PyList_GET_SIZE(tmp)) {
17448
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17449
0
                    goto failed;
17450
0
                }
17451
0
                asdl_seq_SET(patterns, i, val);
17452
0
            }
17453
0
            Py_CLEAR(tmp);
17454
0
        }
17455
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17456
0
            return -1;
17457
0
        }
17458
0
        if (tmp == NULL) {
17459
0
            tmp = PyList_New(0);
17460
0
            if (tmp == NULL) {
17461
0
                return -1;
17462
0
            }
17463
0
        }
17464
0
        {
17465
0
            int res;
17466
0
            Py_ssize_t len;
17467
0
            Py_ssize_t i;
17468
0
            if (!PyList_Check(tmp)) {
17469
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17470
0
                goto failed;
17471
0
            }
17472
0
            len = PyList_GET_SIZE(tmp);
17473
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17474
0
            if (kwd_attrs == NULL) goto failed;
17475
0
            for (i = 0; i < len; i++) {
17476
0
                identifier val;
17477
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17478
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17479
0
                    goto failed;
17480
0
                }
17481
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
17482
0
                _Py_LeaveRecursiveCall();
17483
0
                Py_DECREF(tmp2);
17484
0
                if (res != 0) goto failed;
17485
0
                if (len != PyList_GET_SIZE(tmp)) {
17486
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17487
0
                    goto failed;
17488
0
                }
17489
0
                asdl_seq_SET(kwd_attrs, i, val);
17490
0
            }
17491
0
            Py_CLEAR(tmp);
17492
0
        }
17493
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17494
0
            return -1;
17495
0
        }
17496
0
        if (tmp == NULL) {
17497
0
            tmp = PyList_New(0);
17498
0
            if (tmp == NULL) {
17499
0
                return -1;
17500
0
            }
17501
0
        }
17502
0
        {
17503
0
            int res;
17504
0
            Py_ssize_t len;
17505
0
            Py_ssize_t i;
17506
0
            if (!PyList_Check(tmp)) {
17507
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17508
0
                goto failed;
17509
0
            }
17510
0
            len = PyList_GET_SIZE(tmp);
17511
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17512
0
            if (kwd_patterns == NULL) goto failed;
17513
0
            for (i = 0; i < len; i++) {
17514
0
                pattern_ty val;
17515
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17516
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17517
0
                    goto failed;
17518
0
                }
17519
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17520
0
                _Py_LeaveRecursiveCall();
17521
0
                Py_DECREF(tmp2);
17522
0
                if (res != 0) goto failed;
17523
0
                if (len != PyList_GET_SIZE(tmp)) {
17524
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17525
0
                    goto failed;
17526
0
                }
17527
0
                asdl_seq_SET(kwd_patterns, i, val);
17528
0
            }
17529
0
            Py_CLEAR(tmp);
17530
0
        }
17531
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17532
0
                                 lineno, col_offset, end_lineno,
17533
0
                                 end_col_offset, arena);
17534
0
        if (*out == NULL) goto failed;
17535
0
        return 0;
17536
0
    }
17537
0
    tp = state->MatchStar_type;
17538
0
    isinstance = PyObject_IsInstance(obj, tp);
17539
0
    if (isinstance == -1) {
17540
0
        return -1;
17541
0
    }
17542
0
    if (isinstance) {
17543
0
        identifier name;
17544
17545
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17546
0
            return -1;
17547
0
        }
17548
0
        if (tmp == NULL || tmp == Py_None) {
17549
0
            Py_CLEAR(tmp);
17550
0
            name = NULL;
17551
0
        }
17552
0
        else {
17553
0
            int res;
17554
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17555
0
                goto failed;
17556
0
            }
17557
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17558
0
            _Py_LeaveRecursiveCall();
17559
0
            if (res != 0) goto failed;
17560
0
            Py_CLEAR(tmp);
17561
0
        }
17562
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17563
0
                                end_col_offset, arena);
17564
0
        if (*out == NULL) goto failed;
17565
0
        return 0;
17566
0
    }
17567
0
    tp = state->MatchAs_type;
17568
0
    isinstance = PyObject_IsInstance(obj, tp);
17569
0
    if (isinstance == -1) {
17570
0
        return -1;
17571
0
    }
17572
0
    if (isinstance) {
17573
0
        pattern_ty pattern;
17574
0
        identifier name;
17575
17576
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17577
0
            return -1;
17578
0
        }
17579
0
        if (tmp == NULL || tmp == Py_None) {
17580
0
            Py_CLEAR(tmp);
17581
0
            pattern = NULL;
17582
0
        }
17583
0
        else {
17584
0
            int res;
17585
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17586
0
                goto failed;
17587
0
            }
17588
0
            res = obj2ast_pattern(state, tmp, &pattern, arena);
17589
0
            _Py_LeaveRecursiveCall();
17590
0
            if (res != 0) goto failed;
17591
0
            Py_CLEAR(tmp);
17592
0
        }
17593
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17594
0
            return -1;
17595
0
        }
17596
0
        if (tmp == NULL || tmp == Py_None) {
17597
0
            Py_CLEAR(tmp);
17598
0
            name = NULL;
17599
0
        }
17600
0
        else {
17601
0
            int res;
17602
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17603
0
                goto failed;
17604
0
            }
17605
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17606
0
            _Py_LeaveRecursiveCall();
17607
0
            if (res != 0) goto failed;
17608
0
            Py_CLEAR(tmp);
17609
0
        }
17610
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17611
0
                              end_col_offset, arena);
17612
0
        if (*out == NULL) goto failed;
17613
0
        return 0;
17614
0
    }
17615
0
    tp = state->MatchOr_type;
17616
0
    isinstance = PyObject_IsInstance(obj, tp);
17617
0
    if (isinstance == -1) {
17618
0
        return -1;
17619
0
    }
17620
0
    if (isinstance) {
17621
0
        asdl_pattern_seq* patterns;
17622
17623
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17624
0
            return -1;
17625
0
        }
17626
0
        if (tmp == NULL) {
17627
0
            tmp = PyList_New(0);
17628
0
            if (tmp == NULL) {
17629
0
                return -1;
17630
0
            }
17631
0
        }
17632
0
        {
17633
0
            int res;
17634
0
            Py_ssize_t len;
17635
0
            Py_ssize_t i;
17636
0
            if (!PyList_Check(tmp)) {
17637
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17638
0
                goto failed;
17639
0
            }
17640
0
            len = PyList_GET_SIZE(tmp);
17641
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17642
0
            if (patterns == NULL) goto failed;
17643
0
            for (i = 0; i < len; i++) {
17644
0
                pattern_ty val;
17645
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17646
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17647
0
                    goto failed;
17648
0
                }
17649
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17650
0
                _Py_LeaveRecursiveCall();
17651
0
                Py_DECREF(tmp2);
17652
0
                if (res != 0) goto failed;
17653
0
                if (len != PyList_GET_SIZE(tmp)) {
17654
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17655
0
                    goto failed;
17656
0
                }
17657
0
                asdl_seq_SET(patterns, i, val);
17658
0
            }
17659
0
            Py_CLEAR(tmp);
17660
0
        }
17661
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17662
0
                              end_col_offset, arena);
17663
0
        if (*out == NULL) goto failed;
17664
0
        return 0;
17665
0
    }
17666
17667
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17668
0
    failed:
17669
0
    Py_XDECREF(tmp);
17670
0
    return -1;
17671
0
}
17672
17673
int
17674
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17675
                    out, PyArena* arena)
17676
0
{
17677
0
    int isinstance;
17678
17679
0
    PyObject *tmp = NULL;
17680
0
    PyObject *tp;
17681
17682
0
    if (obj == Py_None) {
17683
0
        *out = NULL;
17684
0
        return 0;
17685
0
    }
17686
0
    tp = state->TypeIgnore_type;
17687
0
    isinstance = PyObject_IsInstance(obj, tp);
17688
0
    if (isinstance == -1) {
17689
0
        return -1;
17690
0
    }
17691
0
    if (isinstance) {
17692
0
        int lineno;
17693
0
        string tag;
17694
17695
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17696
0
            return -1;
17697
0
        }
17698
0
        if (tmp == NULL) {
17699
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17700
0
            return -1;
17701
0
        }
17702
0
        else {
17703
0
            int res;
17704
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17705
0
                goto failed;
17706
0
            }
17707
0
            res = obj2ast_int(state, tmp, &lineno, arena);
17708
0
            _Py_LeaveRecursiveCall();
17709
0
            if (res != 0) goto failed;
17710
0
            Py_CLEAR(tmp);
17711
0
        }
17712
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17713
0
            return -1;
17714
0
        }
17715
0
        if (tmp == NULL) {
17716
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17717
0
            return -1;
17718
0
        }
17719
0
        else {
17720
0
            int res;
17721
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17722
0
                goto failed;
17723
0
            }
17724
0
            res = obj2ast_string(state, tmp, &tag, arena);
17725
0
            _Py_LeaveRecursiveCall();
17726
0
            if (res != 0) goto failed;
17727
0
            Py_CLEAR(tmp);
17728
0
        }
17729
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17730
0
        if (*out == NULL) goto failed;
17731
0
        return 0;
17732
0
    }
17733
17734
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17735
0
    failed:
17736
0
    Py_XDECREF(tmp);
17737
0
    return -1;
17738
0
}
17739
17740
int
17741
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17742
                   PyArena* arena)
17743
0
{
17744
0
    int isinstance;
17745
17746
0
    PyObject *tmp = NULL;
17747
0
    PyObject *tp;
17748
0
    int lineno;
17749
0
    int col_offset;
17750
0
    int end_lineno;
17751
0
    int end_col_offset;
17752
17753
0
    if (obj == Py_None) {
17754
0
        *out = NULL;
17755
0
        return 0;
17756
0
    }
17757
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17758
0
        return -1;
17759
0
    }
17760
0
    if (tmp == NULL) {
17761
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17762
0
        return -1;
17763
0
    }
17764
0
    else {
17765
0
        int res;
17766
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17767
0
            goto failed;
17768
0
        }
17769
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17770
0
        _Py_LeaveRecursiveCall();
17771
0
        if (res != 0) goto failed;
17772
0
        Py_CLEAR(tmp);
17773
0
    }
17774
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17775
0
        return -1;
17776
0
    }
17777
0
    if (tmp == NULL) {
17778
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17779
0
        return -1;
17780
0
    }
17781
0
    else {
17782
0
        int res;
17783
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17784
0
            goto failed;
17785
0
        }
17786
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17787
0
        _Py_LeaveRecursiveCall();
17788
0
        if (res != 0) goto failed;
17789
0
        Py_CLEAR(tmp);
17790
0
    }
17791
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17792
0
        return -1;
17793
0
    }
17794
0
    if (tmp == NULL) {
17795
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17796
0
        return -1;
17797
0
    }
17798
0
    else {
17799
0
        int res;
17800
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17801
0
            goto failed;
17802
0
        }
17803
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17804
0
        _Py_LeaveRecursiveCall();
17805
0
        if (res != 0) goto failed;
17806
0
        Py_CLEAR(tmp);
17807
0
    }
17808
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17809
0
        return -1;
17810
0
    }
17811
0
    if (tmp == NULL) {
17812
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17813
0
        return -1;
17814
0
    }
17815
0
    else {
17816
0
        int res;
17817
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17818
0
            goto failed;
17819
0
        }
17820
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17821
0
        _Py_LeaveRecursiveCall();
17822
0
        if (res != 0) goto failed;
17823
0
        Py_CLEAR(tmp);
17824
0
    }
17825
0
    tp = state->TypeVar_type;
17826
0
    isinstance = PyObject_IsInstance(obj, tp);
17827
0
    if (isinstance == -1) {
17828
0
        return -1;
17829
0
    }
17830
0
    if (isinstance) {
17831
0
        identifier name;
17832
0
        expr_ty bound;
17833
0
        expr_ty default_value;
17834
17835
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17836
0
            return -1;
17837
0
        }
17838
0
        if (tmp == NULL) {
17839
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17840
0
            return -1;
17841
0
        }
17842
0
        else {
17843
0
            int res;
17844
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17845
0
                goto failed;
17846
0
            }
17847
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17848
0
            _Py_LeaveRecursiveCall();
17849
0
            if (res != 0) goto failed;
17850
0
            Py_CLEAR(tmp);
17851
0
        }
17852
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17853
0
            return -1;
17854
0
        }
17855
0
        if (tmp == NULL || tmp == Py_None) {
17856
0
            Py_CLEAR(tmp);
17857
0
            bound = NULL;
17858
0
        }
17859
0
        else {
17860
0
            int res;
17861
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17862
0
                goto failed;
17863
0
            }
17864
0
            res = obj2ast_expr(state, tmp, &bound, arena);
17865
0
            _Py_LeaveRecursiveCall();
17866
0
            if (res != 0) goto failed;
17867
0
            Py_CLEAR(tmp);
17868
0
        }
17869
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17870
0
            return -1;
17871
0
        }
17872
0
        if (tmp == NULL || tmp == Py_None) {
17873
0
            Py_CLEAR(tmp);
17874
0
            default_value = NULL;
17875
0
        }
17876
0
        else {
17877
0
            int res;
17878
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17879
0
                goto failed;
17880
0
            }
17881
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17882
0
            _Py_LeaveRecursiveCall();
17883
0
            if (res != 0) goto failed;
17884
0
            Py_CLEAR(tmp);
17885
0
        }
17886
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17887
0
                              end_lineno, end_col_offset, arena);
17888
0
        if (*out == NULL) goto failed;
17889
0
        return 0;
17890
0
    }
17891
0
    tp = state->ParamSpec_type;
17892
0
    isinstance = PyObject_IsInstance(obj, tp);
17893
0
    if (isinstance == -1) {
17894
0
        return -1;
17895
0
    }
17896
0
    if (isinstance) {
17897
0
        identifier name;
17898
0
        expr_ty default_value;
17899
17900
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17901
0
            return -1;
17902
0
        }
17903
0
        if (tmp == NULL) {
17904
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17905
0
            return -1;
17906
0
        }
17907
0
        else {
17908
0
            int res;
17909
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17910
0
                goto failed;
17911
0
            }
17912
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17913
0
            _Py_LeaveRecursiveCall();
17914
0
            if (res != 0) goto failed;
17915
0
            Py_CLEAR(tmp);
17916
0
        }
17917
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17918
0
            return -1;
17919
0
        }
17920
0
        if (tmp == NULL || tmp == Py_None) {
17921
0
            Py_CLEAR(tmp);
17922
0
            default_value = NULL;
17923
0
        }
17924
0
        else {
17925
0
            int res;
17926
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17927
0
                goto failed;
17928
0
            }
17929
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17930
0
            _Py_LeaveRecursiveCall();
17931
0
            if (res != 0) goto failed;
17932
0
            Py_CLEAR(tmp);
17933
0
        }
17934
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
17935
0
                                end_lineno, end_col_offset, arena);
17936
0
        if (*out == NULL) goto failed;
17937
0
        return 0;
17938
0
    }
17939
0
    tp = state->TypeVarTuple_type;
17940
0
    isinstance = PyObject_IsInstance(obj, tp);
17941
0
    if (isinstance == -1) {
17942
0
        return -1;
17943
0
    }
17944
0
    if (isinstance) {
17945
0
        identifier name;
17946
0
        expr_ty default_value;
17947
17948
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17949
0
            return -1;
17950
0
        }
17951
0
        if (tmp == NULL) {
17952
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
17953
0
            return -1;
17954
0
        }
17955
0
        else {
17956
0
            int res;
17957
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17958
0
                goto failed;
17959
0
            }
17960
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17961
0
            _Py_LeaveRecursiveCall();
17962
0
            if (res != 0) goto failed;
17963
0
            Py_CLEAR(tmp);
17964
0
        }
17965
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17966
0
            return -1;
17967
0
        }
17968
0
        if (tmp == NULL || tmp == Py_None) {
17969
0
            Py_CLEAR(tmp);
17970
0
            default_value = NULL;
17971
0
        }
17972
0
        else {
17973
0
            int res;
17974
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17975
0
                goto failed;
17976
0
            }
17977
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17978
0
            _Py_LeaveRecursiveCall();
17979
0
            if (res != 0) goto failed;
17980
0
            Py_CLEAR(tmp);
17981
0
        }
17982
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
17983
0
                                   end_lineno, end_col_offset, arena);
17984
0
        if (*out == NULL) goto failed;
17985
0
        return 0;
17986
0
    }
17987
17988
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
17989
0
    failed:
17990
0
    Py_XDECREF(tmp);
17991
0
    return -1;
17992
0
}
17993
17994
17995
/* Helper for checking if a node class is abstract in the tests. */
17996
static PyObject *
17997
0
ast_is_abstract(PyObject *Py_UNUSED(module), PyObject *cls) {
17998
0
    struct ast_state *state = get_ast_state();
17999
0
    if (state == NULL) {
18000
0
        return NULL;
18001
0
    }
18002
0
    int contains = PySet_Contains(state->abstract_types, cls);
18003
0
    if (contains == -1) {
18004
0
        return NULL;
18005
0
    }
18006
0
    else if (contains == 1) {
18007
0
        Py_RETURN_TRUE;
18008
0
    }
18009
0
    Py_RETURN_FALSE;
18010
0
}
18011
18012
static struct PyMethodDef astmodule_methods[] = {
18013
    {"_is_abstract", ast_is_abstract, METH_O, NULL},
18014
    {NULL}  /* Sentinel */
18015
};
18016
18017
static int
18018
astmodule_exec(PyObject *m)
18019
9
{
18020
9
    struct ast_state *state = get_ast_state();
18021
9
    if (state == NULL) {
18022
0
        return -1;
18023
0
    }
18024
9
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
18025
0
        return -1;
18026
0
    }
18027
9
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
18028
0
        return -1;
18029
0
    }
18030
9
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
18031
0
        return -1;
18032
0
    }
18033
9
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
18034
0
        return -1;
18035
0
    }
18036
9
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18037
0
        return -1;
18038
0
    }
18039
9
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18040
0
        return -1;
18041
0
    }
18042
9
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18043
0
        return -1;
18044
0
    }
18045
9
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18046
0
        return -1;
18047
0
    }
18048
9
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18049
0
        return -1;
18050
0
    }
18051
9
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18052
0
        {
18053
0
        return -1;
18054
0
    }
18055
9
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18056
0
        return -1;
18057
0
    }
18058
9
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18059
0
        return -1;
18060
0
    }
18061
9
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18062
9
        state->AsyncFunctionDef_type) < 0) {
18063
0
        return -1;
18064
0
    }
18065
9
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18066
0
        return -1;
18067
0
    }
18068
9
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18069
0
        return -1;
18070
0
    }
18071
9
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18072
0
        return -1;
18073
0
    }
18074
9
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18075
0
        return -1;
18076
0
    }
18077
9
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18078
0
        return -1;
18079
0
    }
18080
9
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18081
0
        return -1;
18082
0
    }
18083
9
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18084
0
        return -1;
18085
0
    }
18086
9
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18087
0
        return -1;
18088
0
    }
18089
9
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18090
0
        return -1;
18091
0
    }
18092
9
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18093
0
        return -1;
18094
0
    }
18095
9
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18096
0
        return -1;
18097
0
    }
18098
9
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18099
0
        return -1;
18100
0
    }
18101
9
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18102
0
        return -1;
18103
0
    }
18104
9
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18105
0
        return -1;
18106
0
    }
18107
9
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18108
0
        return -1;
18109
0
    }
18110
9
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18111
0
        return -1;
18112
0
    }
18113
9
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18114
0
        return -1;
18115
0
    }
18116
9
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18117
0
        return -1;
18118
0
    }
18119
9
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18120
0
        return -1;
18121
0
    }
18122
9
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18123
0
        return -1;
18124
0
    }
18125
9
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18126
0
        return -1;
18127
0
    }
18128
9
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18129
0
        return -1;
18130
0
    }
18131
9
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18132
0
        return -1;
18133
0
    }
18134
9
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18135
0
        return -1;
18136
0
    }
18137
9
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18138
0
        return -1;
18139
0
    }
18140
9
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18141
0
        return -1;
18142
0
    }
18143
9
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18144
0
        return -1;
18145
0
    }
18146
9
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18147
0
        return -1;
18148
0
    }
18149
9
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18150
0
        return -1;
18151
0
    }
18152
9
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18153
0
        return -1;
18154
0
    }
18155
9
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18156
0
        return -1;
18157
0
    }
18158
9
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18159
0
        return -1;
18160
0
    }
18161
9
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18162
0
        return -1;
18163
0
    }
18164
9
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18165
0
        return -1;
18166
0
    }
18167
9
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18168
0
        return -1;
18169
0
    }
18170
9
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18171
0
        return -1;
18172
0
    }
18173
9
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18174
0
        return -1;
18175
0
    }
18176
9
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18177
0
        return -1;
18178
0
    }
18179
9
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18180
0
        {
18181
0
        return -1;
18182
0
    }
18183
9
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18184
0
        return -1;
18185
0
    }
18186
9
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18187
0
        return -1;
18188
0
    }
18189
9
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18190
0
        return -1;
18191
0
    }
18192
9
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18193
0
        return -1;
18194
0
    }
18195
9
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18196
0
        return -1;
18197
0
    }
18198
9
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18199
9
        < 0) {
18200
0
        return -1;
18201
0
    }
18202
9
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18203
9
        0) {
18204
0
        return -1;
18205
0
    }
18206
9
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18207
0
        return -1;
18208
0
    }
18209
9
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18210
0
        return -1;
18211
0
    }
18212
9
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18213
0
        return -1;
18214
0
    }
18215
9
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18216
0
        return -1;
18217
0
    }
18218
9
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18219
0
        return -1;
18220
0
    }
18221
9
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18222
0
        return -1;
18223
0
    }
18224
9
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18225
0
        return -1;
18226
0
    }
18227
9
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18228
0
        return -1;
18229
0
    }
18230
9
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18231
0
        return -1;
18232
0
    }
18233
9
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18234
0
        return -1;
18235
0
    }
18236
9
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18237
0
        {
18238
0
        return -1;
18239
0
    }
18240
9
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18241
0
        return -1;
18242
0
    }
18243
9
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18244
0
        return -1;
18245
0
    }
18246
9
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18247
0
        return -1;
18248
0
    }
18249
9
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18250
0
        return -1;
18251
0
    }
18252
9
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18253
0
        return -1;
18254
0
    }
18255
9
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18256
0
        return -1;
18257
0
    }
18258
9
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18259
0
        return -1;
18260
0
    }
18261
9
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18262
0
        return -1;
18263
0
    }
18264
9
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18265
0
        return -1;
18266
0
    }
18267
9
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18268
0
        return -1;
18269
0
    }
18270
9
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18271
0
        return -1;
18272
0
    }
18273
9
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18274
0
        return -1;
18275
0
    }
18276
9
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18277
0
        return -1;
18278
0
    }
18279
9
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18280
0
        return -1;
18281
0
    }
18282
9
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18283
0
        return -1;
18284
0
    }
18285
9
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18286
0
        return -1;
18287
0
    }
18288
9
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18289
0
        return -1;
18290
0
    }
18291
9
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18292
0
        return -1;
18293
0
    }
18294
9
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18295
0
        return -1;
18296
0
    }
18297
9
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18298
0
        return -1;
18299
0
    }
18300
9
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18301
0
        return -1;
18302
0
    }
18303
9
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18304
0
        return -1;
18305
0
    }
18306
9
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18307
0
        return -1;
18308
0
    }
18309
9
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18310
0
        return -1;
18311
0
    }
18312
9
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18313
0
        return -1;
18314
0
    }
18315
9
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18316
0
        return -1;
18317
0
    }
18318
9
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18319
0
        return -1;
18320
0
    }
18321
9
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18322
0
        return -1;
18323
0
    }
18324
9
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18325
0
        return -1;
18326
0
    }
18327
9
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18328
0
        return -1;
18329
0
    }
18330
9
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18331
0
        return -1;
18332
0
    }
18333
9
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18334
0
        return -1;
18335
0
    }
18336
9
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18337
0
        return -1;
18338
0
    }
18339
9
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18340
0
        return -1;
18341
0
    }
18342
9
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18343
0
        return -1;
18344
0
    }
18345
9
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18346
0
        return -1;
18347
0
    }
18348
9
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18349
9
        0) {
18350
0
        return -1;
18351
0
    }
18352
9
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18353
9
        0) {
18354
0
        return -1;
18355
0
    }
18356
9
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18357
9
        0) {
18358
0
        return -1;
18359
0
    }
18360
9
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18361
0
        return -1;
18362
0
    }
18363
9
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18364
0
        return -1;
18365
0
    }
18366
9
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18367
0
        return -1;
18368
0
    }
18369
9
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18370
0
        return -1;
18371
0
    }
18372
9
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18373
0
        return -1;
18374
0
    }
18375
9
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18376
0
        return -1;
18377
0
    }
18378
9
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18379
0
        return -1;
18380
0
    }
18381
9
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18382
0
        return -1;
18383
0
    }
18384
9
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18385
9
        < 0) {
18386
0
        return -1;
18387
0
    }
18388
9
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18389
9
        0) {
18390
0
        return -1;
18391
0
    }
18392
9
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18393
0
        {
18394
0
        return -1;
18395
0
    }
18396
9
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18397
0
        return -1;
18398
0
    }
18399
9
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18400
0
        return -1;
18401
0
    }
18402
9
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18403
0
        return -1;
18404
0
    }
18405
9
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18406
0
        return -1;
18407
0
    }
18408
9
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18409
0
        return -1;
18410
0
    }
18411
9
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18412
0
        return -1;
18413
0
    }
18414
9
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18415
0
        return -1;
18416
0
    }
18417
9
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18418
0
        return -1;
18419
0
    }
18420
9
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18421
0
        return -1;
18422
0
    }
18423
9
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18424
0
        {
18425
0
        return -1;
18426
0
    }
18427
9
    return 0;
18428
9
}
18429
18430
static PyModuleDef_Slot astmodule_slots[] = {
18431
    _Py_ABI_SLOT,
18432
    {Py_mod_exec, astmodule_exec},
18433
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18434
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18435
    {0, NULL}
18436
};
18437
18438
static struct PyModuleDef _astmodule = {
18439
    PyModuleDef_HEAD_INIT,
18440
    .m_name = "_ast",
18441
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18442
    .m_size = 0,
18443
    .m_methods = astmodule_methods,
18444
    .m_slots = astmodule_slots
18445
};
18446
18447
PyMODINIT_FUNC
18448
PyInit__ast(void)
18449
9
{
18450
9
    return PyModuleDef_Init(&_astmodule);
18451
9
}
18452
18453
18454
PyObject* PyAST_mod2obj(mod_ty t)
18455
6.51k
{
18456
6.51k
    struct ast_state *state = get_ast_state();
18457
6.51k
    if (state == NULL) {
18458
0
        return NULL;
18459
0
    }
18460
6.51k
    PyObject *result = ast2obj_mod(state, t);
18461
18462
6.51k
    return result;
18463
6.51k
}
18464
18465
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18466
int PyAst_CheckMode(PyObject *ast, int mode)
18467
0
{
18468
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18469
18470
0
    struct ast_state *state = get_ast_state();
18471
0
    if (state == NULL) {
18472
0
        return -1;
18473
0
    }
18474
18475
0
    PyObject *req_type[3];
18476
0
    req_type[0] = state->Module_type;
18477
0
    req_type[1] = state->Expression_type;
18478
0
    req_type[2] = state->Interactive_type;
18479
18480
0
    assert(0 <= mode && mode <= 2);
18481
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18482
0
    if (isinstance == -1) {
18483
0
        return -1;
18484
0
    }
18485
0
    if (!isinstance) {
18486
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18487
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18488
0
        return -1;
18489
0
    }
18490
0
    return 0;
18491
0
}
18492
18493
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18494
0
{
18495
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18496
0
        return NULL;
18497
0
    }
18498
18499
0
    struct ast_state *state = get_ast_state();
18500
0
    if (state == NULL) {
18501
0
        return NULL;
18502
0
    }
18503
18504
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18505
0
        return NULL;
18506
0
    }
18507
18508
0
    mod_ty res = NULL;
18509
0
    if (obj2ast_mod(state, ast, &res, arena) != 0)
18510
0
        return NULL;
18511
0
    else
18512
0
        return res;
18513
0
}
18514
18515
int PyAST_Check(PyObject* obj)
18516
99.2k
{
18517
99.2k
    struct ast_state *state = get_ast_state();
18518
99.2k
    if (state == NULL) {
18519
0
        return -1;
18520
0
    }
18521
99.2k
    return PyObject_IsInstance(obj, state->AST_type);
18522
99.2k
}
18523
18524