Coverage Report

Created: 2025-11-24 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython3/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
52
{
23
52
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
52
    struct ast_state *state = &interp->ast;
25
52
    assert(!state->finalized);
26
52
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
52
    return state;
30
52
}
31
32
void _PyAST_Fini(PyInterpreterState *interp)
33
0
{
34
0
    struct ast_state *state = &interp->ast;
35
36
0
    Py_CLEAR(state->AST_type);
37
0
    Py_CLEAR(state->Add_singleton);
38
0
    Py_CLEAR(state->Add_type);
39
0
    Py_CLEAR(state->And_singleton);
40
0
    Py_CLEAR(state->And_type);
41
0
    Py_CLEAR(state->AnnAssign_type);
42
0
    Py_CLEAR(state->Assert_type);
43
0
    Py_CLEAR(state->Assign_type);
44
0
    Py_CLEAR(state->AsyncFor_type);
45
0
    Py_CLEAR(state->AsyncFunctionDef_type);
46
0
    Py_CLEAR(state->AsyncWith_type);
47
0
    Py_CLEAR(state->Attribute_type);
48
0
    Py_CLEAR(state->AugAssign_type);
49
0
    Py_CLEAR(state->Await_type);
50
0
    Py_CLEAR(state->BinOp_type);
51
0
    Py_CLEAR(state->BitAnd_singleton);
52
0
    Py_CLEAR(state->BitAnd_type);
53
0
    Py_CLEAR(state->BitOr_singleton);
54
0
    Py_CLEAR(state->BitOr_type);
55
0
    Py_CLEAR(state->BitXor_singleton);
56
0
    Py_CLEAR(state->BitXor_type);
57
0
    Py_CLEAR(state->BoolOp_type);
58
0
    Py_CLEAR(state->Break_type);
59
0
    Py_CLEAR(state->Call_type);
60
0
    Py_CLEAR(state->ClassDef_type);
61
0
    Py_CLEAR(state->Compare_type);
62
0
    Py_CLEAR(state->Constant_type);
63
0
    Py_CLEAR(state->Continue_type);
64
0
    Py_CLEAR(state->Del_singleton);
65
0
    Py_CLEAR(state->Del_type);
66
0
    Py_CLEAR(state->Delete_type);
67
0
    Py_CLEAR(state->DictComp_type);
68
0
    Py_CLEAR(state->Dict_type);
69
0
    Py_CLEAR(state->Div_singleton);
70
0
    Py_CLEAR(state->Div_type);
71
0
    Py_CLEAR(state->Eq_singleton);
72
0
    Py_CLEAR(state->Eq_type);
73
0
    Py_CLEAR(state->ExceptHandler_type);
74
0
    Py_CLEAR(state->Expr_type);
75
0
    Py_CLEAR(state->Expression_type);
76
0
    Py_CLEAR(state->FloorDiv_singleton);
77
0
    Py_CLEAR(state->FloorDiv_type);
78
0
    Py_CLEAR(state->For_type);
79
0
    Py_CLEAR(state->FormattedValue_type);
80
0
    Py_CLEAR(state->FunctionDef_type);
81
0
    Py_CLEAR(state->FunctionType_type);
82
0
    Py_CLEAR(state->GeneratorExp_type);
83
0
    Py_CLEAR(state->Global_type);
84
0
    Py_CLEAR(state->GtE_singleton);
85
0
    Py_CLEAR(state->GtE_type);
86
0
    Py_CLEAR(state->Gt_singleton);
87
0
    Py_CLEAR(state->Gt_type);
88
0
    Py_CLEAR(state->IfExp_type);
89
0
    Py_CLEAR(state->If_type);
90
0
    Py_CLEAR(state->ImportFrom_type);
91
0
    Py_CLEAR(state->Import_type);
92
0
    Py_CLEAR(state->In_singleton);
93
0
    Py_CLEAR(state->In_type);
94
0
    Py_CLEAR(state->Interactive_type);
95
0
    Py_CLEAR(state->Interpolation_type);
96
0
    Py_CLEAR(state->Invert_singleton);
97
0
    Py_CLEAR(state->Invert_type);
98
0
    Py_CLEAR(state->IsNot_singleton);
99
0
    Py_CLEAR(state->IsNot_type);
100
0
    Py_CLEAR(state->Is_singleton);
101
0
    Py_CLEAR(state->Is_type);
102
0
    Py_CLEAR(state->JoinedStr_type);
103
0
    Py_CLEAR(state->LShift_singleton);
104
0
    Py_CLEAR(state->LShift_type);
105
0
    Py_CLEAR(state->Lambda_type);
106
0
    Py_CLEAR(state->ListComp_type);
107
0
    Py_CLEAR(state->List_type);
108
0
    Py_CLEAR(state->Load_singleton);
109
0
    Py_CLEAR(state->Load_type);
110
0
    Py_CLEAR(state->LtE_singleton);
111
0
    Py_CLEAR(state->LtE_type);
112
0
    Py_CLEAR(state->Lt_singleton);
113
0
    Py_CLEAR(state->Lt_type);
114
0
    Py_CLEAR(state->MatMult_singleton);
115
0
    Py_CLEAR(state->MatMult_type);
116
0
    Py_CLEAR(state->MatchAs_type);
117
0
    Py_CLEAR(state->MatchClass_type);
118
0
    Py_CLEAR(state->MatchMapping_type);
119
0
    Py_CLEAR(state->MatchOr_type);
120
0
    Py_CLEAR(state->MatchSequence_type);
121
0
    Py_CLEAR(state->MatchSingleton_type);
122
0
    Py_CLEAR(state->MatchStar_type);
123
0
    Py_CLEAR(state->MatchValue_type);
124
0
    Py_CLEAR(state->Match_type);
125
0
    Py_CLEAR(state->Mod_singleton);
126
0
    Py_CLEAR(state->Mod_type);
127
0
    Py_CLEAR(state->Module_type);
128
0
    Py_CLEAR(state->Mult_singleton);
129
0
    Py_CLEAR(state->Mult_type);
130
0
    Py_CLEAR(state->Name_type);
131
0
    Py_CLEAR(state->NamedExpr_type);
132
0
    Py_CLEAR(state->Nonlocal_type);
133
0
    Py_CLEAR(state->NotEq_singleton);
134
0
    Py_CLEAR(state->NotEq_type);
135
0
    Py_CLEAR(state->NotIn_singleton);
136
0
    Py_CLEAR(state->NotIn_type);
137
0
    Py_CLEAR(state->Not_singleton);
138
0
    Py_CLEAR(state->Not_type);
139
0
    Py_CLEAR(state->Or_singleton);
140
0
    Py_CLEAR(state->Or_type);
141
0
    Py_CLEAR(state->ParamSpec_type);
142
0
    Py_CLEAR(state->Pass_type);
143
0
    Py_CLEAR(state->Pow_singleton);
144
0
    Py_CLEAR(state->Pow_type);
145
0
    Py_CLEAR(state->RShift_singleton);
146
0
    Py_CLEAR(state->RShift_type);
147
0
    Py_CLEAR(state->Raise_type);
148
0
    Py_CLEAR(state->Return_type);
149
0
    Py_CLEAR(state->SetComp_type);
150
0
    Py_CLEAR(state->Set_type);
151
0
    Py_CLEAR(state->Slice_type);
152
0
    Py_CLEAR(state->Starred_type);
153
0
    Py_CLEAR(state->Store_singleton);
154
0
    Py_CLEAR(state->Store_type);
155
0
    Py_CLEAR(state->Sub_singleton);
156
0
    Py_CLEAR(state->Sub_type);
157
0
    Py_CLEAR(state->Subscript_type);
158
0
    Py_CLEAR(state->TemplateStr_type);
159
0
    Py_CLEAR(state->TryStar_type);
160
0
    Py_CLEAR(state->Try_type);
161
0
    Py_CLEAR(state->Tuple_type);
162
0
    Py_CLEAR(state->TypeAlias_type);
163
0
    Py_CLEAR(state->TypeIgnore_type);
164
0
    Py_CLEAR(state->TypeVarTuple_type);
165
0
    Py_CLEAR(state->TypeVar_type);
166
0
    Py_CLEAR(state->UAdd_singleton);
167
0
    Py_CLEAR(state->UAdd_type);
168
0
    Py_CLEAR(state->USub_singleton);
169
0
    Py_CLEAR(state->USub_type);
170
0
    Py_CLEAR(state->UnaryOp_type);
171
0
    Py_CLEAR(state->While_type);
172
0
    Py_CLEAR(state->With_type);
173
0
    Py_CLEAR(state->YieldFrom_type);
174
0
    Py_CLEAR(state->Yield_type);
175
0
    Py_CLEAR(state->__dict__);
176
0
    Py_CLEAR(state->__doc__);
177
0
    Py_CLEAR(state->__match_args__);
178
0
    Py_CLEAR(state->__module__);
179
0
    Py_CLEAR(state->_attributes);
180
0
    Py_CLEAR(state->_fields);
181
0
    Py_CLEAR(state->alias_type);
182
0
    Py_CLEAR(state->annotation);
183
0
    Py_CLEAR(state->arg);
184
0
    Py_CLEAR(state->arg_type);
185
0
    Py_CLEAR(state->args);
186
0
    Py_CLEAR(state->argtypes);
187
0
    Py_CLEAR(state->arguments_type);
188
0
    Py_CLEAR(state->asname);
189
0
    Py_CLEAR(state->ast);
190
0
    Py_CLEAR(state->attr);
191
0
    Py_CLEAR(state->bases);
192
0
    Py_CLEAR(state->body);
193
0
    Py_CLEAR(state->boolop_type);
194
0
    Py_CLEAR(state->bound);
195
0
    Py_CLEAR(state->cases);
196
0
    Py_CLEAR(state->cause);
197
0
    Py_CLEAR(state->cls);
198
0
    Py_CLEAR(state->cmpop_type);
199
0
    Py_CLEAR(state->col_offset);
200
0
    Py_CLEAR(state->comparators);
201
0
    Py_CLEAR(state->comprehension_type);
202
0
    Py_CLEAR(state->context_expr);
203
0
    Py_CLEAR(state->conversion);
204
0
    Py_CLEAR(state->ctx);
205
0
    Py_CLEAR(state->decorator_list);
206
0
    Py_CLEAR(state->default_value);
207
0
    Py_CLEAR(state->defaults);
208
0
    Py_CLEAR(state->elt);
209
0
    Py_CLEAR(state->elts);
210
0
    Py_CLEAR(state->end_col_offset);
211
0
    Py_CLEAR(state->end_lineno);
212
0
    Py_CLEAR(state->exc);
213
0
    Py_CLEAR(state->excepthandler_type);
214
0
    Py_CLEAR(state->expr_context_type);
215
0
    Py_CLEAR(state->expr_type);
216
0
    Py_CLEAR(state->finalbody);
217
0
    Py_CLEAR(state->format_spec);
218
0
    Py_CLEAR(state->func);
219
0
    Py_CLEAR(state->generators);
220
0
    Py_CLEAR(state->guard);
221
0
    Py_CLEAR(state->handlers);
222
0
    Py_CLEAR(state->id);
223
0
    Py_CLEAR(state->ifs);
224
0
    Py_CLEAR(state->is_async);
225
0
    Py_CLEAR(state->items);
226
0
    Py_CLEAR(state->iter);
227
0
    Py_CLEAR(state->key);
228
0
    Py_CLEAR(state->keys);
229
0
    Py_CLEAR(state->keyword_type);
230
0
    Py_CLEAR(state->keywords);
231
0
    Py_CLEAR(state->kind);
232
0
    Py_CLEAR(state->kw_defaults);
233
0
    Py_CLEAR(state->kwarg);
234
0
    Py_CLEAR(state->kwd_attrs);
235
0
    Py_CLEAR(state->kwd_patterns);
236
0
    Py_CLEAR(state->kwonlyargs);
237
0
    Py_CLEAR(state->left);
238
0
    Py_CLEAR(state->level);
239
0
    Py_CLEAR(state->lineno);
240
0
    Py_CLEAR(state->lower);
241
0
    Py_CLEAR(state->match_case_type);
242
0
    Py_CLEAR(state->mod_type);
243
0
    Py_CLEAR(state->module);
244
0
    Py_CLEAR(state->msg);
245
0
    Py_CLEAR(state->name);
246
0
    Py_CLEAR(state->names);
247
0
    Py_CLEAR(state->op);
248
0
    Py_CLEAR(state->operand);
249
0
    Py_CLEAR(state->operator_type);
250
0
    Py_CLEAR(state->ops);
251
0
    Py_CLEAR(state->optional_vars);
252
0
    Py_CLEAR(state->orelse);
253
0
    Py_CLEAR(state->pattern);
254
0
    Py_CLEAR(state->pattern_type);
255
0
    Py_CLEAR(state->patterns);
256
0
    Py_CLEAR(state->posonlyargs);
257
0
    Py_CLEAR(state->rest);
258
0
    Py_CLEAR(state->returns);
259
0
    Py_CLEAR(state->right);
260
0
    Py_CLEAR(state->simple);
261
0
    Py_CLEAR(state->slice);
262
0
    Py_CLEAR(state->step);
263
0
    Py_CLEAR(state->stmt_type);
264
0
    Py_CLEAR(state->str);
265
0
    Py_CLEAR(state->subject);
266
0
    Py_CLEAR(state->tag);
267
0
    Py_CLEAR(state->target);
268
0
    Py_CLEAR(state->targets);
269
0
    Py_CLEAR(state->test);
270
0
    Py_CLEAR(state->type);
271
0
    Py_CLEAR(state->type_comment);
272
0
    Py_CLEAR(state->type_ignore_type);
273
0
    Py_CLEAR(state->type_ignores);
274
0
    Py_CLEAR(state->type_param_type);
275
0
    Py_CLEAR(state->type_params);
276
0
    Py_CLEAR(state->unaryop_type);
277
0
    Py_CLEAR(state->upper);
278
0
    Py_CLEAR(state->value);
279
0
    Py_CLEAR(state->values);
280
0
    Py_CLEAR(state->vararg);
281
0
    Py_CLEAR(state->withitem_type);
282
283
0
    state->finalized = 1;
284
0
    state->once = (_PyOnceFlag){0};
285
0
}
286
287
static int init_identifiers(struct ast_state *state)
288
1
{
289
1
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
290
1
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
291
1
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
292
1
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
293
1
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
294
1
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
295
1
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
296
1
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
297
1
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
298
1
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
299
1
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
300
1
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
301
1
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
302
1
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
303
1
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
304
1
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
305
1
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
306
1
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
307
1
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
308
1
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
309
1
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
310
1
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
311
1
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
312
1
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
313
1
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
314
1
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
315
1
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
316
1
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
317
1
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
318
1
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
319
1
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
320
1
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
321
1
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
322
1
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
323
1
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
324
1
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
325
1
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
326
1
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
327
1
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
328
1
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
329
1
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
330
1
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
331
1
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
332
1
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
333
1
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
334
1
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
335
1
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
336
1
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
337
1
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
338
1
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
339
1
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
340
1
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
341
1
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
342
1
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
343
1
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
344
1
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
345
1
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
346
1
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
347
1
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
348
1
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
349
1
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
350
1
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
351
1
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
352
1
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
353
1
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
354
1
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
355
1
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
356
1
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
357
1
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
358
1
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
359
1
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
360
1
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
361
1
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
362
1
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
363
1
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
364
1
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
365
1
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
366
1
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
367
1
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
368
1
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
369
1
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
370
1
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
371
1
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
372
1
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
373
1
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
374
1
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
375
1
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
376
1
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
377
1
    return 0;
378
1
};
379
380
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
381
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
382
192k
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
384
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
385
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
386
95.6k
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
387
13.8k
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
388
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
389
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
390
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
391
805
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
392
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
393
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
394
395
static PyObject* ast2obj_mod(struct ast_state *state, void*);
396
static const char * const Module_fields[]={
397
    "body",
398
    "type_ignores",
399
};
400
static const char * const Interactive_fields[]={
401
    "body",
402
};
403
static const char * const Expression_fields[]={
404
    "body",
405
};
406
static const char * const FunctionType_fields[]={
407
    "argtypes",
408
    "returns",
409
};
410
static const char * const stmt_attributes[] = {
411
    "lineno",
412
    "col_offset",
413
    "end_lineno",
414
    "end_col_offset",
415
};
416
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
417
static const char * const FunctionDef_fields[]={
418
    "name",
419
    "args",
420
    "body",
421
    "decorator_list",
422
    "returns",
423
    "type_comment",
424
    "type_params",
425
};
426
static const char * const AsyncFunctionDef_fields[]={
427
    "name",
428
    "args",
429
    "body",
430
    "decorator_list",
431
    "returns",
432
    "type_comment",
433
    "type_params",
434
};
435
static const char * const ClassDef_fields[]={
436
    "name",
437
    "bases",
438
    "keywords",
439
    "body",
440
    "decorator_list",
441
    "type_params",
442
};
443
static const char * const Return_fields[]={
444
    "value",
445
};
446
static const char * const Delete_fields[]={
447
    "targets",
448
};
449
static const char * const Assign_fields[]={
450
    "targets",
451
    "value",
452
    "type_comment",
453
};
454
static const char * const TypeAlias_fields[]={
455
    "name",
456
    "type_params",
457
    "value",
458
};
459
static const char * const AugAssign_fields[]={
460
    "target",
461
    "op",
462
    "value",
463
};
464
static const char * const AnnAssign_fields[]={
465
    "target",
466
    "annotation",
467
    "value",
468
    "simple",
469
};
470
static const char * const For_fields[]={
471
    "target",
472
    "iter",
473
    "body",
474
    "orelse",
475
    "type_comment",
476
};
477
static const char * const AsyncFor_fields[]={
478
    "target",
479
    "iter",
480
    "body",
481
    "orelse",
482
    "type_comment",
483
};
484
static const char * const While_fields[]={
485
    "test",
486
    "body",
487
    "orelse",
488
};
489
static const char * const If_fields[]={
490
    "test",
491
    "body",
492
    "orelse",
493
};
494
static const char * const With_fields[]={
495
    "items",
496
    "body",
497
    "type_comment",
498
};
499
static const char * const AsyncWith_fields[]={
500
    "items",
501
    "body",
502
    "type_comment",
503
};
504
static const char * const Match_fields[]={
505
    "subject",
506
    "cases",
507
};
508
static const char * const Raise_fields[]={
509
    "exc",
510
    "cause",
511
};
512
static const char * const Try_fields[]={
513
    "body",
514
    "handlers",
515
    "orelse",
516
    "finalbody",
517
};
518
static const char * const TryStar_fields[]={
519
    "body",
520
    "handlers",
521
    "orelse",
522
    "finalbody",
523
};
524
static const char * const Assert_fields[]={
525
    "test",
526
    "msg",
527
};
528
static const char * const Import_fields[]={
529
    "names",
530
};
531
static const char * const ImportFrom_fields[]={
532
    "module",
533
    "names",
534
    "level",
535
};
536
static const char * const Global_fields[]={
537
    "names",
538
};
539
static const char * const Nonlocal_fields[]={
540
    "names",
541
};
542
static const char * const Expr_fields[]={
543
    "value",
544
};
545
static const char * const expr_attributes[] = {
546
    "lineno",
547
    "col_offset",
548
    "end_lineno",
549
    "end_col_offset",
550
};
551
static PyObject* ast2obj_expr(struct ast_state *state, void*);
552
static const char * const BoolOp_fields[]={
553
    "op",
554
    "values",
555
};
556
static const char * const NamedExpr_fields[]={
557
    "target",
558
    "value",
559
};
560
static const char * const BinOp_fields[]={
561
    "left",
562
    "op",
563
    "right",
564
};
565
static const char * const UnaryOp_fields[]={
566
    "op",
567
    "operand",
568
};
569
static const char * const Lambda_fields[]={
570
    "args",
571
    "body",
572
};
573
static const char * const IfExp_fields[]={
574
    "test",
575
    "body",
576
    "orelse",
577
};
578
static const char * const Dict_fields[]={
579
    "keys",
580
    "values",
581
};
582
static const char * const Set_fields[]={
583
    "elts",
584
};
585
static const char * const ListComp_fields[]={
586
    "elt",
587
    "generators",
588
};
589
static const char * const SetComp_fields[]={
590
    "elt",
591
    "generators",
592
};
593
static const char * const DictComp_fields[]={
594
    "key",
595
    "value",
596
    "generators",
597
};
598
static const char * const GeneratorExp_fields[]={
599
    "elt",
600
    "generators",
601
};
602
static const char * const Await_fields[]={
603
    "value",
604
};
605
static const char * const Yield_fields[]={
606
    "value",
607
};
608
static const char * const YieldFrom_fields[]={
609
    "value",
610
};
611
static const char * const Compare_fields[]={
612
    "left",
613
    "ops",
614
    "comparators",
615
};
616
static const char * const Call_fields[]={
617
    "func",
618
    "args",
619
    "keywords",
620
};
621
static const char * const FormattedValue_fields[]={
622
    "value",
623
    "conversion",
624
    "format_spec",
625
};
626
static const char * const Interpolation_fields[]={
627
    "value",
628
    "str",
629
    "conversion",
630
    "format_spec",
631
};
632
static const char * const JoinedStr_fields[]={
633
    "values",
634
};
635
static const char * const TemplateStr_fields[]={
636
    "values",
637
};
638
static const char * const Constant_fields[]={
639
    "value",
640
    "kind",
641
};
642
static const char * const Attribute_fields[]={
643
    "value",
644
    "attr",
645
    "ctx",
646
};
647
static const char * const Subscript_fields[]={
648
    "value",
649
    "slice",
650
    "ctx",
651
};
652
static const char * const Starred_fields[]={
653
    "value",
654
    "ctx",
655
};
656
static const char * const Name_fields[]={
657
    "id",
658
    "ctx",
659
};
660
static const char * const List_fields[]={
661
    "elts",
662
    "ctx",
663
};
664
static const char * const Tuple_fields[]={
665
    "elts",
666
    "ctx",
667
};
668
static const char * const Slice_fields[]={
669
    "lower",
670
    "upper",
671
    "step",
672
};
673
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
674
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
675
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
676
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
677
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
678
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
679
static const char * const comprehension_fields[]={
680
    "target",
681
    "iter",
682
    "ifs",
683
    "is_async",
684
};
685
static const char * const excepthandler_attributes[] = {
686
    "lineno",
687
    "col_offset",
688
    "end_lineno",
689
    "end_col_offset",
690
};
691
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
692
static const char * const ExceptHandler_fields[]={
693
    "type",
694
    "name",
695
    "body",
696
};
697
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
698
static const char * const arguments_fields[]={
699
    "posonlyargs",
700
    "args",
701
    "vararg",
702
    "kwonlyargs",
703
    "kw_defaults",
704
    "kwarg",
705
    "defaults",
706
};
707
static PyObject* ast2obj_arg(struct ast_state *state, void*);
708
static const char * const arg_attributes[] = {
709
    "lineno",
710
    "col_offset",
711
    "end_lineno",
712
    "end_col_offset",
713
};
714
static const char * const arg_fields[]={
715
    "arg",
716
    "annotation",
717
    "type_comment",
718
};
719
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
720
static const char * const keyword_attributes[] = {
721
    "lineno",
722
    "col_offset",
723
    "end_lineno",
724
    "end_col_offset",
725
};
726
static const char * const keyword_fields[]={
727
    "arg",
728
    "value",
729
};
730
static PyObject* ast2obj_alias(struct ast_state *state, void*);
731
static const char * const alias_attributes[] = {
732
    "lineno",
733
    "col_offset",
734
    "end_lineno",
735
    "end_col_offset",
736
};
737
static const char * const alias_fields[]={
738
    "name",
739
    "asname",
740
};
741
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
742
static const char * const withitem_fields[]={
743
    "context_expr",
744
    "optional_vars",
745
};
746
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
747
static const char * const match_case_fields[]={
748
    "pattern",
749
    "guard",
750
    "body",
751
};
752
static const char * const pattern_attributes[] = {
753
    "lineno",
754
    "col_offset",
755
    "end_lineno",
756
    "end_col_offset",
757
};
758
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
759
static const char * const MatchValue_fields[]={
760
    "value",
761
};
762
static const char * const MatchSingleton_fields[]={
763
    "value",
764
};
765
static const char * const MatchSequence_fields[]={
766
    "patterns",
767
};
768
static const char * const MatchMapping_fields[]={
769
    "keys",
770
    "patterns",
771
    "rest",
772
};
773
static const char * const MatchClass_fields[]={
774
    "cls",
775
    "patterns",
776
    "kwd_attrs",
777
    "kwd_patterns",
778
};
779
static const char * const MatchStar_fields[]={
780
    "name",
781
};
782
static const char * const MatchAs_fields[]={
783
    "pattern",
784
    "name",
785
};
786
static const char * const MatchOr_fields[]={
787
    "patterns",
788
};
789
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
790
static const char * const TypeIgnore_fields[]={
791
    "lineno",
792
    "tag",
793
};
794
static const char * const type_param_attributes[] = {
795
    "lineno",
796
    "col_offset",
797
    "end_lineno",
798
    "end_col_offset",
799
};
800
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
801
static const char * const TypeVar_fields[]={
802
    "name",
803
    "bound",
804
    "default_value",
805
};
806
static const char * const ParamSpec_fields[]={
807
    "name",
808
    "default_value",
809
};
810
static const char * const TypeVarTuple_fields[]={
811
    "name",
812
    "default_value",
813
};
814
815
816
static int
817
add_ast_annotations(struct ast_state *state)
818
1
{
819
1
    bool cond;
820
1
    PyObject *Module_annotations = PyDict_New();
821
1
    if (!Module_annotations) return 0;
822
1
    {
823
1
        PyObject *type = state->stmt_type;
824
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
825
1
        cond = type != NULL;
826
1
        if (!cond) {
827
0
            Py_DECREF(Module_annotations);
828
0
            return 0;
829
0
        }
830
1
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
831
1
        Py_DECREF(type);
832
1
        if (!cond) {
833
0
            Py_DECREF(Module_annotations);
834
0
            return 0;
835
0
        }
836
1
    }
837
1
    {
838
1
        PyObject *type = state->type_ignore_type;
839
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
840
1
        cond = type != NULL;
841
1
        if (!cond) {
842
0
            Py_DECREF(Module_annotations);
843
0
            return 0;
844
0
        }
845
1
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
846
1
                                    == 0;
847
1
        Py_DECREF(type);
848
1
        if (!cond) {
849
0
            Py_DECREF(Module_annotations);
850
0
            return 0;
851
0
        }
852
1
    }
853
1
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
854
1
                                  Module_annotations) == 0;
855
1
    if (!cond) {
856
0
        Py_DECREF(Module_annotations);
857
0
        return 0;
858
0
    }
859
1
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
860
1
                                  Module_annotations) == 0;
861
1
    if (!cond) {
862
0
        Py_DECREF(Module_annotations);
863
0
        return 0;
864
0
    }
865
1
    Py_DECREF(Module_annotations);
866
1
    PyObject *Interactive_annotations = PyDict_New();
867
1
    if (!Interactive_annotations) return 0;
868
1
    {
869
1
        PyObject *type = state->stmt_type;
870
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
871
1
        cond = type != NULL;
872
1
        if (!cond) {
873
0
            Py_DECREF(Interactive_annotations);
874
0
            return 0;
875
0
        }
876
1
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
877
1
        Py_DECREF(type);
878
1
        if (!cond) {
879
0
            Py_DECREF(Interactive_annotations);
880
0
            return 0;
881
0
        }
882
1
    }
883
1
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
884
1
                                  Interactive_annotations) == 0;
885
1
    if (!cond) {
886
0
        Py_DECREF(Interactive_annotations);
887
0
        return 0;
888
0
    }
889
1
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
890
1
                                  Interactive_annotations) == 0;
891
1
    if (!cond) {
892
0
        Py_DECREF(Interactive_annotations);
893
0
        return 0;
894
0
    }
895
1
    Py_DECREF(Interactive_annotations);
896
1
    PyObject *Expression_annotations = PyDict_New();
897
1
    if (!Expression_annotations) return 0;
898
1
    {
899
1
        PyObject *type = state->expr_type;
900
1
        Py_INCREF(type);
901
1
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
902
1
        Py_DECREF(type);
903
1
        if (!cond) {
904
0
            Py_DECREF(Expression_annotations);
905
0
            return 0;
906
0
        }
907
1
    }
908
1
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
909
1
                                  Expression_annotations) == 0;
910
1
    if (!cond) {
911
0
        Py_DECREF(Expression_annotations);
912
0
        return 0;
913
0
    }
914
1
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
915
1
                                  Expression_annotations) == 0;
916
1
    if (!cond) {
917
0
        Py_DECREF(Expression_annotations);
918
0
        return 0;
919
0
    }
920
1
    Py_DECREF(Expression_annotations);
921
1
    PyObject *FunctionType_annotations = PyDict_New();
922
1
    if (!FunctionType_annotations) return 0;
923
1
    {
924
1
        PyObject *type = state->expr_type;
925
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
926
1
        cond = type != NULL;
927
1
        if (!cond) {
928
0
            Py_DECREF(FunctionType_annotations);
929
0
            return 0;
930
0
        }
931
1
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
932
1
                                    == 0;
933
1
        Py_DECREF(type);
934
1
        if (!cond) {
935
0
            Py_DECREF(FunctionType_annotations);
936
0
            return 0;
937
0
        }
938
1
    }
939
1
    {
940
1
        PyObject *type = state->expr_type;
941
1
        Py_INCREF(type);
942
1
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
943
1
                                    == 0;
944
1
        Py_DECREF(type);
945
1
        if (!cond) {
946
0
            Py_DECREF(FunctionType_annotations);
947
0
            return 0;
948
0
        }
949
1
    }
950
1
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
951
1
                                  FunctionType_annotations) == 0;
952
1
    if (!cond) {
953
0
        Py_DECREF(FunctionType_annotations);
954
0
        return 0;
955
0
    }
956
1
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
957
1
                                  FunctionType_annotations) == 0;
958
1
    if (!cond) {
959
0
        Py_DECREF(FunctionType_annotations);
960
0
        return 0;
961
0
    }
962
1
    Py_DECREF(FunctionType_annotations);
963
1
    PyObject *FunctionDef_annotations = PyDict_New();
964
1
    if (!FunctionDef_annotations) return 0;
965
1
    {
966
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
967
1
        Py_INCREF(type);
968
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
969
1
        Py_DECREF(type);
970
1
        if (!cond) {
971
0
            Py_DECREF(FunctionDef_annotations);
972
0
            return 0;
973
0
        }
974
1
    }
975
1
    {
976
1
        PyObject *type = state->arguments_type;
977
1
        Py_INCREF(type);
978
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
979
1
        Py_DECREF(type);
980
1
        if (!cond) {
981
0
            Py_DECREF(FunctionDef_annotations);
982
0
            return 0;
983
0
        }
984
1
    }
985
1
    {
986
1
        PyObject *type = state->stmt_type;
987
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
988
1
        cond = type != NULL;
989
1
        if (!cond) {
990
0
            Py_DECREF(FunctionDef_annotations);
991
0
            return 0;
992
0
        }
993
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
994
1
        Py_DECREF(type);
995
1
        if (!cond) {
996
0
            Py_DECREF(FunctionDef_annotations);
997
0
            return 0;
998
0
        }
999
1
    }
1000
1
    {
1001
1
        PyObject *type = state->expr_type;
1002
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1003
1
        cond = type != NULL;
1004
1
        if (!cond) {
1005
0
            Py_DECREF(FunctionDef_annotations);
1006
0
            return 0;
1007
0
        }
1008
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1009
1
                                    type) == 0;
1010
1
        Py_DECREF(type);
1011
1
        if (!cond) {
1012
0
            Py_DECREF(FunctionDef_annotations);
1013
0
            return 0;
1014
0
        }
1015
1
    }
1016
1
    {
1017
1
        PyObject *type = state->expr_type;
1018
1
        type = _Py_union_type_or(type, Py_None);
1019
1
        cond = type != NULL;
1020
1
        if (!cond) {
1021
0
            Py_DECREF(FunctionDef_annotations);
1022
0
            return 0;
1023
0
        }
1024
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1025
1
                                    == 0;
1026
1
        Py_DECREF(type);
1027
1
        if (!cond) {
1028
0
            Py_DECREF(FunctionDef_annotations);
1029
0
            return 0;
1030
0
        }
1031
1
    }
1032
1
    {
1033
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1034
1
        type = _Py_union_type_or(type, Py_None);
1035
1
        cond = type != NULL;
1036
1
        if (!cond) {
1037
0
            Py_DECREF(FunctionDef_annotations);
1038
0
            return 0;
1039
0
        }
1040
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1041
1
                                    type) == 0;
1042
1
        Py_DECREF(type);
1043
1
        if (!cond) {
1044
0
            Py_DECREF(FunctionDef_annotations);
1045
0
            return 0;
1046
0
        }
1047
1
    }
1048
1
    {
1049
1
        PyObject *type = state->type_param_type;
1050
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1051
1
        cond = type != NULL;
1052
1
        if (!cond) {
1053
0
            Py_DECREF(FunctionDef_annotations);
1054
0
            return 0;
1055
0
        }
1056
1
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1057
1
                                    type) == 0;
1058
1
        Py_DECREF(type);
1059
1
        if (!cond) {
1060
0
            Py_DECREF(FunctionDef_annotations);
1061
0
            return 0;
1062
0
        }
1063
1
    }
1064
1
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1065
1
                                  FunctionDef_annotations) == 0;
1066
1
    if (!cond) {
1067
0
        Py_DECREF(FunctionDef_annotations);
1068
0
        return 0;
1069
0
    }
1070
1
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1071
1
                                  FunctionDef_annotations) == 0;
1072
1
    if (!cond) {
1073
0
        Py_DECREF(FunctionDef_annotations);
1074
0
        return 0;
1075
0
    }
1076
1
    Py_DECREF(FunctionDef_annotations);
1077
1
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1078
1
    if (!AsyncFunctionDef_annotations) return 0;
1079
1
    {
1080
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1081
1
        Py_INCREF(type);
1082
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1083
1
                                    == 0;
1084
1
        Py_DECREF(type);
1085
1
        if (!cond) {
1086
0
            Py_DECREF(AsyncFunctionDef_annotations);
1087
0
            return 0;
1088
0
        }
1089
1
    }
1090
1
    {
1091
1
        PyObject *type = state->arguments_type;
1092
1
        Py_INCREF(type);
1093
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1094
1
                                    == 0;
1095
1
        Py_DECREF(type);
1096
1
        if (!cond) {
1097
0
            Py_DECREF(AsyncFunctionDef_annotations);
1098
0
            return 0;
1099
0
        }
1100
1
    }
1101
1
    {
1102
1
        PyObject *type = state->stmt_type;
1103
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1104
1
        cond = type != NULL;
1105
1
        if (!cond) {
1106
0
            Py_DECREF(AsyncFunctionDef_annotations);
1107
0
            return 0;
1108
0
        }
1109
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1110
1
                                    == 0;
1111
1
        Py_DECREF(type);
1112
1
        if (!cond) {
1113
0
            Py_DECREF(AsyncFunctionDef_annotations);
1114
0
            return 0;
1115
0
        }
1116
1
    }
1117
1
    {
1118
1
        PyObject *type = state->expr_type;
1119
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1120
1
        cond = type != NULL;
1121
1
        if (!cond) {
1122
0
            Py_DECREF(AsyncFunctionDef_annotations);
1123
0
            return 0;
1124
0
        }
1125
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1126
1
                                    "decorator_list", type) == 0;
1127
1
        Py_DECREF(type);
1128
1
        if (!cond) {
1129
0
            Py_DECREF(AsyncFunctionDef_annotations);
1130
0
            return 0;
1131
0
        }
1132
1
    }
1133
1
    {
1134
1
        PyObject *type = state->expr_type;
1135
1
        type = _Py_union_type_or(type, Py_None);
1136
1
        cond = type != NULL;
1137
1
        if (!cond) {
1138
0
            Py_DECREF(AsyncFunctionDef_annotations);
1139
0
            return 0;
1140
0
        }
1141
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1142
1
                                    type) == 0;
1143
1
        Py_DECREF(type);
1144
1
        if (!cond) {
1145
0
            Py_DECREF(AsyncFunctionDef_annotations);
1146
0
            return 0;
1147
0
        }
1148
1
    }
1149
1
    {
1150
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1151
1
        type = _Py_union_type_or(type, Py_None);
1152
1
        cond = type != NULL;
1153
1
        if (!cond) {
1154
0
            Py_DECREF(AsyncFunctionDef_annotations);
1155
0
            return 0;
1156
0
        }
1157
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1158
1
                                    "type_comment", type) == 0;
1159
1
        Py_DECREF(type);
1160
1
        if (!cond) {
1161
0
            Py_DECREF(AsyncFunctionDef_annotations);
1162
0
            return 0;
1163
0
        }
1164
1
    }
1165
1
    {
1166
1
        PyObject *type = state->type_param_type;
1167
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1168
1
        cond = type != NULL;
1169
1
        if (!cond) {
1170
0
            Py_DECREF(AsyncFunctionDef_annotations);
1171
0
            return 0;
1172
0
        }
1173
1
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1174
1
                                    "type_params", type) == 0;
1175
1
        Py_DECREF(type);
1176
1
        if (!cond) {
1177
0
            Py_DECREF(AsyncFunctionDef_annotations);
1178
0
            return 0;
1179
0
        }
1180
1
    }
1181
1
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1182
1
                                  AsyncFunctionDef_annotations) == 0;
1183
1
    if (!cond) {
1184
0
        Py_DECREF(AsyncFunctionDef_annotations);
1185
0
        return 0;
1186
0
    }
1187
1
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1188
1
                                  "__annotations__",
1189
1
                                  AsyncFunctionDef_annotations) == 0;
1190
1
    if (!cond) {
1191
0
        Py_DECREF(AsyncFunctionDef_annotations);
1192
0
        return 0;
1193
0
    }
1194
1
    Py_DECREF(AsyncFunctionDef_annotations);
1195
1
    PyObject *ClassDef_annotations = PyDict_New();
1196
1
    if (!ClassDef_annotations) return 0;
1197
1
    {
1198
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1199
1
        Py_INCREF(type);
1200
1
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1201
1
        Py_DECREF(type);
1202
1
        if (!cond) {
1203
0
            Py_DECREF(ClassDef_annotations);
1204
0
            return 0;
1205
0
        }
1206
1
    }
1207
1
    {
1208
1
        PyObject *type = state->expr_type;
1209
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1210
1
        cond = type != NULL;
1211
1
        if (!cond) {
1212
0
            Py_DECREF(ClassDef_annotations);
1213
0
            return 0;
1214
0
        }
1215
1
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1216
1
        Py_DECREF(type);
1217
1
        if (!cond) {
1218
0
            Py_DECREF(ClassDef_annotations);
1219
0
            return 0;
1220
0
        }
1221
1
    }
1222
1
    {
1223
1
        PyObject *type = state->keyword_type;
1224
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1225
1
        cond = type != NULL;
1226
1
        if (!cond) {
1227
0
            Py_DECREF(ClassDef_annotations);
1228
0
            return 0;
1229
0
        }
1230
1
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1231
1
                                    0;
1232
1
        Py_DECREF(type);
1233
1
        if (!cond) {
1234
0
            Py_DECREF(ClassDef_annotations);
1235
0
            return 0;
1236
0
        }
1237
1
    }
1238
1
    {
1239
1
        PyObject *type = state->stmt_type;
1240
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1241
1
        cond = type != NULL;
1242
1
        if (!cond) {
1243
0
            Py_DECREF(ClassDef_annotations);
1244
0
            return 0;
1245
0
        }
1246
1
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1247
1
        Py_DECREF(type);
1248
1
        if (!cond) {
1249
0
            Py_DECREF(ClassDef_annotations);
1250
0
            return 0;
1251
0
        }
1252
1
    }
1253
1
    {
1254
1
        PyObject *type = state->expr_type;
1255
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1256
1
        cond = type != NULL;
1257
1
        if (!cond) {
1258
0
            Py_DECREF(ClassDef_annotations);
1259
0
            return 0;
1260
0
        }
1261
1
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1262
1
                                    type) == 0;
1263
1
        Py_DECREF(type);
1264
1
        if (!cond) {
1265
0
            Py_DECREF(ClassDef_annotations);
1266
0
            return 0;
1267
0
        }
1268
1
    }
1269
1
    {
1270
1
        PyObject *type = state->type_param_type;
1271
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1272
1
        cond = type != NULL;
1273
1
        if (!cond) {
1274
0
            Py_DECREF(ClassDef_annotations);
1275
0
            return 0;
1276
0
        }
1277
1
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1278
1
                                    == 0;
1279
1
        Py_DECREF(type);
1280
1
        if (!cond) {
1281
0
            Py_DECREF(ClassDef_annotations);
1282
0
            return 0;
1283
0
        }
1284
1
    }
1285
1
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1286
1
                                  ClassDef_annotations) == 0;
1287
1
    if (!cond) {
1288
0
        Py_DECREF(ClassDef_annotations);
1289
0
        return 0;
1290
0
    }
1291
1
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1292
1
                                  ClassDef_annotations) == 0;
1293
1
    if (!cond) {
1294
0
        Py_DECREF(ClassDef_annotations);
1295
0
        return 0;
1296
0
    }
1297
1
    Py_DECREF(ClassDef_annotations);
1298
1
    PyObject *Return_annotations = PyDict_New();
1299
1
    if (!Return_annotations) return 0;
1300
1
    {
1301
1
        PyObject *type = state->expr_type;
1302
1
        type = _Py_union_type_or(type, Py_None);
1303
1
        cond = type != NULL;
1304
1
        if (!cond) {
1305
0
            Py_DECREF(Return_annotations);
1306
0
            return 0;
1307
0
        }
1308
1
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1309
1
        Py_DECREF(type);
1310
1
        if (!cond) {
1311
0
            Py_DECREF(Return_annotations);
1312
0
            return 0;
1313
0
        }
1314
1
    }
1315
1
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1316
1
                                  Return_annotations) == 0;
1317
1
    if (!cond) {
1318
0
        Py_DECREF(Return_annotations);
1319
0
        return 0;
1320
0
    }
1321
1
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1322
1
                                  Return_annotations) == 0;
1323
1
    if (!cond) {
1324
0
        Py_DECREF(Return_annotations);
1325
0
        return 0;
1326
0
    }
1327
1
    Py_DECREF(Return_annotations);
1328
1
    PyObject *Delete_annotations = PyDict_New();
1329
1
    if (!Delete_annotations) return 0;
1330
1
    {
1331
1
        PyObject *type = state->expr_type;
1332
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1333
1
        cond = type != NULL;
1334
1
        if (!cond) {
1335
0
            Py_DECREF(Delete_annotations);
1336
0
            return 0;
1337
0
        }
1338
1
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1339
1
        Py_DECREF(type);
1340
1
        if (!cond) {
1341
0
            Py_DECREF(Delete_annotations);
1342
0
            return 0;
1343
0
        }
1344
1
    }
1345
1
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1346
1
                                  Delete_annotations) == 0;
1347
1
    if (!cond) {
1348
0
        Py_DECREF(Delete_annotations);
1349
0
        return 0;
1350
0
    }
1351
1
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1352
1
                                  Delete_annotations) == 0;
1353
1
    if (!cond) {
1354
0
        Py_DECREF(Delete_annotations);
1355
0
        return 0;
1356
0
    }
1357
1
    Py_DECREF(Delete_annotations);
1358
1
    PyObject *Assign_annotations = PyDict_New();
1359
1
    if (!Assign_annotations) return 0;
1360
1
    {
1361
1
        PyObject *type = state->expr_type;
1362
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1363
1
        cond = type != NULL;
1364
1
        if (!cond) {
1365
0
            Py_DECREF(Assign_annotations);
1366
0
            return 0;
1367
0
        }
1368
1
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1369
1
        Py_DECREF(type);
1370
1
        if (!cond) {
1371
0
            Py_DECREF(Assign_annotations);
1372
0
            return 0;
1373
0
        }
1374
1
    }
1375
1
    {
1376
1
        PyObject *type = state->expr_type;
1377
1
        Py_INCREF(type);
1378
1
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1379
1
        Py_DECREF(type);
1380
1
        if (!cond) {
1381
0
            Py_DECREF(Assign_annotations);
1382
0
            return 0;
1383
0
        }
1384
1
    }
1385
1
    {
1386
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1387
1
        type = _Py_union_type_or(type, Py_None);
1388
1
        cond = type != NULL;
1389
1
        if (!cond) {
1390
0
            Py_DECREF(Assign_annotations);
1391
0
            return 0;
1392
0
        }
1393
1
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1394
1
                                    == 0;
1395
1
        Py_DECREF(type);
1396
1
        if (!cond) {
1397
0
            Py_DECREF(Assign_annotations);
1398
0
            return 0;
1399
0
        }
1400
1
    }
1401
1
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1402
1
                                  Assign_annotations) == 0;
1403
1
    if (!cond) {
1404
0
        Py_DECREF(Assign_annotations);
1405
0
        return 0;
1406
0
    }
1407
1
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1408
1
                                  Assign_annotations) == 0;
1409
1
    if (!cond) {
1410
0
        Py_DECREF(Assign_annotations);
1411
0
        return 0;
1412
0
    }
1413
1
    Py_DECREF(Assign_annotations);
1414
1
    PyObject *TypeAlias_annotations = PyDict_New();
1415
1
    if (!TypeAlias_annotations) return 0;
1416
1
    {
1417
1
        PyObject *type = state->expr_type;
1418
1
        Py_INCREF(type);
1419
1
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1420
1
        Py_DECREF(type);
1421
1
        if (!cond) {
1422
0
            Py_DECREF(TypeAlias_annotations);
1423
0
            return 0;
1424
0
        }
1425
1
    }
1426
1
    {
1427
1
        PyObject *type = state->type_param_type;
1428
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1429
1
        cond = type != NULL;
1430
1
        if (!cond) {
1431
0
            Py_DECREF(TypeAlias_annotations);
1432
0
            return 0;
1433
0
        }
1434
1
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1435
1
                                    == 0;
1436
1
        Py_DECREF(type);
1437
1
        if (!cond) {
1438
0
            Py_DECREF(TypeAlias_annotations);
1439
0
            return 0;
1440
0
        }
1441
1
    }
1442
1
    {
1443
1
        PyObject *type = state->expr_type;
1444
1
        Py_INCREF(type);
1445
1
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1446
1
        Py_DECREF(type);
1447
1
        if (!cond) {
1448
0
            Py_DECREF(TypeAlias_annotations);
1449
0
            return 0;
1450
0
        }
1451
1
    }
1452
1
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1453
1
                                  TypeAlias_annotations) == 0;
1454
1
    if (!cond) {
1455
0
        Py_DECREF(TypeAlias_annotations);
1456
0
        return 0;
1457
0
    }
1458
1
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1459
1
                                  TypeAlias_annotations) == 0;
1460
1
    if (!cond) {
1461
0
        Py_DECREF(TypeAlias_annotations);
1462
0
        return 0;
1463
0
    }
1464
1
    Py_DECREF(TypeAlias_annotations);
1465
1
    PyObject *AugAssign_annotations = PyDict_New();
1466
1
    if (!AugAssign_annotations) return 0;
1467
1
    {
1468
1
        PyObject *type = state->expr_type;
1469
1
        Py_INCREF(type);
1470
1
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1471
1
        Py_DECREF(type);
1472
1
        if (!cond) {
1473
0
            Py_DECREF(AugAssign_annotations);
1474
0
            return 0;
1475
0
        }
1476
1
    }
1477
1
    {
1478
1
        PyObject *type = state->operator_type;
1479
1
        Py_INCREF(type);
1480
1
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1481
1
        Py_DECREF(type);
1482
1
        if (!cond) {
1483
0
            Py_DECREF(AugAssign_annotations);
1484
0
            return 0;
1485
0
        }
1486
1
    }
1487
1
    {
1488
1
        PyObject *type = state->expr_type;
1489
1
        Py_INCREF(type);
1490
1
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1491
1
        Py_DECREF(type);
1492
1
        if (!cond) {
1493
0
            Py_DECREF(AugAssign_annotations);
1494
0
            return 0;
1495
0
        }
1496
1
    }
1497
1
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1498
1
                                  AugAssign_annotations) == 0;
1499
1
    if (!cond) {
1500
0
        Py_DECREF(AugAssign_annotations);
1501
0
        return 0;
1502
0
    }
1503
1
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1504
1
                                  AugAssign_annotations) == 0;
1505
1
    if (!cond) {
1506
0
        Py_DECREF(AugAssign_annotations);
1507
0
        return 0;
1508
0
    }
1509
1
    Py_DECREF(AugAssign_annotations);
1510
1
    PyObject *AnnAssign_annotations = PyDict_New();
1511
1
    if (!AnnAssign_annotations) return 0;
1512
1
    {
1513
1
        PyObject *type = state->expr_type;
1514
1
        Py_INCREF(type);
1515
1
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1516
1
        Py_DECREF(type);
1517
1
        if (!cond) {
1518
0
            Py_DECREF(AnnAssign_annotations);
1519
0
            return 0;
1520
0
        }
1521
1
    }
1522
1
    {
1523
1
        PyObject *type = state->expr_type;
1524
1
        Py_INCREF(type);
1525
1
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1526
1
                                    == 0;
1527
1
        Py_DECREF(type);
1528
1
        if (!cond) {
1529
0
            Py_DECREF(AnnAssign_annotations);
1530
0
            return 0;
1531
0
        }
1532
1
    }
1533
1
    {
1534
1
        PyObject *type = state->expr_type;
1535
1
        type = _Py_union_type_or(type, Py_None);
1536
1
        cond = type != NULL;
1537
1
        if (!cond) {
1538
0
            Py_DECREF(AnnAssign_annotations);
1539
0
            return 0;
1540
0
        }
1541
1
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1542
1
        Py_DECREF(type);
1543
1
        if (!cond) {
1544
0
            Py_DECREF(AnnAssign_annotations);
1545
0
            return 0;
1546
0
        }
1547
1
    }
1548
1
    {
1549
1
        PyObject *type = (PyObject *)&PyLong_Type;
1550
1
        Py_INCREF(type);
1551
1
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1552
1
        Py_DECREF(type);
1553
1
        if (!cond) {
1554
0
            Py_DECREF(AnnAssign_annotations);
1555
0
            return 0;
1556
0
        }
1557
1
    }
1558
1
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1559
1
                                  AnnAssign_annotations) == 0;
1560
1
    if (!cond) {
1561
0
        Py_DECREF(AnnAssign_annotations);
1562
0
        return 0;
1563
0
    }
1564
1
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1565
1
                                  AnnAssign_annotations) == 0;
1566
1
    if (!cond) {
1567
0
        Py_DECREF(AnnAssign_annotations);
1568
0
        return 0;
1569
0
    }
1570
1
    Py_DECREF(AnnAssign_annotations);
1571
1
    PyObject *For_annotations = PyDict_New();
1572
1
    if (!For_annotations) return 0;
1573
1
    {
1574
1
        PyObject *type = state->expr_type;
1575
1
        Py_INCREF(type);
1576
1
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1577
1
        Py_DECREF(type);
1578
1
        if (!cond) {
1579
0
            Py_DECREF(For_annotations);
1580
0
            return 0;
1581
0
        }
1582
1
    }
1583
1
    {
1584
1
        PyObject *type = state->expr_type;
1585
1
        Py_INCREF(type);
1586
1
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1587
1
        Py_DECREF(type);
1588
1
        if (!cond) {
1589
0
            Py_DECREF(For_annotations);
1590
0
            return 0;
1591
0
        }
1592
1
    }
1593
1
    {
1594
1
        PyObject *type = state->stmt_type;
1595
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1596
1
        cond = type != NULL;
1597
1
        if (!cond) {
1598
0
            Py_DECREF(For_annotations);
1599
0
            return 0;
1600
0
        }
1601
1
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1602
1
        Py_DECREF(type);
1603
1
        if (!cond) {
1604
0
            Py_DECREF(For_annotations);
1605
0
            return 0;
1606
0
        }
1607
1
    }
1608
1
    {
1609
1
        PyObject *type = state->stmt_type;
1610
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1611
1
        cond = type != NULL;
1612
1
        if (!cond) {
1613
0
            Py_DECREF(For_annotations);
1614
0
            return 0;
1615
0
        }
1616
1
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1617
1
        Py_DECREF(type);
1618
1
        if (!cond) {
1619
0
            Py_DECREF(For_annotations);
1620
0
            return 0;
1621
0
        }
1622
1
    }
1623
1
    {
1624
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1625
1
        type = _Py_union_type_or(type, Py_None);
1626
1
        cond = type != NULL;
1627
1
        if (!cond) {
1628
0
            Py_DECREF(For_annotations);
1629
0
            return 0;
1630
0
        }
1631
1
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1632
1
        Py_DECREF(type);
1633
1
        if (!cond) {
1634
0
            Py_DECREF(For_annotations);
1635
0
            return 0;
1636
0
        }
1637
1
    }
1638
1
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1639
1
                                  For_annotations) == 0;
1640
1
    if (!cond) {
1641
0
        Py_DECREF(For_annotations);
1642
0
        return 0;
1643
0
    }
1644
1
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1645
1
                                  For_annotations) == 0;
1646
1
    if (!cond) {
1647
0
        Py_DECREF(For_annotations);
1648
0
        return 0;
1649
0
    }
1650
1
    Py_DECREF(For_annotations);
1651
1
    PyObject *AsyncFor_annotations = PyDict_New();
1652
1
    if (!AsyncFor_annotations) return 0;
1653
1
    {
1654
1
        PyObject *type = state->expr_type;
1655
1
        Py_INCREF(type);
1656
1
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1657
1
        Py_DECREF(type);
1658
1
        if (!cond) {
1659
0
            Py_DECREF(AsyncFor_annotations);
1660
0
            return 0;
1661
0
        }
1662
1
    }
1663
1
    {
1664
1
        PyObject *type = state->expr_type;
1665
1
        Py_INCREF(type);
1666
1
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1667
1
        Py_DECREF(type);
1668
1
        if (!cond) {
1669
0
            Py_DECREF(AsyncFor_annotations);
1670
0
            return 0;
1671
0
        }
1672
1
    }
1673
1
    {
1674
1
        PyObject *type = state->stmt_type;
1675
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1676
1
        cond = type != NULL;
1677
1
        if (!cond) {
1678
0
            Py_DECREF(AsyncFor_annotations);
1679
0
            return 0;
1680
0
        }
1681
1
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1682
1
        Py_DECREF(type);
1683
1
        if (!cond) {
1684
0
            Py_DECREF(AsyncFor_annotations);
1685
0
            return 0;
1686
0
        }
1687
1
    }
1688
1
    {
1689
1
        PyObject *type = state->stmt_type;
1690
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1691
1
        cond = type != NULL;
1692
1
        if (!cond) {
1693
0
            Py_DECREF(AsyncFor_annotations);
1694
0
            return 0;
1695
0
        }
1696
1
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1697
1
        Py_DECREF(type);
1698
1
        if (!cond) {
1699
0
            Py_DECREF(AsyncFor_annotations);
1700
0
            return 0;
1701
0
        }
1702
1
    }
1703
1
    {
1704
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1705
1
        type = _Py_union_type_or(type, Py_None);
1706
1
        cond = type != NULL;
1707
1
        if (!cond) {
1708
0
            Py_DECREF(AsyncFor_annotations);
1709
0
            return 0;
1710
0
        }
1711
1
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1712
1
                                    == 0;
1713
1
        Py_DECREF(type);
1714
1
        if (!cond) {
1715
0
            Py_DECREF(AsyncFor_annotations);
1716
0
            return 0;
1717
0
        }
1718
1
    }
1719
1
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1720
1
                                  AsyncFor_annotations) == 0;
1721
1
    if (!cond) {
1722
0
        Py_DECREF(AsyncFor_annotations);
1723
0
        return 0;
1724
0
    }
1725
1
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1726
1
                                  AsyncFor_annotations) == 0;
1727
1
    if (!cond) {
1728
0
        Py_DECREF(AsyncFor_annotations);
1729
0
        return 0;
1730
0
    }
1731
1
    Py_DECREF(AsyncFor_annotations);
1732
1
    PyObject *While_annotations = PyDict_New();
1733
1
    if (!While_annotations) return 0;
1734
1
    {
1735
1
        PyObject *type = state->expr_type;
1736
1
        Py_INCREF(type);
1737
1
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1738
1
        Py_DECREF(type);
1739
1
        if (!cond) {
1740
0
            Py_DECREF(While_annotations);
1741
0
            return 0;
1742
0
        }
1743
1
    }
1744
1
    {
1745
1
        PyObject *type = state->stmt_type;
1746
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1747
1
        cond = type != NULL;
1748
1
        if (!cond) {
1749
0
            Py_DECREF(While_annotations);
1750
0
            return 0;
1751
0
        }
1752
1
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1753
1
        Py_DECREF(type);
1754
1
        if (!cond) {
1755
0
            Py_DECREF(While_annotations);
1756
0
            return 0;
1757
0
        }
1758
1
    }
1759
1
    {
1760
1
        PyObject *type = state->stmt_type;
1761
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1762
1
        cond = type != NULL;
1763
1
        if (!cond) {
1764
0
            Py_DECREF(While_annotations);
1765
0
            return 0;
1766
0
        }
1767
1
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1768
1
        Py_DECREF(type);
1769
1
        if (!cond) {
1770
0
            Py_DECREF(While_annotations);
1771
0
            return 0;
1772
0
        }
1773
1
    }
1774
1
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1775
1
                                  While_annotations) == 0;
1776
1
    if (!cond) {
1777
0
        Py_DECREF(While_annotations);
1778
0
        return 0;
1779
0
    }
1780
1
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1781
1
                                  While_annotations) == 0;
1782
1
    if (!cond) {
1783
0
        Py_DECREF(While_annotations);
1784
0
        return 0;
1785
0
    }
1786
1
    Py_DECREF(While_annotations);
1787
1
    PyObject *If_annotations = PyDict_New();
1788
1
    if (!If_annotations) return 0;
1789
1
    {
1790
1
        PyObject *type = state->expr_type;
1791
1
        Py_INCREF(type);
1792
1
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1793
1
        Py_DECREF(type);
1794
1
        if (!cond) {
1795
0
            Py_DECREF(If_annotations);
1796
0
            return 0;
1797
0
        }
1798
1
    }
1799
1
    {
1800
1
        PyObject *type = state->stmt_type;
1801
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1802
1
        cond = type != NULL;
1803
1
        if (!cond) {
1804
0
            Py_DECREF(If_annotations);
1805
0
            return 0;
1806
0
        }
1807
1
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1808
1
        Py_DECREF(type);
1809
1
        if (!cond) {
1810
0
            Py_DECREF(If_annotations);
1811
0
            return 0;
1812
0
        }
1813
1
    }
1814
1
    {
1815
1
        PyObject *type = state->stmt_type;
1816
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1817
1
        cond = type != NULL;
1818
1
        if (!cond) {
1819
0
            Py_DECREF(If_annotations);
1820
0
            return 0;
1821
0
        }
1822
1
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1823
1
        Py_DECREF(type);
1824
1
        if (!cond) {
1825
0
            Py_DECREF(If_annotations);
1826
0
            return 0;
1827
0
        }
1828
1
    }
1829
1
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1830
1
                                  If_annotations) == 0;
1831
1
    if (!cond) {
1832
0
        Py_DECREF(If_annotations);
1833
0
        return 0;
1834
0
    }
1835
1
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1836
1
                                  If_annotations) == 0;
1837
1
    if (!cond) {
1838
0
        Py_DECREF(If_annotations);
1839
0
        return 0;
1840
0
    }
1841
1
    Py_DECREF(If_annotations);
1842
1
    PyObject *With_annotations = PyDict_New();
1843
1
    if (!With_annotations) return 0;
1844
1
    {
1845
1
        PyObject *type = state->withitem_type;
1846
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1847
1
        cond = type != NULL;
1848
1
        if (!cond) {
1849
0
            Py_DECREF(With_annotations);
1850
0
            return 0;
1851
0
        }
1852
1
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1853
1
        Py_DECREF(type);
1854
1
        if (!cond) {
1855
0
            Py_DECREF(With_annotations);
1856
0
            return 0;
1857
0
        }
1858
1
    }
1859
1
    {
1860
1
        PyObject *type = state->stmt_type;
1861
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1862
1
        cond = type != NULL;
1863
1
        if (!cond) {
1864
0
            Py_DECREF(With_annotations);
1865
0
            return 0;
1866
0
        }
1867
1
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1868
1
        Py_DECREF(type);
1869
1
        if (!cond) {
1870
0
            Py_DECREF(With_annotations);
1871
0
            return 0;
1872
0
        }
1873
1
    }
1874
1
    {
1875
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1876
1
        type = _Py_union_type_or(type, Py_None);
1877
1
        cond = type != NULL;
1878
1
        if (!cond) {
1879
0
            Py_DECREF(With_annotations);
1880
0
            return 0;
1881
0
        }
1882
1
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1883
1
                                    0;
1884
1
        Py_DECREF(type);
1885
1
        if (!cond) {
1886
0
            Py_DECREF(With_annotations);
1887
0
            return 0;
1888
0
        }
1889
1
    }
1890
1
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1891
1
                                  With_annotations) == 0;
1892
1
    if (!cond) {
1893
0
        Py_DECREF(With_annotations);
1894
0
        return 0;
1895
0
    }
1896
1
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1897
1
                                  With_annotations) == 0;
1898
1
    if (!cond) {
1899
0
        Py_DECREF(With_annotations);
1900
0
        return 0;
1901
0
    }
1902
1
    Py_DECREF(With_annotations);
1903
1
    PyObject *AsyncWith_annotations = PyDict_New();
1904
1
    if (!AsyncWith_annotations) return 0;
1905
1
    {
1906
1
        PyObject *type = state->withitem_type;
1907
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1908
1
        cond = type != NULL;
1909
1
        if (!cond) {
1910
0
            Py_DECREF(AsyncWith_annotations);
1911
0
            return 0;
1912
0
        }
1913
1
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1914
1
        Py_DECREF(type);
1915
1
        if (!cond) {
1916
0
            Py_DECREF(AsyncWith_annotations);
1917
0
            return 0;
1918
0
        }
1919
1
    }
1920
1
    {
1921
1
        PyObject *type = state->stmt_type;
1922
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1923
1
        cond = type != NULL;
1924
1
        if (!cond) {
1925
0
            Py_DECREF(AsyncWith_annotations);
1926
0
            return 0;
1927
0
        }
1928
1
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1929
1
        Py_DECREF(type);
1930
1
        if (!cond) {
1931
0
            Py_DECREF(AsyncWith_annotations);
1932
0
            return 0;
1933
0
        }
1934
1
    }
1935
1
    {
1936
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
1937
1
        type = _Py_union_type_or(type, Py_None);
1938
1
        cond = type != NULL;
1939
1
        if (!cond) {
1940
0
            Py_DECREF(AsyncWith_annotations);
1941
0
            return 0;
1942
0
        }
1943
1
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1944
1
                                    type) == 0;
1945
1
        Py_DECREF(type);
1946
1
        if (!cond) {
1947
0
            Py_DECREF(AsyncWith_annotations);
1948
0
            return 0;
1949
0
        }
1950
1
    }
1951
1
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1952
1
                                  AsyncWith_annotations) == 0;
1953
1
    if (!cond) {
1954
0
        Py_DECREF(AsyncWith_annotations);
1955
0
        return 0;
1956
0
    }
1957
1
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1958
1
                                  AsyncWith_annotations) == 0;
1959
1
    if (!cond) {
1960
0
        Py_DECREF(AsyncWith_annotations);
1961
0
        return 0;
1962
0
    }
1963
1
    Py_DECREF(AsyncWith_annotations);
1964
1
    PyObject *Match_annotations = PyDict_New();
1965
1
    if (!Match_annotations) return 0;
1966
1
    {
1967
1
        PyObject *type = state->expr_type;
1968
1
        Py_INCREF(type);
1969
1
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1970
1
        Py_DECREF(type);
1971
1
        if (!cond) {
1972
0
            Py_DECREF(Match_annotations);
1973
0
            return 0;
1974
0
        }
1975
1
    }
1976
1
    {
1977
1
        PyObject *type = state->match_case_type;
1978
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1979
1
        cond = type != NULL;
1980
1
        if (!cond) {
1981
0
            Py_DECREF(Match_annotations);
1982
0
            return 0;
1983
0
        }
1984
1
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1985
1
        Py_DECREF(type);
1986
1
        if (!cond) {
1987
0
            Py_DECREF(Match_annotations);
1988
0
            return 0;
1989
0
        }
1990
1
    }
1991
1
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1992
1
                                  Match_annotations) == 0;
1993
1
    if (!cond) {
1994
0
        Py_DECREF(Match_annotations);
1995
0
        return 0;
1996
0
    }
1997
1
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
1998
1
                                  Match_annotations) == 0;
1999
1
    if (!cond) {
2000
0
        Py_DECREF(Match_annotations);
2001
0
        return 0;
2002
0
    }
2003
1
    Py_DECREF(Match_annotations);
2004
1
    PyObject *Raise_annotations = PyDict_New();
2005
1
    if (!Raise_annotations) return 0;
2006
1
    {
2007
1
        PyObject *type = state->expr_type;
2008
1
        type = _Py_union_type_or(type, Py_None);
2009
1
        cond = type != NULL;
2010
1
        if (!cond) {
2011
0
            Py_DECREF(Raise_annotations);
2012
0
            return 0;
2013
0
        }
2014
1
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2015
1
        Py_DECREF(type);
2016
1
        if (!cond) {
2017
0
            Py_DECREF(Raise_annotations);
2018
0
            return 0;
2019
0
        }
2020
1
    }
2021
1
    {
2022
1
        PyObject *type = state->expr_type;
2023
1
        type = _Py_union_type_or(type, Py_None);
2024
1
        cond = type != NULL;
2025
1
        if (!cond) {
2026
0
            Py_DECREF(Raise_annotations);
2027
0
            return 0;
2028
0
        }
2029
1
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2030
1
        Py_DECREF(type);
2031
1
        if (!cond) {
2032
0
            Py_DECREF(Raise_annotations);
2033
0
            return 0;
2034
0
        }
2035
1
    }
2036
1
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2037
1
                                  Raise_annotations) == 0;
2038
1
    if (!cond) {
2039
0
        Py_DECREF(Raise_annotations);
2040
0
        return 0;
2041
0
    }
2042
1
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2043
1
                                  Raise_annotations) == 0;
2044
1
    if (!cond) {
2045
0
        Py_DECREF(Raise_annotations);
2046
0
        return 0;
2047
0
    }
2048
1
    Py_DECREF(Raise_annotations);
2049
1
    PyObject *Try_annotations = PyDict_New();
2050
1
    if (!Try_annotations) return 0;
2051
1
    {
2052
1
        PyObject *type = state->stmt_type;
2053
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2054
1
        cond = type != NULL;
2055
1
        if (!cond) {
2056
0
            Py_DECREF(Try_annotations);
2057
0
            return 0;
2058
0
        }
2059
1
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2060
1
        Py_DECREF(type);
2061
1
        if (!cond) {
2062
0
            Py_DECREF(Try_annotations);
2063
0
            return 0;
2064
0
        }
2065
1
    }
2066
1
    {
2067
1
        PyObject *type = state->excepthandler_type;
2068
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2069
1
        cond = type != NULL;
2070
1
        if (!cond) {
2071
0
            Py_DECREF(Try_annotations);
2072
0
            return 0;
2073
0
        }
2074
1
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2075
1
        Py_DECREF(type);
2076
1
        if (!cond) {
2077
0
            Py_DECREF(Try_annotations);
2078
0
            return 0;
2079
0
        }
2080
1
    }
2081
1
    {
2082
1
        PyObject *type = state->stmt_type;
2083
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2084
1
        cond = type != NULL;
2085
1
        if (!cond) {
2086
0
            Py_DECREF(Try_annotations);
2087
0
            return 0;
2088
0
        }
2089
1
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2090
1
        Py_DECREF(type);
2091
1
        if (!cond) {
2092
0
            Py_DECREF(Try_annotations);
2093
0
            return 0;
2094
0
        }
2095
1
    }
2096
1
    {
2097
1
        PyObject *type = state->stmt_type;
2098
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2099
1
        cond = type != NULL;
2100
1
        if (!cond) {
2101
0
            Py_DECREF(Try_annotations);
2102
0
            return 0;
2103
0
        }
2104
1
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2105
1
        Py_DECREF(type);
2106
1
        if (!cond) {
2107
0
            Py_DECREF(Try_annotations);
2108
0
            return 0;
2109
0
        }
2110
1
    }
2111
1
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2112
1
                                  Try_annotations) == 0;
2113
1
    if (!cond) {
2114
0
        Py_DECREF(Try_annotations);
2115
0
        return 0;
2116
0
    }
2117
1
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2118
1
                                  Try_annotations) == 0;
2119
1
    if (!cond) {
2120
0
        Py_DECREF(Try_annotations);
2121
0
        return 0;
2122
0
    }
2123
1
    Py_DECREF(Try_annotations);
2124
1
    PyObject *TryStar_annotations = PyDict_New();
2125
1
    if (!TryStar_annotations) return 0;
2126
1
    {
2127
1
        PyObject *type = state->stmt_type;
2128
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2129
1
        cond = type != NULL;
2130
1
        if (!cond) {
2131
0
            Py_DECREF(TryStar_annotations);
2132
0
            return 0;
2133
0
        }
2134
1
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2135
1
        Py_DECREF(type);
2136
1
        if (!cond) {
2137
0
            Py_DECREF(TryStar_annotations);
2138
0
            return 0;
2139
0
        }
2140
1
    }
2141
1
    {
2142
1
        PyObject *type = state->excepthandler_type;
2143
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2144
1
        cond = type != NULL;
2145
1
        if (!cond) {
2146
0
            Py_DECREF(TryStar_annotations);
2147
0
            return 0;
2148
0
        }
2149
1
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2150
1
        Py_DECREF(type);
2151
1
        if (!cond) {
2152
0
            Py_DECREF(TryStar_annotations);
2153
0
            return 0;
2154
0
        }
2155
1
    }
2156
1
    {
2157
1
        PyObject *type = state->stmt_type;
2158
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2159
1
        cond = type != NULL;
2160
1
        if (!cond) {
2161
0
            Py_DECREF(TryStar_annotations);
2162
0
            return 0;
2163
0
        }
2164
1
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2165
1
        Py_DECREF(type);
2166
1
        if (!cond) {
2167
0
            Py_DECREF(TryStar_annotations);
2168
0
            return 0;
2169
0
        }
2170
1
    }
2171
1
    {
2172
1
        PyObject *type = state->stmt_type;
2173
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2174
1
        cond = type != NULL;
2175
1
        if (!cond) {
2176
0
            Py_DECREF(TryStar_annotations);
2177
0
            return 0;
2178
0
        }
2179
1
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2180
1
                                    0;
2181
1
        Py_DECREF(type);
2182
1
        if (!cond) {
2183
0
            Py_DECREF(TryStar_annotations);
2184
0
            return 0;
2185
0
        }
2186
1
    }
2187
1
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2188
1
                                  TryStar_annotations) == 0;
2189
1
    if (!cond) {
2190
0
        Py_DECREF(TryStar_annotations);
2191
0
        return 0;
2192
0
    }
2193
1
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2194
1
                                  TryStar_annotations) == 0;
2195
1
    if (!cond) {
2196
0
        Py_DECREF(TryStar_annotations);
2197
0
        return 0;
2198
0
    }
2199
1
    Py_DECREF(TryStar_annotations);
2200
1
    PyObject *Assert_annotations = PyDict_New();
2201
1
    if (!Assert_annotations) return 0;
2202
1
    {
2203
1
        PyObject *type = state->expr_type;
2204
1
        Py_INCREF(type);
2205
1
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2206
1
        Py_DECREF(type);
2207
1
        if (!cond) {
2208
0
            Py_DECREF(Assert_annotations);
2209
0
            return 0;
2210
0
        }
2211
1
    }
2212
1
    {
2213
1
        PyObject *type = state->expr_type;
2214
1
        type = _Py_union_type_or(type, Py_None);
2215
1
        cond = type != NULL;
2216
1
        if (!cond) {
2217
0
            Py_DECREF(Assert_annotations);
2218
0
            return 0;
2219
0
        }
2220
1
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2221
1
        Py_DECREF(type);
2222
1
        if (!cond) {
2223
0
            Py_DECREF(Assert_annotations);
2224
0
            return 0;
2225
0
        }
2226
1
    }
2227
1
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2228
1
                                  Assert_annotations) == 0;
2229
1
    if (!cond) {
2230
0
        Py_DECREF(Assert_annotations);
2231
0
        return 0;
2232
0
    }
2233
1
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2234
1
                                  Assert_annotations) == 0;
2235
1
    if (!cond) {
2236
0
        Py_DECREF(Assert_annotations);
2237
0
        return 0;
2238
0
    }
2239
1
    Py_DECREF(Assert_annotations);
2240
1
    PyObject *Import_annotations = PyDict_New();
2241
1
    if (!Import_annotations) return 0;
2242
1
    {
2243
1
        PyObject *type = state->alias_type;
2244
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2245
1
        cond = type != NULL;
2246
1
        if (!cond) {
2247
0
            Py_DECREF(Import_annotations);
2248
0
            return 0;
2249
0
        }
2250
1
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2251
1
        Py_DECREF(type);
2252
1
        if (!cond) {
2253
0
            Py_DECREF(Import_annotations);
2254
0
            return 0;
2255
0
        }
2256
1
    }
2257
1
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2258
1
                                  Import_annotations) == 0;
2259
1
    if (!cond) {
2260
0
        Py_DECREF(Import_annotations);
2261
0
        return 0;
2262
0
    }
2263
1
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2264
1
                                  Import_annotations) == 0;
2265
1
    if (!cond) {
2266
0
        Py_DECREF(Import_annotations);
2267
0
        return 0;
2268
0
    }
2269
1
    Py_DECREF(Import_annotations);
2270
1
    PyObject *ImportFrom_annotations = PyDict_New();
2271
1
    if (!ImportFrom_annotations) return 0;
2272
1
    {
2273
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
2274
1
        type = _Py_union_type_or(type, Py_None);
2275
1
        cond = type != NULL;
2276
1
        if (!cond) {
2277
0
            Py_DECREF(ImportFrom_annotations);
2278
0
            return 0;
2279
0
        }
2280
1
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2281
1
                                    0;
2282
1
        Py_DECREF(type);
2283
1
        if (!cond) {
2284
0
            Py_DECREF(ImportFrom_annotations);
2285
0
            return 0;
2286
0
        }
2287
1
    }
2288
1
    {
2289
1
        PyObject *type = state->alias_type;
2290
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2291
1
        cond = type != NULL;
2292
1
        if (!cond) {
2293
0
            Py_DECREF(ImportFrom_annotations);
2294
0
            return 0;
2295
0
        }
2296
1
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2297
1
        Py_DECREF(type);
2298
1
        if (!cond) {
2299
0
            Py_DECREF(ImportFrom_annotations);
2300
0
            return 0;
2301
0
        }
2302
1
    }
2303
1
    {
2304
1
        PyObject *type = (PyObject *)&PyLong_Type;
2305
1
        type = _Py_union_type_or(type, Py_None);
2306
1
        cond = type != NULL;
2307
1
        if (!cond) {
2308
0
            Py_DECREF(ImportFrom_annotations);
2309
0
            return 0;
2310
0
        }
2311
1
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2312
1
        Py_DECREF(type);
2313
1
        if (!cond) {
2314
0
            Py_DECREF(ImportFrom_annotations);
2315
0
            return 0;
2316
0
        }
2317
1
    }
2318
1
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2319
1
                                  ImportFrom_annotations) == 0;
2320
1
    if (!cond) {
2321
0
        Py_DECREF(ImportFrom_annotations);
2322
0
        return 0;
2323
0
    }
2324
1
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2325
1
                                  ImportFrom_annotations) == 0;
2326
1
    if (!cond) {
2327
0
        Py_DECREF(ImportFrom_annotations);
2328
0
        return 0;
2329
0
    }
2330
1
    Py_DECREF(ImportFrom_annotations);
2331
1
    PyObject *Global_annotations = PyDict_New();
2332
1
    if (!Global_annotations) return 0;
2333
1
    {
2334
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
2335
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2336
1
        cond = type != NULL;
2337
1
        if (!cond) {
2338
0
            Py_DECREF(Global_annotations);
2339
0
            return 0;
2340
0
        }
2341
1
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2342
1
        Py_DECREF(type);
2343
1
        if (!cond) {
2344
0
            Py_DECREF(Global_annotations);
2345
0
            return 0;
2346
0
        }
2347
1
    }
2348
1
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2349
1
                                  Global_annotations) == 0;
2350
1
    if (!cond) {
2351
0
        Py_DECREF(Global_annotations);
2352
0
        return 0;
2353
0
    }
2354
1
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2355
1
                                  Global_annotations) == 0;
2356
1
    if (!cond) {
2357
0
        Py_DECREF(Global_annotations);
2358
0
        return 0;
2359
0
    }
2360
1
    Py_DECREF(Global_annotations);
2361
1
    PyObject *Nonlocal_annotations = PyDict_New();
2362
1
    if (!Nonlocal_annotations) return 0;
2363
1
    {
2364
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
2365
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2366
1
        cond = type != NULL;
2367
1
        if (!cond) {
2368
0
            Py_DECREF(Nonlocal_annotations);
2369
0
            return 0;
2370
0
        }
2371
1
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2372
1
        Py_DECREF(type);
2373
1
        if (!cond) {
2374
0
            Py_DECREF(Nonlocal_annotations);
2375
0
            return 0;
2376
0
        }
2377
1
    }
2378
1
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2379
1
                                  Nonlocal_annotations) == 0;
2380
1
    if (!cond) {
2381
0
        Py_DECREF(Nonlocal_annotations);
2382
0
        return 0;
2383
0
    }
2384
1
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2385
1
                                  Nonlocal_annotations) == 0;
2386
1
    if (!cond) {
2387
0
        Py_DECREF(Nonlocal_annotations);
2388
0
        return 0;
2389
0
    }
2390
1
    Py_DECREF(Nonlocal_annotations);
2391
1
    PyObject *Expr_annotations = PyDict_New();
2392
1
    if (!Expr_annotations) return 0;
2393
1
    {
2394
1
        PyObject *type = state->expr_type;
2395
1
        Py_INCREF(type);
2396
1
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2397
1
        Py_DECREF(type);
2398
1
        if (!cond) {
2399
0
            Py_DECREF(Expr_annotations);
2400
0
            return 0;
2401
0
        }
2402
1
    }
2403
1
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2404
1
                                  Expr_annotations) == 0;
2405
1
    if (!cond) {
2406
0
        Py_DECREF(Expr_annotations);
2407
0
        return 0;
2408
0
    }
2409
1
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2410
1
                                  Expr_annotations) == 0;
2411
1
    if (!cond) {
2412
0
        Py_DECREF(Expr_annotations);
2413
0
        return 0;
2414
0
    }
2415
1
    Py_DECREF(Expr_annotations);
2416
1
    PyObject *Pass_annotations = PyDict_New();
2417
1
    if (!Pass_annotations) return 0;
2418
1
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2419
1
                                  Pass_annotations) == 0;
2420
1
    if (!cond) {
2421
0
        Py_DECREF(Pass_annotations);
2422
0
        return 0;
2423
0
    }
2424
1
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2425
1
                                  Pass_annotations) == 0;
2426
1
    if (!cond) {
2427
0
        Py_DECREF(Pass_annotations);
2428
0
        return 0;
2429
0
    }
2430
1
    Py_DECREF(Pass_annotations);
2431
1
    PyObject *Break_annotations = PyDict_New();
2432
1
    if (!Break_annotations) return 0;
2433
1
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2434
1
                                  Break_annotations) == 0;
2435
1
    if (!cond) {
2436
0
        Py_DECREF(Break_annotations);
2437
0
        return 0;
2438
0
    }
2439
1
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2440
1
                                  Break_annotations) == 0;
2441
1
    if (!cond) {
2442
0
        Py_DECREF(Break_annotations);
2443
0
        return 0;
2444
0
    }
2445
1
    Py_DECREF(Break_annotations);
2446
1
    PyObject *Continue_annotations = PyDict_New();
2447
1
    if (!Continue_annotations) return 0;
2448
1
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2449
1
                                  Continue_annotations) == 0;
2450
1
    if (!cond) {
2451
0
        Py_DECREF(Continue_annotations);
2452
0
        return 0;
2453
0
    }
2454
1
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2455
1
                                  Continue_annotations) == 0;
2456
1
    if (!cond) {
2457
0
        Py_DECREF(Continue_annotations);
2458
0
        return 0;
2459
0
    }
2460
1
    Py_DECREF(Continue_annotations);
2461
1
    PyObject *BoolOp_annotations = PyDict_New();
2462
1
    if (!BoolOp_annotations) return 0;
2463
1
    {
2464
1
        PyObject *type = state->boolop_type;
2465
1
        Py_INCREF(type);
2466
1
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2467
1
        Py_DECREF(type);
2468
1
        if (!cond) {
2469
0
            Py_DECREF(BoolOp_annotations);
2470
0
            return 0;
2471
0
        }
2472
1
    }
2473
1
    {
2474
1
        PyObject *type = state->expr_type;
2475
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2476
1
        cond = type != NULL;
2477
1
        if (!cond) {
2478
0
            Py_DECREF(BoolOp_annotations);
2479
0
            return 0;
2480
0
        }
2481
1
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2482
1
        Py_DECREF(type);
2483
1
        if (!cond) {
2484
0
            Py_DECREF(BoolOp_annotations);
2485
0
            return 0;
2486
0
        }
2487
1
    }
2488
1
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2489
1
                                  BoolOp_annotations) == 0;
2490
1
    if (!cond) {
2491
0
        Py_DECREF(BoolOp_annotations);
2492
0
        return 0;
2493
0
    }
2494
1
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2495
1
                                  BoolOp_annotations) == 0;
2496
1
    if (!cond) {
2497
0
        Py_DECREF(BoolOp_annotations);
2498
0
        return 0;
2499
0
    }
2500
1
    Py_DECREF(BoolOp_annotations);
2501
1
    PyObject *NamedExpr_annotations = PyDict_New();
2502
1
    if (!NamedExpr_annotations) return 0;
2503
1
    {
2504
1
        PyObject *type = state->expr_type;
2505
1
        Py_INCREF(type);
2506
1
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2507
1
        Py_DECREF(type);
2508
1
        if (!cond) {
2509
0
            Py_DECREF(NamedExpr_annotations);
2510
0
            return 0;
2511
0
        }
2512
1
    }
2513
1
    {
2514
1
        PyObject *type = state->expr_type;
2515
1
        Py_INCREF(type);
2516
1
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2517
1
        Py_DECREF(type);
2518
1
        if (!cond) {
2519
0
            Py_DECREF(NamedExpr_annotations);
2520
0
            return 0;
2521
0
        }
2522
1
    }
2523
1
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2524
1
                                  NamedExpr_annotations) == 0;
2525
1
    if (!cond) {
2526
0
        Py_DECREF(NamedExpr_annotations);
2527
0
        return 0;
2528
0
    }
2529
1
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2530
1
                                  NamedExpr_annotations) == 0;
2531
1
    if (!cond) {
2532
0
        Py_DECREF(NamedExpr_annotations);
2533
0
        return 0;
2534
0
    }
2535
1
    Py_DECREF(NamedExpr_annotations);
2536
1
    PyObject *BinOp_annotations = PyDict_New();
2537
1
    if (!BinOp_annotations) return 0;
2538
1
    {
2539
1
        PyObject *type = state->expr_type;
2540
1
        Py_INCREF(type);
2541
1
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2542
1
        Py_DECREF(type);
2543
1
        if (!cond) {
2544
0
            Py_DECREF(BinOp_annotations);
2545
0
            return 0;
2546
0
        }
2547
1
    }
2548
1
    {
2549
1
        PyObject *type = state->operator_type;
2550
1
        Py_INCREF(type);
2551
1
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2552
1
        Py_DECREF(type);
2553
1
        if (!cond) {
2554
0
            Py_DECREF(BinOp_annotations);
2555
0
            return 0;
2556
0
        }
2557
1
    }
2558
1
    {
2559
1
        PyObject *type = state->expr_type;
2560
1
        Py_INCREF(type);
2561
1
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2562
1
        Py_DECREF(type);
2563
1
        if (!cond) {
2564
0
            Py_DECREF(BinOp_annotations);
2565
0
            return 0;
2566
0
        }
2567
1
    }
2568
1
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2569
1
                                  BinOp_annotations) == 0;
2570
1
    if (!cond) {
2571
0
        Py_DECREF(BinOp_annotations);
2572
0
        return 0;
2573
0
    }
2574
1
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2575
1
                                  BinOp_annotations) == 0;
2576
1
    if (!cond) {
2577
0
        Py_DECREF(BinOp_annotations);
2578
0
        return 0;
2579
0
    }
2580
1
    Py_DECREF(BinOp_annotations);
2581
1
    PyObject *UnaryOp_annotations = PyDict_New();
2582
1
    if (!UnaryOp_annotations) return 0;
2583
1
    {
2584
1
        PyObject *type = state->unaryop_type;
2585
1
        Py_INCREF(type);
2586
1
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2587
1
        Py_DECREF(type);
2588
1
        if (!cond) {
2589
0
            Py_DECREF(UnaryOp_annotations);
2590
0
            return 0;
2591
0
        }
2592
1
    }
2593
1
    {
2594
1
        PyObject *type = state->expr_type;
2595
1
        Py_INCREF(type);
2596
1
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2597
1
        Py_DECREF(type);
2598
1
        if (!cond) {
2599
0
            Py_DECREF(UnaryOp_annotations);
2600
0
            return 0;
2601
0
        }
2602
1
    }
2603
1
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2604
1
                                  UnaryOp_annotations) == 0;
2605
1
    if (!cond) {
2606
0
        Py_DECREF(UnaryOp_annotations);
2607
0
        return 0;
2608
0
    }
2609
1
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2610
1
                                  UnaryOp_annotations) == 0;
2611
1
    if (!cond) {
2612
0
        Py_DECREF(UnaryOp_annotations);
2613
0
        return 0;
2614
0
    }
2615
1
    Py_DECREF(UnaryOp_annotations);
2616
1
    PyObject *Lambda_annotations = PyDict_New();
2617
1
    if (!Lambda_annotations) return 0;
2618
1
    {
2619
1
        PyObject *type = state->arguments_type;
2620
1
        Py_INCREF(type);
2621
1
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2622
1
        Py_DECREF(type);
2623
1
        if (!cond) {
2624
0
            Py_DECREF(Lambda_annotations);
2625
0
            return 0;
2626
0
        }
2627
1
    }
2628
1
    {
2629
1
        PyObject *type = state->expr_type;
2630
1
        Py_INCREF(type);
2631
1
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2632
1
        Py_DECREF(type);
2633
1
        if (!cond) {
2634
0
            Py_DECREF(Lambda_annotations);
2635
0
            return 0;
2636
0
        }
2637
1
    }
2638
1
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2639
1
                                  Lambda_annotations) == 0;
2640
1
    if (!cond) {
2641
0
        Py_DECREF(Lambda_annotations);
2642
0
        return 0;
2643
0
    }
2644
1
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2645
1
                                  Lambda_annotations) == 0;
2646
1
    if (!cond) {
2647
0
        Py_DECREF(Lambda_annotations);
2648
0
        return 0;
2649
0
    }
2650
1
    Py_DECREF(Lambda_annotations);
2651
1
    PyObject *IfExp_annotations = PyDict_New();
2652
1
    if (!IfExp_annotations) return 0;
2653
1
    {
2654
1
        PyObject *type = state->expr_type;
2655
1
        Py_INCREF(type);
2656
1
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2657
1
        Py_DECREF(type);
2658
1
        if (!cond) {
2659
0
            Py_DECREF(IfExp_annotations);
2660
0
            return 0;
2661
0
        }
2662
1
    }
2663
1
    {
2664
1
        PyObject *type = state->expr_type;
2665
1
        Py_INCREF(type);
2666
1
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2667
1
        Py_DECREF(type);
2668
1
        if (!cond) {
2669
0
            Py_DECREF(IfExp_annotations);
2670
0
            return 0;
2671
0
        }
2672
1
    }
2673
1
    {
2674
1
        PyObject *type = state->expr_type;
2675
1
        Py_INCREF(type);
2676
1
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2677
1
        Py_DECREF(type);
2678
1
        if (!cond) {
2679
0
            Py_DECREF(IfExp_annotations);
2680
0
            return 0;
2681
0
        }
2682
1
    }
2683
1
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2684
1
                                  IfExp_annotations) == 0;
2685
1
    if (!cond) {
2686
0
        Py_DECREF(IfExp_annotations);
2687
0
        return 0;
2688
0
    }
2689
1
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2690
1
                                  IfExp_annotations) == 0;
2691
1
    if (!cond) {
2692
0
        Py_DECREF(IfExp_annotations);
2693
0
        return 0;
2694
0
    }
2695
1
    Py_DECREF(IfExp_annotations);
2696
1
    PyObject *Dict_annotations = PyDict_New();
2697
1
    if (!Dict_annotations) return 0;
2698
1
    {
2699
1
        PyObject *type = state->expr_type;
2700
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2701
1
        cond = type != NULL;
2702
1
        if (!cond) {
2703
0
            Py_DECREF(Dict_annotations);
2704
0
            return 0;
2705
0
        }
2706
1
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2707
1
        Py_DECREF(type);
2708
1
        if (!cond) {
2709
0
            Py_DECREF(Dict_annotations);
2710
0
            return 0;
2711
0
        }
2712
1
    }
2713
1
    {
2714
1
        PyObject *type = state->expr_type;
2715
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2716
1
        cond = type != NULL;
2717
1
        if (!cond) {
2718
0
            Py_DECREF(Dict_annotations);
2719
0
            return 0;
2720
0
        }
2721
1
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2722
1
        Py_DECREF(type);
2723
1
        if (!cond) {
2724
0
            Py_DECREF(Dict_annotations);
2725
0
            return 0;
2726
0
        }
2727
1
    }
2728
1
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2729
1
                                  Dict_annotations) == 0;
2730
1
    if (!cond) {
2731
0
        Py_DECREF(Dict_annotations);
2732
0
        return 0;
2733
0
    }
2734
1
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2735
1
                                  Dict_annotations) == 0;
2736
1
    if (!cond) {
2737
0
        Py_DECREF(Dict_annotations);
2738
0
        return 0;
2739
0
    }
2740
1
    Py_DECREF(Dict_annotations);
2741
1
    PyObject *Set_annotations = PyDict_New();
2742
1
    if (!Set_annotations) return 0;
2743
1
    {
2744
1
        PyObject *type = state->expr_type;
2745
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2746
1
        cond = type != NULL;
2747
1
        if (!cond) {
2748
0
            Py_DECREF(Set_annotations);
2749
0
            return 0;
2750
0
        }
2751
1
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2752
1
        Py_DECREF(type);
2753
1
        if (!cond) {
2754
0
            Py_DECREF(Set_annotations);
2755
0
            return 0;
2756
0
        }
2757
1
    }
2758
1
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2759
1
                                  Set_annotations) == 0;
2760
1
    if (!cond) {
2761
0
        Py_DECREF(Set_annotations);
2762
0
        return 0;
2763
0
    }
2764
1
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2765
1
                                  Set_annotations) == 0;
2766
1
    if (!cond) {
2767
0
        Py_DECREF(Set_annotations);
2768
0
        return 0;
2769
0
    }
2770
1
    Py_DECREF(Set_annotations);
2771
1
    PyObject *ListComp_annotations = PyDict_New();
2772
1
    if (!ListComp_annotations) return 0;
2773
1
    {
2774
1
        PyObject *type = state->expr_type;
2775
1
        Py_INCREF(type);
2776
1
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2777
1
        Py_DECREF(type);
2778
1
        if (!cond) {
2779
0
            Py_DECREF(ListComp_annotations);
2780
0
            return 0;
2781
0
        }
2782
1
    }
2783
1
    {
2784
1
        PyObject *type = state->comprehension_type;
2785
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2786
1
        cond = type != NULL;
2787
1
        if (!cond) {
2788
0
            Py_DECREF(ListComp_annotations);
2789
0
            return 0;
2790
0
        }
2791
1
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2792
1
                                    == 0;
2793
1
        Py_DECREF(type);
2794
1
        if (!cond) {
2795
0
            Py_DECREF(ListComp_annotations);
2796
0
            return 0;
2797
0
        }
2798
1
    }
2799
1
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2800
1
                                  ListComp_annotations) == 0;
2801
1
    if (!cond) {
2802
0
        Py_DECREF(ListComp_annotations);
2803
0
        return 0;
2804
0
    }
2805
1
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2806
1
                                  ListComp_annotations) == 0;
2807
1
    if (!cond) {
2808
0
        Py_DECREF(ListComp_annotations);
2809
0
        return 0;
2810
0
    }
2811
1
    Py_DECREF(ListComp_annotations);
2812
1
    PyObject *SetComp_annotations = PyDict_New();
2813
1
    if (!SetComp_annotations) return 0;
2814
1
    {
2815
1
        PyObject *type = state->expr_type;
2816
1
        Py_INCREF(type);
2817
1
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2818
1
        Py_DECREF(type);
2819
1
        if (!cond) {
2820
0
            Py_DECREF(SetComp_annotations);
2821
0
            return 0;
2822
0
        }
2823
1
    }
2824
1
    {
2825
1
        PyObject *type = state->comprehension_type;
2826
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2827
1
        cond = type != NULL;
2828
1
        if (!cond) {
2829
0
            Py_DECREF(SetComp_annotations);
2830
0
            return 0;
2831
0
        }
2832
1
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2833
1
                                    0;
2834
1
        Py_DECREF(type);
2835
1
        if (!cond) {
2836
0
            Py_DECREF(SetComp_annotations);
2837
0
            return 0;
2838
0
        }
2839
1
    }
2840
1
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2841
1
                                  SetComp_annotations) == 0;
2842
1
    if (!cond) {
2843
0
        Py_DECREF(SetComp_annotations);
2844
0
        return 0;
2845
0
    }
2846
1
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2847
1
                                  SetComp_annotations) == 0;
2848
1
    if (!cond) {
2849
0
        Py_DECREF(SetComp_annotations);
2850
0
        return 0;
2851
0
    }
2852
1
    Py_DECREF(SetComp_annotations);
2853
1
    PyObject *DictComp_annotations = PyDict_New();
2854
1
    if (!DictComp_annotations) return 0;
2855
1
    {
2856
1
        PyObject *type = state->expr_type;
2857
1
        Py_INCREF(type);
2858
1
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2859
1
        Py_DECREF(type);
2860
1
        if (!cond) {
2861
0
            Py_DECREF(DictComp_annotations);
2862
0
            return 0;
2863
0
        }
2864
1
    }
2865
1
    {
2866
1
        PyObject *type = state->expr_type;
2867
1
        Py_INCREF(type);
2868
1
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2869
1
        Py_DECREF(type);
2870
1
        if (!cond) {
2871
0
            Py_DECREF(DictComp_annotations);
2872
0
            return 0;
2873
0
        }
2874
1
    }
2875
1
    {
2876
1
        PyObject *type = state->comprehension_type;
2877
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2878
1
        cond = type != NULL;
2879
1
        if (!cond) {
2880
0
            Py_DECREF(DictComp_annotations);
2881
0
            return 0;
2882
0
        }
2883
1
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2884
1
                                    == 0;
2885
1
        Py_DECREF(type);
2886
1
        if (!cond) {
2887
0
            Py_DECREF(DictComp_annotations);
2888
0
            return 0;
2889
0
        }
2890
1
    }
2891
1
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2892
1
                                  DictComp_annotations) == 0;
2893
1
    if (!cond) {
2894
0
        Py_DECREF(DictComp_annotations);
2895
0
        return 0;
2896
0
    }
2897
1
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2898
1
                                  DictComp_annotations) == 0;
2899
1
    if (!cond) {
2900
0
        Py_DECREF(DictComp_annotations);
2901
0
        return 0;
2902
0
    }
2903
1
    Py_DECREF(DictComp_annotations);
2904
1
    PyObject *GeneratorExp_annotations = PyDict_New();
2905
1
    if (!GeneratorExp_annotations) return 0;
2906
1
    {
2907
1
        PyObject *type = state->expr_type;
2908
1
        Py_INCREF(type);
2909
1
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2910
1
        Py_DECREF(type);
2911
1
        if (!cond) {
2912
0
            Py_DECREF(GeneratorExp_annotations);
2913
0
            return 0;
2914
0
        }
2915
1
    }
2916
1
    {
2917
1
        PyObject *type = state->comprehension_type;
2918
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2919
1
        cond = type != NULL;
2920
1
        if (!cond) {
2921
0
            Py_DECREF(GeneratorExp_annotations);
2922
0
            return 0;
2923
0
        }
2924
1
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2925
1
                                    type) == 0;
2926
1
        Py_DECREF(type);
2927
1
        if (!cond) {
2928
0
            Py_DECREF(GeneratorExp_annotations);
2929
0
            return 0;
2930
0
        }
2931
1
    }
2932
1
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2933
1
                                  GeneratorExp_annotations) == 0;
2934
1
    if (!cond) {
2935
0
        Py_DECREF(GeneratorExp_annotations);
2936
0
        return 0;
2937
0
    }
2938
1
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2939
1
                                  GeneratorExp_annotations) == 0;
2940
1
    if (!cond) {
2941
0
        Py_DECREF(GeneratorExp_annotations);
2942
0
        return 0;
2943
0
    }
2944
1
    Py_DECREF(GeneratorExp_annotations);
2945
1
    PyObject *Await_annotations = PyDict_New();
2946
1
    if (!Await_annotations) return 0;
2947
1
    {
2948
1
        PyObject *type = state->expr_type;
2949
1
        Py_INCREF(type);
2950
1
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2951
1
        Py_DECREF(type);
2952
1
        if (!cond) {
2953
0
            Py_DECREF(Await_annotations);
2954
0
            return 0;
2955
0
        }
2956
1
    }
2957
1
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2958
1
                                  Await_annotations) == 0;
2959
1
    if (!cond) {
2960
0
        Py_DECREF(Await_annotations);
2961
0
        return 0;
2962
0
    }
2963
1
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
2964
1
                                  Await_annotations) == 0;
2965
1
    if (!cond) {
2966
0
        Py_DECREF(Await_annotations);
2967
0
        return 0;
2968
0
    }
2969
1
    Py_DECREF(Await_annotations);
2970
1
    PyObject *Yield_annotations = PyDict_New();
2971
1
    if (!Yield_annotations) return 0;
2972
1
    {
2973
1
        PyObject *type = state->expr_type;
2974
1
        type = _Py_union_type_or(type, Py_None);
2975
1
        cond = type != NULL;
2976
1
        if (!cond) {
2977
0
            Py_DECREF(Yield_annotations);
2978
0
            return 0;
2979
0
        }
2980
1
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
2981
1
        Py_DECREF(type);
2982
1
        if (!cond) {
2983
0
            Py_DECREF(Yield_annotations);
2984
0
            return 0;
2985
0
        }
2986
1
    }
2987
1
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
2988
1
                                  Yield_annotations) == 0;
2989
1
    if (!cond) {
2990
0
        Py_DECREF(Yield_annotations);
2991
0
        return 0;
2992
0
    }
2993
1
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
2994
1
                                  Yield_annotations) == 0;
2995
1
    if (!cond) {
2996
0
        Py_DECREF(Yield_annotations);
2997
0
        return 0;
2998
0
    }
2999
1
    Py_DECREF(Yield_annotations);
3000
1
    PyObject *YieldFrom_annotations = PyDict_New();
3001
1
    if (!YieldFrom_annotations) return 0;
3002
1
    {
3003
1
        PyObject *type = state->expr_type;
3004
1
        Py_INCREF(type);
3005
1
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3006
1
        Py_DECREF(type);
3007
1
        if (!cond) {
3008
0
            Py_DECREF(YieldFrom_annotations);
3009
0
            return 0;
3010
0
        }
3011
1
    }
3012
1
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3013
1
                                  YieldFrom_annotations) == 0;
3014
1
    if (!cond) {
3015
0
        Py_DECREF(YieldFrom_annotations);
3016
0
        return 0;
3017
0
    }
3018
1
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3019
1
                                  YieldFrom_annotations) == 0;
3020
1
    if (!cond) {
3021
0
        Py_DECREF(YieldFrom_annotations);
3022
0
        return 0;
3023
0
    }
3024
1
    Py_DECREF(YieldFrom_annotations);
3025
1
    PyObject *Compare_annotations = PyDict_New();
3026
1
    if (!Compare_annotations) return 0;
3027
1
    {
3028
1
        PyObject *type = state->expr_type;
3029
1
        Py_INCREF(type);
3030
1
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3031
1
        Py_DECREF(type);
3032
1
        if (!cond) {
3033
0
            Py_DECREF(Compare_annotations);
3034
0
            return 0;
3035
0
        }
3036
1
    }
3037
1
    {
3038
1
        PyObject *type = state->cmpop_type;
3039
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3040
1
        cond = type != NULL;
3041
1
        if (!cond) {
3042
0
            Py_DECREF(Compare_annotations);
3043
0
            return 0;
3044
0
        }
3045
1
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3046
1
        Py_DECREF(type);
3047
1
        if (!cond) {
3048
0
            Py_DECREF(Compare_annotations);
3049
0
            return 0;
3050
0
        }
3051
1
    }
3052
1
    {
3053
1
        PyObject *type = state->expr_type;
3054
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3055
1
        cond = type != NULL;
3056
1
        if (!cond) {
3057
0
            Py_DECREF(Compare_annotations);
3058
0
            return 0;
3059
0
        }
3060
1
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3061
1
                                    == 0;
3062
1
        Py_DECREF(type);
3063
1
        if (!cond) {
3064
0
            Py_DECREF(Compare_annotations);
3065
0
            return 0;
3066
0
        }
3067
1
    }
3068
1
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3069
1
                                  Compare_annotations) == 0;
3070
1
    if (!cond) {
3071
0
        Py_DECREF(Compare_annotations);
3072
0
        return 0;
3073
0
    }
3074
1
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3075
1
                                  Compare_annotations) == 0;
3076
1
    if (!cond) {
3077
0
        Py_DECREF(Compare_annotations);
3078
0
        return 0;
3079
0
    }
3080
1
    Py_DECREF(Compare_annotations);
3081
1
    PyObject *Call_annotations = PyDict_New();
3082
1
    if (!Call_annotations) return 0;
3083
1
    {
3084
1
        PyObject *type = state->expr_type;
3085
1
        Py_INCREF(type);
3086
1
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3087
1
        Py_DECREF(type);
3088
1
        if (!cond) {
3089
0
            Py_DECREF(Call_annotations);
3090
0
            return 0;
3091
0
        }
3092
1
    }
3093
1
    {
3094
1
        PyObject *type = state->expr_type;
3095
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3096
1
        cond = type != NULL;
3097
1
        if (!cond) {
3098
0
            Py_DECREF(Call_annotations);
3099
0
            return 0;
3100
0
        }
3101
1
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3102
1
        Py_DECREF(type);
3103
1
        if (!cond) {
3104
0
            Py_DECREF(Call_annotations);
3105
0
            return 0;
3106
0
        }
3107
1
    }
3108
1
    {
3109
1
        PyObject *type = state->keyword_type;
3110
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3111
1
        cond = type != NULL;
3112
1
        if (!cond) {
3113
0
            Py_DECREF(Call_annotations);
3114
0
            return 0;
3115
0
        }
3116
1
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3117
1
        Py_DECREF(type);
3118
1
        if (!cond) {
3119
0
            Py_DECREF(Call_annotations);
3120
0
            return 0;
3121
0
        }
3122
1
    }
3123
1
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3124
1
                                  Call_annotations) == 0;
3125
1
    if (!cond) {
3126
0
        Py_DECREF(Call_annotations);
3127
0
        return 0;
3128
0
    }
3129
1
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3130
1
                                  Call_annotations) == 0;
3131
1
    if (!cond) {
3132
0
        Py_DECREF(Call_annotations);
3133
0
        return 0;
3134
0
    }
3135
1
    Py_DECREF(Call_annotations);
3136
1
    PyObject *FormattedValue_annotations = PyDict_New();
3137
1
    if (!FormattedValue_annotations) return 0;
3138
1
    {
3139
1
        PyObject *type = state->expr_type;
3140
1
        Py_INCREF(type);
3141
1
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3142
1
                                    == 0;
3143
1
        Py_DECREF(type);
3144
1
        if (!cond) {
3145
0
            Py_DECREF(FormattedValue_annotations);
3146
0
            return 0;
3147
0
        }
3148
1
    }
3149
1
    {
3150
1
        PyObject *type = (PyObject *)&PyLong_Type;
3151
1
        Py_INCREF(type);
3152
1
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3153
1
                                    type) == 0;
3154
1
        Py_DECREF(type);
3155
1
        if (!cond) {
3156
0
            Py_DECREF(FormattedValue_annotations);
3157
0
            return 0;
3158
0
        }
3159
1
    }
3160
1
    {
3161
1
        PyObject *type = state->expr_type;
3162
1
        type = _Py_union_type_or(type, Py_None);
3163
1
        cond = type != NULL;
3164
1
        if (!cond) {
3165
0
            Py_DECREF(FormattedValue_annotations);
3166
0
            return 0;
3167
0
        }
3168
1
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3169
1
                                    type) == 0;
3170
1
        Py_DECREF(type);
3171
1
        if (!cond) {
3172
0
            Py_DECREF(FormattedValue_annotations);
3173
0
            return 0;
3174
0
        }
3175
1
    }
3176
1
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3177
1
                                  FormattedValue_annotations) == 0;
3178
1
    if (!cond) {
3179
0
        Py_DECREF(FormattedValue_annotations);
3180
0
        return 0;
3181
0
    }
3182
1
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3183
1
                                  "__annotations__",
3184
1
                                  FormattedValue_annotations) == 0;
3185
1
    if (!cond) {
3186
0
        Py_DECREF(FormattedValue_annotations);
3187
0
        return 0;
3188
0
    }
3189
1
    Py_DECREF(FormattedValue_annotations);
3190
1
    PyObject *Interpolation_annotations = PyDict_New();
3191
1
    if (!Interpolation_annotations) return 0;
3192
1
    {
3193
1
        PyObject *type = state->expr_type;
3194
1
        Py_INCREF(type);
3195
1
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3196
1
                                    == 0;
3197
1
        Py_DECREF(type);
3198
1
        if (!cond) {
3199
0
            Py_DECREF(Interpolation_annotations);
3200
0
            return 0;
3201
0
        }
3202
1
    }
3203
1
    {
3204
1
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3205
1
        Py_INCREF(type);
3206
1
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3207
1
                                    0;
3208
1
        Py_DECREF(type);
3209
1
        if (!cond) {
3210
0
            Py_DECREF(Interpolation_annotations);
3211
0
            return 0;
3212
0
        }
3213
1
    }
3214
1
    {
3215
1
        PyObject *type = (PyObject *)&PyLong_Type;
3216
1
        Py_INCREF(type);
3217
1
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3218
1
                                    type) == 0;
3219
1
        Py_DECREF(type);
3220
1
        if (!cond) {
3221
0
            Py_DECREF(Interpolation_annotations);
3222
0
            return 0;
3223
0
        }
3224
1
    }
3225
1
    {
3226
1
        PyObject *type = state->expr_type;
3227
1
        type = _Py_union_type_or(type, Py_None);
3228
1
        cond = type != NULL;
3229
1
        if (!cond) {
3230
0
            Py_DECREF(Interpolation_annotations);
3231
0
            return 0;
3232
0
        }
3233
1
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3234
1
                                    type) == 0;
3235
1
        Py_DECREF(type);
3236
1
        if (!cond) {
3237
0
            Py_DECREF(Interpolation_annotations);
3238
0
            return 0;
3239
0
        }
3240
1
    }
3241
1
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3242
1
                                  Interpolation_annotations) == 0;
3243
1
    if (!cond) {
3244
0
        Py_DECREF(Interpolation_annotations);
3245
0
        return 0;
3246
0
    }
3247
1
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3248
1
                                  Interpolation_annotations) == 0;
3249
1
    if (!cond) {
3250
0
        Py_DECREF(Interpolation_annotations);
3251
0
        return 0;
3252
0
    }
3253
1
    Py_DECREF(Interpolation_annotations);
3254
1
    PyObject *JoinedStr_annotations = PyDict_New();
3255
1
    if (!JoinedStr_annotations) return 0;
3256
1
    {
3257
1
        PyObject *type = state->expr_type;
3258
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3259
1
        cond = type != NULL;
3260
1
        if (!cond) {
3261
0
            Py_DECREF(JoinedStr_annotations);
3262
0
            return 0;
3263
0
        }
3264
1
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3265
1
        Py_DECREF(type);
3266
1
        if (!cond) {
3267
0
            Py_DECREF(JoinedStr_annotations);
3268
0
            return 0;
3269
0
        }
3270
1
    }
3271
1
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3272
1
                                  JoinedStr_annotations) == 0;
3273
1
    if (!cond) {
3274
0
        Py_DECREF(JoinedStr_annotations);
3275
0
        return 0;
3276
0
    }
3277
1
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3278
1
                                  JoinedStr_annotations) == 0;
3279
1
    if (!cond) {
3280
0
        Py_DECREF(JoinedStr_annotations);
3281
0
        return 0;
3282
0
    }
3283
1
    Py_DECREF(JoinedStr_annotations);
3284
1
    PyObject *TemplateStr_annotations = PyDict_New();
3285
1
    if (!TemplateStr_annotations) return 0;
3286
1
    {
3287
1
        PyObject *type = state->expr_type;
3288
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3289
1
        cond = type != NULL;
3290
1
        if (!cond) {
3291
0
            Py_DECREF(TemplateStr_annotations);
3292
0
            return 0;
3293
0
        }
3294
1
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3295
1
                                    0;
3296
1
        Py_DECREF(type);
3297
1
        if (!cond) {
3298
0
            Py_DECREF(TemplateStr_annotations);
3299
0
            return 0;
3300
0
        }
3301
1
    }
3302
1
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3303
1
                                  TemplateStr_annotations) == 0;
3304
1
    if (!cond) {
3305
0
        Py_DECREF(TemplateStr_annotations);
3306
0
        return 0;
3307
0
    }
3308
1
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3309
1
                                  TemplateStr_annotations) == 0;
3310
1
    if (!cond) {
3311
0
        Py_DECREF(TemplateStr_annotations);
3312
0
        return 0;
3313
0
    }
3314
1
    Py_DECREF(TemplateStr_annotations);
3315
1
    PyObject *Constant_annotations = PyDict_New();
3316
1
    if (!Constant_annotations) return 0;
3317
1
    {
3318
1
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3319
1
        Py_INCREF(type);
3320
1
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3321
1
        Py_DECREF(type);
3322
1
        if (!cond) {
3323
0
            Py_DECREF(Constant_annotations);
3324
0
            return 0;
3325
0
        }
3326
1
    }
3327
1
    {
3328
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
3329
1
        type = _Py_union_type_or(type, Py_None);
3330
1
        cond = type != NULL;
3331
1
        if (!cond) {
3332
0
            Py_DECREF(Constant_annotations);
3333
0
            return 0;
3334
0
        }
3335
1
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3336
1
        Py_DECREF(type);
3337
1
        if (!cond) {
3338
0
            Py_DECREF(Constant_annotations);
3339
0
            return 0;
3340
0
        }
3341
1
    }
3342
1
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3343
1
                                  Constant_annotations) == 0;
3344
1
    if (!cond) {
3345
0
        Py_DECREF(Constant_annotations);
3346
0
        return 0;
3347
0
    }
3348
1
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3349
1
                                  Constant_annotations) == 0;
3350
1
    if (!cond) {
3351
0
        Py_DECREF(Constant_annotations);
3352
0
        return 0;
3353
0
    }
3354
1
    Py_DECREF(Constant_annotations);
3355
1
    PyObject *Attribute_annotations = PyDict_New();
3356
1
    if (!Attribute_annotations) return 0;
3357
1
    {
3358
1
        PyObject *type = state->expr_type;
3359
1
        Py_INCREF(type);
3360
1
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3361
1
        Py_DECREF(type);
3362
1
        if (!cond) {
3363
0
            Py_DECREF(Attribute_annotations);
3364
0
            return 0;
3365
0
        }
3366
1
    }
3367
1
    {
3368
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
3369
1
        Py_INCREF(type);
3370
1
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3371
1
        Py_DECREF(type);
3372
1
        if (!cond) {
3373
0
            Py_DECREF(Attribute_annotations);
3374
0
            return 0;
3375
0
        }
3376
1
    }
3377
1
    {
3378
1
        PyObject *type = state->expr_context_type;
3379
1
        Py_INCREF(type);
3380
1
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3381
1
        Py_DECREF(type);
3382
1
        if (!cond) {
3383
0
            Py_DECREF(Attribute_annotations);
3384
0
            return 0;
3385
0
        }
3386
1
    }
3387
1
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3388
1
                                  Attribute_annotations) == 0;
3389
1
    if (!cond) {
3390
0
        Py_DECREF(Attribute_annotations);
3391
0
        return 0;
3392
0
    }
3393
1
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3394
1
                                  Attribute_annotations) == 0;
3395
1
    if (!cond) {
3396
0
        Py_DECREF(Attribute_annotations);
3397
0
        return 0;
3398
0
    }
3399
1
    Py_DECREF(Attribute_annotations);
3400
1
    PyObject *Subscript_annotations = PyDict_New();
3401
1
    if (!Subscript_annotations) return 0;
3402
1
    {
3403
1
        PyObject *type = state->expr_type;
3404
1
        Py_INCREF(type);
3405
1
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3406
1
        Py_DECREF(type);
3407
1
        if (!cond) {
3408
0
            Py_DECREF(Subscript_annotations);
3409
0
            return 0;
3410
0
        }
3411
1
    }
3412
1
    {
3413
1
        PyObject *type = state->expr_type;
3414
1
        Py_INCREF(type);
3415
1
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3416
1
        Py_DECREF(type);
3417
1
        if (!cond) {
3418
0
            Py_DECREF(Subscript_annotations);
3419
0
            return 0;
3420
0
        }
3421
1
    }
3422
1
    {
3423
1
        PyObject *type = state->expr_context_type;
3424
1
        Py_INCREF(type);
3425
1
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3426
1
        Py_DECREF(type);
3427
1
        if (!cond) {
3428
0
            Py_DECREF(Subscript_annotations);
3429
0
            return 0;
3430
0
        }
3431
1
    }
3432
1
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3433
1
                                  Subscript_annotations) == 0;
3434
1
    if (!cond) {
3435
0
        Py_DECREF(Subscript_annotations);
3436
0
        return 0;
3437
0
    }
3438
1
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3439
1
                                  Subscript_annotations) == 0;
3440
1
    if (!cond) {
3441
0
        Py_DECREF(Subscript_annotations);
3442
0
        return 0;
3443
0
    }
3444
1
    Py_DECREF(Subscript_annotations);
3445
1
    PyObject *Starred_annotations = PyDict_New();
3446
1
    if (!Starred_annotations) return 0;
3447
1
    {
3448
1
        PyObject *type = state->expr_type;
3449
1
        Py_INCREF(type);
3450
1
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3451
1
        Py_DECREF(type);
3452
1
        if (!cond) {
3453
0
            Py_DECREF(Starred_annotations);
3454
0
            return 0;
3455
0
        }
3456
1
    }
3457
1
    {
3458
1
        PyObject *type = state->expr_context_type;
3459
1
        Py_INCREF(type);
3460
1
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3461
1
        Py_DECREF(type);
3462
1
        if (!cond) {
3463
0
            Py_DECREF(Starred_annotations);
3464
0
            return 0;
3465
0
        }
3466
1
    }
3467
1
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3468
1
                                  Starred_annotations) == 0;
3469
1
    if (!cond) {
3470
0
        Py_DECREF(Starred_annotations);
3471
0
        return 0;
3472
0
    }
3473
1
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3474
1
                                  Starred_annotations) == 0;
3475
1
    if (!cond) {
3476
0
        Py_DECREF(Starred_annotations);
3477
0
        return 0;
3478
0
    }
3479
1
    Py_DECREF(Starred_annotations);
3480
1
    PyObject *Name_annotations = PyDict_New();
3481
1
    if (!Name_annotations) return 0;
3482
1
    {
3483
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
3484
1
        Py_INCREF(type);
3485
1
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3486
1
        Py_DECREF(type);
3487
1
        if (!cond) {
3488
0
            Py_DECREF(Name_annotations);
3489
0
            return 0;
3490
0
        }
3491
1
    }
3492
1
    {
3493
1
        PyObject *type = state->expr_context_type;
3494
1
        Py_INCREF(type);
3495
1
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3496
1
        Py_DECREF(type);
3497
1
        if (!cond) {
3498
0
            Py_DECREF(Name_annotations);
3499
0
            return 0;
3500
0
        }
3501
1
    }
3502
1
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3503
1
                                  Name_annotations) == 0;
3504
1
    if (!cond) {
3505
0
        Py_DECREF(Name_annotations);
3506
0
        return 0;
3507
0
    }
3508
1
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3509
1
                                  Name_annotations) == 0;
3510
1
    if (!cond) {
3511
0
        Py_DECREF(Name_annotations);
3512
0
        return 0;
3513
0
    }
3514
1
    Py_DECREF(Name_annotations);
3515
1
    PyObject *List_annotations = PyDict_New();
3516
1
    if (!List_annotations) return 0;
3517
1
    {
3518
1
        PyObject *type = state->expr_type;
3519
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3520
1
        cond = type != NULL;
3521
1
        if (!cond) {
3522
0
            Py_DECREF(List_annotations);
3523
0
            return 0;
3524
0
        }
3525
1
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3526
1
        Py_DECREF(type);
3527
1
        if (!cond) {
3528
0
            Py_DECREF(List_annotations);
3529
0
            return 0;
3530
0
        }
3531
1
    }
3532
1
    {
3533
1
        PyObject *type = state->expr_context_type;
3534
1
        Py_INCREF(type);
3535
1
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3536
1
        Py_DECREF(type);
3537
1
        if (!cond) {
3538
0
            Py_DECREF(List_annotations);
3539
0
            return 0;
3540
0
        }
3541
1
    }
3542
1
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3543
1
                                  List_annotations) == 0;
3544
1
    if (!cond) {
3545
0
        Py_DECREF(List_annotations);
3546
0
        return 0;
3547
0
    }
3548
1
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3549
1
                                  List_annotations) == 0;
3550
1
    if (!cond) {
3551
0
        Py_DECREF(List_annotations);
3552
0
        return 0;
3553
0
    }
3554
1
    Py_DECREF(List_annotations);
3555
1
    PyObject *Tuple_annotations = PyDict_New();
3556
1
    if (!Tuple_annotations) return 0;
3557
1
    {
3558
1
        PyObject *type = state->expr_type;
3559
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3560
1
        cond = type != NULL;
3561
1
        if (!cond) {
3562
0
            Py_DECREF(Tuple_annotations);
3563
0
            return 0;
3564
0
        }
3565
1
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3566
1
        Py_DECREF(type);
3567
1
        if (!cond) {
3568
0
            Py_DECREF(Tuple_annotations);
3569
0
            return 0;
3570
0
        }
3571
1
    }
3572
1
    {
3573
1
        PyObject *type = state->expr_context_type;
3574
1
        Py_INCREF(type);
3575
1
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3576
1
        Py_DECREF(type);
3577
1
        if (!cond) {
3578
0
            Py_DECREF(Tuple_annotations);
3579
0
            return 0;
3580
0
        }
3581
1
    }
3582
1
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3583
1
                                  Tuple_annotations) == 0;
3584
1
    if (!cond) {
3585
0
        Py_DECREF(Tuple_annotations);
3586
0
        return 0;
3587
0
    }
3588
1
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3589
1
                                  Tuple_annotations) == 0;
3590
1
    if (!cond) {
3591
0
        Py_DECREF(Tuple_annotations);
3592
0
        return 0;
3593
0
    }
3594
1
    Py_DECREF(Tuple_annotations);
3595
1
    PyObject *Slice_annotations = PyDict_New();
3596
1
    if (!Slice_annotations) return 0;
3597
1
    {
3598
1
        PyObject *type = state->expr_type;
3599
1
        type = _Py_union_type_or(type, Py_None);
3600
1
        cond = type != NULL;
3601
1
        if (!cond) {
3602
0
            Py_DECREF(Slice_annotations);
3603
0
            return 0;
3604
0
        }
3605
1
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3606
1
        Py_DECREF(type);
3607
1
        if (!cond) {
3608
0
            Py_DECREF(Slice_annotations);
3609
0
            return 0;
3610
0
        }
3611
1
    }
3612
1
    {
3613
1
        PyObject *type = state->expr_type;
3614
1
        type = _Py_union_type_or(type, Py_None);
3615
1
        cond = type != NULL;
3616
1
        if (!cond) {
3617
0
            Py_DECREF(Slice_annotations);
3618
0
            return 0;
3619
0
        }
3620
1
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3621
1
        Py_DECREF(type);
3622
1
        if (!cond) {
3623
0
            Py_DECREF(Slice_annotations);
3624
0
            return 0;
3625
0
        }
3626
1
    }
3627
1
    {
3628
1
        PyObject *type = state->expr_type;
3629
1
        type = _Py_union_type_or(type, Py_None);
3630
1
        cond = type != NULL;
3631
1
        if (!cond) {
3632
0
            Py_DECREF(Slice_annotations);
3633
0
            return 0;
3634
0
        }
3635
1
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3636
1
        Py_DECREF(type);
3637
1
        if (!cond) {
3638
0
            Py_DECREF(Slice_annotations);
3639
0
            return 0;
3640
0
        }
3641
1
    }
3642
1
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3643
1
                                  Slice_annotations) == 0;
3644
1
    if (!cond) {
3645
0
        Py_DECREF(Slice_annotations);
3646
0
        return 0;
3647
0
    }
3648
1
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3649
1
                                  Slice_annotations) == 0;
3650
1
    if (!cond) {
3651
0
        Py_DECREF(Slice_annotations);
3652
0
        return 0;
3653
0
    }
3654
1
    Py_DECREF(Slice_annotations);
3655
1
    PyObject *Load_annotations = PyDict_New();
3656
1
    if (!Load_annotations) return 0;
3657
1
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3658
1
                                  Load_annotations) == 0;
3659
1
    if (!cond) {
3660
0
        Py_DECREF(Load_annotations);
3661
0
        return 0;
3662
0
    }
3663
1
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3664
1
                                  Load_annotations) == 0;
3665
1
    if (!cond) {
3666
0
        Py_DECREF(Load_annotations);
3667
0
        return 0;
3668
0
    }
3669
1
    Py_DECREF(Load_annotations);
3670
1
    PyObject *Store_annotations = PyDict_New();
3671
1
    if (!Store_annotations) return 0;
3672
1
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3673
1
                                  Store_annotations) == 0;
3674
1
    if (!cond) {
3675
0
        Py_DECREF(Store_annotations);
3676
0
        return 0;
3677
0
    }
3678
1
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3679
1
                                  Store_annotations) == 0;
3680
1
    if (!cond) {
3681
0
        Py_DECREF(Store_annotations);
3682
0
        return 0;
3683
0
    }
3684
1
    Py_DECREF(Store_annotations);
3685
1
    PyObject *Del_annotations = PyDict_New();
3686
1
    if (!Del_annotations) return 0;
3687
1
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3688
1
                                  Del_annotations) == 0;
3689
1
    if (!cond) {
3690
0
        Py_DECREF(Del_annotations);
3691
0
        return 0;
3692
0
    }
3693
1
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3694
1
                                  Del_annotations) == 0;
3695
1
    if (!cond) {
3696
0
        Py_DECREF(Del_annotations);
3697
0
        return 0;
3698
0
    }
3699
1
    Py_DECREF(Del_annotations);
3700
1
    PyObject *And_annotations = PyDict_New();
3701
1
    if (!And_annotations) return 0;
3702
1
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3703
1
                                  And_annotations) == 0;
3704
1
    if (!cond) {
3705
0
        Py_DECREF(And_annotations);
3706
0
        return 0;
3707
0
    }
3708
1
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3709
1
                                  And_annotations) == 0;
3710
1
    if (!cond) {
3711
0
        Py_DECREF(And_annotations);
3712
0
        return 0;
3713
0
    }
3714
1
    Py_DECREF(And_annotations);
3715
1
    PyObject *Or_annotations = PyDict_New();
3716
1
    if (!Or_annotations) return 0;
3717
1
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3718
1
                                  Or_annotations) == 0;
3719
1
    if (!cond) {
3720
0
        Py_DECREF(Or_annotations);
3721
0
        return 0;
3722
0
    }
3723
1
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3724
1
                                  Or_annotations) == 0;
3725
1
    if (!cond) {
3726
0
        Py_DECREF(Or_annotations);
3727
0
        return 0;
3728
0
    }
3729
1
    Py_DECREF(Or_annotations);
3730
1
    PyObject *Add_annotations = PyDict_New();
3731
1
    if (!Add_annotations) return 0;
3732
1
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3733
1
                                  Add_annotations) == 0;
3734
1
    if (!cond) {
3735
0
        Py_DECREF(Add_annotations);
3736
0
        return 0;
3737
0
    }
3738
1
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3739
1
                                  Add_annotations) == 0;
3740
1
    if (!cond) {
3741
0
        Py_DECREF(Add_annotations);
3742
0
        return 0;
3743
0
    }
3744
1
    Py_DECREF(Add_annotations);
3745
1
    PyObject *Sub_annotations = PyDict_New();
3746
1
    if (!Sub_annotations) return 0;
3747
1
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3748
1
                                  Sub_annotations) == 0;
3749
1
    if (!cond) {
3750
0
        Py_DECREF(Sub_annotations);
3751
0
        return 0;
3752
0
    }
3753
1
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3754
1
                                  Sub_annotations) == 0;
3755
1
    if (!cond) {
3756
0
        Py_DECREF(Sub_annotations);
3757
0
        return 0;
3758
0
    }
3759
1
    Py_DECREF(Sub_annotations);
3760
1
    PyObject *Mult_annotations = PyDict_New();
3761
1
    if (!Mult_annotations) return 0;
3762
1
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3763
1
                                  Mult_annotations) == 0;
3764
1
    if (!cond) {
3765
0
        Py_DECREF(Mult_annotations);
3766
0
        return 0;
3767
0
    }
3768
1
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3769
1
                                  Mult_annotations) == 0;
3770
1
    if (!cond) {
3771
0
        Py_DECREF(Mult_annotations);
3772
0
        return 0;
3773
0
    }
3774
1
    Py_DECREF(Mult_annotations);
3775
1
    PyObject *MatMult_annotations = PyDict_New();
3776
1
    if (!MatMult_annotations) return 0;
3777
1
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3778
1
                                  MatMult_annotations) == 0;
3779
1
    if (!cond) {
3780
0
        Py_DECREF(MatMult_annotations);
3781
0
        return 0;
3782
0
    }
3783
1
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3784
1
                                  MatMult_annotations) == 0;
3785
1
    if (!cond) {
3786
0
        Py_DECREF(MatMult_annotations);
3787
0
        return 0;
3788
0
    }
3789
1
    Py_DECREF(MatMult_annotations);
3790
1
    PyObject *Div_annotations = PyDict_New();
3791
1
    if (!Div_annotations) return 0;
3792
1
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3793
1
                                  Div_annotations) == 0;
3794
1
    if (!cond) {
3795
0
        Py_DECREF(Div_annotations);
3796
0
        return 0;
3797
0
    }
3798
1
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3799
1
                                  Div_annotations) == 0;
3800
1
    if (!cond) {
3801
0
        Py_DECREF(Div_annotations);
3802
0
        return 0;
3803
0
    }
3804
1
    Py_DECREF(Div_annotations);
3805
1
    PyObject *Mod_annotations = PyDict_New();
3806
1
    if (!Mod_annotations) return 0;
3807
1
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3808
1
                                  Mod_annotations) == 0;
3809
1
    if (!cond) {
3810
0
        Py_DECREF(Mod_annotations);
3811
0
        return 0;
3812
0
    }
3813
1
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3814
1
                                  Mod_annotations) == 0;
3815
1
    if (!cond) {
3816
0
        Py_DECREF(Mod_annotations);
3817
0
        return 0;
3818
0
    }
3819
1
    Py_DECREF(Mod_annotations);
3820
1
    PyObject *Pow_annotations = PyDict_New();
3821
1
    if (!Pow_annotations) return 0;
3822
1
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3823
1
                                  Pow_annotations) == 0;
3824
1
    if (!cond) {
3825
0
        Py_DECREF(Pow_annotations);
3826
0
        return 0;
3827
0
    }
3828
1
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3829
1
                                  Pow_annotations) == 0;
3830
1
    if (!cond) {
3831
0
        Py_DECREF(Pow_annotations);
3832
0
        return 0;
3833
0
    }
3834
1
    Py_DECREF(Pow_annotations);
3835
1
    PyObject *LShift_annotations = PyDict_New();
3836
1
    if (!LShift_annotations) return 0;
3837
1
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3838
1
                                  LShift_annotations) == 0;
3839
1
    if (!cond) {
3840
0
        Py_DECREF(LShift_annotations);
3841
0
        return 0;
3842
0
    }
3843
1
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3844
1
                                  LShift_annotations) == 0;
3845
1
    if (!cond) {
3846
0
        Py_DECREF(LShift_annotations);
3847
0
        return 0;
3848
0
    }
3849
1
    Py_DECREF(LShift_annotations);
3850
1
    PyObject *RShift_annotations = PyDict_New();
3851
1
    if (!RShift_annotations) return 0;
3852
1
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3853
1
                                  RShift_annotations) == 0;
3854
1
    if (!cond) {
3855
0
        Py_DECREF(RShift_annotations);
3856
0
        return 0;
3857
0
    }
3858
1
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3859
1
                                  RShift_annotations) == 0;
3860
1
    if (!cond) {
3861
0
        Py_DECREF(RShift_annotations);
3862
0
        return 0;
3863
0
    }
3864
1
    Py_DECREF(RShift_annotations);
3865
1
    PyObject *BitOr_annotations = PyDict_New();
3866
1
    if (!BitOr_annotations) return 0;
3867
1
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3868
1
                                  BitOr_annotations) == 0;
3869
1
    if (!cond) {
3870
0
        Py_DECREF(BitOr_annotations);
3871
0
        return 0;
3872
0
    }
3873
1
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3874
1
                                  BitOr_annotations) == 0;
3875
1
    if (!cond) {
3876
0
        Py_DECREF(BitOr_annotations);
3877
0
        return 0;
3878
0
    }
3879
1
    Py_DECREF(BitOr_annotations);
3880
1
    PyObject *BitXor_annotations = PyDict_New();
3881
1
    if (!BitXor_annotations) return 0;
3882
1
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3883
1
                                  BitXor_annotations) == 0;
3884
1
    if (!cond) {
3885
0
        Py_DECREF(BitXor_annotations);
3886
0
        return 0;
3887
0
    }
3888
1
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3889
1
                                  BitXor_annotations) == 0;
3890
1
    if (!cond) {
3891
0
        Py_DECREF(BitXor_annotations);
3892
0
        return 0;
3893
0
    }
3894
1
    Py_DECREF(BitXor_annotations);
3895
1
    PyObject *BitAnd_annotations = PyDict_New();
3896
1
    if (!BitAnd_annotations) return 0;
3897
1
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3898
1
                                  BitAnd_annotations) == 0;
3899
1
    if (!cond) {
3900
0
        Py_DECREF(BitAnd_annotations);
3901
0
        return 0;
3902
0
    }
3903
1
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3904
1
                                  BitAnd_annotations) == 0;
3905
1
    if (!cond) {
3906
0
        Py_DECREF(BitAnd_annotations);
3907
0
        return 0;
3908
0
    }
3909
1
    Py_DECREF(BitAnd_annotations);
3910
1
    PyObject *FloorDiv_annotations = PyDict_New();
3911
1
    if (!FloorDiv_annotations) return 0;
3912
1
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3913
1
                                  FloorDiv_annotations) == 0;
3914
1
    if (!cond) {
3915
0
        Py_DECREF(FloorDiv_annotations);
3916
0
        return 0;
3917
0
    }
3918
1
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3919
1
                                  FloorDiv_annotations) == 0;
3920
1
    if (!cond) {
3921
0
        Py_DECREF(FloorDiv_annotations);
3922
0
        return 0;
3923
0
    }
3924
1
    Py_DECREF(FloorDiv_annotations);
3925
1
    PyObject *Invert_annotations = PyDict_New();
3926
1
    if (!Invert_annotations) return 0;
3927
1
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3928
1
                                  Invert_annotations) == 0;
3929
1
    if (!cond) {
3930
0
        Py_DECREF(Invert_annotations);
3931
0
        return 0;
3932
0
    }
3933
1
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3934
1
                                  Invert_annotations) == 0;
3935
1
    if (!cond) {
3936
0
        Py_DECREF(Invert_annotations);
3937
0
        return 0;
3938
0
    }
3939
1
    Py_DECREF(Invert_annotations);
3940
1
    PyObject *Not_annotations = PyDict_New();
3941
1
    if (!Not_annotations) return 0;
3942
1
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3943
1
                                  Not_annotations) == 0;
3944
1
    if (!cond) {
3945
0
        Py_DECREF(Not_annotations);
3946
0
        return 0;
3947
0
    }
3948
1
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3949
1
                                  Not_annotations) == 0;
3950
1
    if (!cond) {
3951
0
        Py_DECREF(Not_annotations);
3952
0
        return 0;
3953
0
    }
3954
1
    Py_DECREF(Not_annotations);
3955
1
    PyObject *UAdd_annotations = PyDict_New();
3956
1
    if (!UAdd_annotations) return 0;
3957
1
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3958
1
                                  UAdd_annotations) == 0;
3959
1
    if (!cond) {
3960
0
        Py_DECREF(UAdd_annotations);
3961
0
        return 0;
3962
0
    }
3963
1
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
3964
1
                                  UAdd_annotations) == 0;
3965
1
    if (!cond) {
3966
0
        Py_DECREF(UAdd_annotations);
3967
0
        return 0;
3968
0
    }
3969
1
    Py_DECREF(UAdd_annotations);
3970
1
    PyObject *USub_annotations = PyDict_New();
3971
1
    if (!USub_annotations) return 0;
3972
1
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
3973
1
                                  USub_annotations) == 0;
3974
1
    if (!cond) {
3975
0
        Py_DECREF(USub_annotations);
3976
0
        return 0;
3977
0
    }
3978
1
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
3979
1
                                  USub_annotations) == 0;
3980
1
    if (!cond) {
3981
0
        Py_DECREF(USub_annotations);
3982
0
        return 0;
3983
0
    }
3984
1
    Py_DECREF(USub_annotations);
3985
1
    PyObject *Eq_annotations = PyDict_New();
3986
1
    if (!Eq_annotations) return 0;
3987
1
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
3988
1
                                  Eq_annotations) == 0;
3989
1
    if (!cond) {
3990
0
        Py_DECREF(Eq_annotations);
3991
0
        return 0;
3992
0
    }
3993
1
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
3994
1
                                  Eq_annotations) == 0;
3995
1
    if (!cond) {
3996
0
        Py_DECREF(Eq_annotations);
3997
0
        return 0;
3998
0
    }
3999
1
    Py_DECREF(Eq_annotations);
4000
1
    PyObject *NotEq_annotations = PyDict_New();
4001
1
    if (!NotEq_annotations) return 0;
4002
1
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4003
1
                                  NotEq_annotations) == 0;
4004
1
    if (!cond) {
4005
0
        Py_DECREF(NotEq_annotations);
4006
0
        return 0;
4007
0
    }
4008
1
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4009
1
                                  NotEq_annotations) == 0;
4010
1
    if (!cond) {
4011
0
        Py_DECREF(NotEq_annotations);
4012
0
        return 0;
4013
0
    }
4014
1
    Py_DECREF(NotEq_annotations);
4015
1
    PyObject *Lt_annotations = PyDict_New();
4016
1
    if (!Lt_annotations) return 0;
4017
1
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4018
1
                                  Lt_annotations) == 0;
4019
1
    if (!cond) {
4020
0
        Py_DECREF(Lt_annotations);
4021
0
        return 0;
4022
0
    }
4023
1
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4024
1
                                  Lt_annotations) == 0;
4025
1
    if (!cond) {
4026
0
        Py_DECREF(Lt_annotations);
4027
0
        return 0;
4028
0
    }
4029
1
    Py_DECREF(Lt_annotations);
4030
1
    PyObject *LtE_annotations = PyDict_New();
4031
1
    if (!LtE_annotations) return 0;
4032
1
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4033
1
                                  LtE_annotations) == 0;
4034
1
    if (!cond) {
4035
0
        Py_DECREF(LtE_annotations);
4036
0
        return 0;
4037
0
    }
4038
1
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4039
1
                                  LtE_annotations) == 0;
4040
1
    if (!cond) {
4041
0
        Py_DECREF(LtE_annotations);
4042
0
        return 0;
4043
0
    }
4044
1
    Py_DECREF(LtE_annotations);
4045
1
    PyObject *Gt_annotations = PyDict_New();
4046
1
    if (!Gt_annotations) return 0;
4047
1
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4048
1
                                  Gt_annotations) == 0;
4049
1
    if (!cond) {
4050
0
        Py_DECREF(Gt_annotations);
4051
0
        return 0;
4052
0
    }
4053
1
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4054
1
                                  Gt_annotations) == 0;
4055
1
    if (!cond) {
4056
0
        Py_DECREF(Gt_annotations);
4057
0
        return 0;
4058
0
    }
4059
1
    Py_DECREF(Gt_annotations);
4060
1
    PyObject *GtE_annotations = PyDict_New();
4061
1
    if (!GtE_annotations) return 0;
4062
1
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4063
1
                                  GtE_annotations) == 0;
4064
1
    if (!cond) {
4065
0
        Py_DECREF(GtE_annotations);
4066
0
        return 0;
4067
0
    }
4068
1
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4069
1
                                  GtE_annotations) == 0;
4070
1
    if (!cond) {
4071
0
        Py_DECREF(GtE_annotations);
4072
0
        return 0;
4073
0
    }
4074
1
    Py_DECREF(GtE_annotations);
4075
1
    PyObject *Is_annotations = PyDict_New();
4076
1
    if (!Is_annotations) return 0;
4077
1
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4078
1
                                  Is_annotations) == 0;
4079
1
    if (!cond) {
4080
0
        Py_DECREF(Is_annotations);
4081
0
        return 0;
4082
0
    }
4083
1
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4084
1
                                  Is_annotations) == 0;
4085
1
    if (!cond) {
4086
0
        Py_DECREF(Is_annotations);
4087
0
        return 0;
4088
0
    }
4089
1
    Py_DECREF(Is_annotations);
4090
1
    PyObject *IsNot_annotations = PyDict_New();
4091
1
    if (!IsNot_annotations) return 0;
4092
1
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4093
1
                                  IsNot_annotations) == 0;
4094
1
    if (!cond) {
4095
0
        Py_DECREF(IsNot_annotations);
4096
0
        return 0;
4097
0
    }
4098
1
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4099
1
                                  IsNot_annotations) == 0;
4100
1
    if (!cond) {
4101
0
        Py_DECREF(IsNot_annotations);
4102
0
        return 0;
4103
0
    }
4104
1
    Py_DECREF(IsNot_annotations);
4105
1
    PyObject *In_annotations = PyDict_New();
4106
1
    if (!In_annotations) return 0;
4107
1
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4108
1
                                  In_annotations) == 0;
4109
1
    if (!cond) {
4110
0
        Py_DECREF(In_annotations);
4111
0
        return 0;
4112
0
    }
4113
1
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4114
1
                                  In_annotations) == 0;
4115
1
    if (!cond) {
4116
0
        Py_DECREF(In_annotations);
4117
0
        return 0;
4118
0
    }
4119
1
    Py_DECREF(In_annotations);
4120
1
    PyObject *NotIn_annotations = PyDict_New();
4121
1
    if (!NotIn_annotations) return 0;
4122
1
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4123
1
                                  NotIn_annotations) == 0;
4124
1
    if (!cond) {
4125
0
        Py_DECREF(NotIn_annotations);
4126
0
        return 0;
4127
0
    }
4128
1
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4129
1
                                  NotIn_annotations) == 0;
4130
1
    if (!cond) {
4131
0
        Py_DECREF(NotIn_annotations);
4132
0
        return 0;
4133
0
    }
4134
1
    Py_DECREF(NotIn_annotations);
4135
1
    PyObject *comprehension_annotations = PyDict_New();
4136
1
    if (!comprehension_annotations) return 0;
4137
1
    {
4138
1
        PyObject *type = state->expr_type;
4139
1
        Py_INCREF(type);
4140
1
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4141
1
                                    == 0;
4142
1
        Py_DECREF(type);
4143
1
        if (!cond) {
4144
0
            Py_DECREF(comprehension_annotations);
4145
0
            return 0;
4146
0
        }
4147
1
    }
4148
1
    {
4149
1
        PyObject *type = state->expr_type;
4150
1
        Py_INCREF(type);
4151
1
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4152
1
                                    0;
4153
1
        Py_DECREF(type);
4154
1
        if (!cond) {
4155
0
            Py_DECREF(comprehension_annotations);
4156
0
            return 0;
4157
0
        }
4158
1
    }
4159
1
    {
4160
1
        PyObject *type = state->expr_type;
4161
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4162
1
        cond = type != NULL;
4163
1
        if (!cond) {
4164
0
            Py_DECREF(comprehension_annotations);
4165
0
            return 0;
4166
0
        }
4167
1
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4168
1
                                    0;
4169
1
        Py_DECREF(type);
4170
1
        if (!cond) {
4171
0
            Py_DECREF(comprehension_annotations);
4172
0
            return 0;
4173
0
        }
4174
1
    }
4175
1
    {
4176
1
        PyObject *type = (PyObject *)&PyLong_Type;
4177
1
        Py_INCREF(type);
4178
1
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4179
1
                                    type) == 0;
4180
1
        Py_DECREF(type);
4181
1
        if (!cond) {
4182
0
            Py_DECREF(comprehension_annotations);
4183
0
            return 0;
4184
0
        }
4185
1
    }
4186
1
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4187
1
                                  comprehension_annotations) == 0;
4188
1
    if (!cond) {
4189
0
        Py_DECREF(comprehension_annotations);
4190
0
        return 0;
4191
0
    }
4192
1
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4193
1
                                  comprehension_annotations) == 0;
4194
1
    if (!cond) {
4195
0
        Py_DECREF(comprehension_annotations);
4196
0
        return 0;
4197
0
    }
4198
1
    Py_DECREF(comprehension_annotations);
4199
1
    PyObject *ExceptHandler_annotations = PyDict_New();
4200
1
    if (!ExceptHandler_annotations) return 0;
4201
1
    {
4202
1
        PyObject *type = state->expr_type;
4203
1
        type = _Py_union_type_or(type, Py_None);
4204
1
        cond = type != NULL;
4205
1
        if (!cond) {
4206
0
            Py_DECREF(ExceptHandler_annotations);
4207
0
            return 0;
4208
0
        }
4209
1
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4210
1
                                    0;
4211
1
        Py_DECREF(type);
4212
1
        if (!cond) {
4213
0
            Py_DECREF(ExceptHandler_annotations);
4214
0
            return 0;
4215
0
        }
4216
1
    }
4217
1
    {
4218
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4219
1
        type = _Py_union_type_or(type, Py_None);
4220
1
        cond = type != NULL;
4221
1
        if (!cond) {
4222
0
            Py_DECREF(ExceptHandler_annotations);
4223
0
            return 0;
4224
0
        }
4225
1
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4226
1
                                    0;
4227
1
        Py_DECREF(type);
4228
1
        if (!cond) {
4229
0
            Py_DECREF(ExceptHandler_annotations);
4230
0
            return 0;
4231
0
        }
4232
1
    }
4233
1
    {
4234
1
        PyObject *type = state->stmt_type;
4235
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4236
1
        cond = type != NULL;
4237
1
        if (!cond) {
4238
0
            Py_DECREF(ExceptHandler_annotations);
4239
0
            return 0;
4240
0
        }
4241
1
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4242
1
                                    0;
4243
1
        Py_DECREF(type);
4244
1
        if (!cond) {
4245
0
            Py_DECREF(ExceptHandler_annotations);
4246
0
            return 0;
4247
0
        }
4248
1
    }
4249
1
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4250
1
                                  ExceptHandler_annotations) == 0;
4251
1
    if (!cond) {
4252
0
        Py_DECREF(ExceptHandler_annotations);
4253
0
        return 0;
4254
0
    }
4255
1
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4256
1
                                  ExceptHandler_annotations) == 0;
4257
1
    if (!cond) {
4258
0
        Py_DECREF(ExceptHandler_annotations);
4259
0
        return 0;
4260
0
    }
4261
1
    Py_DECREF(ExceptHandler_annotations);
4262
1
    PyObject *arguments_annotations = PyDict_New();
4263
1
    if (!arguments_annotations) return 0;
4264
1
    {
4265
1
        PyObject *type = state->arg_type;
4266
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4267
1
        cond = type != NULL;
4268
1
        if (!cond) {
4269
0
            Py_DECREF(arguments_annotations);
4270
0
            return 0;
4271
0
        }
4272
1
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4273
1
                                    == 0;
4274
1
        Py_DECREF(type);
4275
1
        if (!cond) {
4276
0
            Py_DECREF(arguments_annotations);
4277
0
            return 0;
4278
0
        }
4279
1
    }
4280
1
    {
4281
1
        PyObject *type = state->arg_type;
4282
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4283
1
        cond = type != NULL;
4284
1
        if (!cond) {
4285
0
            Py_DECREF(arguments_annotations);
4286
0
            return 0;
4287
0
        }
4288
1
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4289
1
        Py_DECREF(type);
4290
1
        if (!cond) {
4291
0
            Py_DECREF(arguments_annotations);
4292
0
            return 0;
4293
0
        }
4294
1
    }
4295
1
    {
4296
1
        PyObject *type = state->arg_type;
4297
1
        type = _Py_union_type_or(type, Py_None);
4298
1
        cond = type != NULL;
4299
1
        if (!cond) {
4300
0
            Py_DECREF(arguments_annotations);
4301
0
            return 0;
4302
0
        }
4303
1
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4304
1
        Py_DECREF(type);
4305
1
        if (!cond) {
4306
0
            Py_DECREF(arguments_annotations);
4307
0
            return 0;
4308
0
        }
4309
1
    }
4310
1
    {
4311
1
        PyObject *type = state->arg_type;
4312
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4313
1
        cond = type != NULL;
4314
1
        if (!cond) {
4315
0
            Py_DECREF(arguments_annotations);
4316
0
            return 0;
4317
0
        }
4318
1
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4319
1
                                    == 0;
4320
1
        Py_DECREF(type);
4321
1
        if (!cond) {
4322
0
            Py_DECREF(arguments_annotations);
4323
0
            return 0;
4324
0
        }
4325
1
    }
4326
1
    {
4327
1
        PyObject *type = state->expr_type;
4328
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4329
1
        cond = type != NULL;
4330
1
        if (!cond) {
4331
0
            Py_DECREF(arguments_annotations);
4332
0
            return 0;
4333
0
        }
4334
1
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4335
1
                                    == 0;
4336
1
        Py_DECREF(type);
4337
1
        if (!cond) {
4338
0
            Py_DECREF(arguments_annotations);
4339
0
            return 0;
4340
0
        }
4341
1
    }
4342
1
    {
4343
1
        PyObject *type = state->arg_type;
4344
1
        type = _Py_union_type_or(type, Py_None);
4345
1
        cond = type != NULL;
4346
1
        if (!cond) {
4347
0
            Py_DECREF(arguments_annotations);
4348
0
            return 0;
4349
0
        }
4350
1
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4351
1
        Py_DECREF(type);
4352
1
        if (!cond) {
4353
0
            Py_DECREF(arguments_annotations);
4354
0
            return 0;
4355
0
        }
4356
1
    }
4357
1
    {
4358
1
        PyObject *type = state->expr_type;
4359
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4360
1
        cond = type != NULL;
4361
1
        if (!cond) {
4362
0
            Py_DECREF(arguments_annotations);
4363
0
            return 0;
4364
0
        }
4365
1
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4366
1
                                    0;
4367
1
        Py_DECREF(type);
4368
1
        if (!cond) {
4369
0
            Py_DECREF(arguments_annotations);
4370
0
            return 0;
4371
0
        }
4372
1
    }
4373
1
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4374
1
                                  arguments_annotations) == 0;
4375
1
    if (!cond) {
4376
0
        Py_DECREF(arguments_annotations);
4377
0
        return 0;
4378
0
    }
4379
1
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4380
1
                                  arguments_annotations) == 0;
4381
1
    if (!cond) {
4382
0
        Py_DECREF(arguments_annotations);
4383
0
        return 0;
4384
0
    }
4385
1
    Py_DECREF(arguments_annotations);
4386
1
    PyObject *arg_annotations = PyDict_New();
4387
1
    if (!arg_annotations) return 0;
4388
1
    {
4389
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4390
1
        Py_INCREF(type);
4391
1
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4392
1
        Py_DECREF(type);
4393
1
        if (!cond) {
4394
0
            Py_DECREF(arg_annotations);
4395
0
            return 0;
4396
0
        }
4397
1
    }
4398
1
    {
4399
1
        PyObject *type = state->expr_type;
4400
1
        type = _Py_union_type_or(type, Py_None);
4401
1
        cond = type != NULL;
4402
1
        if (!cond) {
4403
0
            Py_DECREF(arg_annotations);
4404
0
            return 0;
4405
0
        }
4406
1
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4407
1
        Py_DECREF(type);
4408
1
        if (!cond) {
4409
0
            Py_DECREF(arg_annotations);
4410
0
            return 0;
4411
0
        }
4412
1
    }
4413
1
    {
4414
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4415
1
        type = _Py_union_type_or(type, Py_None);
4416
1
        cond = type != NULL;
4417
1
        if (!cond) {
4418
0
            Py_DECREF(arg_annotations);
4419
0
            return 0;
4420
0
        }
4421
1
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4422
1
        Py_DECREF(type);
4423
1
        if (!cond) {
4424
0
            Py_DECREF(arg_annotations);
4425
0
            return 0;
4426
0
        }
4427
1
    }
4428
1
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4429
1
                                  arg_annotations) == 0;
4430
1
    if (!cond) {
4431
0
        Py_DECREF(arg_annotations);
4432
0
        return 0;
4433
0
    }
4434
1
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4435
1
                                  arg_annotations) == 0;
4436
1
    if (!cond) {
4437
0
        Py_DECREF(arg_annotations);
4438
0
        return 0;
4439
0
    }
4440
1
    Py_DECREF(arg_annotations);
4441
1
    PyObject *keyword_annotations = PyDict_New();
4442
1
    if (!keyword_annotations) return 0;
4443
1
    {
4444
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4445
1
        type = _Py_union_type_or(type, Py_None);
4446
1
        cond = type != NULL;
4447
1
        if (!cond) {
4448
0
            Py_DECREF(keyword_annotations);
4449
0
            return 0;
4450
0
        }
4451
1
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4452
1
        Py_DECREF(type);
4453
1
        if (!cond) {
4454
0
            Py_DECREF(keyword_annotations);
4455
0
            return 0;
4456
0
        }
4457
1
    }
4458
1
    {
4459
1
        PyObject *type = state->expr_type;
4460
1
        Py_INCREF(type);
4461
1
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4462
1
        Py_DECREF(type);
4463
1
        if (!cond) {
4464
0
            Py_DECREF(keyword_annotations);
4465
0
            return 0;
4466
0
        }
4467
1
    }
4468
1
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4469
1
                                  keyword_annotations) == 0;
4470
1
    if (!cond) {
4471
0
        Py_DECREF(keyword_annotations);
4472
0
        return 0;
4473
0
    }
4474
1
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4475
1
                                  keyword_annotations) == 0;
4476
1
    if (!cond) {
4477
0
        Py_DECREF(keyword_annotations);
4478
0
        return 0;
4479
0
    }
4480
1
    Py_DECREF(keyword_annotations);
4481
1
    PyObject *alias_annotations = PyDict_New();
4482
1
    if (!alias_annotations) return 0;
4483
1
    {
4484
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4485
1
        Py_INCREF(type);
4486
1
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4487
1
        Py_DECREF(type);
4488
1
        if (!cond) {
4489
0
            Py_DECREF(alias_annotations);
4490
0
            return 0;
4491
0
        }
4492
1
    }
4493
1
    {
4494
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4495
1
        type = _Py_union_type_or(type, Py_None);
4496
1
        cond = type != NULL;
4497
1
        if (!cond) {
4498
0
            Py_DECREF(alias_annotations);
4499
0
            return 0;
4500
0
        }
4501
1
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4502
1
        Py_DECREF(type);
4503
1
        if (!cond) {
4504
0
            Py_DECREF(alias_annotations);
4505
0
            return 0;
4506
0
        }
4507
1
    }
4508
1
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4509
1
                                  alias_annotations) == 0;
4510
1
    if (!cond) {
4511
0
        Py_DECREF(alias_annotations);
4512
0
        return 0;
4513
0
    }
4514
1
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4515
1
                                  alias_annotations) == 0;
4516
1
    if (!cond) {
4517
0
        Py_DECREF(alias_annotations);
4518
0
        return 0;
4519
0
    }
4520
1
    Py_DECREF(alias_annotations);
4521
1
    PyObject *withitem_annotations = PyDict_New();
4522
1
    if (!withitem_annotations) return 0;
4523
1
    {
4524
1
        PyObject *type = state->expr_type;
4525
1
        Py_INCREF(type);
4526
1
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4527
1
                                    == 0;
4528
1
        Py_DECREF(type);
4529
1
        if (!cond) {
4530
0
            Py_DECREF(withitem_annotations);
4531
0
            return 0;
4532
0
        }
4533
1
    }
4534
1
    {
4535
1
        PyObject *type = state->expr_type;
4536
1
        type = _Py_union_type_or(type, Py_None);
4537
1
        cond = type != NULL;
4538
1
        if (!cond) {
4539
0
            Py_DECREF(withitem_annotations);
4540
0
            return 0;
4541
0
        }
4542
1
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4543
1
                                    type) == 0;
4544
1
        Py_DECREF(type);
4545
1
        if (!cond) {
4546
0
            Py_DECREF(withitem_annotations);
4547
0
            return 0;
4548
0
        }
4549
1
    }
4550
1
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4551
1
                                  withitem_annotations) == 0;
4552
1
    if (!cond) {
4553
0
        Py_DECREF(withitem_annotations);
4554
0
        return 0;
4555
0
    }
4556
1
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4557
1
                                  withitem_annotations) == 0;
4558
1
    if (!cond) {
4559
0
        Py_DECREF(withitem_annotations);
4560
0
        return 0;
4561
0
    }
4562
1
    Py_DECREF(withitem_annotations);
4563
1
    PyObject *match_case_annotations = PyDict_New();
4564
1
    if (!match_case_annotations) return 0;
4565
1
    {
4566
1
        PyObject *type = state->pattern_type;
4567
1
        Py_INCREF(type);
4568
1
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4569
1
                                    0;
4570
1
        Py_DECREF(type);
4571
1
        if (!cond) {
4572
0
            Py_DECREF(match_case_annotations);
4573
0
            return 0;
4574
0
        }
4575
1
    }
4576
1
    {
4577
1
        PyObject *type = state->expr_type;
4578
1
        type = _Py_union_type_or(type, Py_None);
4579
1
        cond = type != NULL;
4580
1
        if (!cond) {
4581
0
            Py_DECREF(match_case_annotations);
4582
0
            return 0;
4583
0
        }
4584
1
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4585
1
        Py_DECREF(type);
4586
1
        if (!cond) {
4587
0
            Py_DECREF(match_case_annotations);
4588
0
            return 0;
4589
0
        }
4590
1
    }
4591
1
    {
4592
1
        PyObject *type = state->stmt_type;
4593
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4594
1
        cond = type != NULL;
4595
1
        if (!cond) {
4596
0
            Py_DECREF(match_case_annotations);
4597
0
            return 0;
4598
0
        }
4599
1
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4600
1
        Py_DECREF(type);
4601
1
        if (!cond) {
4602
0
            Py_DECREF(match_case_annotations);
4603
0
            return 0;
4604
0
        }
4605
1
    }
4606
1
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4607
1
                                  match_case_annotations) == 0;
4608
1
    if (!cond) {
4609
0
        Py_DECREF(match_case_annotations);
4610
0
        return 0;
4611
0
    }
4612
1
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4613
1
                                  match_case_annotations) == 0;
4614
1
    if (!cond) {
4615
0
        Py_DECREF(match_case_annotations);
4616
0
        return 0;
4617
0
    }
4618
1
    Py_DECREF(match_case_annotations);
4619
1
    PyObject *MatchValue_annotations = PyDict_New();
4620
1
    if (!MatchValue_annotations) return 0;
4621
1
    {
4622
1
        PyObject *type = state->expr_type;
4623
1
        Py_INCREF(type);
4624
1
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4625
1
        Py_DECREF(type);
4626
1
        if (!cond) {
4627
0
            Py_DECREF(MatchValue_annotations);
4628
0
            return 0;
4629
0
        }
4630
1
    }
4631
1
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4632
1
                                  MatchValue_annotations) == 0;
4633
1
    if (!cond) {
4634
0
        Py_DECREF(MatchValue_annotations);
4635
0
        return 0;
4636
0
    }
4637
1
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4638
1
                                  MatchValue_annotations) == 0;
4639
1
    if (!cond) {
4640
0
        Py_DECREF(MatchValue_annotations);
4641
0
        return 0;
4642
0
    }
4643
1
    Py_DECREF(MatchValue_annotations);
4644
1
    PyObject *MatchSingleton_annotations = PyDict_New();
4645
1
    if (!MatchSingleton_annotations) return 0;
4646
1
    {
4647
1
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4648
1
        Py_INCREF(type);
4649
1
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4650
1
                                    == 0;
4651
1
        Py_DECREF(type);
4652
1
        if (!cond) {
4653
0
            Py_DECREF(MatchSingleton_annotations);
4654
0
            return 0;
4655
0
        }
4656
1
    }
4657
1
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4658
1
                                  MatchSingleton_annotations) == 0;
4659
1
    if (!cond) {
4660
0
        Py_DECREF(MatchSingleton_annotations);
4661
0
        return 0;
4662
0
    }
4663
1
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4664
1
                                  "__annotations__",
4665
1
                                  MatchSingleton_annotations) == 0;
4666
1
    if (!cond) {
4667
0
        Py_DECREF(MatchSingleton_annotations);
4668
0
        return 0;
4669
0
    }
4670
1
    Py_DECREF(MatchSingleton_annotations);
4671
1
    PyObject *MatchSequence_annotations = PyDict_New();
4672
1
    if (!MatchSequence_annotations) return 0;
4673
1
    {
4674
1
        PyObject *type = state->pattern_type;
4675
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4676
1
        cond = type != NULL;
4677
1
        if (!cond) {
4678
0
            Py_DECREF(MatchSequence_annotations);
4679
0
            return 0;
4680
0
        }
4681
1
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4682
1
                                    type) == 0;
4683
1
        Py_DECREF(type);
4684
1
        if (!cond) {
4685
0
            Py_DECREF(MatchSequence_annotations);
4686
0
            return 0;
4687
0
        }
4688
1
    }
4689
1
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4690
1
                                  MatchSequence_annotations) == 0;
4691
1
    if (!cond) {
4692
0
        Py_DECREF(MatchSequence_annotations);
4693
0
        return 0;
4694
0
    }
4695
1
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4696
1
                                  MatchSequence_annotations) == 0;
4697
1
    if (!cond) {
4698
0
        Py_DECREF(MatchSequence_annotations);
4699
0
        return 0;
4700
0
    }
4701
1
    Py_DECREF(MatchSequence_annotations);
4702
1
    PyObject *MatchMapping_annotations = PyDict_New();
4703
1
    if (!MatchMapping_annotations) return 0;
4704
1
    {
4705
1
        PyObject *type = state->expr_type;
4706
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4707
1
        cond = type != NULL;
4708
1
        if (!cond) {
4709
0
            Py_DECREF(MatchMapping_annotations);
4710
0
            return 0;
4711
0
        }
4712
1
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4713
1
                                    0;
4714
1
        Py_DECREF(type);
4715
1
        if (!cond) {
4716
0
            Py_DECREF(MatchMapping_annotations);
4717
0
            return 0;
4718
0
        }
4719
1
    }
4720
1
    {
4721
1
        PyObject *type = state->pattern_type;
4722
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4723
1
        cond = type != NULL;
4724
1
        if (!cond) {
4725
0
            Py_DECREF(MatchMapping_annotations);
4726
0
            return 0;
4727
0
        }
4728
1
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4729
1
                                    == 0;
4730
1
        Py_DECREF(type);
4731
1
        if (!cond) {
4732
0
            Py_DECREF(MatchMapping_annotations);
4733
0
            return 0;
4734
0
        }
4735
1
    }
4736
1
    {
4737
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4738
1
        type = _Py_union_type_or(type, Py_None);
4739
1
        cond = type != NULL;
4740
1
        if (!cond) {
4741
0
            Py_DECREF(MatchMapping_annotations);
4742
0
            return 0;
4743
0
        }
4744
1
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4745
1
                                    0;
4746
1
        Py_DECREF(type);
4747
1
        if (!cond) {
4748
0
            Py_DECREF(MatchMapping_annotations);
4749
0
            return 0;
4750
0
        }
4751
1
    }
4752
1
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4753
1
                                  MatchMapping_annotations) == 0;
4754
1
    if (!cond) {
4755
0
        Py_DECREF(MatchMapping_annotations);
4756
0
        return 0;
4757
0
    }
4758
1
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4759
1
                                  MatchMapping_annotations) == 0;
4760
1
    if (!cond) {
4761
0
        Py_DECREF(MatchMapping_annotations);
4762
0
        return 0;
4763
0
    }
4764
1
    Py_DECREF(MatchMapping_annotations);
4765
1
    PyObject *MatchClass_annotations = PyDict_New();
4766
1
    if (!MatchClass_annotations) return 0;
4767
1
    {
4768
1
        PyObject *type = state->expr_type;
4769
1
        Py_INCREF(type);
4770
1
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4771
1
        Py_DECREF(type);
4772
1
        if (!cond) {
4773
0
            Py_DECREF(MatchClass_annotations);
4774
0
            return 0;
4775
0
        }
4776
1
    }
4777
1
    {
4778
1
        PyObject *type = state->pattern_type;
4779
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4780
1
        cond = type != NULL;
4781
1
        if (!cond) {
4782
0
            Py_DECREF(MatchClass_annotations);
4783
0
            return 0;
4784
0
        }
4785
1
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4786
1
                                    == 0;
4787
1
        Py_DECREF(type);
4788
1
        if (!cond) {
4789
0
            Py_DECREF(MatchClass_annotations);
4790
0
            return 0;
4791
0
        }
4792
1
    }
4793
1
    {
4794
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4795
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4796
1
        cond = type != NULL;
4797
1
        if (!cond) {
4798
0
            Py_DECREF(MatchClass_annotations);
4799
0
            return 0;
4800
0
        }
4801
1
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4802
1
                                    == 0;
4803
1
        Py_DECREF(type);
4804
1
        if (!cond) {
4805
0
            Py_DECREF(MatchClass_annotations);
4806
0
            return 0;
4807
0
        }
4808
1
    }
4809
1
    {
4810
1
        PyObject *type = state->pattern_type;
4811
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4812
1
        cond = type != NULL;
4813
1
        if (!cond) {
4814
0
            Py_DECREF(MatchClass_annotations);
4815
0
            return 0;
4816
0
        }
4817
1
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4818
1
                                    type) == 0;
4819
1
        Py_DECREF(type);
4820
1
        if (!cond) {
4821
0
            Py_DECREF(MatchClass_annotations);
4822
0
            return 0;
4823
0
        }
4824
1
    }
4825
1
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4826
1
                                  MatchClass_annotations) == 0;
4827
1
    if (!cond) {
4828
0
        Py_DECREF(MatchClass_annotations);
4829
0
        return 0;
4830
0
    }
4831
1
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4832
1
                                  MatchClass_annotations) == 0;
4833
1
    if (!cond) {
4834
0
        Py_DECREF(MatchClass_annotations);
4835
0
        return 0;
4836
0
    }
4837
1
    Py_DECREF(MatchClass_annotations);
4838
1
    PyObject *MatchStar_annotations = PyDict_New();
4839
1
    if (!MatchStar_annotations) return 0;
4840
1
    {
4841
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4842
1
        type = _Py_union_type_or(type, Py_None);
4843
1
        cond = type != NULL;
4844
1
        if (!cond) {
4845
0
            Py_DECREF(MatchStar_annotations);
4846
0
            return 0;
4847
0
        }
4848
1
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4849
1
        Py_DECREF(type);
4850
1
        if (!cond) {
4851
0
            Py_DECREF(MatchStar_annotations);
4852
0
            return 0;
4853
0
        }
4854
1
    }
4855
1
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4856
1
                                  MatchStar_annotations) == 0;
4857
1
    if (!cond) {
4858
0
        Py_DECREF(MatchStar_annotations);
4859
0
        return 0;
4860
0
    }
4861
1
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4862
1
                                  MatchStar_annotations) == 0;
4863
1
    if (!cond) {
4864
0
        Py_DECREF(MatchStar_annotations);
4865
0
        return 0;
4866
0
    }
4867
1
    Py_DECREF(MatchStar_annotations);
4868
1
    PyObject *MatchAs_annotations = PyDict_New();
4869
1
    if (!MatchAs_annotations) return 0;
4870
1
    {
4871
1
        PyObject *type = state->pattern_type;
4872
1
        type = _Py_union_type_or(type, Py_None);
4873
1
        cond = type != NULL;
4874
1
        if (!cond) {
4875
0
            Py_DECREF(MatchAs_annotations);
4876
0
            return 0;
4877
0
        }
4878
1
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4879
1
        Py_DECREF(type);
4880
1
        if (!cond) {
4881
0
            Py_DECREF(MatchAs_annotations);
4882
0
            return 0;
4883
0
        }
4884
1
    }
4885
1
    {
4886
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4887
1
        type = _Py_union_type_or(type, Py_None);
4888
1
        cond = type != NULL;
4889
1
        if (!cond) {
4890
0
            Py_DECREF(MatchAs_annotations);
4891
0
            return 0;
4892
0
        }
4893
1
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4894
1
        Py_DECREF(type);
4895
1
        if (!cond) {
4896
0
            Py_DECREF(MatchAs_annotations);
4897
0
            return 0;
4898
0
        }
4899
1
    }
4900
1
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4901
1
                                  MatchAs_annotations) == 0;
4902
1
    if (!cond) {
4903
0
        Py_DECREF(MatchAs_annotations);
4904
0
        return 0;
4905
0
    }
4906
1
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4907
1
                                  MatchAs_annotations) == 0;
4908
1
    if (!cond) {
4909
0
        Py_DECREF(MatchAs_annotations);
4910
0
        return 0;
4911
0
    }
4912
1
    Py_DECREF(MatchAs_annotations);
4913
1
    PyObject *MatchOr_annotations = PyDict_New();
4914
1
    if (!MatchOr_annotations) return 0;
4915
1
    {
4916
1
        PyObject *type = state->pattern_type;
4917
1
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4918
1
        cond = type != NULL;
4919
1
        if (!cond) {
4920
0
            Py_DECREF(MatchOr_annotations);
4921
0
            return 0;
4922
0
        }
4923
1
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4924
1
        Py_DECREF(type);
4925
1
        if (!cond) {
4926
0
            Py_DECREF(MatchOr_annotations);
4927
0
            return 0;
4928
0
        }
4929
1
    }
4930
1
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4931
1
                                  MatchOr_annotations) == 0;
4932
1
    if (!cond) {
4933
0
        Py_DECREF(MatchOr_annotations);
4934
0
        return 0;
4935
0
    }
4936
1
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4937
1
                                  MatchOr_annotations) == 0;
4938
1
    if (!cond) {
4939
0
        Py_DECREF(MatchOr_annotations);
4940
0
        return 0;
4941
0
    }
4942
1
    Py_DECREF(MatchOr_annotations);
4943
1
    PyObject *TypeIgnore_annotations = PyDict_New();
4944
1
    if (!TypeIgnore_annotations) return 0;
4945
1
    {
4946
1
        PyObject *type = (PyObject *)&PyLong_Type;
4947
1
        Py_INCREF(type);
4948
1
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4949
1
                                    0;
4950
1
        Py_DECREF(type);
4951
1
        if (!cond) {
4952
0
            Py_DECREF(TypeIgnore_annotations);
4953
0
            return 0;
4954
0
        }
4955
1
    }
4956
1
    {
4957
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4958
1
        Py_INCREF(type);
4959
1
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
4960
1
        Py_DECREF(type);
4961
1
        if (!cond) {
4962
0
            Py_DECREF(TypeIgnore_annotations);
4963
0
            return 0;
4964
0
        }
4965
1
    }
4966
1
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
4967
1
                                  TypeIgnore_annotations) == 0;
4968
1
    if (!cond) {
4969
0
        Py_DECREF(TypeIgnore_annotations);
4970
0
        return 0;
4971
0
    }
4972
1
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
4973
1
                                  TypeIgnore_annotations) == 0;
4974
1
    if (!cond) {
4975
0
        Py_DECREF(TypeIgnore_annotations);
4976
0
        return 0;
4977
0
    }
4978
1
    Py_DECREF(TypeIgnore_annotations);
4979
1
    PyObject *TypeVar_annotations = PyDict_New();
4980
1
    if (!TypeVar_annotations) return 0;
4981
1
    {
4982
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
4983
1
        Py_INCREF(type);
4984
1
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
4985
1
        Py_DECREF(type);
4986
1
        if (!cond) {
4987
0
            Py_DECREF(TypeVar_annotations);
4988
0
            return 0;
4989
0
        }
4990
1
    }
4991
1
    {
4992
1
        PyObject *type = state->expr_type;
4993
1
        type = _Py_union_type_or(type, Py_None);
4994
1
        cond = type != NULL;
4995
1
        if (!cond) {
4996
0
            Py_DECREF(TypeVar_annotations);
4997
0
            return 0;
4998
0
        }
4999
1
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5000
1
        Py_DECREF(type);
5001
1
        if (!cond) {
5002
0
            Py_DECREF(TypeVar_annotations);
5003
0
            return 0;
5004
0
        }
5005
1
    }
5006
1
    {
5007
1
        PyObject *type = state->expr_type;
5008
1
        type = _Py_union_type_or(type, Py_None);
5009
1
        cond = type != NULL;
5010
1
        if (!cond) {
5011
0
            Py_DECREF(TypeVar_annotations);
5012
0
            return 0;
5013
0
        }
5014
1
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5015
1
                                    == 0;
5016
1
        Py_DECREF(type);
5017
1
        if (!cond) {
5018
0
            Py_DECREF(TypeVar_annotations);
5019
0
            return 0;
5020
0
        }
5021
1
    }
5022
1
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5023
1
                                  TypeVar_annotations) == 0;
5024
1
    if (!cond) {
5025
0
        Py_DECREF(TypeVar_annotations);
5026
0
        return 0;
5027
0
    }
5028
1
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5029
1
                                  TypeVar_annotations) == 0;
5030
1
    if (!cond) {
5031
0
        Py_DECREF(TypeVar_annotations);
5032
0
        return 0;
5033
0
    }
5034
1
    Py_DECREF(TypeVar_annotations);
5035
1
    PyObject *ParamSpec_annotations = PyDict_New();
5036
1
    if (!ParamSpec_annotations) return 0;
5037
1
    {
5038
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
5039
1
        Py_INCREF(type);
5040
1
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5041
1
        Py_DECREF(type);
5042
1
        if (!cond) {
5043
0
            Py_DECREF(ParamSpec_annotations);
5044
0
            return 0;
5045
0
        }
5046
1
    }
5047
1
    {
5048
1
        PyObject *type = state->expr_type;
5049
1
        type = _Py_union_type_or(type, Py_None);
5050
1
        cond = type != NULL;
5051
1
        if (!cond) {
5052
0
            Py_DECREF(ParamSpec_annotations);
5053
0
            return 0;
5054
0
        }
5055
1
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5056
1
                                    type) == 0;
5057
1
        Py_DECREF(type);
5058
1
        if (!cond) {
5059
0
            Py_DECREF(ParamSpec_annotations);
5060
0
            return 0;
5061
0
        }
5062
1
    }
5063
1
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5064
1
                                  ParamSpec_annotations) == 0;
5065
1
    if (!cond) {
5066
0
        Py_DECREF(ParamSpec_annotations);
5067
0
        return 0;
5068
0
    }
5069
1
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5070
1
                                  ParamSpec_annotations) == 0;
5071
1
    if (!cond) {
5072
0
        Py_DECREF(ParamSpec_annotations);
5073
0
        return 0;
5074
0
    }
5075
1
    Py_DECREF(ParamSpec_annotations);
5076
1
    PyObject *TypeVarTuple_annotations = PyDict_New();
5077
1
    if (!TypeVarTuple_annotations) return 0;
5078
1
    {
5079
1
        PyObject *type = (PyObject *)&PyUnicode_Type;
5080
1
        Py_INCREF(type);
5081
1
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5082
1
                                    0;
5083
1
        Py_DECREF(type);
5084
1
        if (!cond) {
5085
0
            Py_DECREF(TypeVarTuple_annotations);
5086
0
            return 0;
5087
0
        }
5088
1
    }
5089
1
    {
5090
1
        PyObject *type = state->expr_type;
5091
1
        type = _Py_union_type_or(type, Py_None);
5092
1
        cond = type != NULL;
5093
1
        if (!cond) {
5094
0
            Py_DECREF(TypeVarTuple_annotations);
5095
0
            return 0;
5096
0
        }
5097
1
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5098
1
                                    type) == 0;
5099
1
        Py_DECREF(type);
5100
1
        if (!cond) {
5101
0
            Py_DECREF(TypeVarTuple_annotations);
5102
0
            return 0;
5103
0
        }
5104
1
    }
5105
1
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5106
1
                                  TypeVarTuple_annotations) == 0;
5107
1
    if (!cond) {
5108
0
        Py_DECREF(TypeVarTuple_annotations);
5109
0
        return 0;
5110
0
    }
5111
1
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5112
1
                                  TypeVarTuple_annotations) == 0;
5113
1
    if (!cond) {
5114
0
        Py_DECREF(TypeVarTuple_annotations);
5115
0
        return 0;
5116
0
    }
5117
1
    Py_DECREF(TypeVarTuple_annotations);
5118
5119
1
    return 1;
5120
1
}
5121
5122
5123
5124
typedef struct {
5125
    PyObject_HEAD
5126
    PyObject *dict;
5127
} AST_object;
5128
5129
static void
5130
ast_dealloc(PyObject *op)
5131
24
{
5132
24
    AST_object *self = (AST_object*)op;
5133
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5134
24
    PyTypeObject *tp = Py_TYPE(self);
5135
24
    PyObject_GC_UnTrack(self);
5136
24
    Py_CLEAR(self->dict);
5137
24
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5138
24
    assert(free_func != NULL);
5139
24
    free_func(self);
5140
24
    Py_DECREF(tp);
5141
24
}
5142
5143
static int
5144
ast_traverse(PyObject *op, visitproc visit, void *arg)
5145
0
{
5146
0
    AST_object *self = (AST_object*)op;
5147
0
    Py_VISIT(Py_TYPE(self));
5148
0
    Py_VISIT(self->dict);
5149
0
    return 0;
5150
0
}
5151
5152
static int
5153
ast_clear(PyObject *op)
5154
0
{
5155
0
    AST_object *self = (AST_object*)op;
5156
0
    Py_CLEAR(self->dict);
5157
0
    return 0;
5158
0
}
5159
5160
static int
5161
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
5162
0
{
5163
0
    struct ast_state *state = get_ast_state();
5164
0
    if (state == NULL) {
5165
0
        return -1;
5166
0
    }
5167
5168
0
    Py_ssize_t i, numfields = 0;
5169
0
    int res = -1;
5170
0
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5171
5172
0
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5173
0
    if (fields == NULL) {
5174
0
        goto cleanup;
5175
0
    }
5176
5177
0
    numfields = PySequence_Size(fields);
5178
0
    if (numfields == -1) {
5179
0
        goto cleanup;
5180
0
    }
5181
0
    remaining_fields = PySet_New(fields);
5182
0
    if (remaining_fields == NULL) {
5183
0
        goto cleanup;
5184
0
    }
5185
5186
0
    res = 0; /* if no error occurs, this stays 0 to the end */
5187
0
    if (numfields < PyTuple_GET_SIZE(args)) {
5188
0
        PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
5189
0
                     "%zd positional argument%s",
5190
0
                     _PyType_Name(Py_TYPE(self)),
5191
0
                     numfields, numfields == 1 ? "" : "s");
5192
0
        res = -1;
5193
0
        goto cleanup;
5194
0
    }
5195
0
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5196
        /* cannot be reached when fields is NULL */
5197
0
        PyObject *name = PySequence_GetItem(fields, i);
5198
0
        if (!name) {
5199
0
            res = -1;
5200
0
            goto cleanup;
5201
0
        }
5202
0
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5203
0
        if (PySet_Discard(remaining_fields, name) < 0) {
5204
0
            res = -1;
5205
0
            Py_DECREF(name);
5206
0
            goto cleanup;
5207
0
        }
5208
0
        Py_DECREF(name);
5209
0
        if (res < 0) {
5210
0
            goto cleanup;
5211
0
        }
5212
0
    }
5213
0
    if (kw) {
5214
0
        i = 0;  /* needed by PyDict_Next */
5215
0
        while (PyDict_Next(kw, &i, &key, &value)) {
5216
0
            int contains = PySequence_Contains(fields, key);
5217
0
            if (contains == -1) {
5218
0
                res = -1;
5219
0
                goto cleanup;
5220
0
            }
5221
0
            else if (contains == 1) {
5222
0
                int p = PySet_Discard(remaining_fields, key);
5223
0
                if (p == -1) {
5224
0
                    res = -1;
5225
0
                    goto cleanup;
5226
0
                }
5227
0
                if (p == 0) {
5228
0
                    PyErr_Format(PyExc_TypeError,
5229
0
                        "%.400s got multiple values for argument '%U'",
5230
0
                        Py_TYPE(self)->tp_name, key);
5231
0
                    res = -1;
5232
0
                    goto cleanup;
5233
0
                }
5234
0
            }
5235
0
            else {
5236
                // Lazily initialize "attributes"
5237
0
                if (attributes == NULL) {
5238
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5239
0
                    if (attributes == NULL) {
5240
0
                        res = -1;
5241
0
                        goto cleanup;
5242
0
                    }
5243
0
                }
5244
0
                int contains = PySequence_Contains(attributes, key);
5245
0
                if (contains == -1) {
5246
0
                    res = -1;
5247
0
                    goto cleanup;
5248
0
                }
5249
0
                else if (contains == 0) {
5250
0
                    if (PyErr_WarnFormat(
5251
0
                        PyExc_DeprecationWarning, 1,
5252
0
                        "%.400s.__init__ got an unexpected keyword argument '%U'. "
5253
0
                        "Support for arbitrary keyword arguments is deprecated "
5254
0
                        "and will be removed in Python 3.15.",
5255
0
                        Py_TYPE(self)->tp_name, key
5256
0
                    ) < 0) {
5257
0
                        res = -1;
5258
0
                        goto cleanup;
5259
0
                    }
5260
0
                }
5261
0
            }
5262
0
            res = PyObject_SetAttr(self, key, value);
5263
0
            if (res < 0) {
5264
0
                goto cleanup;
5265
0
            }
5266
0
        }
5267
0
    }
5268
0
    Py_ssize_t size = PySet_Size(remaining_fields);
5269
0
    PyObject *field_types = NULL, *remaining_list = NULL;
5270
0
    if (size > 0) {
5271
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5272
0
                                     &field_types) < 0) {
5273
0
            res = -1;
5274
0
            goto cleanup;
5275
0
        }
5276
0
        if (field_types == NULL) {
5277
            // Probably a user-defined subclass of AST that lacks _field_types.
5278
            // This will continue to work as it did before 3.13; i.e., attributes
5279
            // that are not passed in simply do not exist on the instance.
5280
0
            goto cleanup;
5281
0
        }
5282
0
        remaining_list = PySequence_List(remaining_fields);
5283
0
        if (!remaining_list) {
5284
0
            goto set_remaining_cleanup;
5285
0
        }
5286
0
        for (Py_ssize_t i = 0; i < size; i++) {
5287
0
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5288
0
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5289
0
            if (!type) {
5290
0
                if (PyErr_Occurred()) {
5291
0
                    goto set_remaining_cleanup;
5292
0
                }
5293
0
                else {
5294
0
                    if (PyErr_WarnFormat(
5295
0
                        PyExc_DeprecationWarning, 1,
5296
0
                        "Field %R is missing from %.400s._field_types. "
5297
0
                        "This will become an error in Python 3.15.",
5298
0
                        name, Py_TYPE(self)->tp_name
5299
0
                    ) < 0) {
5300
0
                        goto set_remaining_cleanup;
5301
0
                    }
5302
0
                }
5303
0
            }
5304
0
            else if (_PyUnion_Check(type)) {
5305
                // optional field
5306
                // do nothing, we'll have set a None default on the class
5307
0
            }
5308
0
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5309
                // list field
5310
0
                PyObject *empty = PyList_New(0);
5311
0
                if (!empty) {
5312
0
                    goto set_remaining_cleanup;
5313
0
                }
5314
0
                res = PyObject_SetAttr(self, name, empty);
5315
0
                Py_DECREF(empty);
5316
0
                if (res < 0) {
5317
0
                    goto set_remaining_cleanup;
5318
0
                }
5319
0
            }
5320
0
            else if (type == state->expr_context_type) {
5321
                // special case for expr_context: default to Load()
5322
0
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5323
0
                if (res < 0) {
5324
0
                    goto set_remaining_cleanup;
5325
0
                }
5326
0
            }
5327
0
            else {
5328
                // simple field (e.g., identifier)
5329
0
                if (PyErr_WarnFormat(
5330
0
                    PyExc_DeprecationWarning, 1,
5331
0
                    "%.400s.__init__ missing 1 required positional argument: %R. "
5332
0
                    "This will become an error in Python 3.15.",
5333
0
                    Py_TYPE(self)->tp_name, name
5334
0
                ) < 0) {
5335
0
                    goto set_remaining_cleanup;
5336
0
                }
5337
0
            }
5338
0
        }
5339
0
        Py_DECREF(remaining_list);
5340
0
        Py_DECREF(field_types);
5341
0
    }
5342
0
  cleanup:
5343
0
    Py_XDECREF(attributes);
5344
0
    Py_XDECREF(fields);
5345
0
    Py_XDECREF(remaining_fields);
5346
0
    return res;
5347
0
  set_remaining_cleanup:
5348
0
    Py_XDECREF(remaining_list);
5349
0
    Py_XDECREF(field_types);
5350
0
    res = -1;
5351
0
    goto cleanup;
5352
0
}
5353
5354
/* Pickling support */
5355
static PyObject *
5356
ast_type_reduce(PyObject *self, PyObject *unused)
5357
0
{
5358
0
    struct ast_state *state = get_ast_state();
5359
0
    if (state == NULL) {
5360
0
        return NULL;
5361
0
    }
5362
5363
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5364
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5365
0
        return NULL;
5366
0
    }
5367
0
    PyObject *result = NULL;
5368
0
    if (dict) {
5369
        // Unpickling (or copying) works as follows:
5370
        // - Construct the object with only positional arguments
5371
        // - Set the fields from the dict
5372
        // We have two constraints:
5373
        // - We must set all the required fields in the initial constructor call,
5374
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5375
        // - We must not include child nodes in the positional args, because
5376
        //   that may trigger runaway recursion during copying (gh-120108).
5377
        // To satisfy both constraints, we set all the fields to None in the
5378
        // initial list of positional args, and then set the fields from the dict.
5379
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5380
0
            goto cleanup;
5381
0
        }
5382
0
        if (fields) {
5383
0
            Py_ssize_t numfields = PySequence_Size(fields);
5384
0
            if (numfields == -1) {
5385
0
                Py_DECREF(dict);
5386
0
                goto cleanup;
5387
0
            }
5388
0
            positional_args = PyList_New(0);
5389
0
            if (!positional_args) {
5390
0
                goto cleanup;
5391
0
            }
5392
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5393
0
                PyObject *name = PySequence_GetItem(fields, i);
5394
0
                if (!name) {
5395
0
                    goto cleanup;
5396
0
                }
5397
0
                PyObject *value;
5398
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5399
0
                Py_DECREF(name);
5400
0
                if (rc < 0) {
5401
0
                    goto cleanup;
5402
0
                }
5403
0
                if (!value) {
5404
0
                    break;
5405
0
                }
5406
0
                rc = PyList_Append(positional_args, Py_None);
5407
0
                Py_DECREF(value);
5408
0
                if (rc < 0) {
5409
0
                    goto cleanup;
5410
0
                }
5411
0
            }
5412
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5413
0
            if (!args_tuple) {
5414
0
                goto cleanup;
5415
0
            }
5416
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5417
0
        }
5418
0
        else {
5419
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5420
0
        }
5421
0
    }
5422
0
    else {
5423
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5424
0
    }
5425
0
cleanup:
5426
0
    Py_XDECREF(fields);
5427
0
    Py_XDECREF(positional_args);
5428
0
    return result;
5429
0
}
5430
5431
/*
5432
 * Perform the following validations:
5433
 *
5434
 *   - All keyword arguments are known 'fields' or 'attributes'.
5435
 *   - No field or attribute would be left unfilled after copy.replace().
5436
 *
5437
 * On success, this returns 1. Otherwise, set a TypeError
5438
 * exception and returns -1 (no exception is set if some
5439
 * other internal errors occur).
5440
 *
5441
 * Parameters
5442
 *
5443
 *      self          The AST node instance.
5444
 *      dict          The AST node instance dictionary (self.__dict__).
5445
 *      fields        The list of fields (self._fields).
5446
 *      attributes    The list of attributes (self._attributes).
5447
 *      kwargs        Keyword arguments passed to ast_type_replace().
5448
 *
5449
 * The 'dict', 'fields', 'attributes' and 'kwargs' arguments can be NULL.
5450
 *
5451
 * Note: this function can be removed in 3.15 since the verification
5452
 *       will be done inside the constructor.
5453
 */
5454
static inline int
5455
ast_type_replace_check(PyObject *self,
5456
                       PyObject *dict,
5457
                       PyObject *fields,
5458
                       PyObject *attributes,
5459
                       PyObject *kwargs)
5460
0
{
5461
    // While it is possible to make some fast paths that would avoid
5462
    // allocating objects on the stack, this would cost us readability.
5463
    // For instance, if 'fields' and 'attributes' are both empty, and
5464
    // 'kwargs' is not empty, we could raise a TypeError immediately.
5465
0
    PyObject *expecting = PySet_New(fields);
5466
0
    if (expecting == NULL) {
5467
0
        return -1;
5468
0
    }
5469
0
    if (attributes) {
5470
0
        if (_PySet_Update(expecting, attributes) < 0) {
5471
0
            Py_DECREF(expecting);
5472
0
            return -1;
5473
0
        }
5474
0
    }
5475
    // Any keyword argument that is neither a field nor attribute is rejected.
5476
    // We first need to check whether a keyword argument is accepted or not.
5477
    // If all keyword arguments are accepted, we compute the required fields
5478
    // and attributes. A field or attribute is not needed if:
5479
    //
5480
    //  1) it is given in 'kwargs', or
5481
    //  2) it already exists on 'self'.
5482
0
    if (kwargs) {
5483
0
        Py_ssize_t pos = 0;
5484
0
        PyObject *key, *value;
5485
0
        while (PyDict_Next(kwargs, &pos, &key, &value)) {
5486
0
            int rc = PySet_Discard(expecting, key);
5487
0
            if (rc < 0) {
5488
0
                Py_DECREF(expecting);
5489
0
                return -1;
5490
0
            }
5491
0
            if (rc == 0) {
5492
0
                PyErr_Format(PyExc_TypeError,
5493
0
                             "%.400s.__replace__ got an unexpected keyword "
5494
0
                             "argument '%U'.", Py_TYPE(self)->tp_name, key);
5495
0
                Py_DECREF(expecting);
5496
0
                return -1;
5497
0
            }
5498
0
        }
5499
0
    }
5500
    // check that the remaining fields or attributes would be filled
5501
0
    if (dict) {
5502
0
        Py_ssize_t pos = 0;
5503
0
        PyObject *key, *value;
5504
0
        while (PyDict_Next(dict, &pos, &key, &value)) {
5505
            // Mark fields or attributes that are found on the instance
5506
            // as non-mandatory. If they are not given in 'kwargs', they
5507
            // will be shallow-coied; otherwise, they would be replaced
5508
            // (not in this function).
5509
0
            if (PySet_Discard(expecting, key) < 0) {
5510
0
                Py_DECREF(expecting);
5511
0
                return -1;
5512
0
            }
5513
0
        }
5514
0
        if (attributes) {
5515
            // Some attributes may or may not be present at runtime.
5516
            // In particular, now that we checked whether 'kwargs'
5517
            // is correct or not, we allow any attribute to be missing.
5518
            //
5519
            // Note that fields must still be entirely determined when
5520
            // calling the constructor later.
5521
0
            PyObject *unused = PyObject_CallMethodOneArg(expecting,
5522
0
                                                         &_Py_ID(difference_update),
5523
0
                                                         attributes);
5524
0
            if (unused == NULL) {
5525
0
                Py_DECREF(expecting);
5526
0
                return -1;
5527
0
            }
5528
0
            Py_DECREF(unused);
5529
0
        }
5530
0
    }
5531
5532
    // Discard fields from 'expecting' that default to None
5533
0
    PyObject *field_types = NULL;
5534
0
    if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self),
5535
0
                                 &_Py_ID(_field_types),
5536
0
                                 &field_types) < 0)
5537
0
    {
5538
0
        Py_DECREF(expecting);
5539
0
        return -1;
5540
0
    }
5541
0
    if (field_types != NULL) {
5542
0
        Py_ssize_t pos = 0;
5543
0
        PyObject *field_name, *field_type;
5544
0
        while (PyDict_Next(field_types, &pos, &field_name, &field_type)) {
5545
0
            if (_PyUnion_Check(field_type)) {
5546
                // optional field
5547
0
                if (PySet_Discard(expecting, field_name) < 0) {
5548
0
                    Py_DECREF(expecting);
5549
0
                    Py_DECREF(field_types);
5550
0
                    return -1;
5551
0
                }
5552
0
            }
5553
0
        }
5554
0
        Py_DECREF(field_types);
5555
0
    }
5556
5557
    // Now 'expecting' contains the fields or attributes
5558
    // that would not be filled inside ast_type_replace().
5559
0
    Py_ssize_t m = PySet_GET_SIZE(expecting);
5560
0
    if (m > 0) {
5561
0
        PyObject *names = PyList_New(m);
5562
0
        if (names == NULL) {
5563
0
            Py_DECREF(expecting);
5564
0
            return -1;
5565
0
        }
5566
0
        Py_ssize_t i = 0, pos = 0;
5567
0
        PyObject *item;
5568
0
        Py_hash_t hash;
5569
0
        while (_PySet_NextEntry(expecting, &pos, &item, &hash)) {
5570
0
            PyObject *name = PyObject_Repr(item);
5571
0
            if (name == NULL) {
5572
0
                Py_DECREF(expecting);
5573
0
                Py_DECREF(names);
5574
0
                return -1;
5575
0
            }
5576
            // steal the reference 'name'
5577
0
            PyList_SET_ITEM(names, i++, name);
5578
0
        }
5579
0
        Py_DECREF(expecting);
5580
0
        if (PyList_Sort(names) < 0) {
5581
0
            Py_DECREF(names);
5582
0
            return -1;
5583
0
        }
5584
0
        PyObject *sep = PyUnicode_FromString(", ");
5585
0
        if (sep == NULL) {
5586
0
            Py_DECREF(names);
5587
0
            return -1;
5588
0
        }
5589
0
        PyObject *str_names = PyUnicode_Join(sep, names);
5590
0
        Py_DECREF(sep);
5591
0
        Py_DECREF(names);
5592
0
        if (str_names == NULL) {
5593
0
            return -1;
5594
0
        }
5595
0
        PyErr_Format(PyExc_TypeError,
5596
0
                     "%.400s.__replace__ missing %ld keyword argument%s: %U.",
5597
0
                     Py_TYPE(self)->tp_name, m, m == 1 ? "" : "s", str_names);
5598
0
        Py_DECREF(str_names);
5599
0
        return -1;
5600
0
    }
5601
0
    else {
5602
0
        Py_DECREF(expecting);
5603
0
        return 1;
5604
0
    }
5605
0
}
5606
5607
/*
5608
 * Python equivalent:
5609
 *
5610
 *   for key in keys:
5611
 *       if hasattr(self, key):
5612
 *           payload[key] = getattr(self, key)
5613
 *
5614
 * The 'keys' argument is a sequence corresponding to
5615
 * the '_fields' or the '_attributes' of an AST node.
5616
 *
5617
 * This returns -1 if an error occurs and 0 otherwise.
5618
 *
5619
 * Parameters
5620
 *
5621
 *      payload   A dictionary to fill.
5622
 *      keys      A sequence of keys or NULL for an empty sequence.
5623
 *      dict      The AST node instance dictionary (must not be NULL).
5624
 */
5625
static inline int
5626
ast_type_replace_update_payload(PyObject *payload,
5627
                                PyObject *keys,
5628
                                PyObject *dict)
5629
0
{
5630
0
    assert(dict != NULL);
5631
0
    if (keys == NULL) {
5632
0
        return 0;
5633
0
    }
5634
0
    Py_ssize_t n = PySequence_Size(keys);
5635
0
    if (n == -1) {
5636
0
        return -1;
5637
0
    }
5638
0
    for (Py_ssize_t i = 0; i < n; i++) {
5639
0
        PyObject *key = PySequence_GetItem(keys, i);
5640
0
        if (key == NULL) {
5641
0
            return -1;
5642
0
        }
5643
0
        PyObject *value;
5644
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5645
0
            Py_DECREF(key);
5646
0
            return -1;
5647
0
        }
5648
0
        if (value == NULL) {
5649
0
            Py_DECREF(key);
5650
            // If a field or attribute is not present at runtime, it should
5651
            // be explicitly given in 'kwargs'. If not, the constructor will
5652
            // issue a warning (which becomes an error in 3.15).
5653
0
            continue;
5654
0
        }
5655
0
        int rc = PyDict_SetItem(payload, key, value);
5656
0
        Py_DECREF(key);
5657
0
        Py_DECREF(value);
5658
0
        if (rc < 0) {
5659
0
            return -1;
5660
0
        }
5661
0
    }
5662
0
    return 0;
5663
0
}
5664
5665
/* copy.replace() support (shallow copy) */
5666
static PyObject *
5667
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5668
0
{
5669
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5670
0
        return NULL;
5671
0
    }
5672
5673
0
    struct ast_state *state = get_ast_state();
5674
0
    if (state == NULL) {
5675
0
        return NULL;
5676
0
    }
5677
5678
0
    PyObject *result = NULL;
5679
    // known AST class fields and attributes
5680
0
    PyObject *fields = NULL, *attributes = NULL;
5681
    // current instance dictionary
5682
0
    PyObject *dict = NULL;
5683
    // constructor positional and keyword arguments
5684
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5685
5686
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5687
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5688
0
        goto cleanup;
5689
0
    }
5690
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5691
0
        goto cleanup;
5692
0
    }
5693
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5694
0
        goto cleanup;
5695
0
    }
5696
0
    if (ast_type_replace_check(self, dict, fields, attributes, kwargs) < 0) {
5697
0
        goto cleanup;
5698
0
    }
5699
0
    empty_tuple = PyTuple_New(0);
5700
0
    if (empty_tuple == NULL) {
5701
0
        goto cleanup;
5702
0
    }
5703
0
    payload = PyDict_New();
5704
0
    if (payload == NULL) {
5705
0
        goto cleanup;
5706
0
    }
5707
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5708
        // copy the instance's fields (possibly NULL)
5709
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5710
0
            goto cleanup;
5711
0
        }
5712
        // copy the instance's attributes (possibly NULL)
5713
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5714
0
            goto cleanup;
5715
0
        }
5716
0
    }
5717
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5718
0
        goto cleanup;
5719
0
    }
5720
0
    result = PyObject_Call(type, empty_tuple, payload);
5721
0
cleanup:
5722
0
    Py_XDECREF(payload);
5723
0
    Py_XDECREF(empty_tuple);
5724
0
    Py_XDECREF(dict);
5725
0
    Py_XDECREF(attributes);
5726
0
    Py_XDECREF(fields);
5727
0
    return result;
5728
0
}
5729
5730
static PyMemberDef ast_type_members[] = {
5731
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5732
    {NULL}  /* Sentinel */
5733
};
5734
5735
static PyMethodDef ast_type_methods[] = {
5736
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5737
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5738
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5739
               "Return a copy of the AST node with new values "
5740
               "for the specified fields.")},
5741
    {NULL}
5742
};
5743
5744
static PyGetSetDef ast_type_getsets[] = {
5745
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5746
    {NULL}
5747
};
5748
5749
static PyObject *
5750
ast_repr_max_depth(AST_object *self, int depth);
5751
5752
/* Format list and tuple properties of AST nodes.
5753
   Note that, only the first and last elements are shown.
5754
   Anything in between is represented with an ellipsis ('...').
5755
   For example, the list [1, 2, 3] is formatted as
5756
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5757
static PyObject *
5758
ast_repr_list(PyObject *list, int depth)
5759
0
{
5760
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5761
5762
0
    struct ast_state *state = get_ast_state();
5763
0
    if (state == NULL) {
5764
0
        return NULL;
5765
0
    }
5766
5767
0
    Py_ssize_t length = PySequence_Size(list);
5768
0
    if (length < 0) {
5769
0
        return NULL;
5770
0
    }
5771
0
    else if (length == 0) {
5772
0
        return PyObject_Repr(list);
5773
0
    }
5774
5775
0
    PyObject *items[2] = {NULL, NULL};
5776
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5777
0
    if (writer == NULL) {
5778
0
        goto error;
5779
0
    }
5780
5781
0
    items[0] = PySequence_GetItem(list, 0);
5782
0
    if (!items[0]) {
5783
0
        goto error;
5784
0
    }
5785
0
    if (length > 1) {
5786
0
        items[1] = PySequence_GetItem(list, length - 1);
5787
0
        if (!items[1]) {
5788
0
            goto error;
5789
0
        }
5790
0
    }
5791
5792
0
    bool is_list = PyList_Check(list);
5793
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5794
0
        goto error;
5795
0
    }
5796
5797
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5798
0
        if (i > 0) {
5799
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5800
0
                goto error;
5801
0
            }
5802
0
        }
5803
5804
0
        PyObject *item = items[i];
5805
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5806
0
            PyObject *item_repr;
5807
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5808
0
            if (!item_repr) {
5809
0
                goto error;
5810
0
            }
5811
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5812
0
                Py_DECREF(item_repr);
5813
0
                goto error;
5814
0
            }
5815
0
            Py_DECREF(item_repr);
5816
0
        } else {
5817
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5818
0
                goto error;
5819
0
            }
5820
0
        }
5821
5822
0
        if (i == 0 && length > 2) {
5823
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5824
0
                goto error;
5825
0
            }
5826
0
        }
5827
0
    }
5828
5829
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5830
0
        goto error;
5831
0
    }
5832
5833
0
    Py_XDECREF(items[0]);
5834
0
    Py_XDECREF(items[1]);
5835
0
    return PyUnicodeWriter_Finish(writer);
5836
5837
0
error:
5838
0
    Py_XDECREF(items[0]);
5839
0
    Py_XDECREF(items[1]);
5840
0
    PyUnicodeWriter_Discard(writer);
5841
0
    return NULL;
5842
0
}
5843
5844
static PyObject *
5845
ast_repr_max_depth(AST_object *self, int depth)
5846
28
{
5847
28
    struct ast_state *state = get_ast_state();
5848
28
    if (state == NULL) {
5849
0
        return NULL;
5850
0
    }
5851
5852
28
    if (depth <= 0) {
5853
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5854
0
    }
5855
5856
28
    int status = Py_ReprEnter((PyObject *)self);
5857
28
    if (status != 0) {
5858
0
        if (status < 0) {
5859
0
            return NULL;
5860
0
        }
5861
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5862
0
    }
5863
5864
28
    PyObject *fields;
5865
28
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5866
0
        Py_ReprLeave((PyObject *)self);
5867
0
        return NULL;
5868
0
    }
5869
5870
28
    Py_ssize_t numfields = PySequence_Size(fields);
5871
28
    if (numfields < 0) {
5872
0
        Py_ReprLeave((PyObject *)self);
5873
0
        Py_DECREF(fields);
5874
0
        return NULL;
5875
0
    }
5876
5877
28
    if (numfields == 0) {
5878
13
        Py_ReprLeave((PyObject *)self);
5879
13
        Py_DECREF(fields);
5880
13
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5881
13
    }
5882
5883
15
    const char* tp_name = Py_TYPE(self)->tp_name;
5884
15
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5885
15
    if (writer == NULL) {
5886
0
        goto error;
5887
0
    }
5888
5889
15
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5890
0
        goto error;
5891
0
    }
5892
15
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5893
0
        goto error;
5894
0
    }
5895
5896
49
    for (Py_ssize_t i = 0; i < numfields; i++) {
5897
34
        PyObject *name = PySequence_GetItem(fields, i);
5898
34
        if (!name) {
5899
0
            goto error;
5900
0
        }
5901
5902
34
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5903
34
        if (!value) {
5904
0
            Py_DECREF(name);
5905
0
            goto error;
5906
0
        }
5907
5908
34
        PyObject *value_repr;
5909
34
        if (PyList_Check(value) || PyTuple_Check(value)) {
5910
0
            value_repr = ast_repr_list(value, depth);
5911
0
        }
5912
34
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5913
21
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5914
21
        }
5915
13
        else {
5916
13
            value_repr = PyObject_Repr(value);
5917
13
        }
5918
5919
34
        Py_DECREF(value);
5920
5921
34
        if (!value_repr) {
5922
0
            Py_DECREF(name);
5923
0
            goto error;
5924
0
        }
5925
5926
34
        if (i > 0) {
5927
19
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5928
0
                Py_DECREF(name);
5929
0
                Py_DECREF(value_repr);
5930
0
                goto error;
5931
0
            }
5932
19
        }
5933
34
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5934
0
            Py_DECREF(name);
5935
0
            Py_DECREF(value_repr);
5936
0
            goto error;
5937
0
        }
5938
5939
34
        Py_DECREF(name);
5940
5941
34
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5942
0
            Py_DECREF(value_repr);
5943
0
            goto error;
5944
0
        }
5945
34
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5946
0
            Py_DECREF(value_repr);
5947
0
            goto error;
5948
0
        }
5949
5950
34
        Py_DECREF(value_repr);
5951
34
    }
5952
5953
15
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5954
0
        goto error;
5955
0
    }
5956
15
    Py_ReprLeave((PyObject *)self);
5957
15
    Py_DECREF(fields);
5958
15
    return PyUnicodeWriter_Finish(writer);
5959
5960
0
error:
5961
0
    Py_ReprLeave((PyObject *)self);
5962
0
    Py_DECREF(fields);
5963
0
    PyUnicodeWriter_Discard(writer);
5964
0
    return NULL;
5965
15
}
5966
5967
static PyObject *
5968
ast_repr(PyObject *self)
5969
7
{
5970
7
    return ast_repr_max_depth((AST_object*)self, 3);
5971
7
}
5972
5973
static PyType_Slot AST_type_slots[] = {
5974
    {Py_tp_dealloc, ast_dealloc},
5975
    {Py_tp_repr, ast_repr},
5976
    {Py_tp_getattro, PyObject_GenericGetAttr},
5977
    {Py_tp_setattro, PyObject_GenericSetAttr},
5978
    {Py_tp_traverse, ast_traverse},
5979
    {Py_tp_clear, ast_clear},
5980
    {Py_tp_members, ast_type_members},
5981
    {Py_tp_methods, ast_type_methods},
5982
    {Py_tp_getset, ast_type_getsets},
5983
    {Py_tp_init, ast_type_init},
5984
    {Py_tp_alloc, PyType_GenericAlloc},
5985
    {Py_tp_new, PyType_GenericNew},
5986
    {Py_tp_free, PyObject_GC_Del},
5987
    {0, 0},
5988
};
5989
5990
static PyType_Spec AST_type_spec = {
5991
    "ast.AST",
5992
    sizeof(AST_object),
5993
    0,
5994
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
5995
    AST_type_slots
5996
};
5997
5998
static PyObject *
5999
make_type(struct ast_state *state, const char *type, PyObject* base,
6000
          const char* const* fields, int num_fields, const char *doc)
6001
125
{
6002
125
    PyObject *fnames, *result;
6003
125
    int i;
6004
125
    fnames = PyTuple_New(num_fields);
6005
125
    if (!fnames) return NULL;
6006
321
    for (i = 0; i < num_fields; i++) {
6007
196
        PyObject *field = PyUnicode_InternFromString(fields[i]);
6008
196
        if (!field) {
6009
0
            Py_DECREF(fnames);
6010
0
            return NULL;
6011
0
        }
6012
196
        PyTuple_SET_ITEM(fnames, i, field);
6013
196
    }
6014
125
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
6015
125
                    type, base,
6016
125
                    state->_fields, fnames,
6017
125
                    state->__match_args__, fnames,
6018
125
                    state->__module__,
6019
125
                    state->ast,
6020
125
                    state->__doc__, doc);
6021
125
    Py_DECREF(fnames);
6022
125
    return result;
6023
125
}
6024
6025
static int
6026
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
6027
19
{
6028
19
    int i, result;
6029
19
    PyObject *s, *l = PyTuple_New(num_fields);
6030
19
    if (!l)
6031
0
        return -1;
6032
51
    for (i = 0; i < num_fields; i++) {
6033
32
        s = PyUnicode_InternFromString(attrs[i]);
6034
32
        if (!s) {
6035
0
            Py_DECREF(l);
6036
0
            return -1;
6037
0
        }
6038
32
        PyTuple_SET_ITEM(l, i, s);
6039
32
    }
6040
19
    result = PyObject_SetAttr(type, state->_attributes, l);
6041
19
    Py_DECREF(l);
6042
19
    return result;
6043
19
}
6044
6045
/* Conversion AST -> Python */
6046
6047
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
6048
                              PyObject* (*func)(struct ast_state *state, void*))
6049
1
{
6050
1
    Py_ssize_t i, n = asdl_seq_LEN(seq);
6051
1
    PyObject *result = PyList_New(n);
6052
1
    PyObject *value;
6053
1
    if (!result)
6054
0
        return NULL;
6055
3
    for (i = 0; i < n; i++) {
6056
2
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6057
2
        if (!value) {
6058
0
            Py_DECREF(result);
6059
0
            return NULL;
6060
0
        }
6061
2
        PyList_SET_ITEM(result, i, value);
6062
2
    }
6063
1
    return result;
6064
1
}
6065
6066
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6067
14
{
6068
14
    PyObject *op = (PyObject*)o;
6069
14
    if (!op) {
6070
2
        op = Py_None;
6071
2
    }
6072
14
    return Py_NewRef(op);
6073
14
}
6074
2
#define ast2obj_constant ast2obj_object
6075
10
#define ast2obj_identifier ast2obj_object
6076
2
#define ast2obj_string ast2obj_object
6077
6078
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6079
68
{
6080
68
    return PyLong_FromLong(b);
6081
68
}
6082
6083
/* Conversion Python -> AST */
6084
6085
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6086
0
{
6087
0
    if (obj == Py_None)
6088
0
        obj = NULL;
6089
0
    if (obj) {
6090
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6091
0
            *out = NULL;
6092
0
            return -1;
6093
0
        }
6094
0
        *out = Py_NewRef(obj);
6095
0
    }
6096
0
    else {
6097
0
        *out = NULL;
6098
0
    }
6099
0
    return 0;
6100
0
}
6101
6102
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6103
0
{
6104
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6105
0
        *out = NULL;
6106
0
        return -1;
6107
0
    }
6108
0
    *out = Py_NewRef(obj);
6109
0
    return 0;
6110
0
}
6111
6112
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6113
0
{
6114
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6115
0
        PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
6116
0
        return -1;
6117
0
    }
6118
0
    return obj2ast_object(state, obj, out, arena);
6119
0
}
6120
6121
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6122
0
{
6123
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6124
0
        PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
6125
0
        return -1;
6126
0
    }
6127
0
    return obj2ast_object(state, obj, out, arena);
6128
0
}
6129
6130
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
6131
0
{
6132
0
    int i;
6133
0
    if (!PyLong_Check(obj)) {
6134
0
        PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
6135
0
        return -1;
6136
0
    }
6137
6138
0
    i = PyLong_AsInt(obj);
6139
0
    if (i == -1 && PyErr_Occurred())
6140
0
        return -1;
6141
0
    *out = i;
6142
0
    return 0;
6143
0
}
6144
6145
static int add_ast_fields(struct ast_state *state)
6146
1
{
6147
1
    PyObject *empty_tuple;
6148
1
    empty_tuple = PyTuple_New(0);
6149
1
    if (!empty_tuple ||
6150
1
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6151
1
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6152
1
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6153
0
        Py_XDECREF(empty_tuple);
6154
0
        return -1;
6155
0
    }
6156
1
    Py_DECREF(empty_tuple);
6157
1
    return 0;
6158
1
}
6159
6160
6161
6162
static int
6163
init_types(void *arg)
6164
1
{
6165
1
    struct ast_state *state = arg;
6166
1
    if (init_identifiers(state) < 0) {
6167
0
        return -1;
6168
0
    }
6169
1
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6170
1
    if (!state->AST_type) {
6171
0
        return -1;
6172
0
    }
6173
1
    if (add_ast_fields(state) < 0) {
6174
0
        return -1;
6175
0
    }
6176
1
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6177
1
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6178
1
        "    | Interactive(stmt* body)\n"
6179
1
        "    | Expression(expr body)\n"
6180
1
        "    | FunctionType(expr* argtypes, expr returns)");
6181
1
    if (!state->mod_type) return -1;
6182
1
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6183
1
    state->Module_type = make_type(state, "Module", state->mod_type,
6184
1
                                   Module_fields, 2,
6185
1
        "Module(stmt* body, type_ignore* type_ignores)");
6186
1
    if (!state->Module_type) return -1;
6187
1
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6188
1
                                        Interactive_fields, 1,
6189
1
        "Interactive(stmt* body)");
6190
1
    if (!state->Interactive_type) return -1;
6191
1
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6192
1
                                       Expression_fields, 1,
6193
1
        "Expression(expr body)");
6194
1
    if (!state->Expression_type) return -1;
6195
1
    state->FunctionType_type = make_type(state, "FunctionType",
6196
1
                                         state->mod_type, FunctionType_fields,
6197
1
                                         2,
6198
1
        "FunctionType(expr* argtypes, expr returns)");
6199
1
    if (!state->FunctionType_type) return -1;
6200
1
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6201
1
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6202
1
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6203
1
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6204
1
        "     | Return(expr? value)\n"
6205
1
        "     | Delete(expr* targets)\n"
6206
1
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6207
1
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6208
1
        "     | AugAssign(expr target, operator op, expr value)\n"
6209
1
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6210
1
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6211
1
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6212
1
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6213
1
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6214
1
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6215
1
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6216
1
        "     | Match(expr subject, match_case* cases)\n"
6217
1
        "     | Raise(expr? exc, expr? cause)\n"
6218
1
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6219
1
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6220
1
        "     | Assert(expr test, expr? msg)\n"
6221
1
        "     | Import(alias* names)\n"
6222
1
        "     | ImportFrom(identifier? module, alias* names, int? level)\n"
6223
1
        "     | Global(identifier* names)\n"
6224
1
        "     | Nonlocal(identifier* names)\n"
6225
1
        "     | Expr(expr value)\n"
6226
1
        "     | Pass\n"
6227
1
        "     | Break\n"
6228
1
        "     | Continue");
6229
1
    if (!state->stmt_type) return -1;
6230
1
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6231
0
        -1;
6232
1
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6233
0
        return -1;
6234
1
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6235
1
        -1)
6236
0
        return -1;
6237
1
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6238
1
                                        FunctionDef_fields, 7,
6239
1
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6240
1
    if (!state->FunctionDef_type) return -1;
6241
1
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6242
1
        -1)
6243
0
        return -1;
6244
1
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6245
1
        == -1)
6246
0
        return -1;
6247
1
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6248
1
                                             state->stmt_type,
6249
1
                                             AsyncFunctionDef_fields, 7,
6250
1
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6251
1
    if (!state->AsyncFunctionDef_type) return -1;
6252
1
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6253
1
        == -1)
6254
0
        return -1;
6255
1
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6256
1
        Py_None) == -1)
6257
0
        return -1;
6258
1
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6259
1
                                     ClassDef_fields, 6,
6260
1
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6261
1
    if (!state->ClassDef_type) return -1;
6262
1
    state->Return_type = make_type(state, "Return", state->stmt_type,
6263
1
                                   Return_fields, 1,
6264
1
        "Return(expr? value)");
6265
1
    if (!state->Return_type) return -1;
6266
1
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6267
0
        return -1;
6268
1
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6269
1
                                   Delete_fields, 1,
6270
1
        "Delete(expr* targets)");
6271
1
    if (!state->Delete_type) return -1;
6272
1
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6273
1
                                   Assign_fields, 3,
6274
1
        "Assign(expr* targets, expr value, string? type_comment)");
6275
1
    if (!state->Assign_type) return -1;
6276
1
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6277
1
        -1)
6278
0
        return -1;
6279
1
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6280
1
                                      TypeAlias_fields, 3,
6281
1
        "TypeAlias(expr name, type_param* type_params, expr value)");
6282
1
    if (!state->TypeAlias_type) return -1;
6283
1
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6284
1
                                      AugAssign_fields, 3,
6285
1
        "AugAssign(expr target, operator op, expr value)");
6286
1
    if (!state->AugAssign_type) return -1;
6287
1
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6288
1
                                      AnnAssign_fields, 4,
6289
1
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6290
1
    if (!state->AnnAssign_type) return -1;
6291
1
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6292
0
        return -1;
6293
1
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6294
1
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6295
1
    if (!state->For_type) return -1;
6296
1
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6297
0
        return -1;
6298
1
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6299
1
                                     AsyncFor_fields, 5,
6300
1
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6301
1
    if (!state->AsyncFor_type) return -1;
6302
1
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6303
1
        -1)
6304
0
        return -1;
6305
1
    state->While_type = make_type(state, "While", state->stmt_type,
6306
1
                                  While_fields, 3,
6307
1
        "While(expr test, stmt* body, stmt* orelse)");
6308
1
    if (!state->While_type) return -1;
6309
1
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6310
1
        "If(expr test, stmt* body, stmt* orelse)");
6311
1
    if (!state->If_type) return -1;
6312
1
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6313
1
                                 3,
6314
1
        "With(withitem* items, stmt* body, string? type_comment)");
6315
1
    if (!state->With_type) return -1;
6316
1
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6317
0
        return -1;
6318
1
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6319
1
                                      AsyncWith_fields, 3,
6320
1
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6321
1
    if (!state->AsyncWith_type) return -1;
6322
1
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6323
1
        == -1)
6324
0
        return -1;
6325
1
    state->Match_type = make_type(state, "Match", state->stmt_type,
6326
1
                                  Match_fields, 2,
6327
1
        "Match(expr subject, match_case* cases)");
6328
1
    if (!state->Match_type) return -1;
6329
1
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6330
1
                                  Raise_fields, 2,
6331
1
        "Raise(expr? exc, expr? cause)");
6332
1
    if (!state->Raise_type) return -1;
6333
1
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6334
0
        return -1;
6335
1
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6336
0
        return -1;
6337
1
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6338
1
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6339
1
    if (!state->Try_type) return -1;
6340
1
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6341
1
                                    TryStar_fields, 4,
6342
1
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6343
1
    if (!state->TryStar_type) return -1;
6344
1
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6345
1
                                   Assert_fields, 2,
6346
1
        "Assert(expr test, expr? msg)");
6347
1
    if (!state->Assert_type) return -1;
6348
1
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6349
0
        return -1;
6350
1
    state->Import_type = make_type(state, "Import", state->stmt_type,
6351
1
                                   Import_fields, 1,
6352
1
        "Import(alias* names)");
6353
1
    if (!state->Import_type) return -1;
6354
1
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6355
1
                                       ImportFrom_fields, 3,
6356
1
        "ImportFrom(identifier? module, alias* names, int? level)");
6357
1
    if (!state->ImportFrom_type) return -1;
6358
1
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6359
0
        return -1;
6360
1
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6361
0
        return -1;
6362
1
    state->Global_type = make_type(state, "Global", state->stmt_type,
6363
1
                                   Global_fields, 1,
6364
1
        "Global(identifier* names)");
6365
1
    if (!state->Global_type) return -1;
6366
1
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6367
1
                                     Nonlocal_fields, 1,
6368
1
        "Nonlocal(identifier* names)");
6369
1
    if (!state->Nonlocal_type) return -1;
6370
1
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6371
1
                                 1,
6372
1
        "Expr(expr value)");
6373
1
    if (!state->Expr_type) return -1;
6374
1
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6375
1
        "Pass");
6376
1
    if (!state->Pass_type) return -1;
6377
1
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6378
1
        "Break");
6379
1
    if (!state->Break_type) return -1;
6380
1
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6381
1
                                     0,
6382
1
        "Continue");
6383
1
    if (!state->Continue_type) return -1;
6384
1
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6385
1
        "expr = BoolOp(boolop op, expr* values)\n"
6386
1
        "     | NamedExpr(expr target, expr value)\n"
6387
1
        "     | BinOp(expr left, operator op, expr right)\n"
6388
1
        "     | UnaryOp(unaryop op, expr operand)\n"
6389
1
        "     | Lambda(arguments args, expr body)\n"
6390
1
        "     | IfExp(expr test, expr body, expr orelse)\n"
6391
1
        "     | Dict(expr?* keys, expr* values)\n"
6392
1
        "     | Set(expr* elts)\n"
6393
1
        "     | ListComp(expr elt, comprehension* generators)\n"
6394
1
        "     | SetComp(expr elt, comprehension* generators)\n"
6395
1
        "     | DictComp(expr key, expr value, comprehension* generators)\n"
6396
1
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6397
1
        "     | Await(expr value)\n"
6398
1
        "     | Yield(expr? value)\n"
6399
1
        "     | YieldFrom(expr value)\n"
6400
1
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6401
1
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6402
1
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6403
1
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6404
1
        "     | JoinedStr(expr* values)\n"
6405
1
        "     | TemplateStr(expr* values)\n"
6406
1
        "     | Constant(constant value, string? kind)\n"
6407
1
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6408
1
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6409
1
        "     | Starred(expr value, expr_context ctx)\n"
6410
1
        "     | Name(identifier id, expr_context ctx)\n"
6411
1
        "     | List(expr* elts, expr_context ctx)\n"
6412
1
        "     | Tuple(expr* elts, expr_context ctx)\n"
6413
1
        "     | Slice(expr? lower, expr? upper, expr? step)");
6414
1
    if (!state->expr_type) return -1;
6415
1
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6416
0
        -1;
6417
1
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6418
0
        return -1;
6419
1
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6420
1
        -1)
6421
0
        return -1;
6422
1
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6423
1
                                   BoolOp_fields, 2,
6424
1
        "BoolOp(boolop op, expr* values)");
6425
1
    if (!state->BoolOp_type) return -1;
6426
1
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6427
1
                                      NamedExpr_fields, 2,
6428
1
        "NamedExpr(expr target, expr value)");
6429
1
    if (!state->NamedExpr_type) return -1;
6430
1
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6431
1
                                  BinOp_fields, 3,
6432
1
        "BinOp(expr left, operator op, expr right)");
6433
1
    if (!state->BinOp_type) return -1;
6434
1
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6435
1
                                    UnaryOp_fields, 2,
6436
1
        "UnaryOp(unaryop op, expr operand)");
6437
1
    if (!state->UnaryOp_type) return -1;
6438
1
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6439
1
                                   Lambda_fields, 2,
6440
1
        "Lambda(arguments args, expr body)");
6441
1
    if (!state->Lambda_type) return -1;
6442
1
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6443
1
                                  IfExp_fields, 3,
6444
1
        "IfExp(expr test, expr body, expr orelse)");
6445
1
    if (!state->IfExp_type) return -1;
6446
1
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6447
1
                                 2,
6448
1
        "Dict(expr?* keys, expr* values)");
6449
1
    if (!state->Dict_type) return -1;
6450
1
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6451
1
        "Set(expr* elts)");
6452
1
    if (!state->Set_type) return -1;
6453
1
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6454
1
                                     ListComp_fields, 2,
6455
1
        "ListComp(expr elt, comprehension* generators)");
6456
1
    if (!state->ListComp_type) return -1;
6457
1
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6458
1
                                    SetComp_fields, 2,
6459
1
        "SetComp(expr elt, comprehension* generators)");
6460
1
    if (!state->SetComp_type) return -1;
6461
1
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6462
1
                                     DictComp_fields, 3,
6463
1
        "DictComp(expr key, expr value, comprehension* generators)");
6464
1
    if (!state->DictComp_type) return -1;
6465
1
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6466
1
                                         state->expr_type, GeneratorExp_fields,
6467
1
                                         2,
6468
1
        "GeneratorExp(expr elt, comprehension* generators)");
6469
1
    if (!state->GeneratorExp_type) return -1;
6470
1
    state->Await_type = make_type(state, "Await", state->expr_type,
6471
1
                                  Await_fields, 1,
6472
1
        "Await(expr value)");
6473
1
    if (!state->Await_type) return -1;
6474
1
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6475
1
                                  Yield_fields, 1,
6476
1
        "Yield(expr? value)");
6477
1
    if (!state->Yield_type) return -1;
6478
1
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6479
0
        return -1;
6480
1
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6481
1
                                      YieldFrom_fields, 1,
6482
1
        "YieldFrom(expr value)");
6483
1
    if (!state->YieldFrom_type) return -1;
6484
1
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6485
1
                                    Compare_fields, 3,
6486
1
        "Compare(expr left, cmpop* ops, expr* comparators)");
6487
1
    if (!state->Compare_type) return -1;
6488
1
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6489
1
                                 3,
6490
1
        "Call(expr func, expr* args, keyword* keywords)");
6491
1
    if (!state->Call_type) return -1;
6492
1
    state->FormattedValue_type = make_type(state, "FormattedValue",
6493
1
                                           state->expr_type,
6494
1
                                           FormattedValue_fields, 3,
6495
1
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6496
1
    if (!state->FormattedValue_type) return -1;
6497
1
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6498
1
        Py_None) == -1)
6499
0
        return -1;
6500
1
    state->Interpolation_type = make_type(state, "Interpolation",
6501
1
                                          state->expr_type,
6502
1
                                          Interpolation_fields, 4,
6503
1
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6504
1
    if (!state->Interpolation_type) return -1;
6505
1
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6506
1
        Py_None) == -1)
6507
0
        return -1;
6508
1
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6509
1
                                      JoinedStr_fields, 1,
6510
1
        "JoinedStr(expr* values)");
6511
1
    if (!state->JoinedStr_type) return -1;
6512
1
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6513
1
                                        TemplateStr_fields, 1,
6514
1
        "TemplateStr(expr* values)");
6515
1
    if (!state->TemplateStr_type) return -1;
6516
1
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6517
1
                                     Constant_fields, 2,
6518
1
        "Constant(constant value, string? kind)");
6519
1
    if (!state->Constant_type) return -1;
6520
1
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6521
0
        return -1;
6522
1
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6523
1
                                      Attribute_fields, 3,
6524
1
        "Attribute(expr value, identifier attr, expr_context ctx)");
6525
1
    if (!state->Attribute_type) return -1;
6526
1
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6527
1
                                      Subscript_fields, 3,
6528
1
        "Subscript(expr value, expr slice, expr_context ctx)");
6529
1
    if (!state->Subscript_type) return -1;
6530
1
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6531
1
                                    Starred_fields, 2,
6532
1
        "Starred(expr value, expr_context ctx)");
6533
1
    if (!state->Starred_type) return -1;
6534
1
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6535
1
                                 2,
6536
1
        "Name(identifier id, expr_context ctx)");
6537
1
    if (!state->Name_type) return -1;
6538
1
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6539
1
                                 2,
6540
1
        "List(expr* elts, expr_context ctx)");
6541
1
    if (!state->List_type) return -1;
6542
1
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6543
1
                                  Tuple_fields, 2,
6544
1
        "Tuple(expr* elts, expr_context ctx)");
6545
1
    if (!state->Tuple_type) return -1;
6546
1
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6547
1
                                  Slice_fields, 3,
6548
1
        "Slice(expr? lower, expr? upper, expr? step)");
6549
1
    if (!state->Slice_type) return -1;
6550
1
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6551
0
        return -1;
6552
1
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6553
0
        return -1;
6554
1
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6555
0
        return -1;
6556
1
    state->expr_context_type = make_type(state, "expr_context",
6557
1
                                         state->AST_type, NULL, 0,
6558
1
        "expr_context = Load | Store | Del");
6559
1
    if (!state->expr_context_type) return -1;
6560
1
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6561
1
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6562
1
                                 0,
6563
1
        "Load");
6564
1
    if (!state->Load_type) return -1;
6565
1
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6566
1
                                              NULL, NULL);
6567
1
    if (!state->Load_singleton) return -1;
6568
1
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6569
1
                                  NULL, 0,
6570
1
        "Store");
6571
1
    if (!state->Store_type) return -1;
6572
1
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6573
1
                                               *)state->Store_type, NULL, NULL);
6574
1
    if (!state->Store_singleton) return -1;
6575
1
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6576
1
        "Del");
6577
1
    if (!state->Del_type) return -1;
6578
1
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6579
1
                                             NULL, NULL);
6580
1
    if (!state->Del_singleton) return -1;
6581
1
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6582
1
        "boolop = And | Or");
6583
1
    if (!state->boolop_type) return -1;
6584
1
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6585
1
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6586
1
        "And");
6587
1
    if (!state->And_type) return -1;
6588
1
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6589
1
                                             NULL, NULL);
6590
1
    if (!state->And_singleton) return -1;
6591
1
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6592
1
        "Or");
6593
1
    if (!state->Or_type) return -1;
6594
1
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6595
1
                                            NULL, NULL);
6596
1
    if (!state->Or_singleton) return -1;
6597
1
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6598
1
                                     0,
6599
1
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6600
1
    if (!state->operator_type) return -1;
6601
1
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6602
1
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6603
1
        "Add");
6604
1
    if (!state->Add_type) return -1;
6605
1
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6606
1
                                             NULL, NULL);
6607
1
    if (!state->Add_singleton) return -1;
6608
1
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6609
1
        "Sub");
6610
1
    if (!state->Sub_type) return -1;
6611
1
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6612
1
                                             NULL, NULL);
6613
1
    if (!state->Sub_singleton) return -1;
6614
1
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6615
1
        "Mult");
6616
1
    if (!state->Mult_type) return -1;
6617
1
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6618
1
                                              NULL, NULL);
6619
1
    if (!state->Mult_singleton) return -1;
6620
1
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6621
1
                                    NULL, 0,
6622
1
        "MatMult");
6623
1
    if (!state->MatMult_type) return -1;
6624
1
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6625
1
                                                 *)state->MatMult_type, NULL,
6626
1
                                                 NULL);
6627
1
    if (!state->MatMult_singleton) return -1;
6628
1
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6629
1
        "Div");
6630
1
    if (!state->Div_type) return -1;
6631
1
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6632
1
                                             NULL, NULL);
6633
1
    if (!state->Div_singleton) return -1;
6634
1
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6635
1
        "Mod");
6636
1
    if (!state->Mod_type) return -1;
6637
1
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6638
1
                                             NULL, NULL);
6639
1
    if (!state->Mod_singleton) return -1;
6640
1
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6641
1
        "Pow");
6642
1
    if (!state->Pow_type) return -1;
6643
1
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6644
1
                                             NULL, NULL);
6645
1
    if (!state->Pow_singleton) return -1;
6646
1
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6647
1
                                   0,
6648
1
        "LShift");
6649
1
    if (!state->LShift_type) return -1;
6650
1
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6651
1
                                                *)state->LShift_type, NULL,
6652
1
                                                NULL);
6653
1
    if (!state->LShift_singleton) return -1;
6654
1
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6655
1
                                   0,
6656
1
        "RShift");
6657
1
    if (!state->RShift_type) return -1;
6658
1
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6659
1
                                                *)state->RShift_type, NULL,
6660
1
                                                NULL);
6661
1
    if (!state->RShift_singleton) return -1;
6662
1
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6663
1
        "BitOr");
6664
1
    if (!state->BitOr_type) return -1;
6665
1
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6666
1
                                               *)state->BitOr_type, NULL, NULL);
6667
1
    if (!state->BitOr_singleton) return -1;
6668
1
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6669
1
                                   0,
6670
1
        "BitXor");
6671
1
    if (!state->BitXor_type) return -1;
6672
1
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6673
1
                                                *)state->BitXor_type, NULL,
6674
1
                                                NULL);
6675
1
    if (!state->BitXor_singleton) return -1;
6676
1
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6677
1
                                   0,
6678
1
        "BitAnd");
6679
1
    if (!state->BitAnd_type) return -1;
6680
1
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6681
1
                                                *)state->BitAnd_type, NULL,
6682
1
                                                NULL);
6683
1
    if (!state->BitAnd_singleton) return -1;
6684
1
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6685
1
                                     NULL, 0,
6686
1
        "FloorDiv");
6687
1
    if (!state->FloorDiv_type) return -1;
6688
1
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6689
1
                                                  *)state->FloorDiv_type, NULL,
6690
1
                                                  NULL);
6691
1
    if (!state->FloorDiv_singleton) return -1;
6692
1
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6693
1
        "unaryop = Invert | Not | UAdd | USub");
6694
1
    if (!state->unaryop_type) return -1;
6695
1
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6696
1
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6697
1
                                   0,
6698
1
        "Invert");
6699
1
    if (!state->Invert_type) return -1;
6700
1
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6701
1
                                                *)state->Invert_type, NULL,
6702
1
                                                NULL);
6703
1
    if (!state->Invert_singleton) return -1;
6704
1
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6705
1
        "Not");
6706
1
    if (!state->Not_type) return -1;
6707
1
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6708
1
                                             NULL, NULL);
6709
1
    if (!state->Not_singleton) return -1;
6710
1
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6711
1
        "UAdd");
6712
1
    if (!state->UAdd_type) return -1;
6713
1
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6714
1
                                              NULL, NULL);
6715
1
    if (!state->UAdd_singleton) return -1;
6716
1
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6717
1
        "USub");
6718
1
    if (!state->USub_type) return -1;
6719
1
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6720
1
                                              NULL, NULL);
6721
1
    if (!state->USub_singleton) return -1;
6722
1
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6723
1
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6724
1
    if (!state->cmpop_type) return -1;
6725
1
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6726
1
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6727
1
        "Eq");
6728
1
    if (!state->Eq_type) return -1;
6729
1
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6730
1
                                            NULL, NULL);
6731
1
    if (!state->Eq_singleton) return -1;
6732
1
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6733
1
        "NotEq");
6734
1
    if (!state->NotEq_type) return -1;
6735
1
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6736
1
                                               *)state->NotEq_type, NULL, NULL);
6737
1
    if (!state->NotEq_singleton) return -1;
6738
1
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6739
1
        "Lt");
6740
1
    if (!state->Lt_type) return -1;
6741
1
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6742
1
                                            NULL, NULL);
6743
1
    if (!state->Lt_singleton) return -1;
6744
1
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6745
1
        "LtE");
6746
1
    if (!state->LtE_type) return -1;
6747
1
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6748
1
                                             NULL, NULL);
6749
1
    if (!state->LtE_singleton) return -1;
6750
1
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6751
1
        "Gt");
6752
1
    if (!state->Gt_type) return -1;
6753
1
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6754
1
                                            NULL, NULL);
6755
1
    if (!state->Gt_singleton) return -1;
6756
1
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6757
1
        "GtE");
6758
1
    if (!state->GtE_type) return -1;
6759
1
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6760
1
                                             NULL, NULL);
6761
1
    if (!state->GtE_singleton) return -1;
6762
1
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6763
1
        "Is");
6764
1
    if (!state->Is_type) return -1;
6765
1
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6766
1
                                            NULL, NULL);
6767
1
    if (!state->Is_singleton) return -1;
6768
1
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6769
1
        "IsNot");
6770
1
    if (!state->IsNot_type) return -1;
6771
1
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6772
1
                                               *)state->IsNot_type, NULL, NULL);
6773
1
    if (!state->IsNot_singleton) return -1;
6774
1
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6775
1
        "In");
6776
1
    if (!state->In_type) return -1;
6777
1
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6778
1
                                            NULL, NULL);
6779
1
    if (!state->In_singleton) return -1;
6780
1
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6781
1
        "NotIn");
6782
1
    if (!state->NotIn_type) return -1;
6783
1
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6784
1
                                               *)state->NotIn_type, NULL, NULL);
6785
1
    if (!state->NotIn_singleton) return -1;
6786
1
    state->comprehension_type = make_type(state, "comprehension",
6787
1
                                          state->AST_type,
6788
1
                                          comprehension_fields, 4,
6789
1
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6790
1
    if (!state->comprehension_type) return -1;
6791
1
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6792
0
        -1;
6793
1
    state->excepthandler_type = make_type(state, "excepthandler",
6794
1
                                          state->AST_type, NULL, 0,
6795
1
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6796
1
    if (!state->excepthandler_type) return -1;
6797
1
    if (add_attributes(state, state->excepthandler_type,
6798
1
        excepthandler_attributes, 4) < 0) return -1;
6799
1
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6800
1
        == -1)
6801
0
        return -1;
6802
1
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6803
1
        Py_None) == -1)
6804
0
        return -1;
6805
1
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6806
1
                                          state->excepthandler_type,
6807
1
                                          ExceptHandler_fields, 3,
6808
1
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6809
1
    if (!state->ExceptHandler_type) return -1;
6810
1
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6811
0
        return -1;
6812
1
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6813
0
        return -1;
6814
1
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6815
1
                                      arguments_fields, 7,
6816
1
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults, arg? kwarg, expr* defaults)");
6817
1
    if (!state->arguments_type) return -1;
6818
1
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6819
1
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6820
0
        return -1;
6821
1
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6822
0
        return -1;
6823
1
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6824
1
        "arg(identifier arg, expr? annotation, string? type_comment)");
6825
1
    if (!state->arg_type) return -1;
6826
1
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6827
0
        -1;
6828
1
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6829
0
        return -1;
6830
1
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6831
0
        return -1;
6832
1
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6833
0
        return -1;
6834
1
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6835
0
        return -1;
6836
1
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6837
1
                                    keyword_fields, 2,
6838
1
        "keyword(identifier? arg, expr value)");
6839
1
    if (!state->keyword_type) return -1;
6840
1
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6841
0
        return -1;
6842
1
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6843
0
        return -1;
6844
1
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6845
0
        return -1;
6846
1
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6847
1
        == -1)
6848
0
        return -1;
6849
1
    state->alias_type = make_type(state, "alias", state->AST_type,
6850
1
                                  alias_fields, 2,
6851
1
        "alias(identifier name, identifier? asname)");
6852
1
    if (!state->alias_type) return -1;
6853
1
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6854
0
        return -1;
6855
1
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6856
0
        return -1;
6857
1
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6858
0
        return -1;
6859
1
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6860
1
        -1)
6861
0
        return -1;
6862
1
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6863
1
                                     withitem_fields, 2,
6864
1
        "withitem(expr context_expr, expr? optional_vars)");
6865
1
    if (!state->withitem_type) return -1;
6866
1
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6867
1
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6868
1
        == -1)
6869
0
        return -1;
6870
1
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6871
1
                                       match_case_fields, 3,
6872
1
        "match_case(pattern pattern, expr? guard, stmt* body)");
6873
1
    if (!state->match_case_type) return -1;
6874
1
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6875
1
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6876
0
        return -1;
6877
1
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6878
1
        "pattern = MatchValue(expr value)\n"
6879
1
        "        | MatchSingleton(constant value)\n"
6880
1
        "        | MatchSequence(pattern* patterns)\n"
6881
1
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6882
1
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6883
1
        "        | MatchStar(identifier? name)\n"
6884
1
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6885
1
        "        | MatchOr(pattern* patterns)");
6886
1
    if (!state->pattern_type) return -1;
6887
1
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6888
0
        return -1;
6889
1
    state->MatchValue_type = make_type(state, "MatchValue",
6890
1
                                       state->pattern_type, MatchValue_fields,
6891
1
                                       1,
6892
1
        "MatchValue(expr value)");
6893
1
    if (!state->MatchValue_type) return -1;
6894
1
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6895
1
                                           state->pattern_type,
6896
1
                                           MatchSingleton_fields, 1,
6897
1
        "MatchSingleton(constant value)");
6898
1
    if (!state->MatchSingleton_type) return -1;
6899
1
    state->MatchSequence_type = make_type(state, "MatchSequence",
6900
1
                                          state->pattern_type,
6901
1
                                          MatchSequence_fields, 1,
6902
1
        "MatchSequence(pattern* patterns)");
6903
1
    if (!state->MatchSequence_type) return -1;
6904
1
    state->MatchMapping_type = make_type(state, "MatchMapping",
6905
1
                                         state->pattern_type,
6906
1
                                         MatchMapping_fields, 3,
6907
1
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6908
1
    if (!state->MatchMapping_type) return -1;
6909
1
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6910
0
        return -1;
6911
1
    state->MatchClass_type = make_type(state, "MatchClass",
6912
1
                                       state->pattern_type, MatchClass_fields,
6913
1
                                       4,
6914
1
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6915
1
    if (!state->MatchClass_type) return -1;
6916
1
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6917
1
                                      MatchStar_fields, 1,
6918
1
        "MatchStar(identifier? name)");
6919
1
    if (!state->MatchStar_type) return -1;
6920
1
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6921
0
        return -1;
6922
1
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6923
1
                                    MatchAs_fields, 2,
6924
1
        "MatchAs(pattern? pattern, identifier? name)");
6925
1
    if (!state->MatchAs_type) return -1;
6926
1
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6927
0
        return -1;
6928
1
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6929
0
        return -1;
6930
1
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6931
1
                                    MatchOr_fields, 1,
6932
1
        "MatchOr(pattern* patterns)");
6933
1
    if (!state->MatchOr_type) return -1;
6934
1
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6935
1
                                        NULL, 0,
6936
1
        "type_ignore = TypeIgnore(int lineno, string tag)");
6937
1
    if (!state->type_ignore_type) return -1;
6938
1
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6939
1
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6940
1
                                       state->type_ignore_type,
6941
1
                                       TypeIgnore_fields, 2,
6942
1
        "TypeIgnore(int lineno, string tag)");
6943
1
    if (!state->TypeIgnore_type) return -1;
6944
1
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6945
1
                                       NULL, 0,
6946
1
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6947
1
        "           | ParamSpec(identifier name, expr? default_value)\n"
6948
1
        "           | TypeVarTuple(identifier name, expr? default_value)");
6949
1
    if (!state->type_param_type) return -1;
6950
1
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6951
1
        < 0) return -1;
6952
1
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6953
1
                                    TypeVar_fields, 3,
6954
1
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6955
1
    if (!state->TypeVar_type) return -1;
6956
1
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6957
0
        return -1;
6958
1
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6959
1
        -1)
6960
0
        return -1;
6961
1
    state->ParamSpec_type = make_type(state, "ParamSpec",
6962
1
                                      state->type_param_type, ParamSpec_fields,
6963
1
                                      2,
6964
1
        "ParamSpec(identifier name, expr? default_value)");
6965
1
    if (!state->ParamSpec_type) return -1;
6966
1
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6967
1
        == -1)
6968
0
        return -1;
6969
1
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6970
1
                                         state->type_param_type,
6971
1
                                         TypeVarTuple_fields, 2,
6972
1
        "TypeVarTuple(identifier name, expr? default_value)");
6973
1
    if (!state->TypeVarTuple_type) return -1;
6974
1
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6975
1
        Py_None) == -1)
6976
0
        return -1;
6977
6978
1
    if (!add_ast_annotations(state)) {
6979
0
        return -1;
6980
0
    }
6981
1
    return 0;
6982
1
}
6983
6984
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6985
                       PyArena* arena);
6986
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6987
                        PyArena* arena);
6988
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6989
                        PyArena* arena);
6990
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6991
                                expr_context_ty* out, PyArena* arena);
6992
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
6993
                          out, PyArena* arena);
6994
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
6995
                            operator_ty* out, PyArena* arena);
6996
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
6997
                           out, PyArena* arena);
6998
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
6999
                         PyArena* arena);
7000
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
7001
                                 comprehension_ty* out, PyArena* arena);
7002
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
7003
                                 excepthandler_ty* out, PyArena* arena);
7004
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
7005
                             arguments_ty* out, PyArena* arena);
7006
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
7007
                       PyArena* arena);
7008
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
7009
                           out, PyArena* arena);
7010
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
7011
                         PyArena* arena);
7012
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
7013
                            withitem_ty* out, PyArena* arena);
7014
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
7015
                              match_case_ty* out, PyArena* arena);
7016
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
7017
                           out, PyArena* arena);
7018
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
7019
                               type_ignore_ty* out, PyArena* arena);
7020
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
7021
                              type_param_ty* out, PyArena* arena);
7022
7023
mod_ty
7024
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
7025
              PyArena *arena)
7026
7.76k
{
7027
7.76k
    mod_ty p;
7028
7.76k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7029
7.76k
    if (!p)
7030
0
        return NULL;
7031
7.76k
    p->kind = Module_kind;
7032
7.76k
    p->v.Module.body = body;
7033
7.76k
    p->v.Module.type_ignores = type_ignores;
7034
7.76k
    return p;
7035
7.76k
}
7036
7037
mod_ty
7038
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7039
3.12k
{
7040
3.12k
    mod_ty p;
7041
3.12k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7042
3.12k
    if (!p)
7043
0
        return NULL;
7044
3.12k
    p->kind = Interactive_kind;
7045
3.12k
    p->v.Interactive.body = body;
7046
3.12k
    return p;
7047
3.12k
}
7048
7049
mod_ty
7050
_PyAST_Expression(expr_ty body, PyArena *arena)
7051
1.94k
{
7052
1.94k
    mod_ty p;
7053
1.94k
    if (!body) {
7054
0
        PyErr_SetString(PyExc_ValueError,
7055
0
                        "field 'body' is required for Expression");
7056
0
        return NULL;
7057
0
    }
7058
1.94k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7059
1.94k
    if (!p)
7060
0
        return NULL;
7061
1.94k
    p->kind = Expression_kind;
7062
1.94k
    p->v.Expression.body = body;
7063
1.94k
    return p;
7064
1.94k
}
7065
7066
mod_ty
7067
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7068
0
{
7069
0
    mod_ty p;
7070
0
    if (!returns) {
7071
0
        PyErr_SetString(PyExc_ValueError,
7072
0
                        "field 'returns' is required for FunctionType");
7073
0
        return NULL;
7074
0
    }
7075
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7076
0
    if (!p)
7077
0
        return NULL;
7078
0
    p->kind = FunctionType_kind;
7079
0
    p->v.FunctionType.argtypes = argtypes;
7080
0
    p->v.FunctionType.returns = returns;
7081
0
    return p;
7082
0
}
7083
7084
stmt_ty
7085
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7086
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7087
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7088
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7089
                   *arena)
7090
7.78k
{
7091
7.78k
    stmt_ty p;
7092
7.78k
    if (!name) {
7093
0
        PyErr_SetString(PyExc_ValueError,
7094
0
                        "field 'name' is required for FunctionDef");
7095
0
        return NULL;
7096
0
    }
7097
7.78k
    if (!args) {
7098
0
        PyErr_SetString(PyExc_ValueError,
7099
0
                        "field 'args' is required for FunctionDef");
7100
0
        return NULL;
7101
0
    }
7102
7.78k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7103
7.78k
    if (!p)
7104
0
        return NULL;
7105
7.78k
    p->kind = FunctionDef_kind;
7106
7.78k
    p->v.FunctionDef.name = name;
7107
7.78k
    p->v.FunctionDef.args = args;
7108
7.78k
    p->v.FunctionDef.body = body;
7109
7.78k
    p->v.FunctionDef.decorator_list = decorator_list;
7110
7.78k
    p->v.FunctionDef.returns = returns;
7111
7.78k
    p->v.FunctionDef.type_comment = type_comment;
7112
7.78k
    p->v.FunctionDef.type_params = type_params;
7113
7.78k
    p->lineno = lineno;
7114
7.78k
    p->col_offset = col_offset;
7115
7.78k
    p->end_lineno = end_lineno;
7116
7.78k
    p->end_col_offset = end_col_offset;
7117
7.78k
    return p;
7118
7.78k
}
7119
7120
stmt_ty
7121
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7122
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7123
                        string type_comment, asdl_type_param_seq * type_params,
7124
                        int lineno, int col_offset, int end_lineno, int
7125
                        end_col_offset, PyArena *arena)
7126
2.72k
{
7127
2.72k
    stmt_ty p;
7128
2.72k
    if (!name) {
7129
0
        PyErr_SetString(PyExc_ValueError,
7130
0
                        "field 'name' is required for AsyncFunctionDef");
7131
0
        return NULL;
7132
0
    }
7133
2.72k
    if (!args) {
7134
0
        PyErr_SetString(PyExc_ValueError,
7135
0
                        "field 'args' is required for AsyncFunctionDef");
7136
0
        return NULL;
7137
0
    }
7138
2.72k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7139
2.72k
    if (!p)
7140
0
        return NULL;
7141
2.72k
    p->kind = AsyncFunctionDef_kind;
7142
2.72k
    p->v.AsyncFunctionDef.name = name;
7143
2.72k
    p->v.AsyncFunctionDef.args = args;
7144
2.72k
    p->v.AsyncFunctionDef.body = body;
7145
2.72k
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7146
2.72k
    p->v.AsyncFunctionDef.returns = returns;
7147
2.72k
    p->v.AsyncFunctionDef.type_comment = type_comment;
7148
2.72k
    p->v.AsyncFunctionDef.type_params = type_params;
7149
2.72k
    p->lineno = lineno;
7150
2.72k
    p->col_offset = col_offset;
7151
2.72k
    p->end_lineno = end_lineno;
7152
2.72k
    p->end_col_offset = end_col_offset;
7153
2.72k
    return p;
7154
2.72k
}
7155
7156
stmt_ty
7157
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7158
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7159
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7160
                int end_lineno, int end_col_offset, PyArena *arena)
7161
10.6k
{
7162
10.6k
    stmt_ty p;
7163
10.6k
    if (!name) {
7164
0
        PyErr_SetString(PyExc_ValueError,
7165
0
                        "field 'name' is required for ClassDef");
7166
0
        return NULL;
7167
0
    }
7168
10.6k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7169
10.6k
    if (!p)
7170
0
        return NULL;
7171
10.6k
    p->kind = ClassDef_kind;
7172
10.6k
    p->v.ClassDef.name = name;
7173
10.6k
    p->v.ClassDef.bases = bases;
7174
10.6k
    p->v.ClassDef.keywords = keywords;
7175
10.6k
    p->v.ClassDef.body = body;
7176
10.6k
    p->v.ClassDef.decorator_list = decorator_list;
7177
10.6k
    p->v.ClassDef.type_params = type_params;
7178
10.6k
    p->lineno = lineno;
7179
10.6k
    p->col_offset = col_offset;
7180
10.6k
    p->end_lineno = end_lineno;
7181
10.6k
    p->end_col_offset = end_col_offset;
7182
10.6k
    return p;
7183
10.6k
}
7184
7185
stmt_ty
7186
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7187
              end_col_offset, PyArena *arena)
7188
410
{
7189
410
    stmt_ty p;
7190
410
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7191
410
    if (!p)
7192
0
        return NULL;
7193
410
    p->kind = Return_kind;
7194
410
    p->v.Return.value = value;
7195
410
    p->lineno = lineno;
7196
410
    p->col_offset = col_offset;
7197
410
    p->end_lineno = end_lineno;
7198
410
    p->end_col_offset = end_col_offset;
7199
410
    return p;
7200
410
}
7201
7202
stmt_ty
7203
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7204
              end_lineno, int end_col_offset, PyArena *arena)
7205
2.19k
{
7206
2.19k
    stmt_ty p;
7207
2.19k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7208
2.19k
    if (!p)
7209
0
        return NULL;
7210
2.19k
    p->kind = Delete_kind;
7211
2.19k
    p->v.Delete.targets = targets;
7212
2.19k
    p->lineno = lineno;
7213
2.19k
    p->col_offset = col_offset;
7214
2.19k
    p->end_lineno = end_lineno;
7215
2.19k
    p->end_col_offset = end_col_offset;
7216
2.19k
    return p;
7217
2.19k
}
7218
7219
stmt_ty
7220
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7221
              lineno, int col_offset, int end_lineno, int end_col_offset,
7222
              PyArena *arena)
7223
7.95k
{
7224
7.95k
    stmt_ty p;
7225
7.95k
    if (!value) {
7226
0
        PyErr_SetString(PyExc_ValueError,
7227
0
                        "field 'value' is required for Assign");
7228
0
        return NULL;
7229
0
    }
7230
7.95k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7231
7.95k
    if (!p)
7232
0
        return NULL;
7233
7.95k
    p->kind = Assign_kind;
7234
7.95k
    p->v.Assign.targets = targets;
7235
7.95k
    p->v.Assign.value = value;
7236
7.95k
    p->v.Assign.type_comment = type_comment;
7237
7.95k
    p->lineno = lineno;
7238
7.95k
    p->col_offset = col_offset;
7239
7.95k
    p->end_lineno = end_lineno;
7240
7.95k
    p->end_col_offset = end_col_offset;
7241
7.95k
    return p;
7242
7.95k
}
7243
7244
stmt_ty
7245
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7246
                 value, int lineno, int col_offset, int end_lineno, int
7247
                 end_col_offset, PyArena *arena)
7248
1.30k
{
7249
1.30k
    stmt_ty p;
7250
1.30k
    if (!name) {
7251
0
        PyErr_SetString(PyExc_ValueError,
7252
0
                        "field 'name' is required for TypeAlias");
7253
0
        return NULL;
7254
0
    }
7255
1.30k
    if (!value) {
7256
0
        PyErr_SetString(PyExc_ValueError,
7257
0
                        "field 'value' is required for TypeAlias");
7258
0
        return NULL;
7259
0
    }
7260
1.30k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7261
1.30k
    if (!p)
7262
0
        return NULL;
7263
1.30k
    p->kind = TypeAlias_kind;
7264
1.30k
    p->v.TypeAlias.name = name;
7265
1.30k
    p->v.TypeAlias.type_params = type_params;
7266
1.30k
    p->v.TypeAlias.value = value;
7267
1.30k
    p->lineno = lineno;
7268
1.30k
    p->col_offset = col_offset;
7269
1.30k
    p->end_lineno = end_lineno;
7270
1.30k
    p->end_col_offset = end_col_offset;
7271
1.30k
    return p;
7272
1.30k
}
7273
7274
stmt_ty
7275
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7276
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7277
5.61k
{
7278
5.61k
    stmt_ty p;
7279
5.61k
    if (!target) {
7280
0
        PyErr_SetString(PyExc_ValueError,
7281
0
                        "field 'target' is required for AugAssign");
7282
0
        return NULL;
7283
0
    }
7284
5.61k
    if (!op) {
7285
0
        PyErr_SetString(PyExc_ValueError,
7286
0
                        "field 'op' is required for AugAssign");
7287
0
        return NULL;
7288
0
    }
7289
5.61k
    if (!value) {
7290
0
        PyErr_SetString(PyExc_ValueError,
7291
0
                        "field 'value' is required for AugAssign");
7292
0
        return NULL;
7293
0
    }
7294
5.61k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7295
5.61k
    if (!p)
7296
0
        return NULL;
7297
5.61k
    p->kind = AugAssign_kind;
7298
5.61k
    p->v.AugAssign.target = target;
7299
5.61k
    p->v.AugAssign.op = op;
7300
5.61k
    p->v.AugAssign.value = value;
7301
5.61k
    p->lineno = lineno;
7302
5.61k
    p->col_offset = col_offset;
7303
5.61k
    p->end_lineno = end_lineno;
7304
5.61k
    p->end_col_offset = end_col_offset;
7305
5.61k
    return p;
7306
5.61k
}
7307
7308
stmt_ty
7309
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7310
                 int lineno, int col_offset, int end_lineno, int
7311
                 end_col_offset, PyArena *arena)
7312
15.3k
{
7313
15.3k
    stmt_ty p;
7314
15.3k
    if (!target) {
7315
0
        PyErr_SetString(PyExc_ValueError,
7316
0
                        "field 'target' is required for AnnAssign");
7317
0
        return NULL;
7318
0
    }
7319
15.3k
    if (!annotation) {
7320
0
        PyErr_SetString(PyExc_ValueError,
7321
0
                        "field 'annotation' is required for AnnAssign");
7322
0
        return NULL;
7323
0
    }
7324
15.3k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7325
15.3k
    if (!p)
7326
0
        return NULL;
7327
15.3k
    p->kind = AnnAssign_kind;
7328
15.3k
    p->v.AnnAssign.target = target;
7329
15.3k
    p->v.AnnAssign.annotation = annotation;
7330
15.3k
    p->v.AnnAssign.value = value;
7331
15.3k
    p->v.AnnAssign.simple = simple;
7332
15.3k
    p->lineno = lineno;
7333
15.3k
    p->col_offset = col_offset;
7334
15.3k
    p->end_lineno = end_lineno;
7335
15.3k
    p->end_col_offset = end_col_offset;
7336
15.3k
    return p;
7337
15.3k
}
7338
7339
stmt_ty
7340
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7341
           orelse, string type_comment, int lineno, int col_offset, int
7342
           end_lineno, int end_col_offset, PyArena *arena)
7343
375
{
7344
375
    stmt_ty p;
7345
375
    if (!target) {
7346
0
        PyErr_SetString(PyExc_ValueError,
7347
0
                        "field 'target' is required for For");
7348
0
        return NULL;
7349
0
    }
7350
375
    if (!iter) {
7351
0
        PyErr_SetString(PyExc_ValueError,
7352
0
                        "field 'iter' is required for For");
7353
0
        return NULL;
7354
0
    }
7355
375
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7356
375
    if (!p)
7357
0
        return NULL;
7358
375
    p->kind = For_kind;
7359
375
    p->v.For.target = target;
7360
375
    p->v.For.iter = iter;
7361
375
    p->v.For.body = body;
7362
375
    p->v.For.orelse = orelse;
7363
375
    p->v.For.type_comment = type_comment;
7364
375
    p->lineno = lineno;
7365
375
    p->col_offset = col_offset;
7366
375
    p->end_lineno = end_lineno;
7367
375
    p->end_col_offset = end_col_offset;
7368
375
    return p;
7369
375
}
7370
7371
stmt_ty
7372
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7373
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7374
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7375
43
{
7376
43
    stmt_ty p;
7377
43
    if (!target) {
7378
0
        PyErr_SetString(PyExc_ValueError,
7379
0
                        "field 'target' is required for AsyncFor");
7380
0
        return NULL;
7381
0
    }
7382
43
    if (!iter) {
7383
0
        PyErr_SetString(PyExc_ValueError,
7384
0
                        "field 'iter' is required for AsyncFor");
7385
0
        return NULL;
7386
0
    }
7387
43
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7388
43
    if (!p)
7389
0
        return NULL;
7390
43
    p->kind = AsyncFor_kind;
7391
43
    p->v.AsyncFor.target = target;
7392
43
    p->v.AsyncFor.iter = iter;
7393
43
    p->v.AsyncFor.body = body;
7394
43
    p->v.AsyncFor.orelse = orelse;
7395
43
    p->v.AsyncFor.type_comment = type_comment;
7396
43
    p->lineno = lineno;
7397
43
    p->col_offset = col_offset;
7398
43
    p->end_lineno = end_lineno;
7399
43
    p->end_col_offset = end_col_offset;
7400
43
    return p;
7401
43
}
7402
7403
stmt_ty
7404
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7405
             lineno, int col_offset, int end_lineno, int end_col_offset,
7406
             PyArena *arena)
7407
1.57k
{
7408
1.57k
    stmt_ty p;
7409
1.57k
    if (!test) {
7410
0
        PyErr_SetString(PyExc_ValueError,
7411
0
                        "field 'test' is required for While");
7412
0
        return NULL;
7413
0
    }
7414
1.57k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7415
1.57k
    if (!p)
7416
0
        return NULL;
7417
1.57k
    p->kind = While_kind;
7418
1.57k
    p->v.While.test = test;
7419
1.57k
    p->v.While.body = body;
7420
1.57k
    p->v.While.orelse = orelse;
7421
1.57k
    p->lineno = lineno;
7422
1.57k
    p->col_offset = col_offset;
7423
1.57k
    p->end_lineno = end_lineno;
7424
1.57k
    p->end_col_offset = end_col_offset;
7425
1.57k
    return p;
7426
1.57k
}
7427
7428
stmt_ty
7429
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7430
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7431
          *arena)
7432
2.98k
{
7433
2.98k
    stmt_ty p;
7434
2.98k
    if (!test) {
7435
0
        PyErr_SetString(PyExc_ValueError,
7436
0
                        "field 'test' is required for If");
7437
0
        return NULL;
7438
0
    }
7439
2.98k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7440
2.98k
    if (!p)
7441
0
        return NULL;
7442
2.98k
    p->kind = If_kind;
7443
2.98k
    p->v.If.test = test;
7444
2.98k
    p->v.If.body = body;
7445
2.98k
    p->v.If.orelse = orelse;
7446
2.98k
    p->lineno = lineno;
7447
2.98k
    p->col_offset = col_offset;
7448
2.98k
    p->end_lineno = end_lineno;
7449
2.98k
    p->end_col_offset = end_col_offset;
7450
2.98k
    return p;
7451
2.98k
}
7452
7453
stmt_ty
7454
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7455
            type_comment, int lineno, int col_offset, int end_lineno, int
7456
            end_col_offset, PyArena *arena)
7457
3.82k
{
7458
3.82k
    stmt_ty p;
7459
3.82k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7460
3.82k
    if (!p)
7461
0
        return NULL;
7462
3.82k
    p->kind = With_kind;
7463
3.82k
    p->v.With.items = items;
7464
3.82k
    p->v.With.body = body;
7465
3.82k
    p->v.With.type_comment = type_comment;
7466
3.82k
    p->lineno = lineno;
7467
3.82k
    p->col_offset = col_offset;
7468
3.82k
    p->end_lineno = end_lineno;
7469
3.82k
    p->end_col_offset = end_col_offset;
7470
3.82k
    return p;
7471
3.82k
}
7472
7473
stmt_ty
7474
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7475
                 type_comment, int lineno, int col_offset, int end_lineno, int
7476
                 end_col_offset, PyArena *arena)
7477
1.36k
{
7478
1.36k
    stmt_ty p;
7479
1.36k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7480
1.36k
    if (!p)
7481
0
        return NULL;
7482
1.36k
    p->kind = AsyncWith_kind;
7483
1.36k
    p->v.AsyncWith.items = items;
7484
1.36k
    p->v.AsyncWith.body = body;
7485
1.36k
    p->v.AsyncWith.type_comment = type_comment;
7486
1.36k
    p->lineno = lineno;
7487
1.36k
    p->col_offset = col_offset;
7488
1.36k
    p->end_lineno = end_lineno;
7489
1.36k
    p->end_col_offset = end_col_offset;
7490
1.36k
    return p;
7491
1.36k
}
7492
7493
stmt_ty
7494
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7495
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7496
306
{
7497
306
    stmt_ty p;
7498
306
    if (!subject) {
7499
0
        PyErr_SetString(PyExc_ValueError,
7500
0
                        "field 'subject' is required for Match");
7501
0
        return NULL;
7502
0
    }
7503
306
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7504
306
    if (!p)
7505
0
        return NULL;
7506
306
    p->kind = Match_kind;
7507
306
    p->v.Match.subject = subject;
7508
306
    p->v.Match.cases = cases;
7509
306
    p->lineno = lineno;
7510
306
    p->col_offset = col_offset;
7511
306
    p->end_lineno = end_lineno;
7512
306
    p->end_col_offset = end_col_offset;
7513
306
    return p;
7514
306
}
7515
7516
stmt_ty
7517
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7518
             end_lineno, int end_col_offset, PyArena *arena)
7519
2.29k
{
7520
2.29k
    stmt_ty p;
7521
2.29k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7522
2.29k
    if (!p)
7523
0
        return NULL;
7524
2.29k
    p->kind = Raise_kind;
7525
2.29k
    p->v.Raise.exc = exc;
7526
2.29k
    p->v.Raise.cause = cause;
7527
2.29k
    p->lineno = lineno;
7528
2.29k
    p->col_offset = col_offset;
7529
2.29k
    p->end_lineno = end_lineno;
7530
2.29k
    p->end_col_offset = end_col_offset;
7531
2.29k
    return p;
7532
2.29k
}
7533
7534
stmt_ty
7535
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7536
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7537
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7538
2.35k
{
7539
2.35k
    stmt_ty p;
7540
2.35k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7541
2.35k
    if (!p)
7542
0
        return NULL;
7543
2.35k
    p->kind = Try_kind;
7544
2.35k
    p->v.Try.body = body;
7545
2.35k
    p->v.Try.handlers = handlers;
7546
2.35k
    p->v.Try.orelse = orelse;
7547
2.35k
    p->v.Try.finalbody = finalbody;
7548
2.35k
    p->lineno = lineno;
7549
2.35k
    p->col_offset = col_offset;
7550
2.35k
    p->end_lineno = end_lineno;
7551
2.35k
    p->end_col_offset = end_col_offset;
7552
2.35k
    return p;
7553
2.35k
}
7554
7555
stmt_ty
7556
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7557
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7558
               int col_offset, int end_lineno, int end_col_offset, PyArena
7559
               *arena)
7560
1.67k
{
7561
1.67k
    stmt_ty p;
7562
1.67k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7563
1.67k
    if (!p)
7564
0
        return NULL;
7565
1.67k
    p->kind = TryStar_kind;
7566
1.67k
    p->v.TryStar.body = body;
7567
1.67k
    p->v.TryStar.handlers = handlers;
7568
1.67k
    p->v.TryStar.orelse = orelse;
7569
1.67k
    p->v.TryStar.finalbody = finalbody;
7570
1.67k
    p->lineno = lineno;
7571
1.67k
    p->col_offset = col_offset;
7572
1.67k
    p->end_lineno = end_lineno;
7573
1.67k
    p->end_col_offset = end_col_offset;
7574
1.67k
    return p;
7575
1.67k
}
7576
7577
stmt_ty
7578
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7579
              end_lineno, int end_col_offset, PyArena *arena)
7580
3.42k
{
7581
3.42k
    stmt_ty p;
7582
3.42k
    if (!test) {
7583
0
        PyErr_SetString(PyExc_ValueError,
7584
0
                        "field 'test' is required for Assert");
7585
0
        return NULL;
7586
0
    }
7587
3.42k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7588
3.42k
    if (!p)
7589
0
        return NULL;
7590
3.42k
    p->kind = Assert_kind;
7591
3.42k
    p->v.Assert.test = test;
7592
3.42k
    p->v.Assert.msg = msg;
7593
3.42k
    p->lineno = lineno;
7594
3.42k
    p->col_offset = col_offset;
7595
3.42k
    p->end_lineno = end_lineno;
7596
3.42k
    p->end_col_offset = end_col_offset;
7597
3.42k
    return p;
7598
3.42k
}
7599
7600
stmt_ty
7601
_PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
7602
              end_lineno, int end_col_offset, PyArena *arena)
7603
2.52k
{
7604
2.52k
    stmt_ty p;
7605
2.52k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7606
2.52k
    if (!p)
7607
0
        return NULL;
7608
2.52k
    p->kind = Import_kind;
7609
2.52k
    p->v.Import.names = names;
7610
2.52k
    p->lineno = lineno;
7611
2.52k
    p->col_offset = col_offset;
7612
2.52k
    p->end_lineno = end_lineno;
7613
2.52k
    p->end_col_offset = end_col_offset;
7614
2.52k
    return p;
7615
2.52k
}
7616
7617
stmt_ty
7618
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7619
                  lineno, int col_offset, int end_lineno, int end_col_offset,
7620
                  PyArena *arena)
7621
5.31k
{
7622
5.31k
    stmt_ty p;
7623
5.31k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7624
5.31k
    if (!p)
7625
0
        return NULL;
7626
5.31k
    p->kind = ImportFrom_kind;
7627
5.31k
    p->v.ImportFrom.module = module;
7628
5.31k
    p->v.ImportFrom.names = names;
7629
5.31k
    p->v.ImportFrom.level = level;
7630
5.31k
    p->lineno = lineno;
7631
5.31k
    p->col_offset = col_offset;
7632
5.31k
    p->end_lineno = end_lineno;
7633
5.31k
    p->end_col_offset = end_col_offset;
7634
5.31k
    return p;
7635
5.31k
}
7636
7637
stmt_ty
7638
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7639
              end_lineno, int end_col_offset, PyArena *arena)
7640
1.16k
{
7641
1.16k
    stmt_ty p;
7642
1.16k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7643
1.16k
    if (!p)
7644
0
        return NULL;
7645
1.16k
    p->kind = Global_kind;
7646
1.16k
    p->v.Global.names = names;
7647
1.16k
    p->lineno = lineno;
7648
1.16k
    p->col_offset = col_offset;
7649
1.16k
    p->end_lineno = end_lineno;
7650
1.16k
    p->end_col_offset = end_col_offset;
7651
1.16k
    return p;
7652
1.16k
}
7653
7654
stmt_ty
7655
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7656
                end_lineno, int end_col_offset, PyArena *arena)
7657
267
{
7658
267
    stmt_ty p;
7659
267
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7660
267
    if (!p)
7661
0
        return NULL;
7662
267
    p->kind = Nonlocal_kind;
7663
267
    p->v.Nonlocal.names = names;
7664
267
    p->lineno = lineno;
7665
267
    p->col_offset = col_offset;
7666
267
    p->end_lineno = end_lineno;
7667
267
    p->end_col_offset = end_col_offset;
7668
267
    return p;
7669
267
}
7670
7671
stmt_ty
7672
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7673
            end_col_offset, PyArena *arena)
7674
134k
{
7675
134k
    stmt_ty p;
7676
134k
    if (!value) {
7677
0
        PyErr_SetString(PyExc_ValueError,
7678
0
                        "field 'value' is required for Expr");
7679
0
        return NULL;
7680
0
    }
7681
134k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7682
134k
    if (!p)
7683
0
        return NULL;
7684
134k
    p->kind = Expr_kind;
7685
134k
    p->v.Expr.value = value;
7686
134k
    p->lineno = lineno;
7687
134k
    p->col_offset = col_offset;
7688
134k
    p->end_lineno = end_lineno;
7689
134k
    p->end_col_offset = end_col_offset;
7690
134k
    return p;
7691
134k
}
7692
7693
stmt_ty
7694
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7695
            PyArena *arena)
7696
1.52k
{
7697
1.52k
    stmt_ty p;
7698
1.52k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7699
1.52k
    if (!p)
7700
0
        return NULL;
7701
1.52k
    p->kind = Pass_kind;
7702
1.52k
    p->lineno = lineno;
7703
1.52k
    p->col_offset = col_offset;
7704
1.52k
    p->end_lineno = end_lineno;
7705
1.52k
    p->end_col_offset = end_col_offset;
7706
1.52k
    return p;
7707
1.52k
}
7708
7709
stmt_ty
7710
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7711
             PyArena *arena)
7712
1.87k
{
7713
1.87k
    stmt_ty p;
7714
1.87k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7715
1.87k
    if (!p)
7716
0
        return NULL;
7717
1.87k
    p->kind = Break_kind;
7718
1.87k
    p->lineno = lineno;
7719
1.87k
    p->col_offset = col_offset;
7720
1.87k
    p->end_lineno = end_lineno;
7721
1.87k
    p->end_col_offset = end_col_offset;
7722
1.87k
    return p;
7723
1.87k
}
7724
7725
stmt_ty
7726
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7727
                PyArena *arena)
7728
668
{
7729
668
    stmt_ty p;
7730
668
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7731
668
    if (!p)
7732
0
        return NULL;
7733
668
    p->kind = Continue_kind;
7734
668
    p->lineno = lineno;
7735
668
    p->col_offset = col_offset;
7736
668
    p->end_lineno = end_lineno;
7737
668
    p->end_col_offset = end_col_offset;
7738
668
    return p;
7739
668
}
7740
7741
expr_ty
7742
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7743
              int end_lineno, int end_col_offset, PyArena *arena)
7744
3.08k
{
7745
3.08k
    expr_ty p;
7746
3.08k
    if (!op) {
7747
0
        PyErr_SetString(PyExc_ValueError,
7748
0
                        "field 'op' is required for BoolOp");
7749
0
        return NULL;
7750
0
    }
7751
3.08k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7752
3.08k
    if (!p)
7753
0
        return NULL;
7754
3.08k
    p->kind = BoolOp_kind;
7755
3.08k
    p->v.BoolOp.op = op;
7756
3.08k
    p->v.BoolOp.values = values;
7757
3.08k
    p->lineno = lineno;
7758
3.08k
    p->col_offset = col_offset;
7759
3.08k
    p->end_lineno = end_lineno;
7760
3.08k
    p->end_col_offset = end_col_offset;
7761
3.08k
    return p;
7762
3.08k
}
7763
7764
expr_ty
7765
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7766
                 end_lineno, int end_col_offset, PyArena *arena)
7767
2.46k
{
7768
2.46k
    expr_ty p;
7769
2.46k
    if (!target) {
7770
0
        PyErr_SetString(PyExc_ValueError,
7771
0
                        "field 'target' is required for NamedExpr");
7772
0
        return NULL;
7773
0
    }
7774
2.46k
    if (!value) {
7775
0
        PyErr_SetString(PyExc_ValueError,
7776
0
                        "field 'value' is required for NamedExpr");
7777
0
        return NULL;
7778
0
    }
7779
2.46k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7780
2.46k
    if (!p)
7781
0
        return NULL;
7782
2.46k
    p->kind = NamedExpr_kind;
7783
2.46k
    p->v.NamedExpr.target = target;
7784
2.46k
    p->v.NamedExpr.value = value;
7785
2.46k
    p->lineno = lineno;
7786
2.46k
    p->col_offset = col_offset;
7787
2.46k
    p->end_lineno = end_lineno;
7788
2.46k
    p->end_col_offset = end_col_offset;
7789
2.46k
    return p;
7790
2.46k
}
7791
7792
expr_ty
7793
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7794
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7795
576k
{
7796
576k
    expr_ty p;
7797
576k
    if (!left) {
7798
0
        PyErr_SetString(PyExc_ValueError,
7799
0
                        "field 'left' is required for BinOp");
7800
0
        return NULL;
7801
0
    }
7802
576k
    if (!op) {
7803
0
        PyErr_SetString(PyExc_ValueError,
7804
0
                        "field 'op' is required for BinOp");
7805
0
        return NULL;
7806
0
    }
7807
576k
    if (!right) {
7808
0
        PyErr_SetString(PyExc_ValueError,
7809
0
                        "field 'right' is required for BinOp");
7810
0
        return NULL;
7811
0
    }
7812
576k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7813
576k
    if (!p)
7814
0
        return NULL;
7815
576k
    p->kind = BinOp_kind;
7816
576k
    p->v.BinOp.left = left;
7817
576k
    p->v.BinOp.op = op;
7818
576k
    p->v.BinOp.right = right;
7819
576k
    p->lineno = lineno;
7820
576k
    p->col_offset = col_offset;
7821
576k
    p->end_lineno = end_lineno;
7822
576k
    p->end_col_offset = end_col_offset;
7823
576k
    return p;
7824
576k
}
7825
7826
expr_ty
7827
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7828
               end_lineno, int end_col_offset, PyArena *arena)
7829
243k
{
7830
243k
    expr_ty p;
7831
243k
    if (!op) {
7832
0
        PyErr_SetString(PyExc_ValueError,
7833
0
                        "field 'op' is required for UnaryOp");
7834
0
        return NULL;
7835
0
    }
7836
243k
    if (!operand) {
7837
0
        PyErr_SetString(PyExc_ValueError,
7838
0
                        "field 'operand' is required for UnaryOp");
7839
0
        return NULL;
7840
0
    }
7841
243k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7842
243k
    if (!p)
7843
0
        return NULL;
7844
243k
    p->kind = UnaryOp_kind;
7845
243k
    p->v.UnaryOp.op = op;
7846
243k
    p->v.UnaryOp.operand = operand;
7847
243k
    p->lineno = lineno;
7848
243k
    p->col_offset = col_offset;
7849
243k
    p->end_lineno = end_lineno;
7850
243k
    p->end_col_offset = end_col_offset;
7851
243k
    return p;
7852
243k
}
7853
7854
expr_ty
7855
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7856
              end_lineno, int end_col_offset, PyArena *arena)
7857
12.2k
{
7858
12.2k
    expr_ty p;
7859
12.2k
    if (!args) {
7860
0
        PyErr_SetString(PyExc_ValueError,
7861
0
                        "field 'args' is required for Lambda");
7862
0
        return NULL;
7863
0
    }
7864
12.2k
    if (!body) {
7865
0
        PyErr_SetString(PyExc_ValueError,
7866
0
                        "field 'body' is required for Lambda");
7867
0
        return NULL;
7868
0
    }
7869
12.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7870
12.2k
    if (!p)
7871
0
        return NULL;
7872
12.2k
    p->kind = Lambda_kind;
7873
12.2k
    p->v.Lambda.args = args;
7874
12.2k
    p->v.Lambda.body = body;
7875
12.2k
    p->lineno = lineno;
7876
12.2k
    p->col_offset = col_offset;
7877
12.2k
    p->end_lineno = end_lineno;
7878
12.2k
    p->end_col_offset = end_col_offset;
7879
12.2k
    return p;
7880
12.2k
}
7881
7882
expr_ty
7883
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7884
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7885
2.46k
{
7886
2.46k
    expr_ty p;
7887
2.46k
    if (!test) {
7888
0
        PyErr_SetString(PyExc_ValueError,
7889
0
                        "field 'test' is required for IfExp");
7890
0
        return NULL;
7891
0
    }
7892
2.46k
    if (!body) {
7893
0
        PyErr_SetString(PyExc_ValueError,
7894
0
                        "field 'body' is required for IfExp");
7895
0
        return NULL;
7896
0
    }
7897
2.46k
    if (!orelse) {
7898
0
        PyErr_SetString(PyExc_ValueError,
7899
0
                        "field 'orelse' is required for IfExp");
7900
0
        return NULL;
7901
0
    }
7902
2.46k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7903
2.46k
    if (!p)
7904
0
        return NULL;
7905
2.46k
    p->kind = IfExp_kind;
7906
2.46k
    p->v.IfExp.test = test;
7907
2.46k
    p->v.IfExp.body = body;
7908
2.46k
    p->v.IfExp.orelse = orelse;
7909
2.46k
    p->lineno = lineno;
7910
2.46k
    p->col_offset = col_offset;
7911
2.46k
    p->end_lineno = end_lineno;
7912
2.46k
    p->end_col_offset = end_col_offset;
7913
2.46k
    return p;
7914
2.46k
}
7915
7916
expr_ty
7917
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7918
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7919
2.63k
{
7920
2.63k
    expr_ty p;
7921
2.63k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7922
2.63k
    if (!p)
7923
0
        return NULL;
7924
2.63k
    p->kind = Dict_kind;
7925
2.63k
    p->v.Dict.keys = keys;
7926
2.63k
    p->v.Dict.values = values;
7927
2.63k
    p->lineno = lineno;
7928
2.63k
    p->col_offset = col_offset;
7929
2.63k
    p->end_lineno = end_lineno;
7930
2.63k
    p->end_col_offset = end_col_offset;
7931
2.63k
    return p;
7932
2.63k
}
7933
7934
expr_ty
7935
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7936
           int end_col_offset, PyArena *arena)
7937
14.2k
{
7938
14.2k
    expr_ty p;
7939
14.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7940
14.2k
    if (!p)
7941
0
        return NULL;
7942
14.2k
    p->kind = Set_kind;
7943
14.2k
    p->v.Set.elts = elts;
7944
14.2k
    p->lineno = lineno;
7945
14.2k
    p->col_offset = col_offset;
7946
14.2k
    p->end_lineno = end_lineno;
7947
14.2k
    p->end_col_offset = end_col_offset;
7948
14.2k
    return p;
7949
14.2k
}
7950
7951
expr_ty
7952
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7953
                int col_offset, int end_lineno, int end_col_offset, PyArena
7954
                *arena)
7955
3.85k
{
7956
3.85k
    expr_ty p;
7957
3.85k
    if (!elt) {
7958
0
        PyErr_SetString(PyExc_ValueError,
7959
0
                        "field 'elt' is required for ListComp");
7960
0
        return NULL;
7961
0
    }
7962
3.85k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7963
3.85k
    if (!p)
7964
0
        return NULL;
7965
3.85k
    p->kind = ListComp_kind;
7966
3.85k
    p->v.ListComp.elt = elt;
7967
3.85k
    p->v.ListComp.generators = generators;
7968
3.85k
    p->lineno = lineno;
7969
3.85k
    p->col_offset = col_offset;
7970
3.85k
    p->end_lineno = end_lineno;
7971
3.85k
    p->end_col_offset = end_col_offset;
7972
3.85k
    return p;
7973
3.85k
}
7974
7975
expr_ty
7976
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7977
               int col_offset, int end_lineno, int end_col_offset, PyArena
7978
               *arena)
7979
3.73k
{
7980
3.73k
    expr_ty p;
7981
3.73k
    if (!elt) {
7982
0
        PyErr_SetString(PyExc_ValueError,
7983
0
                        "field 'elt' is required for SetComp");
7984
0
        return NULL;
7985
0
    }
7986
3.73k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7987
3.73k
    if (!p)
7988
0
        return NULL;
7989
3.73k
    p->kind = SetComp_kind;
7990
3.73k
    p->v.SetComp.elt = elt;
7991
3.73k
    p->v.SetComp.generators = generators;
7992
3.73k
    p->lineno = lineno;
7993
3.73k
    p->col_offset = col_offset;
7994
3.73k
    p->end_lineno = end_lineno;
7995
3.73k
    p->end_col_offset = end_col_offset;
7996
3.73k
    return p;
7997
3.73k
}
7998
7999
expr_ty
8000
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
8001
                generators, int lineno, int col_offset, int end_lineno, int
8002
                end_col_offset, PyArena *arena)
8003
1.47k
{
8004
1.47k
    expr_ty p;
8005
1.47k
    if (!key) {
8006
0
        PyErr_SetString(PyExc_ValueError,
8007
0
                        "field 'key' is required for DictComp");
8008
0
        return NULL;
8009
0
    }
8010
1.47k
    if (!value) {
8011
0
        PyErr_SetString(PyExc_ValueError,
8012
0
                        "field 'value' is required for DictComp");
8013
0
        return NULL;
8014
0
    }
8015
1.47k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8016
1.47k
    if (!p)
8017
0
        return NULL;
8018
1.47k
    p->kind = DictComp_kind;
8019
1.47k
    p->v.DictComp.key = key;
8020
1.47k
    p->v.DictComp.value = value;
8021
1.47k
    p->v.DictComp.generators = generators;
8022
1.47k
    p->lineno = lineno;
8023
1.47k
    p->col_offset = col_offset;
8024
1.47k
    p->end_lineno = end_lineno;
8025
1.47k
    p->end_col_offset = end_col_offset;
8026
1.47k
    return p;
8027
1.47k
}
8028
8029
expr_ty
8030
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8031
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8032
                    PyArena *arena)
8033
8.80k
{
8034
8.80k
    expr_ty p;
8035
8.80k
    if (!elt) {
8036
0
        PyErr_SetString(PyExc_ValueError,
8037
0
                        "field 'elt' is required for GeneratorExp");
8038
0
        return NULL;
8039
0
    }
8040
8.80k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8041
8.80k
    if (!p)
8042
0
        return NULL;
8043
8.80k
    p->kind = GeneratorExp_kind;
8044
8.80k
    p->v.GeneratorExp.elt = elt;
8045
8.80k
    p->v.GeneratorExp.generators = generators;
8046
8.80k
    p->lineno = lineno;
8047
8.80k
    p->col_offset = col_offset;
8048
8.80k
    p->end_lineno = end_lineno;
8049
8.80k
    p->end_col_offset = end_col_offset;
8050
8.80k
    return p;
8051
8.80k
}
8052
8053
expr_ty
8054
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8055
             end_col_offset, PyArena *arena)
8056
251
{
8057
251
    expr_ty p;
8058
251
    if (!value) {
8059
0
        PyErr_SetString(PyExc_ValueError,
8060
0
                        "field 'value' is required for Await");
8061
0
        return NULL;
8062
0
    }
8063
251
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8064
251
    if (!p)
8065
0
        return NULL;
8066
251
    p->kind = Await_kind;
8067
251
    p->v.Await.value = value;
8068
251
    p->lineno = lineno;
8069
251
    p->col_offset = col_offset;
8070
251
    p->end_lineno = end_lineno;
8071
251
    p->end_col_offset = end_col_offset;
8072
251
    return p;
8073
251
}
8074
8075
expr_ty
8076
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8077
             end_col_offset, PyArena *arena)
8078
2.88k
{
8079
2.88k
    expr_ty p;
8080
2.88k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8081
2.88k
    if (!p)
8082
0
        return NULL;
8083
2.88k
    p->kind = Yield_kind;
8084
2.88k
    p->v.Yield.value = value;
8085
2.88k
    p->lineno = lineno;
8086
2.88k
    p->col_offset = col_offset;
8087
2.88k
    p->end_lineno = end_lineno;
8088
2.88k
    p->end_col_offset = end_col_offset;
8089
2.88k
    return p;
8090
2.88k
}
8091
8092
expr_ty
8093
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8094
                 end_col_offset, PyArena *arena)
8095
94
{
8096
94
    expr_ty p;
8097
94
    if (!value) {
8098
0
        PyErr_SetString(PyExc_ValueError,
8099
0
                        "field 'value' is required for YieldFrom");
8100
0
        return NULL;
8101
0
    }
8102
94
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8103
94
    if (!p)
8104
0
        return NULL;
8105
94
    p->kind = YieldFrom_kind;
8106
94
    p->v.YieldFrom.value = value;
8107
94
    p->lineno = lineno;
8108
94
    p->col_offset = col_offset;
8109
94
    p->end_lineno = end_lineno;
8110
94
    p->end_col_offset = end_col_offset;
8111
94
    return p;
8112
94
}
8113
8114
expr_ty
8115
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8116
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8117
               PyArena *arena)
8118
21.5k
{
8119
21.5k
    expr_ty p;
8120
21.5k
    if (!left) {
8121
0
        PyErr_SetString(PyExc_ValueError,
8122
0
                        "field 'left' is required for Compare");
8123
0
        return NULL;
8124
0
    }
8125
21.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8126
21.5k
    if (!p)
8127
0
        return NULL;
8128
21.5k
    p->kind = Compare_kind;
8129
21.5k
    p->v.Compare.left = left;
8130
21.5k
    p->v.Compare.ops = ops;
8131
21.5k
    p->v.Compare.comparators = comparators;
8132
21.5k
    p->lineno = lineno;
8133
21.5k
    p->col_offset = col_offset;
8134
21.5k
    p->end_lineno = end_lineno;
8135
21.5k
    p->end_col_offset = end_col_offset;
8136
21.5k
    return p;
8137
21.5k
}
8138
8139
expr_ty
8140
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8141
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8142
            PyArena *arena)
8143
61.2k
{
8144
61.2k
    expr_ty p;
8145
61.2k
    if (!func) {
8146
0
        PyErr_SetString(PyExc_ValueError,
8147
0
                        "field 'func' is required for Call");
8148
0
        return NULL;
8149
0
    }
8150
61.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8151
61.2k
    if (!p)
8152
0
        return NULL;
8153
61.2k
    p->kind = Call_kind;
8154
61.2k
    p->v.Call.func = func;
8155
61.2k
    p->v.Call.args = args;
8156
61.2k
    p->v.Call.keywords = keywords;
8157
61.2k
    p->lineno = lineno;
8158
61.2k
    p->col_offset = col_offset;
8159
61.2k
    p->end_lineno = end_lineno;
8160
61.2k
    p->end_col_offset = end_col_offset;
8161
61.2k
    return p;
8162
61.2k
}
8163
8164
expr_ty
8165
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8166
                      lineno, int col_offset, int end_lineno, int
8167
                      end_col_offset, PyArena *arena)
8168
17.9k
{
8169
17.9k
    expr_ty p;
8170
17.9k
    if (!value) {
8171
0
        PyErr_SetString(PyExc_ValueError,
8172
0
                        "field 'value' is required for FormattedValue");
8173
0
        return NULL;
8174
0
    }
8175
17.9k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8176
17.9k
    if (!p)
8177
0
        return NULL;
8178
17.9k
    p->kind = FormattedValue_kind;
8179
17.9k
    p->v.FormattedValue.value = value;
8180
17.9k
    p->v.FormattedValue.conversion = conversion;
8181
17.9k
    p->v.FormattedValue.format_spec = format_spec;
8182
17.9k
    p->lineno = lineno;
8183
17.9k
    p->col_offset = col_offset;
8184
17.9k
    p->end_lineno = end_lineno;
8185
17.9k
    p->end_col_offset = end_col_offset;
8186
17.9k
    return p;
8187
17.9k
}
8188
8189
expr_ty
8190
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8191
                     format_spec, int lineno, int col_offset, int end_lineno,
8192
                     int end_col_offset, PyArena *arena)
8193
5.30k
{
8194
5.30k
    expr_ty p;
8195
5.30k
    if (!value) {
8196
0
        PyErr_SetString(PyExc_ValueError,
8197
0
                        "field 'value' is required for Interpolation");
8198
0
        return NULL;
8199
0
    }
8200
5.30k
    if (!str) {
8201
0
        PyErr_SetString(PyExc_ValueError,
8202
0
                        "field 'str' is required for Interpolation");
8203
0
        return NULL;
8204
0
    }
8205
5.30k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8206
5.30k
    if (!p)
8207
0
        return NULL;
8208
5.30k
    p->kind = Interpolation_kind;
8209
5.30k
    p->v.Interpolation.value = value;
8210
5.30k
    p->v.Interpolation.str = str;
8211
5.30k
    p->v.Interpolation.conversion = conversion;
8212
5.30k
    p->v.Interpolation.format_spec = format_spec;
8213
5.30k
    p->lineno = lineno;
8214
5.30k
    p->col_offset = col_offset;
8215
5.30k
    p->end_lineno = end_lineno;
8216
5.30k
    p->end_col_offset = end_col_offset;
8217
5.30k
    return p;
8218
5.30k
}
8219
8220
expr_ty
8221
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8222
                 end_lineno, int end_col_offset, PyArena *arena)
8223
38.5k
{
8224
38.5k
    expr_ty p;
8225
38.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8226
38.5k
    if (!p)
8227
0
        return NULL;
8228
38.5k
    p->kind = JoinedStr_kind;
8229
38.5k
    p->v.JoinedStr.values = values;
8230
38.5k
    p->lineno = lineno;
8231
38.5k
    p->col_offset = col_offset;
8232
38.5k
    p->end_lineno = end_lineno;
8233
38.5k
    p->end_col_offset = end_col_offset;
8234
38.5k
    return p;
8235
38.5k
}
8236
8237
expr_ty
8238
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8239
                   end_lineno, int end_col_offset, PyArena *arena)
8240
8.99k
{
8241
8.99k
    expr_ty p;
8242
8.99k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8243
8.99k
    if (!p)
8244
0
        return NULL;
8245
8.99k
    p->kind = TemplateStr_kind;
8246
8.99k
    p->v.TemplateStr.values = values;
8247
8.99k
    p->lineno = lineno;
8248
8.99k
    p->col_offset = col_offset;
8249
8.99k
    p->end_lineno = end_lineno;
8250
8.99k
    p->end_col_offset = end_col_offset;
8251
8.99k
    return p;
8252
8.99k
}
8253
8254
expr_ty
8255
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8256
                end_lineno, int end_col_offset, PyArena *arena)
8257
1.66M
{
8258
1.66M
    expr_ty p;
8259
1.66M
    if (!value) {
8260
3
        PyErr_SetString(PyExc_ValueError,
8261
3
                        "field 'value' is required for Constant");
8262
3
        return NULL;
8263
3
    }
8264
1.66M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8265
1.66M
    if (!p)
8266
0
        return NULL;
8267
1.66M
    p->kind = Constant_kind;
8268
1.66M
    p->v.Constant.value = value;
8269
1.66M
    p->v.Constant.kind = kind;
8270
1.66M
    p->lineno = lineno;
8271
1.66M
    p->col_offset = col_offset;
8272
1.66M
    p->end_lineno = end_lineno;
8273
1.66M
    p->end_col_offset = end_col_offset;
8274
1.66M
    return p;
8275
1.66M
}
8276
8277
expr_ty
8278
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8279
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8280
                 PyArena *arena)
8281
54.2k
{
8282
54.2k
    expr_ty p;
8283
54.2k
    if (!value) {
8284
0
        PyErr_SetString(PyExc_ValueError,
8285
0
                        "field 'value' is required for Attribute");
8286
0
        return NULL;
8287
0
    }
8288
54.2k
    if (!attr) {
8289
0
        PyErr_SetString(PyExc_ValueError,
8290
0
                        "field 'attr' is required for Attribute");
8291
0
        return NULL;
8292
0
    }
8293
54.2k
    if (!ctx) {
8294
0
        PyErr_SetString(PyExc_ValueError,
8295
0
                        "field 'ctx' is required for Attribute");
8296
0
        return NULL;
8297
0
    }
8298
54.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8299
54.2k
    if (!p)
8300
0
        return NULL;
8301
54.2k
    p->kind = Attribute_kind;
8302
54.2k
    p->v.Attribute.value = value;
8303
54.2k
    p->v.Attribute.attr = attr;
8304
54.2k
    p->v.Attribute.ctx = ctx;
8305
54.2k
    p->lineno = lineno;
8306
54.2k
    p->col_offset = col_offset;
8307
54.2k
    p->end_lineno = end_lineno;
8308
54.2k
    p->end_col_offset = end_col_offset;
8309
54.2k
    return p;
8310
54.2k
}
8311
8312
expr_ty
8313
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8314
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8315
                 *arena)
8316
39.0k
{
8317
39.0k
    expr_ty p;
8318
39.0k
    if (!value) {
8319
0
        PyErr_SetString(PyExc_ValueError,
8320
0
                        "field 'value' is required for Subscript");
8321
0
        return NULL;
8322
0
    }
8323
39.0k
    if (!slice) {
8324
0
        PyErr_SetString(PyExc_ValueError,
8325
0
                        "field 'slice' is required for Subscript");
8326
0
        return NULL;
8327
0
    }
8328
39.0k
    if (!ctx) {
8329
0
        PyErr_SetString(PyExc_ValueError,
8330
0
                        "field 'ctx' is required for Subscript");
8331
0
        return NULL;
8332
0
    }
8333
39.0k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8334
39.0k
    if (!p)
8335
0
        return NULL;
8336
39.0k
    p->kind = Subscript_kind;
8337
39.0k
    p->v.Subscript.value = value;
8338
39.0k
    p->v.Subscript.slice = slice;
8339
39.0k
    p->v.Subscript.ctx = ctx;
8340
39.0k
    p->lineno = lineno;
8341
39.0k
    p->col_offset = col_offset;
8342
39.0k
    p->end_lineno = end_lineno;
8343
39.0k
    p->end_col_offset = end_col_offset;
8344
39.0k
    return p;
8345
39.0k
}
8346
8347
expr_ty
8348
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8349
               int end_lineno, int end_col_offset, PyArena *arena)
8350
63.1k
{
8351
63.1k
    expr_ty p;
8352
63.1k
    if (!value) {
8353
0
        PyErr_SetString(PyExc_ValueError,
8354
0
                        "field 'value' is required for Starred");
8355
0
        return NULL;
8356
0
    }
8357
63.1k
    if (!ctx) {
8358
0
        PyErr_SetString(PyExc_ValueError,
8359
0
                        "field 'ctx' is required for Starred");
8360
0
        return NULL;
8361
0
    }
8362
63.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8363
63.1k
    if (!p)
8364
0
        return NULL;
8365
63.1k
    p->kind = Starred_kind;
8366
63.1k
    p->v.Starred.value = value;
8367
63.1k
    p->v.Starred.ctx = ctx;
8368
63.1k
    p->lineno = lineno;
8369
63.1k
    p->col_offset = col_offset;
8370
63.1k
    p->end_lineno = end_lineno;
8371
63.1k
    p->end_col_offset = end_col_offset;
8372
63.1k
    return p;
8373
63.1k
}
8374
8375
expr_ty
8376
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8377
            end_lineno, int end_col_offset, PyArena *arena)
8378
3.36M
{
8379
3.36M
    expr_ty p;
8380
3.36M
    if (!id) {
8381
0
        PyErr_SetString(PyExc_ValueError,
8382
0
                        "field 'id' is required for Name");
8383
0
        return NULL;
8384
0
    }
8385
3.36M
    if (!ctx) {
8386
0
        PyErr_SetString(PyExc_ValueError,
8387
0
                        "field 'ctx' is required for Name");
8388
0
        return NULL;
8389
0
    }
8390
3.36M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8391
3.36M
    if (!p)
8392
0
        return NULL;
8393
3.36M
    p->kind = Name_kind;
8394
3.36M
    p->v.Name.id = id;
8395
3.36M
    p->v.Name.ctx = ctx;
8396
3.36M
    p->lineno = lineno;
8397
3.36M
    p->col_offset = col_offset;
8398
3.36M
    p->end_lineno = end_lineno;
8399
3.36M
    p->end_col_offset = end_col_offset;
8400
3.36M
    return p;
8401
3.36M
}
8402
8403
expr_ty
8404
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8405
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8406
80.1k
{
8407
80.1k
    expr_ty p;
8408
80.1k
    if (!ctx) {
8409
0
        PyErr_SetString(PyExc_ValueError,
8410
0
                        "field 'ctx' is required for List");
8411
0
        return NULL;
8412
0
    }
8413
80.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8414
80.1k
    if (!p)
8415
0
        return NULL;
8416
80.1k
    p->kind = List_kind;
8417
80.1k
    p->v.List.elts = elts;
8418
80.1k
    p->v.List.ctx = ctx;
8419
80.1k
    p->lineno = lineno;
8420
80.1k
    p->col_offset = col_offset;
8421
80.1k
    p->end_lineno = end_lineno;
8422
80.1k
    p->end_col_offset = end_col_offset;
8423
80.1k
    return p;
8424
80.1k
}
8425
8426
expr_ty
8427
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8428
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8429
200k
{
8430
200k
    expr_ty p;
8431
200k
    if (!ctx) {
8432
0
        PyErr_SetString(PyExc_ValueError,
8433
0
                        "field 'ctx' is required for Tuple");
8434
0
        return NULL;
8435
0
    }
8436
200k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8437
200k
    if (!p)
8438
0
        return NULL;
8439
200k
    p->kind = Tuple_kind;
8440
200k
    p->v.Tuple.elts = elts;
8441
200k
    p->v.Tuple.ctx = ctx;
8442
200k
    p->lineno = lineno;
8443
200k
    p->col_offset = col_offset;
8444
200k
    p->end_lineno = end_lineno;
8445
200k
    p->end_col_offset = end_col_offset;
8446
200k
    return p;
8447
200k
}
8448
8449
expr_ty
8450
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8451
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8452
38.4k
{
8453
38.4k
    expr_ty p;
8454
38.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8455
38.4k
    if (!p)
8456
0
        return NULL;
8457
38.4k
    p->kind = Slice_kind;
8458
38.4k
    p->v.Slice.lower = lower;
8459
38.4k
    p->v.Slice.upper = upper;
8460
38.4k
    p->v.Slice.step = step;
8461
38.4k
    p->lineno = lineno;
8462
38.4k
    p->col_offset = col_offset;
8463
38.4k
    p->end_lineno = end_lineno;
8464
38.4k
    p->end_col_offset = end_col_offset;
8465
38.4k
    return p;
8466
38.4k
}
8467
8468
comprehension_ty
8469
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8470
                     is_async, PyArena *arena)
8471
23.9k
{
8472
23.9k
    comprehension_ty p;
8473
23.9k
    if (!target) {
8474
0
        PyErr_SetString(PyExc_ValueError,
8475
0
                        "field 'target' is required for comprehension");
8476
0
        return NULL;
8477
0
    }
8478
23.9k
    if (!iter) {
8479
0
        PyErr_SetString(PyExc_ValueError,
8480
0
                        "field 'iter' is required for comprehension");
8481
0
        return NULL;
8482
0
    }
8483
23.9k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8484
23.9k
    if (!p)
8485
0
        return NULL;
8486
23.9k
    p->target = target;
8487
23.9k
    p->iter = iter;
8488
23.9k
    p->ifs = ifs;
8489
23.9k
    p->is_async = is_async;
8490
23.9k
    return p;
8491
23.9k
}
8492
8493
excepthandler_ty
8494
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8495
                     lineno, int col_offset, int end_lineno, int
8496
                     end_col_offset, PyArena *arena)
8497
7.41k
{
8498
7.41k
    excepthandler_ty p;
8499
7.41k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8500
7.41k
    if (!p)
8501
0
        return NULL;
8502
7.41k
    p->kind = ExceptHandler_kind;
8503
7.41k
    p->v.ExceptHandler.type = type;
8504
7.41k
    p->v.ExceptHandler.name = name;
8505
7.41k
    p->v.ExceptHandler.body = body;
8506
7.41k
    p->lineno = lineno;
8507
7.41k
    p->col_offset = col_offset;
8508
7.41k
    p->end_lineno = end_lineno;
8509
7.41k
    p->end_col_offset = end_col_offset;
8510
7.41k
    return p;
8511
7.41k
}
8512
8513
arguments_ty
8514
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8515
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8516
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8517
                 *arena)
8518
32.4k
{
8519
32.4k
    arguments_ty p;
8520
32.4k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8521
32.4k
    if (!p)
8522
0
        return NULL;
8523
32.4k
    p->posonlyargs = posonlyargs;
8524
32.4k
    p->args = args;
8525
32.4k
    p->vararg = vararg;
8526
32.4k
    p->kwonlyargs = kwonlyargs;
8527
32.4k
    p->kw_defaults = kw_defaults;
8528
32.4k
    p->kwarg = kwarg;
8529
32.4k
    p->defaults = defaults;
8530
32.4k
    return p;
8531
32.4k
}
8532
8533
arg_ty
8534
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8535
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8536
538k
{
8537
538k
    arg_ty p;
8538
538k
    if (!arg) {
8539
0
        PyErr_SetString(PyExc_ValueError,
8540
0
                        "field 'arg' is required for arg");
8541
0
        return NULL;
8542
0
    }
8543
538k
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8544
538k
    if (!p)
8545
0
        return NULL;
8546
538k
    p->arg = arg;
8547
538k
    p->annotation = annotation;
8548
538k
    p->type_comment = type_comment;
8549
538k
    p->lineno = lineno;
8550
538k
    p->col_offset = col_offset;
8551
538k
    p->end_lineno = end_lineno;
8552
538k
    p->end_col_offset = end_col_offset;
8553
538k
    return p;
8554
538k
}
8555
8556
keyword_ty
8557
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8558
               end_lineno, int end_col_offset, PyArena *arena)
8559
45.1k
{
8560
45.1k
    keyword_ty p;
8561
45.1k
    if (!value) {
8562
0
        PyErr_SetString(PyExc_ValueError,
8563
0
                        "field 'value' is required for keyword");
8564
0
        return NULL;
8565
0
    }
8566
45.1k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8567
45.1k
    if (!p)
8568
0
        return NULL;
8569
45.1k
    p->arg = arg;
8570
45.1k
    p->value = value;
8571
45.1k
    p->lineno = lineno;
8572
45.1k
    p->col_offset = col_offset;
8573
45.1k
    p->end_lineno = end_lineno;
8574
45.1k
    p->end_col_offset = end_col_offset;
8575
45.1k
    return p;
8576
45.1k
}
8577
8578
alias_ty
8579
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8580
             int end_lineno, int end_col_offset, PyArena *arena)
8581
18.7k
{
8582
18.7k
    alias_ty p;
8583
18.7k
    if (!name) {
8584
0
        PyErr_SetString(PyExc_ValueError,
8585
0
                        "field 'name' is required for alias");
8586
0
        return NULL;
8587
0
    }
8588
18.7k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8589
18.7k
    if (!p)
8590
0
        return NULL;
8591
18.7k
    p->name = name;
8592
18.7k
    p->asname = asname;
8593
18.7k
    p->lineno = lineno;
8594
18.7k
    p->col_offset = col_offset;
8595
18.7k
    p->end_lineno = end_lineno;
8596
18.7k
    p->end_col_offset = end_col_offset;
8597
18.7k
    return p;
8598
18.7k
}
8599
8600
withitem_ty
8601
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8602
25.4k
{
8603
25.4k
    withitem_ty p;
8604
25.4k
    if (!context_expr) {
8605
0
        PyErr_SetString(PyExc_ValueError,
8606
0
                        "field 'context_expr' is required for withitem");
8607
0
        return NULL;
8608
0
    }
8609
25.4k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8610
25.4k
    if (!p)
8611
0
        return NULL;
8612
25.4k
    p->context_expr = context_expr;
8613
25.4k
    p->optional_vars = optional_vars;
8614
25.4k
    return p;
8615
25.4k
}
8616
8617
match_case_ty
8618
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8619
                  PyArena *arena)
8620
2.75k
{
8621
2.75k
    match_case_ty p;
8622
2.75k
    if (!pattern) {
8623
0
        PyErr_SetString(PyExc_ValueError,
8624
0
                        "field 'pattern' is required for match_case");
8625
0
        return NULL;
8626
0
    }
8627
2.75k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8628
2.75k
    if (!p)
8629
0
        return NULL;
8630
2.75k
    p->pattern = pattern;
8631
2.75k
    p->guard = guard;
8632
2.75k
    p->body = body;
8633
2.75k
    return p;
8634
2.75k
}
8635
8636
pattern_ty
8637
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8638
                  int end_col_offset, PyArena *arena)
8639
36.2k
{
8640
36.2k
    pattern_ty p;
8641
36.2k
    if (!value) {
8642
0
        PyErr_SetString(PyExc_ValueError,
8643
0
                        "field 'value' is required for MatchValue");
8644
0
        return NULL;
8645
0
    }
8646
36.2k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8647
36.2k
    if (!p)
8648
0
        return NULL;
8649
36.2k
    p->kind = MatchValue_kind;
8650
36.2k
    p->v.MatchValue.value = value;
8651
36.2k
    p->lineno = lineno;
8652
36.2k
    p->col_offset = col_offset;
8653
36.2k
    p->end_lineno = end_lineno;
8654
36.2k
    p->end_col_offset = end_col_offset;
8655
36.2k
    return p;
8656
36.2k
}
8657
8658
pattern_ty
8659
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8660
                      end_lineno, int end_col_offset, PyArena *arena)
8661
2.28k
{
8662
2.28k
    pattern_ty p;
8663
2.28k
    if (!value) {
8664
0
        PyErr_SetString(PyExc_ValueError,
8665
0
                        "field 'value' is required for MatchSingleton");
8666
0
        return NULL;
8667
0
    }
8668
2.28k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8669
2.28k
    if (!p)
8670
0
        return NULL;
8671
2.28k
    p->kind = MatchSingleton_kind;
8672
2.28k
    p->v.MatchSingleton.value = value;
8673
2.28k
    p->lineno = lineno;
8674
2.28k
    p->col_offset = col_offset;
8675
2.28k
    p->end_lineno = end_lineno;
8676
2.28k
    p->end_col_offset = end_col_offset;
8677
2.28k
    return p;
8678
2.28k
}
8679
8680
pattern_ty
8681
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8682
                     int end_lineno, int end_col_offset, PyArena *arena)
8683
6.07k
{
8684
6.07k
    pattern_ty p;
8685
6.07k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8686
6.07k
    if (!p)
8687
0
        return NULL;
8688
6.07k
    p->kind = MatchSequence_kind;
8689
6.07k
    p->v.MatchSequence.patterns = patterns;
8690
6.07k
    p->lineno = lineno;
8691
6.07k
    p->col_offset = col_offset;
8692
6.07k
    p->end_lineno = end_lineno;
8693
6.07k
    p->end_col_offset = end_col_offset;
8694
6.07k
    return p;
8695
6.07k
}
8696
8697
pattern_ty
8698
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8699
                    identifier rest, int lineno, int col_offset, int
8700
                    end_lineno, int end_col_offset, PyArena *arena)
8701
58
{
8702
58
    pattern_ty p;
8703
58
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8704
58
    if (!p)
8705
0
        return NULL;
8706
58
    p->kind = MatchMapping_kind;
8707
58
    p->v.MatchMapping.keys = keys;
8708
58
    p->v.MatchMapping.patterns = patterns;
8709
58
    p->v.MatchMapping.rest = rest;
8710
58
    p->lineno = lineno;
8711
58
    p->col_offset = col_offset;
8712
58
    p->end_lineno = end_lineno;
8713
58
    p->end_col_offset = end_col_offset;
8714
58
    return p;
8715
58
}
8716
8717
pattern_ty
8718
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8719
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8720
                  col_offset, int end_lineno, int end_col_offset, PyArena
8721
                  *arena)
8722
3.76k
{
8723
3.76k
    pattern_ty p;
8724
3.76k
    if (!cls) {
8725
0
        PyErr_SetString(PyExc_ValueError,
8726
0
                        "field 'cls' is required for MatchClass");
8727
0
        return NULL;
8728
0
    }
8729
3.76k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8730
3.76k
    if (!p)
8731
0
        return NULL;
8732
3.76k
    p->kind = MatchClass_kind;
8733
3.76k
    p->v.MatchClass.cls = cls;
8734
3.76k
    p->v.MatchClass.patterns = patterns;
8735
3.76k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8736
3.76k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8737
3.76k
    p->lineno = lineno;
8738
3.76k
    p->col_offset = col_offset;
8739
3.76k
    p->end_lineno = end_lineno;
8740
3.76k
    p->end_col_offset = end_col_offset;
8741
3.76k
    return p;
8742
3.76k
}
8743
8744
pattern_ty
8745
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8746
                 int end_col_offset, PyArena *arena)
8747
2.14k
{
8748
2.14k
    pattern_ty p;
8749
2.14k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8750
2.14k
    if (!p)
8751
0
        return NULL;
8752
2.14k
    p->kind = MatchStar_kind;
8753
2.14k
    p->v.MatchStar.name = name;
8754
2.14k
    p->lineno = lineno;
8755
2.14k
    p->col_offset = col_offset;
8756
2.14k
    p->end_lineno = end_lineno;
8757
2.14k
    p->end_col_offset = end_col_offset;
8758
2.14k
    return p;
8759
2.14k
}
8760
8761
pattern_ty
8762
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8763
               int end_lineno, int end_col_offset, PyArena *arena)
8764
13.7k
{
8765
13.7k
    pattern_ty p;
8766
13.7k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8767
13.7k
    if (!p)
8768
0
        return NULL;
8769
13.7k
    p->kind = MatchAs_kind;
8770
13.7k
    p->v.MatchAs.pattern = pattern;
8771
13.7k
    p->v.MatchAs.name = name;
8772
13.7k
    p->lineno = lineno;
8773
13.7k
    p->col_offset = col_offset;
8774
13.7k
    p->end_lineno = end_lineno;
8775
13.7k
    p->end_col_offset = end_col_offset;
8776
13.7k
    return p;
8777
13.7k
}
8778
8779
pattern_ty
8780
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8781
               end_lineno, int end_col_offset, PyArena *arena)
8782
5.38k
{
8783
5.38k
    pattern_ty p;
8784
5.38k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8785
5.38k
    if (!p)
8786
0
        return NULL;
8787
5.38k
    p->kind = MatchOr_kind;
8788
5.38k
    p->v.MatchOr.patterns = patterns;
8789
5.38k
    p->lineno = lineno;
8790
5.38k
    p->col_offset = col_offset;
8791
5.38k
    p->end_lineno = end_lineno;
8792
5.38k
    p->end_col_offset = end_col_offset;
8793
5.38k
    return p;
8794
5.38k
}
8795
8796
type_ignore_ty
8797
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8798
0
{
8799
0
    type_ignore_ty p;
8800
0
    if (!tag) {
8801
0
        PyErr_SetString(PyExc_ValueError,
8802
0
                        "field 'tag' is required for TypeIgnore");
8803
0
        return NULL;
8804
0
    }
8805
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8806
0
    if (!p)
8807
0
        return NULL;
8808
0
    p->kind = TypeIgnore_kind;
8809
0
    p->v.TypeIgnore.lineno = lineno;
8810
0
    p->v.TypeIgnore.tag = tag;
8811
0
    return p;
8812
0
}
8813
8814
type_param_ty
8815
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8816
               lineno, int col_offset, int end_lineno, int end_col_offset,
8817
               PyArena *arena)
8818
11.3k
{
8819
11.3k
    type_param_ty p;
8820
11.3k
    if (!name) {
8821
0
        PyErr_SetString(PyExc_ValueError,
8822
0
                        "field 'name' is required for TypeVar");
8823
0
        return NULL;
8824
0
    }
8825
11.3k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8826
11.3k
    if (!p)
8827
0
        return NULL;
8828
11.3k
    p->kind = TypeVar_kind;
8829
11.3k
    p->v.TypeVar.name = name;
8830
11.3k
    p->v.TypeVar.bound = bound;
8831
11.3k
    p->v.TypeVar.default_value = default_value;
8832
11.3k
    p->lineno = lineno;
8833
11.3k
    p->col_offset = col_offset;
8834
11.3k
    p->end_lineno = end_lineno;
8835
11.3k
    p->end_col_offset = end_col_offset;
8836
11.3k
    return p;
8837
11.3k
}
8838
8839
type_param_ty
8840
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8841
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8842
872
{
8843
872
    type_param_ty p;
8844
872
    if (!name) {
8845
0
        PyErr_SetString(PyExc_ValueError,
8846
0
                        "field 'name' is required for ParamSpec");
8847
0
        return NULL;
8848
0
    }
8849
872
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8850
872
    if (!p)
8851
0
        return NULL;
8852
872
    p->kind = ParamSpec_kind;
8853
872
    p->v.ParamSpec.name = name;
8854
872
    p->v.ParamSpec.default_value = default_value;
8855
872
    p->lineno = lineno;
8856
872
    p->col_offset = col_offset;
8857
872
    p->end_lineno = end_lineno;
8858
872
    p->end_col_offset = end_col_offset;
8859
872
    return p;
8860
872
}
8861
8862
type_param_ty
8863
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8864
                    col_offset, int end_lineno, int end_col_offset, PyArena
8865
                    *arena)
8866
771
{
8867
771
    type_param_ty p;
8868
771
    if (!name) {
8869
0
        PyErr_SetString(PyExc_ValueError,
8870
0
                        "field 'name' is required for TypeVarTuple");
8871
0
        return NULL;
8872
0
    }
8873
771
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8874
771
    if (!p)
8875
0
        return NULL;
8876
771
    p->kind = TypeVarTuple_kind;
8877
771
    p->v.TypeVarTuple.name = name;
8878
771
    p->v.TypeVarTuple.default_value = default_value;
8879
771
    p->lineno = lineno;
8880
771
    p->col_offset = col_offset;
8881
771
    p->end_lineno = end_lineno;
8882
771
    p->end_col_offset = end_col_offset;
8883
771
    return p;
8884
771
}
8885
8886
8887
PyObject*
8888
ast2obj_mod(struct ast_state *state, void* _o)
8889
7
{
8890
7
    mod_ty o = (mod_ty)_o;
8891
7
    PyObject *result = NULL, *value = NULL;
8892
7
    PyTypeObject *tp;
8893
7
    if (!o) {
8894
0
        Py_RETURN_NONE;
8895
0
    }
8896
7
    if (Py_EnterRecursiveCall("during  ast construction")) {
8897
0
        return NULL;
8898
0
    }
8899
7
    switch (o->kind) {
8900
0
    case Module_kind:
8901
0
        tp = (PyTypeObject *)state->Module_type;
8902
0
        result = PyType_GenericNew(tp, NULL, NULL);
8903
0
        if (!result) goto failed;
8904
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8905
0
        if (!value) goto failed;
8906
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8907
0
            goto failed;
8908
0
        Py_DECREF(value);
8909
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8910
0
                             ast2obj_type_ignore);
8911
0
        if (!value) goto failed;
8912
0
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8913
0
            goto failed;
8914
0
        Py_DECREF(value);
8915
0
        break;
8916
0
    case Interactive_kind:
8917
0
        tp = (PyTypeObject *)state->Interactive_type;
8918
0
        result = PyType_GenericNew(tp, NULL, NULL);
8919
0
        if (!result) goto failed;
8920
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8921
0
                             ast2obj_stmt);
8922
0
        if (!value) goto failed;
8923
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8924
0
            goto failed;
8925
0
        Py_DECREF(value);
8926
0
        break;
8927
7
    case Expression_kind:
8928
7
        tp = (PyTypeObject *)state->Expression_type;
8929
7
        result = PyType_GenericNew(tp, NULL, NULL);
8930
7
        if (!result) goto failed;
8931
7
        value = ast2obj_expr(state, o->v.Expression.body);
8932
7
        if (!value) goto failed;
8933
7
        if (PyObject_SetAttr(result, state->body, value) == -1)
8934
0
            goto failed;
8935
7
        Py_DECREF(value);
8936
7
        break;
8937
0
    case FunctionType_kind:
8938
0
        tp = (PyTypeObject *)state->FunctionType_type;
8939
0
        result = PyType_GenericNew(tp, NULL, NULL);
8940
0
        if (!result) goto failed;
8941
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8942
0
                             ast2obj_expr);
8943
0
        if (!value) goto failed;
8944
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8945
0
            goto failed;
8946
0
        Py_DECREF(value);
8947
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8948
0
        if (!value) goto failed;
8949
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8950
0
            goto failed;
8951
0
        Py_DECREF(value);
8952
0
        break;
8953
7
    }
8954
7
    Py_LeaveRecursiveCall();
8955
7
    return result;
8956
0
failed:
8957
0
    Py_LeaveRecursiveCall();
8958
0
    Py_XDECREF(value);
8959
0
    Py_XDECREF(result);
8960
0
    return NULL;
8961
7
}
8962
8963
PyObject*
8964
ast2obj_stmt(struct ast_state *state, void* _o)
8965
0
{
8966
0
    stmt_ty o = (stmt_ty)_o;
8967
0
    PyObject *result = NULL, *value = NULL;
8968
0
    PyTypeObject *tp;
8969
0
    if (!o) {
8970
0
        Py_RETURN_NONE;
8971
0
    }
8972
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
8973
0
        return NULL;
8974
0
    }
8975
0
    switch (o->kind) {
8976
0
    case FunctionDef_kind:
8977
0
        tp = (PyTypeObject *)state->FunctionDef_type;
8978
0
        result = PyType_GenericNew(tp, NULL, NULL);
8979
0
        if (!result) goto failed;
8980
0
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8981
0
        if (!value) goto failed;
8982
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
8983
0
            goto failed;
8984
0
        Py_DECREF(value);
8985
0
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8986
0
        if (!value) goto failed;
8987
0
        if (PyObject_SetAttr(result, state->args, value) == -1)
8988
0
            goto failed;
8989
0
        Py_DECREF(value);
8990
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8991
0
                             ast2obj_stmt);
8992
0
        if (!value) goto failed;
8993
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8994
0
            goto failed;
8995
0
        Py_DECREF(value);
8996
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8997
0
                             ast2obj_expr);
8998
0
        if (!value) goto failed;
8999
0
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9000
0
            goto failed;
9001
0
        Py_DECREF(value);
9002
0
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
9003
0
        if (!value) goto failed;
9004
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9005
0
            goto failed;
9006
0
        Py_DECREF(value);
9007
0
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
9008
0
        if (!value) goto failed;
9009
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9010
0
            goto failed;
9011
0
        Py_DECREF(value);
9012
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
9013
0
                             ast2obj_type_param);
9014
0
        if (!value) goto failed;
9015
0
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9016
0
            goto failed;
9017
0
        Py_DECREF(value);
9018
0
        break;
9019
0
    case AsyncFunctionDef_kind:
9020
0
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9021
0
        result = PyType_GenericNew(tp, NULL, NULL);
9022
0
        if (!result) goto failed;
9023
0
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9024
0
        if (!value) goto failed;
9025
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
9026
0
            goto failed;
9027
0
        Py_DECREF(value);
9028
0
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9029
0
        if (!value) goto failed;
9030
0
        if (PyObject_SetAttr(result, state->args, value) == -1)
9031
0
            goto failed;
9032
0
        Py_DECREF(value);
9033
0
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9034
0
                             ast2obj_stmt);
9035
0
        if (!value) goto failed;
9036
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9037
0
            goto failed;
9038
0
        Py_DECREF(value);
9039
0
        value = ast2obj_list(state,
9040
0
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9041
0
                             ast2obj_expr);
9042
0
        if (!value) goto failed;
9043
0
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9044
0
            goto failed;
9045
0
        Py_DECREF(value);
9046
0
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9047
0
        if (!value) goto failed;
9048
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9049
0
            goto failed;
9050
0
        Py_DECREF(value);
9051
0
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9052
0
        if (!value) goto failed;
9053
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9054
0
            goto failed;
9055
0
        Py_DECREF(value);
9056
0
        value = ast2obj_list(state,
9057
0
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9058
0
                             ast2obj_type_param);
9059
0
        if (!value) goto failed;
9060
0
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9061
0
            goto failed;
9062
0
        Py_DECREF(value);
9063
0
        break;
9064
0
    case ClassDef_kind:
9065
0
        tp = (PyTypeObject *)state->ClassDef_type;
9066
0
        result = PyType_GenericNew(tp, NULL, NULL);
9067
0
        if (!result) goto failed;
9068
0
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9069
0
        if (!value) goto failed;
9070
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
9071
0
            goto failed;
9072
0
        Py_DECREF(value);
9073
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9074
0
                             ast2obj_expr);
9075
0
        if (!value) goto failed;
9076
0
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9077
0
            goto failed;
9078
0
        Py_DECREF(value);
9079
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9080
0
                             ast2obj_keyword);
9081
0
        if (!value) goto failed;
9082
0
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9083
0
            goto failed;
9084
0
        Py_DECREF(value);
9085
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9086
0
                             ast2obj_stmt);
9087
0
        if (!value) goto failed;
9088
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9089
0
            goto failed;
9090
0
        Py_DECREF(value);
9091
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9092
0
                             ast2obj_expr);
9093
0
        if (!value) goto failed;
9094
0
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9095
0
            goto failed;
9096
0
        Py_DECREF(value);
9097
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9098
0
                             ast2obj_type_param);
9099
0
        if (!value) goto failed;
9100
0
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9101
0
            goto failed;
9102
0
        Py_DECREF(value);
9103
0
        break;
9104
0
    case Return_kind:
9105
0
        tp = (PyTypeObject *)state->Return_type;
9106
0
        result = PyType_GenericNew(tp, NULL, NULL);
9107
0
        if (!result) goto failed;
9108
0
        value = ast2obj_expr(state, o->v.Return.value);
9109
0
        if (!value) goto failed;
9110
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9111
0
            goto failed;
9112
0
        Py_DECREF(value);
9113
0
        break;
9114
0
    case Delete_kind:
9115
0
        tp = (PyTypeObject *)state->Delete_type;
9116
0
        result = PyType_GenericNew(tp, NULL, NULL);
9117
0
        if (!result) goto failed;
9118
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9119
0
                             ast2obj_expr);
9120
0
        if (!value) goto failed;
9121
0
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9122
0
            goto failed;
9123
0
        Py_DECREF(value);
9124
0
        break;
9125
0
    case Assign_kind:
9126
0
        tp = (PyTypeObject *)state->Assign_type;
9127
0
        result = PyType_GenericNew(tp, NULL, NULL);
9128
0
        if (!result) goto failed;
9129
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9130
0
                             ast2obj_expr);
9131
0
        if (!value) goto failed;
9132
0
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9133
0
            goto failed;
9134
0
        Py_DECREF(value);
9135
0
        value = ast2obj_expr(state, o->v.Assign.value);
9136
0
        if (!value) goto failed;
9137
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9138
0
            goto failed;
9139
0
        Py_DECREF(value);
9140
0
        value = ast2obj_string(state, o->v.Assign.type_comment);
9141
0
        if (!value) goto failed;
9142
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9143
0
            goto failed;
9144
0
        Py_DECREF(value);
9145
0
        break;
9146
0
    case TypeAlias_kind:
9147
0
        tp = (PyTypeObject *)state->TypeAlias_type;
9148
0
        result = PyType_GenericNew(tp, NULL, NULL);
9149
0
        if (!result) goto failed;
9150
0
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9151
0
        if (!value) goto failed;
9152
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
9153
0
            goto failed;
9154
0
        Py_DECREF(value);
9155
0
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9156
0
                             ast2obj_type_param);
9157
0
        if (!value) goto failed;
9158
0
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9159
0
            goto failed;
9160
0
        Py_DECREF(value);
9161
0
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9162
0
        if (!value) goto failed;
9163
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9164
0
            goto failed;
9165
0
        Py_DECREF(value);
9166
0
        break;
9167
0
    case AugAssign_kind:
9168
0
        tp = (PyTypeObject *)state->AugAssign_type;
9169
0
        result = PyType_GenericNew(tp, NULL, NULL);
9170
0
        if (!result) goto failed;
9171
0
        value = ast2obj_expr(state, o->v.AugAssign.target);
9172
0
        if (!value) goto failed;
9173
0
        if (PyObject_SetAttr(result, state->target, value) == -1)
9174
0
            goto failed;
9175
0
        Py_DECREF(value);
9176
0
        value = ast2obj_operator(state, o->v.AugAssign.op);
9177
0
        if (!value) goto failed;
9178
0
        if (PyObject_SetAttr(result, state->op, value) == -1)
9179
0
            goto failed;
9180
0
        Py_DECREF(value);
9181
0
        value = ast2obj_expr(state, o->v.AugAssign.value);
9182
0
        if (!value) goto failed;
9183
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9184
0
            goto failed;
9185
0
        Py_DECREF(value);
9186
0
        break;
9187
0
    case AnnAssign_kind:
9188
0
        tp = (PyTypeObject *)state->AnnAssign_type;
9189
0
        result = PyType_GenericNew(tp, NULL, NULL);
9190
0
        if (!result) goto failed;
9191
0
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9192
0
        if (!value) goto failed;
9193
0
        if (PyObject_SetAttr(result, state->target, value) == -1)
9194
0
            goto failed;
9195
0
        Py_DECREF(value);
9196
0
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9197
0
        if (!value) goto failed;
9198
0
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9199
0
            goto failed;
9200
0
        Py_DECREF(value);
9201
0
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9202
0
        if (!value) goto failed;
9203
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9204
0
            goto failed;
9205
0
        Py_DECREF(value);
9206
0
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9207
0
        if (!value) goto failed;
9208
0
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9209
0
            goto failed;
9210
0
        Py_DECREF(value);
9211
0
        break;
9212
0
    case For_kind:
9213
0
        tp = (PyTypeObject *)state->For_type;
9214
0
        result = PyType_GenericNew(tp, NULL, NULL);
9215
0
        if (!result) goto failed;
9216
0
        value = ast2obj_expr(state, o->v.For.target);
9217
0
        if (!value) goto failed;
9218
0
        if (PyObject_SetAttr(result, state->target, value) == -1)
9219
0
            goto failed;
9220
0
        Py_DECREF(value);
9221
0
        value = ast2obj_expr(state, o->v.For.iter);
9222
0
        if (!value) goto failed;
9223
0
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9224
0
            goto failed;
9225
0
        Py_DECREF(value);
9226
0
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9227
0
        if (!value) goto failed;
9228
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9229
0
            goto failed;
9230
0
        Py_DECREF(value);
9231
0
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9232
0
        if (!value) goto failed;
9233
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9234
0
            goto failed;
9235
0
        Py_DECREF(value);
9236
0
        value = ast2obj_string(state, o->v.For.type_comment);
9237
0
        if (!value) goto failed;
9238
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9239
0
            goto failed;
9240
0
        Py_DECREF(value);
9241
0
        break;
9242
0
    case AsyncFor_kind:
9243
0
        tp = (PyTypeObject *)state->AsyncFor_type;
9244
0
        result = PyType_GenericNew(tp, NULL, NULL);
9245
0
        if (!result) goto failed;
9246
0
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9247
0
        if (!value) goto failed;
9248
0
        if (PyObject_SetAttr(result, state->target, value) == -1)
9249
0
            goto failed;
9250
0
        Py_DECREF(value);
9251
0
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9252
0
        if (!value) goto failed;
9253
0
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9254
0
            goto failed;
9255
0
        Py_DECREF(value);
9256
0
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9257
0
                             ast2obj_stmt);
9258
0
        if (!value) goto failed;
9259
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9260
0
            goto failed;
9261
0
        Py_DECREF(value);
9262
0
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9263
0
                             ast2obj_stmt);
9264
0
        if (!value) goto failed;
9265
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9266
0
            goto failed;
9267
0
        Py_DECREF(value);
9268
0
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9269
0
        if (!value) goto failed;
9270
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9271
0
            goto failed;
9272
0
        Py_DECREF(value);
9273
0
        break;
9274
0
    case While_kind:
9275
0
        tp = (PyTypeObject *)state->While_type;
9276
0
        result = PyType_GenericNew(tp, NULL, NULL);
9277
0
        if (!result) goto failed;
9278
0
        value = ast2obj_expr(state, o->v.While.test);
9279
0
        if (!value) goto failed;
9280
0
        if (PyObject_SetAttr(result, state->test, value) == -1)
9281
0
            goto failed;
9282
0
        Py_DECREF(value);
9283
0
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9284
0
        if (!value) goto failed;
9285
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9286
0
            goto failed;
9287
0
        Py_DECREF(value);
9288
0
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9289
0
        if (!value) goto failed;
9290
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9291
0
            goto failed;
9292
0
        Py_DECREF(value);
9293
0
        break;
9294
0
    case If_kind:
9295
0
        tp = (PyTypeObject *)state->If_type;
9296
0
        result = PyType_GenericNew(tp, NULL, NULL);
9297
0
        if (!result) goto failed;
9298
0
        value = ast2obj_expr(state, o->v.If.test);
9299
0
        if (!value) goto failed;
9300
0
        if (PyObject_SetAttr(result, state->test, value) == -1)
9301
0
            goto failed;
9302
0
        Py_DECREF(value);
9303
0
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9304
0
        if (!value) goto failed;
9305
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9306
0
            goto failed;
9307
0
        Py_DECREF(value);
9308
0
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9309
0
        if (!value) goto failed;
9310
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9311
0
            goto failed;
9312
0
        Py_DECREF(value);
9313
0
        break;
9314
0
    case With_kind:
9315
0
        tp = (PyTypeObject *)state->With_type;
9316
0
        result = PyType_GenericNew(tp, NULL, NULL);
9317
0
        if (!result) goto failed;
9318
0
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9319
0
                             ast2obj_withitem);
9320
0
        if (!value) goto failed;
9321
0
        if (PyObject_SetAttr(result, state->items, value) == -1)
9322
0
            goto failed;
9323
0
        Py_DECREF(value);
9324
0
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9325
0
        if (!value) goto failed;
9326
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9327
0
            goto failed;
9328
0
        Py_DECREF(value);
9329
0
        value = ast2obj_string(state, o->v.With.type_comment);
9330
0
        if (!value) goto failed;
9331
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9332
0
            goto failed;
9333
0
        Py_DECREF(value);
9334
0
        break;
9335
0
    case AsyncWith_kind:
9336
0
        tp = (PyTypeObject *)state->AsyncWith_type;
9337
0
        result = PyType_GenericNew(tp, NULL, NULL);
9338
0
        if (!result) goto failed;
9339
0
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9340
0
                             ast2obj_withitem);
9341
0
        if (!value) goto failed;
9342
0
        if (PyObject_SetAttr(result, state->items, value) == -1)
9343
0
            goto failed;
9344
0
        Py_DECREF(value);
9345
0
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9346
0
                             ast2obj_stmt);
9347
0
        if (!value) goto failed;
9348
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9349
0
            goto failed;
9350
0
        Py_DECREF(value);
9351
0
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9352
0
        if (!value) goto failed;
9353
0
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9354
0
            goto failed;
9355
0
        Py_DECREF(value);
9356
0
        break;
9357
0
    case Match_kind:
9358
0
        tp = (PyTypeObject *)state->Match_type;
9359
0
        result = PyType_GenericNew(tp, NULL, NULL);
9360
0
        if (!result) goto failed;
9361
0
        value = ast2obj_expr(state, o->v.Match.subject);
9362
0
        if (!value) goto failed;
9363
0
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9364
0
            goto failed;
9365
0
        Py_DECREF(value);
9366
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9367
0
                             ast2obj_match_case);
9368
0
        if (!value) goto failed;
9369
0
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9370
0
            goto failed;
9371
0
        Py_DECREF(value);
9372
0
        break;
9373
0
    case Raise_kind:
9374
0
        tp = (PyTypeObject *)state->Raise_type;
9375
0
        result = PyType_GenericNew(tp, NULL, NULL);
9376
0
        if (!result) goto failed;
9377
0
        value = ast2obj_expr(state, o->v.Raise.exc);
9378
0
        if (!value) goto failed;
9379
0
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9380
0
            goto failed;
9381
0
        Py_DECREF(value);
9382
0
        value = ast2obj_expr(state, o->v.Raise.cause);
9383
0
        if (!value) goto failed;
9384
0
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9385
0
            goto failed;
9386
0
        Py_DECREF(value);
9387
0
        break;
9388
0
    case Try_kind:
9389
0
        tp = (PyTypeObject *)state->Try_type;
9390
0
        result = PyType_GenericNew(tp, NULL, NULL);
9391
0
        if (!result) goto failed;
9392
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9393
0
        if (!value) goto failed;
9394
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9395
0
            goto failed;
9396
0
        Py_DECREF(value);
9397
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9398
0
                             ast2obj_excepthandler);
9399
0
        if (!value) goto failed;
9400
0
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9401
0
            goto failed;
9402
0
        Py_DECREF(value);
9403
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9404
0
        if (!value) goto failed;
9405
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9406
0
            goto failed;
9407
0
        Py_DECREF(value);
9408
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9409
0
                             ast2obj_stmt);
9410
0
        if (!value) goto failed;
9411
0
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9412
0
            goto failed;
9413
0
        Py_DECREF(value);
9414
0
        break;
9415
0
    case TryStar_kind:
9416
0
        tp = (PyTypeObject *)state->TryStar_type;
9417
0
        result = PyType_GenericNew(tp, NULL, NULL);
9418
0
        if (!result) goto failed;
9419
0
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9420
0
        if (!value) goto failed;
9421
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9422
0
            goto failed;
9423
0
        Py_DECREF(value);
9424
0
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9425
0
                             ast2obj_excepthandler);
9426
0
        if (!value) goto failed;
9427
0
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9428
0
            goto failed;
9429
0
        Py_DECREF(value);
9430
0
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9431
0
                             ast2obj_stmt);
9432
0
        if (!value) goto failed;
9433
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9434
0
            goto failed;
9435
0
        Py_DECREF(value);
9436
0
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9437
0
                             ast2obj_stmt);
9438
0
        if (!value) goto failed;
9439
0
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9440
0
            goto failed;
9441
0
        Py_DECREF(value);
9442
0
        break;
9443
0
    case Assert_kind:
9444
0
        tp = (PyTypeObject *)state->Assert_type;
9445
0
        result = PyType_GenericNew(tp, NULL, NULL);
9446
0
        if (!result) goto failed;
9447
0
        value = ast2obj_expr(state, o->v.Assert.test);
9448
0
        if (!value) goto failed;
9449
0
        if (PyObject_SetAttr(result, state->test, value) == -1)
9450
0
            goto failed;
9451
0
        Py_DECREF(value);
9452
0
        value = ast2obj_expr(state, o->v.Assert.msg);
9453
0
        if (!value) goto failed;
9454
0
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9455
0
            goto failed;
9456
0
        Py_DECREF(value);
9457
0
        break;
9458
0
    case Import_kind:
9459
0
        tp = (PyTypeObject *)state->Import_type;
9460
0
        result = PyType_GenericNew(tp, NULL, NULL);
9461
0
        if (!result) goto failed;
9462
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9463
0
                             ast2obj_alias);
9464
0
        if (!value) goto failed;
9465
0
        if (PyObject_SetAttr(result, state->names, value) == -1)
9466
0
            goto failed;
9467
0
        Py_DECREF(value);
9468
0
        break;
9469
0
    case ImportFrom_kind:
9470
0
        tp = (PyTypeObject *)state->ImportFrom_type;
9471
0
        result = PyType_GenericNew(tp, NULL, NULL);
9472
0
        if (!result) goto failed;
9473
0
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9474
0
        if (!value) goto failed;
9475
0
        if (PyObject_SetAttr(result, state->module, value) == -1)
9476
0
            goto failed;
9477
0
        Py_DECREF(value);
9478
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9479
0
                             ast2obj_alias);
9480
0
        if (!value) goto failed;
9481
0
        if (PyObject_SetAttr(result, state->names, value) == -1)
9482
0
            goto failed;
9483
0
        Py_DECREF(value);
9484
0
        value = ast2obj_int(state, o->v.ImportFrom.level);
9485
0
        if (!value) goto failed;
9486
0
        if (PyObject_SetAttr(result, state->level, value) == -1)
9487
0
            goto failed;
9488
0
        Py_DECREF(value);
9489
0
        break;
9490
0
    case Global_kind:
9491
0
        tp = (PyTypeObject *)state->Global_type;
9492
0
        result = PyType_GenericNew(tp, NULL, NULL);
9493
0
        if (!result) goto failed;
9494
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9495
0
                             ast2obj_identifier);
9496
0
        if (!value) goto failed;
9497
0
        if (PyObject_SetAttr(result, state->names, value) == -1)
9498
0
            goto failed;
9499
0
        Py_DECREF(value);
9500
0
        break;
9501
0
    case Nonlocal_kind:
9502
0
        tp = (PyTypeObject *)state->Nonlocal_type;
9503
0
        result = PyType_GenericNew(tp, NULL, NULL);
9504
0
        if (!result) goto failed;
9505
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9506
0
                             ast2obj_identifier);
9507
0
        if (!value) goto failed;
9508
0
        if (PyObject_SetAttr(result, state->names, value) == -1)
9509
0
            goto failed;
9510
0
        Py_DECREF(value);
9511
0
        break;
9512
0
    case Expr_kind:
9513
0
        tp = (PyTypeObject *)state->Expr_type;
9514
0
        result = PyType_GenericNew(tp, NULL, NULL);
9515
0
        if (!result) goto failed;
9516
0
        value = ast2obj_expr(state, o->v.Expr.value);
9517
0
        if (!value) goto failed;
9518
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9519
0
            goto failed;
9520
0
        Py_DECREF(value);
9521
0
        break;
9522
0
    case Pass_kind:
9523
0
        tp = (PyTypeObject *)state->Pass_type;
9524
0
        result = PyType_GenericNew(tp, NULL, NULL);
9525
0
        if (!result) goto failed;
9526
0
        break;
9527
0
    case Break_kind:
9528
0
        tp = (PyTypeObject *)state->Break_type;
9529
0
        result = PyType_GenericNew(tp, NULL, NULL);
9530
0
        if (!result) goto failed;
9531
0
        break;
9532
0
    case Continue_kind:
9533
0
        tp = (PyTypeObject *)state->Continue_type;
9534
0
        result = PyType_GenericNew(tp, NULL, NULL);
9535
0
        if (!result) goto failed;
9536
0
        break;
9537
0
    }
9538
0
    value = ast2obj_int(state, o->lineno);
9539
0
    if (!value) goto failed;
9540
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9541
0
        goto failed;
9542
0
    Py_DECREF(value);
9543
0
    value = ast2obj_int(state, o->col_offset);
9544
0
    if (!value) goto failed;
9545
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9546
0
        goto failed;
9547
0
    Py_DECREF(value);
9548
0
    value = ast2obj_int(state, o->end_lineno);
9549
0
    if (!value) goto failed;
9550
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9551
0
        goto failed;
9552
0
    Py_DECREF(value);
9553
0
    value = ast2obj_int(state, o->end_col_offset);
9554
0
    if (!value) goto failed;
9555
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9556
0
        goto failed;
9557
0
    Py_DECREF(value);
9558
0
    Py_LeaveRecursiveCall();
9559
0
    return result;
9560
0
failed:
9561
0
    Py_LeaveRecursiveCall();
9562
0
    Py_XDECREF(value);
9563
0
    Py_XDECREF(result);
9564
0
    return NULL;
9565
0
}
9566
9567
PyObject*
9568
ast2obj_expr(struct ast_state *state, void* _o)
9569
17
{
9570
17
    expr_ty o = (expr_ty)_o;
9571
17
    PyObject *result = NULL, *value = NULL;
9572
17
    PyTypeObject *tp;
9573
17
    if (!o) {
9574
0
        Py_RETURN_NONE;
9575
0
    }
9576
17
    if (Py_EnterRecursiveCall("during  ast construction")) {
9577
0
        return NULL;
9578
0
    }
9579
17
    switch (o->kind) {
9580
0
    case BoolOp_kind:
9581
0
        tp = (PyTypeObject *)state->BoolOp_type;
9582
0
        result = PyType_GenericNew(tp, NULL, NULL);
9583
0
        if (!result) goto failed;
9584
0
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9585
0
        if (!value) goto failed;
9586
0
        if (PyObject_SetAttr(result, state->op, value) == -1)
9587
0
            goto failed;
9588
0
        Py_DECREF(value);
9589
0
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9590
0
                             ast2obj_expr);
9591
0
        if (!value) goto failed;
9592
0
        if (PyObject_SetAttr(result, state->values, value) == -1)
9593
0
            goto failed;
9594
0
        Py_DECREF(value);
9595
0
        break;
9596
0
    case NamedExpr_kind:
9597
0
        tp = (PyTypeObject *)state->NamedExpr_type;
9598
0
        result = PyType_GenericNew(tp, NULL, NULL);
9599
0
        if (!result) goto failed;
9600
0
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9601
0
        if (!value) goto failed;
9602
0
        if (PyObject_SetAttr(result, state->target, value) == -1)
9603
0
            goto failed;
9604
0
        Py_DECREF(value);
9605
0
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9606
0
        if (!value) goto failed;
9607
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9608
0
            goto failed;
9609
0
        Py_DECREF(value);
9610
0
        break;
9611
4
    case BinOp_kind:
9612
4
        tp = (PyTypeObject *)state->BinOp_type;
9613
4
        result = PyType_GenericNew(tp, NULL, NULL);
9614
4
        if (!result) goto failed;
9615
4
        value = ast2obj_expr(state, o->v.BinOp.left);
9616
4
        if (!value) goto failed;
9617
4
        if (PyObject_SetAttr(result, state->left, value) == -1)
9618
0
            goto failed;
9619
4
        Py_DECREF(value);
9620
4
        value = ast2obj_operator(state, o->v.BinOp.op);
9621
4
        if (!value) goto failed;
9622
4
        if (PyObject_SetAttr(result, state->op, value) == -1)
9623
0
            goto failed;
9624
4
        Py_DECREF(value);
9625
4
        value = ast2obj_expr(state, o->v.BinOp.right);
9626
4
        if (!value) goto failed;
9627
4
        if (PyObject_SetAttr(result, state->right, value) == -1)
9628
0
            goto failed;
9629
4
        Py_DECREF(value);
9630
4
        break;
9631
0
    case UnaryOp_kind:
9632
0
        tp = (PyTypeObject *)state->UnaryOp_type;
9633
0
        result = PyType_GenericNew(tp, NULL, NULL);
9634
0
        if (!result) goto failed;
9635
0
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9636
0
        if (!value) goto failed;
9637
0
        if (PyObject_SetAttr(result, state->op, value) == -1)
9638
0
            goto failed;
9639
0
        Py_DECREF(value);
9640
0
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9641
0
        if (!value) goto failed;
9642
0
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9643
0
            goto failed;
9644
0
        Py_DECREF(value);
9645
0
        break;
9646
0
    case Lambda_kind:
9647
0
        tp = (PyTypeObject *)state->Lambda_type;
9648
0
        result = PyType_GenericNew(tp, NULL, NULL);
9649
0
        if (!result) goto failed;
9650
0
        value = ast2obj_arguments(state, o->v.Lambda.args);
9651
0
        if (!value) goto failed;
9652
0
        if (PyObject_SetAttr(result, state->args, value) == -1)
9653
0
            goto failed;
9654
0
        Py_DECREF(value);
9655
0
        value = ast2obj_expr(state, o->v.Lambda.body);
9656
0
        if (!value) goto failed;
9657
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9658
0
            goto failed;
9659
0
        Py_DECREF(value);
9660
0
        break;
9661
0
    case IfExp_kind:
9662
0
        tp = (PyTypeObject *)state->IfExp_type;
9663
0
        result = PyType_GenericNew(tp, NULL, NULL);
9664
0
        if (!result) goto failed;
9665
0
        value = ast2obj_expr(state, o->v.IfExp.test);
9666
0
        if (!value) goto failed;
9667
0
        if (PyObject_SetAttr(result, state->test, value) == -1)
9668
0
            goto failed;
9669
0
        Py_DECREF(value);
9670
0
        value = ast2obj_expr(state, o->v.IfExp.body);
9671
0
        if (!value) goto failed;
9672
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
9673
0
            goto failed;
9674
0
        Py_DECREF(value);
9675
0
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9676
0
        if (!value) goto failed;
9677
0
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9678
0
            goto failed;
9679
0
        Py_DECREF(value);
9680
0
        break;
9681
0
    case Dict_kind:
9682
0
        tp = (PyTypeObject *)state->Dict_type;
9683
0
        result = PyType_GenericNew(tp, NULL, NULL);
9684
0
        if (!result) goto failed;
9685
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9686
0
        if (!value) goto failed;
9687
0
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9688
0
            goto failed;
9689
0
        Py_DECREF(value);
9690
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9691
0
        if (!value) goto failed;
9692
0
        if (PyObject_SetAttr(result, state->values, value) == -1)
9693
0
            goto failed;
9694
0
        Py_DECREF(value);
9695
0
        break;
9696
0
    case Set_kind:
9697
0
        tp = (PyTypeObject *)state->Set_type;
9698
0
        result = PyType_GenericNew(tp, NULL, NULL);
9699
0
        if (!result) goto failed;
9700
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9701
0
        if (!value) goto failed;
9702
0
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9703
0
            goto failed;
9704
0
        Py_DECREF(value);
9705
0
        break;
9706
0
    case ListComp_kind:
9707
0
        tp = (PyTypeObject *)state->ListComp_type;
9708
0
        result = PyType_GenericNew(tp, NULL, NULL);
9709
0
        if (!result) goto failed;
9710
0
        value = ast2obj_expr(state, o->v.ListComp.elt);
9711
0
        if (!value) goto failed;
9712
0
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9713
0
            goto failed;
9714
0
        Py_DECREF(value);
9715
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9716
0
                             ast2obj_comprehension);
9717
0
        if (!value) goto failed;
9718
0
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9719
0
            goto failed;
9720
0
        Py_DECREF(value);
9721
0
        break;
9722
0
    case SetComp_kind:
9723
0
        tp = (PyTypeObject *)state->SetComp_type;
9724
0
        result = PyType_GenericNew(tp, NULL, NULL);
9725
0
        if (!result) goto failed;
9726
0
        value = ast2obj_expr(state, o->v.SetComp.elt);
9727
0
        if (!value) goto failed;
9728
0
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9729
0
            goto failed;
9730
0
        Py_DECREF(value);
9731
0
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9732
0
                             ast2obj_comprehension);
9733
0
        if (!value) goto failed;
9734
0
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9735
0
            goto failed;
9736
0
        Py_DECREF(value);
9737
0
        break;
9738
0
    case DictComp_kind:
9739
0
        tp = (PyTypeObject *)state->DictComp_type;
9740
0
        result = PyType_GenericNew(tp, NULL, NULL);
9741
0
        if (!result) goto failed;
9742
0
        value = ast2obj_expr(state, o->v.DictComp.key);
9743
0
        if (!value) goto failed;
9744
0
        if (PyObject_SetAttr(result, state->key, value) == -1)
9745
0
            goto failed;
9746
0
        Py_DECREF(value);
9747
0
        value = ast2obj_expr(state, o->v.DictComp.value);
9748
0
        if (!value) goto failed;
9749
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9750
0
            goto failed;
9751
0
        Py_DECREF(value);
9752
0
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9753
0
                             ast2obj_comprehension);
9754
0
        if (!value) goto failed;
9755
0
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9756
0
            goto failed;
9757
0
        Py_DECREF(value);
9758
0
        break;
9759
0
    case GeneratorExp_kind:
9760
0
        tp = (PyTypeObject *)state->GeneratorExp_type;
9761
0
        result = PyType_GenericNew(tp, NULL, NULL);
9762
0
        if (!result) goto failed;
9763
0
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9764
0
        if (!value) goto failed;
9765
0
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9766
0
            goto failed;
9767
0
        Py_DECREF(value);
9768
0
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9769
0
                             ast2obj_comprehension);
9770
0
        if (!value) goto failed;
9771
0
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9772
0
            goto failed;
9773
0
        Py_DECREF(value);
9774
0
        break;
9775
0
    case Await_kind:
9776
0
        tp = (PyTypeObject *)state->Await_type;
9777
0
        result = PyType_GenericNew(tp, NULL, NULL);
9778
0
        if (!result) goto failed;
9779
0
        value = ast2obj_expr(state, o->v.Await.value);
9780
0
        if (!value) goto failed;
9781
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9782
0
            goto failed;
9783
0
        Py_DECREF(value);
9784
0
        break;
9785
0
    case Yield_kind:
9786
0
        tp = (PyTypeObject *)state->Yield_type;
9787
0
        result = PyType_GenericNew(tp, NULL, NULL);
9788
0
        if (!result) goto failed;
9789
0
        value = ast2obj_expr(state, o->v.Yield.value);
9790
0
        if (!value) goto failed;
9791
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9792
0
            goto failed;
9793
0
        Py_DECREF(value);
9794
0
        break;
9795
0
    case YieldFrom_kind:
9796
0
        tp = (PyTypeObject *)state->YieldFrom_type;
9797
0
        result = PyType_GenericNew(tp, NULL, NULL);
9798
0
        if (!result) goto failed;
9799
0
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9800
0
        if (!value) goto failed;
9801
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9802
0
            goto failed;
9803
0
        Py_DECREF(value);
9804
0
        break;
9805
0
    case Compare_kind:
9806
0
        tp = (PyTypeObject *)state->Compare_type;
9807
0
        result = PyType_GenericNew(tp, NULL, NULL);
9808
0
        if (!result) goto failed;
9809
0
        value = ast2obj_expr(state, o->v.Compare.left);
9810
0
        if (!value) goto failed;
9811
0
        if (PyObject_SetAttr(result, state->left, value) == -1)
9812
0
            goto failed;
9813
0
        Py_DECREF(value);
9814
0
        {
9815
0
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9816
0
            value = PyList_New(n);
9817
0
            if (!value) goto failed;
9818
0
            for(i = 0; i < n; i++)
9819
0
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9820
0
        }
9821
0
        if (!value) goto failed;
9822
0
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9823
0
            goto failed;
9824
0
        Py_DECREF(value);
9825
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9826
0
                             ast2obj_expr);
9827
0
        if (!value) goto failed;
9828
0
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9829
0
            goto failed;
9830
0
        Py_DECREF(value);
9831
0
        break;
9832
0
    case Call_kind:
9833
0
        tp = (PyTypeObject *)state->Call_type;
9834
0
        result = PyType_GenericNew(tp, NULL, NULL);
9835
0
        if (!result) goto failed;
9836
0
        value = ast2obj_expr(state, o->v.Call.func);
9837
0
        if (!value) goto failed;
9838
0
        if (PyObject_SetAttr(result, state->func, value) == -1)
9839
0
            goto failed;
9840
0
        Py_DECREF(value);
9841
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9842
0
        if (!value) goto failed;
9843
0
        if (PyObject_SetAttr(result, state->args, value) == -1)
9844
0
            goto failed;
9845
0
        Py_DECREF(value);
9846
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9847
0
                             ast2obj_keyword);
9848
0
        if (!value) goto failed;
9849
0
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9850
0
            goto failed;
9851
0
        Py_DECREF(value);
9852
0
        break;
9853
0
    case FormattedValue_kind:
9854
0
        tp = (PyTypeObject *)state->FormattedValue_type;
9855
0
        result = PyType_GenericNew(tp, NULL, NULL);
9856
0
        if (!result) goto failed;
9857
0
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9858
0
        if (!value) goto failed;
9859
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9860
0
            goto failed;
9861
0
        Py_DECREF(value);
9862
0
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9863
0
        if (!value) goto failed;
9864
0
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9865
0
            goto failed;
9866
0
        Py_DECREF(value);
9867
0
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9868
0
        if (!value) goto failed;
9869
0
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9870
0
            goto failed;
9871
0
        Py_DECREF(value);
9872
0
        break;
9873
0
    case Interpolation_kind:
9874
0
        tp = (PyTypeObject *)state->Interpolation_type;
9875
0
        result = PyType_GenericNew(tp, NULL, NULL);
9876
0
        if (!result) goto failed;
9877
0
        value = ast2obj_expr(state, o->v.Interpolation.value);
9878
0
        if (!value) goto failed;
9879
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9880
0
            goto failed;
9881
0
        Py_DECREF(value);
9882
0
        value = ast2obj_constant(state, o->v.Interpolation.str);
9883
0
        if (!value) goto failed;
9884
0
        if (PyObject_SetAttr(result, state->str, value) == -1)
9885
0
            goto failed;
9886
0
        Py_DECREF(value);
9887
0
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9888
0
        if (!value) goto failed;
9889
0
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9890
0
            goto failed;
9891
0
        Py_DECREF(value);
9892
0
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9893
0
        if (!value) goto failed;
9894
0
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9895
0
            goto failed;
9896
0
        Py_DECREF(value);
9897
0
        break;
9898
0
    case JoinedStr_kind:
9899
0
        tp = (PyTypeObject *)state->JoinedStr_type;
9900
0
        result = PyType_GenericNew(tp, NULL, NULL);
9901
0
        if (!result) goto failed;
9902
0
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9903
0
                             ast2obj_expr);
9904
0
        if (!value) goto failed;
9905
0
        if (PyObject_SetAttr(result, state->values, value) == -1)
9906
0
            goto failed;
9907
0
        Py_DECREF(value);
9908
0
        break;
9909
0
    case TemplateStr_kind:
9910
0
        tp = (PyTypeObject *)state->TemplateStr_type;
9911
0
        result = PyType_GenericNew(tp, NULL, NULL);
9912
0
        if (!result) goto failed;
9913
0
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9914
0
                             ast2obj_expr);
9915
0
        if (!value) goto failed;
9916
0
        if (PyObject_SetAttr(result, state->values, value) == -1)
9917
0
            goto failed;
9918
0
        Py_DECREF(value);
9919
0
        break;
9920
2
    case Constant_kind:
9921
2
        tp = (PyTypeObject *)state->Constant_type;
9922
2
        result = PyType_GenericNew(tp, NULL, NULL);
9923
2
        if (!result) goto failed;
9924
2
        value = ast2obj_constant(state, o->v.Constant.value);
9925
2
        if (!value) goto failed;
9926
2
        if (PyObject_SetAttr(result, state->value, value) == -1)
9927
0
            goto failed;
9928
2
        Py_DECREF(value);
9929
2
        value = ast2obj_string(state, o->v.Constant.kind);
9930
2
        if (!value) goto failed;
9931
2
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9932
0
            goto failed;
9933
2
        Py_DECREF(value);
9934
2
        break;
9935
0
    case Attribute_kind:
9936
0
        tp = (PyTypeObject *)state->Attribute_type;
9937
0
        result = PyType_GenericNew(tp, NULL, NULL);
9938
0
        if (!result) goto failed;
9939
0
        value = ast2obj_expr(state, o->v.Attribute.value);
9940
0
        if (!value) goto failed;
9941
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9942
0
            goto failed;
9943
0
        Py_DECREF(value);
9944
0
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9945
0
        if (!value) goto failed;
9946
0
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9947
0
            goto failed;
9948
0
        Py_DECREF(value);
9949
0
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9950
0
        if (!value) goto failed;
9951
0
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9952
0
            goto failed;
9953
0
        Py_DECREF(value);
9954
0
        break;
9955
0
    case Subscript_kind:
9956
0
        tp = (PyTypeObject *)state->Subscript_type;
9957
0
        result = PyType_GenericNew(tp, NULL, NULL);
9958
0
        if (!result) goto failed;
9959
0
        value = ast2obj_expr(state, o->v.Subscript.value);
9960
0
        if (!value) goto failed;
9961
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9962
0
            goto failed;
9963
0
        Py_DECREF(value);
9964
0
        value = ast2obj_expr(state, o->v.Subscript.slice);
9965
0
        if (!value) goto failed;
9966
0
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9967
0
            goto failed;
9968
0
        Py_DECREF(value);
9969
0
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9970
0
        if (!value) goto failed;
9971
0
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9972
0
            goto failed;
9973
0
        Py_DECREF(value);
9974
0
        break;
9975
0
    case Starred_kind:
9976
0
        tp = (PyTypeObject *)state->Starred_type;
9977
0
        result = PyType_GenericNew(tp, NULL, NULL);
9978
0
        if (!result) goto failed;
9979
0
        value = ast2obj_expr(state, o->v.Starred.value);
9980
0
        if (!value) goto failed;
9981
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
9982
0
            goto failed;
9983
0
        Py_DECREF(value);
9984
0
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9985
0
        if (!value) goto failed;
9986
0
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9987
0
            goto failed;
9988
0
        Py_DECREF(value);
9989
0
        break;
9990
10
    case Name_kind:
9991
10
        tp = (PyTypeObject *)state->Name_type;
9992
10
        result = PyType_GenericNew(tp, NULL, NULL);
9993
10
        if (!result) goto failed;
9994
10
        value = ast2obj_identifier(state, o->v.Name.id);
9995
10
        if (!value) goto failed;
9996
10
        if (PyObject_SetAttr(result, state->id, value) == -1)
9997
0
            goto failed;
9998
10
        Py_DECREF(value);
9999
10
        value = ast2obj_expr_context(state, o->v.Name.ctx);
10000
10
        if (!value) goto failed;
10001
10
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10002
0
            goto failed;
10003
10
        Py_DECREF(value);
10004
10
        break;
10005
0
    case List_kind:
10006
0
        tp = (PyTypeObject *)state->List_type;
10007
0
        result = PyType_GenericNew(tp, NULL, NULL);
10008
0
        if (!result) goto failed;
10009
0
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10010
0
        if (!value) goto failed;
10011
0
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10012
0
            goto failed;
10013
0
        Py_DECREF(value);
10014
0
        value = ast2obj_expr_context(state, o->v.List.ctx);
10015
0
        if (!value) goto failed;
10016
0
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10017
0
            goto failed;
10018
0
        Py_DECREF(value);
10019
0
        break;
10020
1
    case Tuple_kind:
10021
1
        tp = (PyTypeObject *)state->Tuple_type;
10022
1
        result = PyType_GenericNew(tp, NULL, NULL);
10023
1
        if (!result) goto failed;
10024
1
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10025
1
        if (!value) goto failed;
10026
1
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10027
0
            goto failed;
10028
1
        Py_DECREF(value);
10029
1
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10030
1
        if (!value) goto failed;
10031
1
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10032
0
            goto failed;
10033
1
        Py_DECREF(value);
10034
1
        break;
10035
0
    case Slice_kind:
10036
0
        tp = (PyTypeObject *)state->Slice_type;
10037
0
        result = PyType_GenericNew(tp, NULL, NULL);
10038
0
        if (!result) goto failed;
10039
0
        value = ast2obj_expr(state, o->v.Slice.lower);
10040
0
        if (!value) goto failed;
10041
0
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10042
0
            goto failed;
10043
0
        Py_DECREF(value);
10044
0
        value = ast2obj_expr(state, o->v.Slice.upper);
10045
0
        if (!value) goto failed;
10046
0
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10047
0
            goto failed;
10048
0
        Py_DECREF(value);
10049
0
        value = ast2obj_expr(state, o->v.Slice.step);
10050
0
        if (!value) goto failed;
10051
0
        if (PyObject_SetAttr(result, state->step, value) == -1)
10052
0
            goto failed;
10053
0
        Py_DECREF(value);
10054
0
        break;
10055
17
    }
10056
17
    value = ast2obj_int(state, o->lineno);
10057
17
    if (!value) goto failed;
10058
17
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10059
0
        goto failed;
10060
17
    Py_DECREF(value);
10061
17
    value = ast2obj_int(state, o->col_offset);
10062
17
    if (!value) goto failed;
10063
17
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10064
0
        goto failed;
10065
17
    Py_DECREF(value);
10066
17
    value = ast2obj_int(state, o->end_lineno);
10067
17
    if (!value) goto failed;
10068
17
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10069
0
        goto failed;
10070
17
    Py_DECREF(value);
10071
17
    value = ast2obj_int(state, o->end_col_offset);
10072
17
    if (!value) goto failed;
10073
17
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10074
0
        goto failed;
10075
17
    Py_DECREF(value);
10076
17
    Py_LeaveRecursiveCall();
10077
17
    return result;
10078
0
failed:
10079
0
    Py_LeaveRecursiveCall();
10080
0
    Py_XDECREF(value);
10081
0
    Py_XDECREF(result);
10082
0
    return NULL;
10083
17
}
10084
10085
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10086
11
{
10087
11
    switch(o) {
10088
11
        case Load:
10089
11
            return Py_NewRef(state->Load_singleton);
10090
0
        case Store:
10091
0
            return Py_NewRef(state->Store_singleton);
10092
0
        case Del:
10093
0
            return Py_NewRef(state->Del_singleton);
10094
11
    }
10095
11
    Py_UNREACHABLE();
10096
11
}
10097
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10098
0
{
10099
0
    switch(o) {
10100
0
        case And:
10101
0
            return Py_NewRef(state->And_singleton);
10102
0
        case Or:
10103
0
            return Py_NewRef(state->Or_singleton);
10104
0
    }
10105
0
    Py_UNREACHABLE();
10106
0
}
10107
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10108
4
{
10109
4
    switch(o) {
10110
0
        case Add:
10111
0
            return Py_NewRef(state->Add_singleton);
10112
0
        case Sub:
10113
0
            return Py_NewRef(state->Sub_singleton);
10114
1
        case Mult:
10115
1
            return Py_NewRef(state->Mult_singleton);
10116
0
        case MatMult:
10117
0
            return Py_NewRef(state->MatMult_singleton);
10118
0
        case Div:
10119
0
            return Py_NewRef(state->Div_singleton);
10120
0
        case Mod:
10121
0
            return Py_NewRef(state->Mod_singleton);
10122
0
        case Pow:
10123
0
            return Py_NewRef(state->Pow_singleton);
10124
0
        case LShift:
10125
0
            return Py_NewRef(state->LShift_singleton);
10126
0
        case RShift:
10127
0
            return Py_NewRef(state->RShift_singleton);
10128
0
        case BitOr:
10129
0
            return Py_NewRef(state->BitOr_singleton);
10130
0
        case BitXor:
10131
0
            return Py_NewRef(state->BitXor_singleton);
10132
3
        case BitAnd:
10133
3
            return Py_NewRef(state->BitAnd_singleton);
10134
0
        case FloorDiv:
10135
0
            return Py_NewRef(state->FloorDiv_singleton);
10136
4
    }
10137
4
    Py_UNREACHABLE();
10138
4
}
10139
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10140
0
{
10141
0
    switch(o) {
10142
0
        case Invert:
10143
0
            return Py_NewRef(state->Invert_singleton);
10144
0
        case Not:
10145
0
            return Py_NewRef(state->Not_singleton);
10146
0
        case UAdd:
10147
0
            return Py_NewRef(state->UAdd_singleton);
10148
0
        case USub:
10149
0
            return Py_NewRef(state->USub_singleton);
10150
0
    }
10151
0
    Py_UNREACHABLE();
10152
0
}
10153
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10154
0
{
10155
0
    switch(o) {
10156
0
        case Eq:
10157
0
            return Py_NewRef(state->Eq_singleton);
10158
0
        case NotEq:
10159
0
            return Py_NewRef(state->NotEq_singleton);
10160
0
        case Lt:
10161
0
            return Py_NewRef(state->Lt_singleton);
10162
0
        case LtE:
10163
0
            return Py_NewRef(state->LtE_singleton);
10164
0
        case Gt:
10165
0
            return Py_NewRef(state->Gt_singleton);
10166
0
        case GtE:
10167
0
            return Py_NewRef(state->GtE_singleton);
10168
0
        case Is:
10169
0
            return Py_NewRef(state->Is_singleton);
10170
0
        case IsNot:
10171
0
            return Py_NewRef(state->IsNot_singleton);
10172
0
        case In:
10173
0
            return Py_NewRef(state->In_singleton);
10174
0
        case NotIn:
10175
0
            return Py_NewRef(state->NotIn_singleton);
10176
0
    }
10177
0
    Py_UNREACHABLE();
10178
0
}
10179
PyObject*
10180
ast2obj_comprehension(struct ast_state *state, void* _o)
10181
0
{
10182
0
    comprehension_ty o = (comprehension_ty)_o;
10183
0
    PyObject *result = NULL, *value = NULL;
10184
0
    PyTypeObject *tp;
10185
0
    if (!o) {
10186
0
        Py_RETURN_NONE;
10187
0
    }
10188
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10189
0
        return NULL;
10190
0
    }
10191
0
    tp = (PyTypeObject *)state->comprehension_type;
10192
0
    result = PyType_GenericNew(tp, NULL, NULL);
10193
0
    if (!result) return NULL;
10194
0
    value = ast2obj_expr(state, o->target);
10195
0
    if (!value) goto failed;
10196
0
    if (PyObject_SetAttr(result, state->target, value) == -1)
10197
0
        goto failed;
10198
0
    Py_DECREF(value);
10199
0
    value = ast2obj_expr(state, o->iter);
10200
0
    if (!value) goto failed;
10201
0
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10202
0
        goto failed;
10203
0
    Py_DECREF(value);
10204
0
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10205
0
    if (!value) goto failed;
10206
0
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10207
0
        goto failed;
10208
0
    Py_DECREF(value);
10209
0
    value = ast2obj_int(state, o->is_async);
10210
0
    if (!value) goto failed;
10211
0
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10212
0
        goto failed;
10213
0
    Py_DECREF(value);
10214
0
    Py_LeaveRecursiveCall();
10215
0
    return result;
10216
0
failed:
10217
0
    Py_LeaveRecursiveCall();
10218
0
    Py_XDECREF(value);
10219
0
    Py_XDECREF(result);
10220
0
    return NULL;
10221
0
}
10222
10223
PyObject*
10224
ast2obj_excepthandler(struct ast_state *state, void* _o)
10225
0
{
10226
0
    excepthandler_ty o = (excepthandler_ty)_o;
10227
0
    PyObject *result = NULL, *value = NULL;
10228
0
    PyTypeObject *tp;
10229
0
    if (!o) {
10230
0
        Py_RETURN_NONE;
10231
0
    }
10232
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10233
0
        return NULL;
10234
0
    }
10235
0
    switch (o->kind) {
10236
0
    case ExceptHandler_kind:
10237
0
        tp = (PyTypeObject *)state->ExceptHandler_type;
10238
0
        result = PyType_GenericNew(tp, NULL, NULL);
10239
0
        if (!result) goto failed;
10240
0
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10241
0
        if (!value) goto failed;
10242
0
        if (PyObject_SetAttr(result, state->type, value) == -1)
10243
0
            goto failed;
10244
0
        Py_DECREF(value);
10245
0
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10246
0
        if (!value) goto failed;
10247
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
10248
0
            goto failed;
10249
0
        Py_DECREF(value);
10250
0
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10251
0
                             ast2obj_stmt);
10252
0
        if (!value) goto failed;
10253
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
10254
0
            goto failed;
10255
0
        Py_DECREF(value);
10256
0
        break;
10257
0
    }
10258
0
    value = ast2obj_int(state, o->lineno);
10259
0
    if (!value) goto failed;
10260
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10261
0
        goto failed;
10262
0
    Py_DECREF(value);
10263
0
    value = ast2obj_int(state, o->col_offset);
10264
0
    if (!value) goto failed;
10265
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10266
0
        goto failed;
10267
0
    Py_DECREF(value);
10268
0
    value = ast2obj_int(state, o->end_lineno);
10269
0
    if (!value) goto failed;
10270
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10271
0
        goto failed;
10272
0
    Py_DECREF(value);
10273
0
    value = ast2obj_int(state, o->end_col_offset);
10274
0
    if (!value) goto failed;
10275
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10276
0
        goto failed;
10277
0
    Py_DECREF(value);
10278
0
    Py_LeaveRecursiveCall();
10279
0
    return result;
10280
0
failed:
10281
0
    Py_LeaveRecursiveCall();
10282
0
    Py_XDECREF(value);
10283
0
    Py_XDECREF(result);
10284
0
    return NULL;
10285
0
}
10286
10287
PyObject*
10288
ast2obj_arguments(struct ast_state *state, void* _o)
10289
0
{
10290
0
    arguments_ty o = (arguments_ty)_o;
10291
0
    PyObject *result = NULL, *value = NULL;
10292
0
    PyTypeObject *tp;
10293
0
    if (!o) {
10294
0
        Py_RETURN_NONE;
10295
0
    }
10296
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10297
0
        return NULL;
10298
0
    }
10299
0
    tp = (PyTypeObject *)state->arguments_type;
10300
0
    result = PyType_GenericNew(tp, NULL, NULL);
10301
0
    if (!result) return NULL;
10302
0
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10303
0
    if (!value) goto failed;
10304
0
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10305
0
        goto failed;
10306
0
    Py_DECREF(value);
10307
0
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10308
0
    if (!value) goto failed;
10309
0
    if (PyObject_SetAttr(result, state->args, value) == -1)
10310
0
        goto failed;
10311
0
    Py_DECREF(value);
10312
0
    value = ast2obj_arg(state, o->vararg);
10313
0
    if (!value) goto failed;
10314
0
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10315
0
        goto failed;
10316
0
    Py_DECREF(value);
10317
0
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10318
0
    if (!value) goto failed;
10319
0
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10320
0
        goto failed;
10321
0
    Py_DECREF(value);
10322
0
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10323
0
    if (!value) goto failed;
10324
0
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10325
0
        goto failed;
10326
0
    Py_DECREF(value);
10327
0
    value = ast2obj_arg(state, o->kwarg);
10328
0
    if (!value) goto failed;
10329
0
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10330
0
        goto failed;
10331
0
    Py_DECREF(value);
10332
0
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10333
0
    if (!value) goto failed;
10334
0
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10335
0
        goto failed;
10336
0
    Py_DECREF(value);
10337
0
    Py_LeaveRecursiveCall();
10338
0
    return result;
10339
0
failed:
10340
0
    Py_LeaveRecursiveCall();
10341
0
    Py_XDECREF(value);
10342
0
    Py_XDECREF(result);
10343
0
    return NULL;
10344
0
}
10345
10346
PyObject*
10347
ast2obj_arg(struct ast_state *state, void* _o)
10348
0
{
10349
0
    arg_ty o = (arg_ty)_o;
10350
0
    PyObject *result = NULL, *value = NULL;
10351
0
    PyTypeObject *tp;
10352
0
    if (!o) {
10353
0
        Py_RETURN_NONE;
10354
0
    }
10355
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10356
0
        return NULL;
10357
0
    }
10358
0
    tp = (PyTypeObject *)state->arg_type;
10359
0
    result = PyType_GenericNew(tp, NULL, NULL);
10360
0
    if (!result) return NULL;
10361
0
    value = ast2obj_identifier(state, o->arg);
10362
0
    if (!value) goto failed;
10363
0
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10364
0
        goto failed;
10365
0
    Py_DECREF(value);
10366
0
    value = ast2obj_expr(state, o->annotation);
10367
0
    if (!value) goto failed;
10368
0
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10369
0
        goto failed;
10370
0
    Py_DECREF(value);
10371
0
    value = ast2obj_string(state, o->type_comment);
10372
0
    if (!value) goto failed;
10373
0
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10374
0
        goto failed;
10375
0
    Py_DECREF(value);
10376
0
    value = ast2obj_int(state, o->lineno);
10377
0
    if (!value) goto failed;
10378
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10379
0
        goto failed;
10380
0
    Py_DECREF(value);
10381
0
    value = ast2obj_int(state, o->col_offset);
10382
0
    if (!value) goto failed;
10383
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10384
0
        goto failed;
10385
0
    Py_DECREF(value);
10386
0
    value = ast2obj_int(state, o->end_lineno);
10387
0
    if (!value) goto failed;
10388
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10389
0
        goto failed;
10390
0
    Py_DECREF(value);
10391
0
    value = ast2obj_int(state, o->end_col_offset);
10392
0
    if (!value) goto failed;
10393
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10394
0
        goto failed;
10395
0
    Py_DECREF(value);
10396
0
    Py_LeaveRecursiveCall();
10397
0
    return result;
10398
0
failed:
10399
0
    Py_LeaveRecursiveCall();
10400
0
    Py_XDECREF(value);
10401
0
    Py_XDECREF(result);
10402
0
    return NULL;
10403
0
}
10404
10405
PyObject*
10406
ast2obj_keyword(struct ast_state *state, void* _o)
10407
0
{
10408
0
    keyword_ty o = (keyword_ty)_o;
10409
0
    PyObject *result = NULL, *value = NULL;
10410
0
    PyTypeObject *tp;
10411
0
    if (!o) {
10412
0
        Py_RETURN_NONE;
10413
0
    }
10414
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10415
0
        return NULL;
10416
0
    }
10417
0
    tp = (PyTypeObject *)state->keyword_type;
10418
0
    result = PyType_GenericNew(tp, NULL, NULL);
10419
0
    if (!result) return NULL;
10420
0
    value = ast2obj_identifier(state, o->arg);
10421
0
    if (!value) goto failed;
10422
0
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10423
0
        goto failed;
10424
0
    Py_DECREF(value);
10425
0
    value = ast2obj_expr(state, o->value);
10426
0
    if (!value) goto failed;
10427
0
    if (PyObject_SetAttr(result, state->value, value) == -1)
10428
0
        goto failed;
10429
0
    Py_DECREF(value);
10430
0
    value = ast2obj_int(state, o->lineno);
10431
0
    if (!value) goto failed;
10432
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10433
0
        goto failed;
10434
0
    Py_DECREF(value);
10435
0
    value = ast2obj_int(state, o->col_offset);
10436
0
    if (!value) goto failed;
10437
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10438
0
        goto failed;
10439
0
    Py_DECREF(value);
10440
0
    value = ast2obj_int(state, o->end_lineno);
10441
0
    if (!value) goto failed;
10442
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10443
0
        goto failed;
10444
0
    Py_DECREF(value);
10445
0
    value = ast2obj_int(state, o->end_col_offset);
10446
0
    if (!value) goto failed;
10447
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10448
0
        goto failed;
10449
0
    Py_DECREF(value);
10450
0
    Py_LeaveRecursiveCall();
10451
0
    return result;
10452
0
failed:
10453
0
    Py_LeaveRecursiveCall();
10454
0
    Py_XDECREF(value);
10455
0
    Py_XDECREF(result);
10456
0
    return NULL;
10457
0
}
10458
10459
PyObject*
10460
ast2obj_alias(struct ast_state *state, void* _o)
10461
0
{
10462
0
    alias_ty o = (alias_ty)_o;
10463
0
    PyObject *result = NULL, *value = NULL;
10464
0
    PyTypeObject *tp;
10465
0
    if (!o) {
10466
0
        Py_RETURN_NONE;
10467
0
    }
10468
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10469
0
        return NULL;
10470
0
    }
10471
0
    tp = (PyTypeObject *)state->alias_type;
10472
0
    result = PyType_GenericNew(tp, NULL, NULL);
10473
0
    if (!result) return NULL;
10474
0
    value = ast2obj_identifier(state, o->name);
10475
0
    if (!value) goto failed;
10476
0
    if (PyObject_SetAttr(result, state->name, value) == -1)
10477
0
        goto failed;
10478
0
    Py_DECREF(value);
10479
0
    value = ast2obj_identifier(state, o->asname);
10480
0
    if (!value) goto failed;
10481
0
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10482
0
        goto failed;
10483
0
    Py_DECREF(value);
10484
0
    value = ast2obj_int(state, o->lineno);
10485
0
    if (!value) goto failed;
10486
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10487
0
        goto failed;
10488
0
    Py_DECREF(value);
10489
0
    value = ast2obj_int(state, o->col_offset);
10490
0
    if (!value) goto failed;
10491
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10492
0
        goto failed;
10493
0
    Py_DECREF(value);
10494
0
    value = ast2obj_int(state, o->end_lineno);
10495
0
    if (!value) goto failed;
10496
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10497
0
        goto failed;
10498
0
    Py_DECREF(value);
10499
0
    value = ast2obj_int(state, o->end_col_offset);
10500
0
    if (!value) goto failed;
10501
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10502
0
        goto failed;
10503
0
    Py_DECREF(value);
10504
0
    Py_LeaveRecursiveCall();
10505
0
    return result;
10506
0
failed:
10507
0
    Py_LeaveRecursiveCall();
10508
0
    Py_XDECREF(value);
10509
0
    Py_XDECREF(result);
10510
0
    return NULL;
10511
0
}
10512
10513
PyObject*
10514
ast2obj_withitem(struct ast_state *state, void* _o)
10515
0
{
10516
0
    withitem_ty o = (withitem_ty)_o;
10517
0
    PyObject *result = NULL, *value = NULL;
10518
0
    PyTypeObject *tp;
10519
0
    if (!o) {
10520
0
        Py_RETURN_NONE;
10521
0
    }
10522
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10523
0
        return NULL;
10524
0
    }
10525
0
    tp = (PyTypeObject *)state->withitem_type;
10526
0
    result = PyType_GenericNew(tp, NULL, NULL);
10527
0
    if (!result) return NULL;
10528
0
    value = ast2obj_expr(state, o->context_expr);
10529
0
    if (!value) goto failed;
10530
0
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10531
0
        goto failed;
10532
0
    Py_DECREF(value);
10533
0
    value = ast2obj_expr(state, o->optional_vars);
10534
0
    if (!value) goto failed;
10535
0
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10536
0
        goto failed;
10537
0
    Py_DECREF(value);
10538
0
    Py_LeaveRecursiveCall();
10539
0
    return result;
10540
0
failed:
10541
0
    Py_LeaveRecursiveCall();
10542
0
    Py_XDECREF(value);
10543
0
    Py_XDECREF(result);
10544
0
    return NULL;
10545
0
}
10546
10547
PyObject*
10548
ast2obj_match_case(struct ast_state *state, void* _o)
10549
0
{
10550
0
    match_case_ty o = (match_case_ty)_o;
10551
0
    PyObject *result = NULL, *value = NULL;
10552
0
    PyTypeObject *tp;
10553
0
    if (!o) {
10554
0
        Py_RETURN_NONE;
10555
0
    }
10556
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10557
0
        return NULL;
10558
0
    }
10559
0
    tp = (PyTypeObject *)state->match_case_type;
10560
0
    result = PyType_GenericNew(tp, NULL, NULL);
10561
0
    if (!result) return NULL;
10562
0
    value = ast2obj_pattern(state, o->pattern);
10563
0
    if (!value) goto failed;
10564
0
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10565
0
        goto failed;
10566
0
    Py_DECREF(value);
10567
0
    value = ast2obj_expr(state, o->guard);
10568
0
    if (!value) goto failed;
10569
0
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10570
0
        goto failed;
10571
0
    Py_DECREF(value);
10572
0
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10573
0
    if (!value) goto failed;
10574
0
    if (PyObject_SetAttr(result, state->body, value) == -1)
10575
0
        goto failed;
10576
0
    Py_DECREF(value);
10577
0
    Py_LeaveRecursiveCall();
10578
0
    return result;
10579
0
failed:
10580
0
    Py_LeaveRecursiveCall();
10581
0
    Py_XDECREF(value);
10582
0
    Py_XDECREF(result);
10583
0
    return NULL;
10584
0
}
10585
10586
PyObject*
10587
ast2obj_pattern(struct ast_state *state, void* _o)
10588
0
{
10589
0
    pattern_ty o = (pattern_ty)_o;
10590
0
    PyObject *result = NULL, *value = NULL;
10591
0
    PyTypeObject *tp;
10592
0
    if (!o) {
10593
0
        Py_RETURN_NONE;
10594
0
    }
10595
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10596
0
        return NULL;
10597
0
    }
10598
0
    switch (o->kind) {
10599
0
    case MatchValue_kind:
10600
0
        tp = (PyTypeObject *)state->MatchValue_type;
10601
0
        result = PyType_GenericNew(tp, NULL, NULL);
10602
0
        if (!result) goto failed;
10603
0
        value = ast2obj_expr(state, o->v.MatchValue.value);
10604
0
        if (!value) goto failed;
10605
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
10606
0
            goto failed;
10607
0
        Py_DECREF(value);
10608
0
        break;
10609
0
    case MatchSingleton_kind:
10610
0
        tp = (PyTypeObject *)state->MatchSingleton_type;
10611
0
        result = PyType_GenericNew(tp, NULL, NULL);
10612
0
        if (!result) goto failed;
10613
0
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10614
0
        if (!value) goto failed;
10615
0
        if (PyObject_SetAttr(result, state->value, value) == -1)
10616
0
            goto failed;
10617
0
        Py_DECREF(value);
10618
0
        break;
10619
0
    case MatchSequence_kind:
10620
0
        tp = (PyTypeObject *)state->MatchSequence_type;
10621
0
        result = PyType_GenericNew(tp, NULL, NULL);
10622
0
        if (!result) goto failed;
10623
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10624
0
                             ast2obj_pattern);
10625
0
        if (!value) goto failed;
10626
0
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10627
0
            goto failed;
10628
0
        Py_DECREF(value);
10629
0
        break;
10630
0
    case MatchMapping_kind:
10631
0
        tp = (PyTypeObject *)state->MatchMapping_type;
10632
0
        result = PyType_GenericNew(tp, NULL, NULL);
10633
0
        if (!result) goto failed;
10634
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10635
0
                             ast2obj_expr);
10636
0
        if (!value) goto failed;
10637
0
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10638
0
            goto failed;
10639
0
        Py_DECREF(value);
10640
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10641
0
                             ast2obj_pattern);
10642
0
        if (!value) goto failed;
10643
0
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10644
0
            goto failed;
10645
0
        Py_DECREF(value);
10646
0
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10647
0
        if (!value) goto failed;
10648
0
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10649
0
            goto failed;
10650
0
        Py_DECREF(value);
10651
0
        break;
10652
0
    case MatchClass_kind:
10653
0
        tp = (PyTypeObject *)state->MatchClass_type;
10654
0
        result = PyType_GenericNew(tp, NULL, NULL);
10655
0
        if (!result) goto failed;
10656
0
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10657
0
        if (!value) goto failed;
10658
0
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10659
0
            goto failed;
10660
0
        Py_DECREF(value);
10661
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10662
0
                             ast2obj_pattern);
10663
0
        if (!value) goto failed;
10664
0
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10665
0
            goto failed;
10666
0
        Py_DECREF(value);
10667
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10668
0
                             ast2obj_identifier);
10669
0
        if (!value) goto failed;
10670
0
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10671
0
            goto failed;
10672
0
        Py_DECREF(value);
10673
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10674
0
                             ast2obj_pattern);
10675
0
        if (!value) goto failed;
10676
0
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10677
0
            goto failed;
10678
0
        Py_DECREF(value);
10679
0
        break;
10680
0
    case MatchStar_kind:
10681
0
        tp = (PyTypeObject *)state->MatchStar_type;
10682
0
        result = PyType_GenericNew(tp, NULL, NULL);
10683
0
        if (!result) goto failed;
10684
0
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10685
0
        if (!value) goto failed;
10686
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
10687
0
            goto failed;
10688
0
        Py_DECREF(value);
10689
0
        break;
10690
0
    case MatchAs_kind:
10691
0
        tp = (PyTypeObject *)state->MatchAs_type;
10692
0
        result = PyType_GenericNew(tp, NULL, NULL);
10693
0
        if (!result) goto failed;
10694
0
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10695
0
        if (!value) goto failed;
10696
0
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10697
0
            goto failed;
10698
0
        Py_DECREF(value);
10699
0
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10700
0
        if (!value) goto failed;
10701
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
10702
0
            goto failed;
10703
0
        Py_DECREF(value);
10704
0
        break;
10705
0
    case MatchOr_kind:
10706
0
        tp = (PyTypeObject *)state->MatchOr_type;
10707
0
        result = PyType_GenericNew(tp, NULL, NULL);
10708
0
        if (!result) goto failed;
10709
0
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10710
0
                             ast2obj_pattern);
10711
0
        if (!value) goto failed;
10712
0
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10713
0
            goto failed;
10714
0
        Py_DECREF(value);
10715
0
        break;
10716
0
    }
10717
0
    value = ast2obj_int(state, o->lineno);
10718
0
    if (!value) goto failed;
10719
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10720
0
        goto failed;
10721
0
    Py_DECREF(value);
10722
0
    value = ast2obj_int(state, o->col_offset);
10723
0
    if (!value) goto failed;
10724
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10725
0
        goto failed;
10726
0
    Py_DECREF(value);
10727
0
    value = ast2obj_int(state, o->end_lineno);
10728
0
    if (!value) goto failed;
10729
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10730
0
        goto failed;
10731
0
    Py_DECREF(value);
10732
0
    value = ast2obj_int(state, o->end_col_offset);
10733
0
    if (!value) goto failed;
10734
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10735
0
        goto failed;
10736
0
    Py_DECREF(value);
10737
0
    Py_LeaveRecursiveCall();
10738
0
    return result;
10739
0
failed:
10740
0
    Py_LeaveRecursiveCall();
10741
0
    Py_XDECREF(value);
10742
0
    Py_XDECREF(result);
10743
0
    return NULL;
10744
0
}
10745
10746
PyObject*
10747
ast2obj_type_ignore(struct ast_state *state, void* _o)
10748
0
{
10749
0
    type_ignore_ty o = (type_ignore_ty)_o;
10750
0
    PyObject *result = NULL, *value = NULL;
10751
0
    PyTypeObject *tp;
10752
0
    if (!o) {
10753
0
        Py_RETURN_NONE;
10754
0
    }
10755
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10756
0
        return NULL;
10757
0
    }
10758
0
    switch (o->kind) {
10759
0
    case TypeIgnore_kind:
10760
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10761
0
        result = PyType_GenericNew(tp, NULL, NULL);
10762
0
        if (!result) goto failed;
10763
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10764
0
        if (!value) goto failed;
10765
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10766
0
            goto failed;
10767
0
        Py_DECREF(value);
10768
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10769
0
        if (!value) goto failed;
10770
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10771
0
            goto failed;
10772
0
        Py_DECREF(value);
10773
0
        break;
10774
0
    }
10775
0
    Py_LeaveRecursiveCall();
10776
0
    return result;
10777
0
failed:
10778
0
    Py_LeaveRecursiveCall();
10779
0
    Py_XDECREF(value);
10780
0
    Py_XDECREF(result);
10781
0
    return NULL;
10782
0
}
10783
10784
PyObject*
10785
ast2obj_type_param(struct ast_state *state, void* _o)
10786
0
{
10787
0
    type_param_ty o = (type_param_ty)_o;
10788
0
    PyObject *result = NULL, *value = NULL;
10789
0
    PyTypeObject *tp;
10790
0
    if (!o) {
10791
0
        Py_RETURN_NONE;
10792
0
    }
10793
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10794
0
        return NULL;
10795
0
    }
10796
0
    switch (o->kind) {
10797
0
    case TypeVar_kind:
10798
0
        tp = (PyTypeObject *)state->TypeVar_type;
10799
0
        result = PyType_GenericNew(tp, NULL, NULL);
10800
0
        if (!result) goto failed;
10801
0
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10802
0
        if (!value) goto failed;
10803
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
10804
0
            goto failed;
10805
0
        Py_DECREF(value);
10806
0
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10807
0
        if (!value) goto failed;
10808
0
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10809
0
            goto failed;
10810
0
        Py_DECREF(value);
10811
0
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10812
0
        if (!value) goto failed;
10813
0
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10814
0
            goto failed;
10815
0
        Py_DECREF(value);
10816
0
        break;
10817
0
    case ParamSpec_kind:
10818
0
        tp = (PyTypeObject *)state->ParamSpec_type;
10819
0
        result = PyType_GenericNew(tp, NULL, NULL);
10820
0
        if (!result) goto failed;
10821
0
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10822
0
        if (!value) goto failed;
10823
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
10824
0
            goto failed;
10825
0
        Py_DECREF(value);
10826
0
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10827
0
        if (!value) goto failed;
10828
0
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10829
0
            goto failed;
10830
0
        Py_DECREF(value);
10831
0
        break;
10832
0
    case TypeVarTuple_kind:
10833
0
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10834
0
        result = PyType_GenericNew(tp, NULL, NULL);
10835
0
        if (!result) goto failed;
10836
0
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10837
0
        if (!value) goto failed;
10838
0
        if (PyObject_SetAttr(result, state->name, value) == -1)
10839
0
            goto failed;
10840
0
        Py_DECREF(value);
10841
0
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10842
0
        if (!value) goto failed;
10843
0
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10844
0
            goto failed;
10845
0
        Py_DECREF(value);
10846
0
        break;
10847
0
    }
10848
0
    value = ast2obj_int(state, o->lineno);
10849
0
    if (!value) goto failed;
10850
0
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10851
0
        goto failed;
10852
0
    Py_DECREF(value);
10853
0
    value = ast2obj_int(state, o->col_offset);
10854
0
    if (!value) goto failed;
10855
0
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10856
0
        goto failed;
10857
0
    Py_DECREF(value);
10858
0
    value = ast2obj_int(state, o->end_lineno);
10859
0
    if (!value) goto failed;
10860
0
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10861
0
        goto failed;
10862
0
    Py_DECREF(value);
10863
0
    value = ast2obj_int(state, o->end_col_offset);
10864
0
    if (!value) goto failed;
10865
0
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10866
0
        goto failed;
10867
0
    Py_DECREF(value);
10868
0
    Py_LeaveRecursiveCall();
10869
0
    return result;
10870
0
failed:
10871
0
    Py_LeaveRecursiveCall();
10872
0
    Py_XDECREF(value);
10873
0
    Py_XDECREF(result);
10874
0
    return NULL;
10875
0
}
10876
10877
10878
int
10879
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
10880
0
{
10881
0
    int isinstance;
10882
10883
0
    PyObject *tmp = NULL;
10884
0
    PyObject *tp;
10885
10886
0
    if (obj == Py_None) {
10887
0
        *out = NULL;
10888
0
        return 0;
10889
0
    }
10890
0
    tp = state->Module_type;
10891
0
    isinstance = PyObject_IsInstance(obj, tp);
10892
0
    if (isinstance == -1) {
10893
0
        return -1;
10894
0
    }
10895
0
    if (isinstance) {
10896
0
        asdl_stmt_seq* body;
10897
0
        asdl_type_ignore_seq* type_ignores;
10898
10899
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10900
0
            return -1;
10901
0
        }
10902
0
        if (tmp == NULL) {
10903
0
            tmp = PyList_New(0);
10904
0
            if (tmp == NULL) {
10905
0
                return -1;
10906
0
            }
10907
0
        }
10908
0
        {
10909
0
            int res;
10910
0
            Py_ssize_t len;
10911
0
            Py_ssize_t i;
10912
0
            if (!PyList_Check(tmp)) {
10913
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10914
0
                goto failed;
10915
0
            }
10916
0
            len = PyList_GET_SIZE(tmp);
10917
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10918
0
            if (body == NULL) goto failed;
10919
0
            for (i = 0; i < len; i++) {
10920
0
                stmt_ty val;
10921
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10922
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10923
0
                    goto failed;
10924
0
                }
10925
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10926
0
                _Py_LeaveRecursiveCall();
10927
0
                Py_DECREF(tmp2);
10928
0
                if (res != 0) goto failed;
10929
0
                if (len != PyList_GET_SIZE(tmp)) {
10930
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10931
0
                    goto failed;
10932
0
                }
10933
0
                asdl_seq_SET(body, i, val);
10934
0
            }
10935
0
            Py_CLEAR(tmp);
10936
0
        }
10937
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10938
0
            return -1;
10939
0
        }
10940
0
        if (tmp == NULL) {
10941
0
            tmp = PyList_New(0);
10942
0
            if (tmp == NULL) {
10943
0
                return -1;
10944
0
            }
10945
0
        }
10946
0
        {
10947
0
            int res;
10948
0
            Py_ssize_t len;
10949
0
            Py_ssize_t i;
10950
0
            if (!PyList_Check(tmp)) {
10951
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10952
0
                goto failed;
10953
0
            }
10954
0
            len = PyList_GET_SIZE(tmp);
10955
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
10956
0
            if (type_ignores == NULL) goto failed;
10957
0
            for (i = 0; i < len; i++) {
10958
0
                type_ignore_ty val;
10959
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10960
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10961
0
                    goto failed;
10962
0
                }
10963
0
                res = obj2ast_type_ignore(state, tmp2, &val, arena);
10964
0
                _Py_LeaveRecursiveCall();
10965
0
                Py_DECREF(tmp2);
10966
0
                if (res != 0) goto failed;
10967
0
                if (len != PyList_GET_SIZE(tmp)) {
10968
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
10969
0
                    goto failed;
10970
0
                }
10971
0
                asdl_seq_SET(type_ignores, i, val);
10972
0
            }
10973
0
            Py_CLEAR(tmp);
10974
0
        }
10975
0
        *out = _PyAST_Module(body, type_ignores, arena);
10976
0
        if (*out == NULL) goto failed;
10977
0
        return 0;
10978
0
    }
10979
0
    tp = state->Interactive_type;
10980
0
    isinstance = PyObject_IsInstance(obj, tp);
10981
0
    if (isinstance == -1) {
10982
0
        return -1;
10983
0
    }
10984
0
    if (isinstance) {
10985
0
        asdl_stmt_seq* body;
10986
10987
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10988
0
            return -1;
10989
0
        }
10990
0
        if (tmp == NULL) {
10991
0
            tmp = PyList_New(0);
10992
0
            if (tmp == NULL) {
10993
0
                return -1;
10994
0
            }
10995
0
        }
10996
0
        {
10997
0
            int res;
10998
0
            Py_ssize_t len;
10999
0
            Py_ssize_t i;
11000
0
            if (!PyList_Check(tmp)) {
11001
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11002
0
                goto failed;
11003
0
            }
11004
0
            len = PyList_GET_SIZE(tmp);
11005
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11006
0
            if (body == NULL) goto failed;
11007
0
            for (i = 0; i < len; i++) {
11008
0
                stmt_ty val;
11009
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11010
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
11011
0
                    goto failed;
11012
0
                }
11013
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11014
0
                _Py_LeaveRecursiveCall();
11015
0
                Py_DECREF(tmp2);
11016
0
                if (res != 0) goto failed;
11017
0
                if (len != PyList_GET_SIZE(tmp)) {
11018
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
11019
0
                    goto failed;
11020
0
                }
11021
0
                asdl_seq_SET(body, i, val);
11022
0
            }
11023
0
            Py_CLEAR(tmp);
11024
0
        }
11025
0
        *out = _PyAST_Interactive(body, arena);
11026
0
        if (*out == NULL) goto failed;
11027
0
        return 0;
11028
0
    }
11029
0
    tp = state->Expression_type;
11030
0
    isinstance = PyObject_IsInstance(obj, tp);
11031
0
    if (isinstance == -1) {
11032
0
        return -1;
11033
0
    }
11034
0
    if (isinstance) {
11035
0
        expr_ty body;
11036
11037
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11038
0
            return -1;
11039
0
        }
11040
0
        if (tmp == NULL) {
11041
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11042
0
            return -1;
11043
0
        }
11044
0
        else {
11045
0
            int res;
11046
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11047
0
                goto failed;
11048
0
            }
11049
0
            res = obj2ast_expr(state, tmp, &body, arena);
11050
0
            _Py_LeaveRecursiveCall();
11051
0
            if (res != 0) goto failed;
11052
0
            Py_CLEAR(tmp);
11053
0
        }
11054
0
        *out = _PyAST_Expression(body, arena);
11055
0
        if (*out == NULL) goto failed;
11056
0
        return 0;
11057
0
    }
11058
0
    tp = state->FunctionType_type;
11059
0
    isinstance = PyObject_IsInstance(obj, tp);
11060
0
    if (isinstance == -1) {
11061
0
        return -1;
11062
0
    }
11063
0
    if (isinstance) {
11064
0
        asdl_expr_seq* argtypes;
11065
0
        expr_ty returns;
11066
11067
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11068
0
            return -1;
11069
0
        }
11070
0
        if (tmp == NULL) {
11071
0
            tmp = PyList_New(0);
11072
0
            if (tmp == NULL) {
11073
0
                return -1;
11074
0
            }
11075
0
        }
11076
0
        {
11077
0
            int res;
11078
0
            Py_ssize_t len;
11079
0
            Py_ssize_t i;
11080
0
            if (!PyList_Check(tmp)) {
11081
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11082
0
                goto failed;
11083
0
            }
11084
0
            len = PyList_GET_SIZE(tmp);
11085
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11086
0
            if (argtypes == NULL) goto failed;
11087
0
            for (i = 0; i < len; i++) {
11088
0
                expr_ty val;
11089
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11090
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11091
0
                    goto failed;
11092
0
                }
11093
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11094
0
                _Py_LeaveRecursiveCall();
11095
0
                Py_DECREF(tmp2);
11096
0
                if (res != 0) goto failed;
11097
0
                if (len != PyList_GET_SIZE(tmp)) {
11098
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11099
0
                    goto failed;
11100
0
                }
11101
0
                asdl_seq_SET(argtypes, i, val);
11102
0
            }
11103
0
            Py_CLEAR(tmp);
11104
0
        }
11105
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11106
0
            return -1;
11107
0
        }
11108
0
        if (tmp == NULL) {
11109
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11110
0
            return -1;
11111
0
        }
11112
0
        else {
11113
0
            int res;
11114
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11115
0
                goto failed;
11116
0
            }
11117
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11118
0
            _Py_LeaveRecursiveCall();
11119
0
            if (res != 0) goto failed;
11120
0
            Py_CLEAR(tmp);
11121
0
        }
11122
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11123
0
        if (*out == NULL) goto failed;
11124
0
        return 0;
11125
0
    }
11126
11127
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11128
0
    failed:
11129
0
    Py_XDECREF(tmp);
11130
0
    return -1;
11131
0
}
11132
11133
int
11134
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
11135
             arena)
11136
0
{
11137
0
    int isinstance;
11138
11139
0
    PyObject *tmp = NULL;
11140
0
    PyObject *tp;
11141
0
    int lineno;
11142
0
    int col_offset;
11143
0
    int end_lineno;
11144
0
    int end_col_offset;
11145
11146
0
    if (obj == Py_None) {
11147
0
        *out = NULL;
11148
0
        return 0;
11149
0
    }
11150
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11151
0
        return -1;
11152
0
    }
11153
0
    if (tmp == NULL) {
11154
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11155
0
        return -1;
11156
0
    }
11157
0
    else {
11158
0
        int res;
11159
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11160
0
            goto failed;
11161
0
        }
11162
0
        res = obj2ast_int(state, tmp, &lineno, arena);
11163
0
        _Py_LeaveRecursiveCall();
11164
0
        if (res != 0) goto failed;
11165
0
        Py_CLEAR(tmp);
11166
0
    }
11167
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11168
0
        return -1;
11169
0
    }
11170
0
    if (tmp == NULL) {
11171
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11172
0
        return -1;
11173
0
    }
11174
0
    else {
11175
0
        int res;
11176
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11177
0
            goto failed;
11178
0
        }
11179
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
11180
0
        _Py_LeaveRecursiveCall();
11181
0
        if (res != 0) goto failed;
11182
0
        Py_CLEAR(tmp);
11183
0
    }
11184
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11185
0
        return -1;
11186
0
    }
11187
0
    if (tmp == NULL || tmp == Py_None) {
11188
0
        Py_CLEAR(tmp);
11189
0
        end_lineno = lineno;
11190
0
    }
11191
0
    else {
11192
0
        int res;
11193
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11194
0
            goto failed;
11195
0
        }
11196
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
11197
0
        _Py_LeaveRecursiveCall();
11198
0
        if (res != 0) goto failed;
11199
0
        Py_CLEAR(tmp);
11200
0
    }
11201
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11202
0
        return -1;
11203
0
    }
11204
0
    if (tmp == NULL || tmp == Py_None) {
11205
0
        Py_CLEAR(tmp);
11206
0
        end_col_offset = col_offset;
11207
0
    }
11208
0
    else {
11209
0
        int res;
11210
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11211
0
            goto failed;
11212
0
        }
11213
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
11214
0
        _Py_LeaveRecursiveCall();
11215
0
        if (res != 0) goto failed;
11216
0
        Py_CLEAR(tmp);
11217
0
    }
11218
0
    tp = state->FunctionDef_type;
11219
0
    isinstance = PyObject_IsInstance(obj, tp);
11220
0
    if (isinstance == -1) {
11221
0
        return -1;
11222
0
    }
11223
0
    if (isinstance) {
11224
0
        identifier name;
11225
0
        arguments_ty args;
11226
0
        asdl_stmt_seq* body;
11227
0
        asdl_expr_seq* decorator_list;
11228
0
        expr_ty returns;
11229
0
        string type_comment;
11230
0
        asdl_type_param_seq* type_params;
11231
11232
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11233
0
            return -1;
11234
0
        }
11235
0
        if (tmp == NULL) {
11236
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11237
0
            return -1;
11238
0
        }
11239
0
        else {
11240
0
            int res;
11241
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11242
0
                goto failed;
11243
0
            }
11244
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11245
0
            _Py_LeaveRecursiveCall();
11246
0
            if (res != 0) goto failed;
11247
0
            Py_CLEAR(tmp);
11248
0
        }
11249
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11250
0
            return -1;
11251
0
        }
11252
0
        if (tmp == NULL) {
11253
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11254
0
            return -1;
11255
0
        }
11256
0
        else {
11257
0
            int res;
11258
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11259
0
                goto failed;
11260
0
            }
11261
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11262
0
            _Py_LeaveRecursiveCall();
11263
0
            if (res != 0) goto failed;
11264
0
            Py_CLEAR(tmp);
11265
0
        }
11266
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11267
0
            return -1;
11268
0
        }
11269
0
        if (tmp == NULL) {
11270
0
            tmp = PyList_New(0);
11271
0
            if (tmp == NULL) {
11272
0
                return -1;
11273
0
            }
11274
0
        }
11275
0
        {
11276
0
            int res;
11277
0
            Py_ssize_t len;
11278
0
            Py_ssize_t i;
11279
0
            if (!PyList_Check(tmp)) {
11280
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11281
0
                goto failed;
11282
0
            }
11283
0
            len = PyList_GET_SIZE(tmp);
11284
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11285
0
            if (body == NULL) goto failed;
11286
0
            for (i = 0; i < len; i++) {
11287
0
                stmt_ty val;
11288
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11289
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11290
0
                    goto failed;
11291
0
                }
11292
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11293
0
                _Py_LeaveRecursiveCall();
11294
0
                Py_DECREF(tmp2);
11295
0
                if (res != 0) goto failed;
11296
0
                if (len != PyList_GET_SIZE(tmp)) {
11297
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11298
0
                    goto failed;
11299
0
                }
11300
0
                asdl_seq_SET(body, i, val);
11301
0
            }
11302
0
            Py_CLEAR(tmp);
11303
0
        }
11304
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11305
0
            return -1;
11306
0
        }
11307
0
        if (tmp == NULL) {
11308
0
            tmp = PyList_New(0);
11309
0
            if (tmp == NULL) {
11310
0
                return -1;
11311
0
            }
11312
0
        }
11313
0
        {
11314
0
            int res;
11315
0
            Py_ssize_t len;
11316
0
            Py_ssize_t i;
11317
0
            if (!PyList_Check(tmp)) {
11318
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11319
0
                goto failed;
11320
0
            }
11321
0
            len = PyList_GET_SIZE(tmp);
11322
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11323
0
            if (decorator_list == NULL) goto failed;
11324
0
            for (i = 0; i < len; i++) {
11325
0
                expr_ty val;
11326
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11327
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11328
0
                    goto failed;
11329
0
                }
11330
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11331
0
                _Py_LeaveRecursiveCall();
11332
0
                Py_DECREF(tmp2);
11333
0
                if (res != 0) goto failed;
11334
0
                if (len != PyList_GET_SIZE(tmp)) {
11335
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11336
0
                    goto failed;
11337
0
                }
11338
0
                asdl_seq_SET(decorator_list, i, val);
11339
0
            }
11340
0
            Py_CLEAR(tmp);
11341
0
        }
11342
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11343
0
            return -1;
11344
0
        }
11345
0
        if (tmp == NULL || tmp == Py_None) {
11346
0
            Py_CLEAR(tmp);
11347
0
            returns = NULL;
11348
0
        }
11349
0
        else {
11350
0
            int res;
11351
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11352
0
                goto failed;
11353
0
            }
11354
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11355
0
            _Py_LeaveRecursiveCall();
11356
0
            if (res != 0) goto failed;
11357
0
            Py_CLEAR(tmp);
11358
0
        }
11359
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11360
0
            return -1;
11361
0
        }
11362
0
        if (tmp == NULL || tmp == Py_None) {
11363
0
            Py_CLEAR(tmp);
11364
0
            type_comment = NULL;
11365
0
        }
11366
0
        else {
11367
0
            int res;
11368
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11369
0
                goto failed;
11370
0
            }
11371
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11372
0
            _Py_LeaveRecursiveCall();
11373
0
            if (res != 0) goto failed;
11374
0
            Py_CLEAR(tmp);
11375
0
        }
11376
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11377
0
            return -1;
11378
0
        }
11379
0
        if (tmp == NULL) {
11380
0
            tmp = PyList_New(0);
11381
0
            if (tmp == NULL) {
11382
0
                return -1;
11383
0
            }
11384
0
        }
11385
0
        {
11386
0
            int res;
11387
0
            Py_ssize_t len;
11388
0
            Py_ssize_t i;
11389
0
            if (!PyList_Check(tmp)) {
11390
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11391
0
                goto failed;
11392
0
            }
11393
0
            len = PyList_GET_SIZE(tmp);
11394
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11395
0
            if (type_params == NULL) goto failed;
11396
0
            for (i = 0; i < len; i++) {
11397
0
                type_param_ty val;
11398
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11399
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11400
0
                    goto failed;
11401
0
                }
11402
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11403
0
                _Py_LeaveRecursiveCall();
11404
0
                Py_DECREF(tmp2);
11405
0
                if (res != 0) goto failed;
11406
0
                if (len != PyList_GET_SIZE(tmp)) {
11407
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11408
0
                    goto failed;
11409
0
                }
11410
0
                asdl_seq_SET(type_params, i, val);
11411
0
            }
11412
0
            Py_CLEAR(tmp);
11413
0
        }
11414
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11415
0
                                  type_comment, type_params, lineno,
11416
0
                                  col_offset, end_lineno, end_col_offset,
11417
0
                                  arena);
11418
0
        if (*out == NULL) goto failed;
11419
0
        return 0;
11420
0
    }
11421
0
    tp = state->AsyncFunctionDef_type;
11422
0
    isinstance = PyObject_IsInstance(obj, tp);
11423
0
    if (isinstance == -1) {
11424
0
        return -1;
11425
0
    }
11426
0
    if (isinstance) {
11427
0
        identifier name;
11428
0
        arguments_ty args;
11429
0
        asdl_stmt_seq* body;
11430
0
        asdl_expr_seq* decorator_list;
11431
0
        expr_ty returns;
11432
0
        string type_comment;
11433
0
        asdl_type_param_seq* type_params;
11434
11435
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11436
0
            return -1;
11437
0
        }
11438
0
        if (tmp == NULL) {
11439
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11440
0
            return -1;
11441
0
        }
11442
0
        else {
11443
0
            int res;
11444
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11445
0
                goto failed;
11446
0
            }
11447
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11448
0
            _Py_LeaveRecursiveCall();
11449
0
            if (res != 0) goto failed;
11450
0
            Py_CLEAR(tmp);
11451
0
        }
11452
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11453
0
            return -1;
11454
0
        }
11455
0
        if (tmp == NULL) {
11456
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11457
0
            return -1;
11458
0
        }
11459
0
        else {
11460
0
            int res;
11461
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11462
0
                goto failed;
11463
0
            }
11464
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11465
0
            _Py_LeaveRecursiveCall();
11466
0
            if (res != 0) goto failed;
11467
0
            Py_CLEAR(tmp);
11468
0
        }
11469
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11470
0
            return -1;
11471
0
        }
11472
0
        if (tmp == NULL) {
11473
0
            tmp = PyList_New(0);
11474
0
            if (tmp == NULL) {
11475
0
                return -1;
11476
0
            }
11477
0
        }
11478
0
        {
11479
0
            int res;
11480
0
            Py_ssize_t len;
11481
0
            Py_ssize_t i;
11482
0
            if (!PyList_Check(tmp)) {
11483
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11484
0
                goto failed;
11485
0
            }
11486
0
            len = PyList_GET_SIZE(tmp);
11487
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11488
0
            if (body == NULL) goto failed;
11489
0
            for (i = 0; i < len; i++) {
11490
0
                stmt_ty val;
11491
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11492
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11493
0
                    goto failed;
11494
0
                }
11495
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11496
0
                _Py_LeaveRecursiveCall();
11497
0
                Py_DECREF(tmp2);
11498
0
                if (res != 0) goto failed;
11499
0
                if (len != PyList_GET_SIZE(tmp)) {
11500
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11501
0
                    goto failed;
11502
0
                }
11503
0
                asdl_seq_SET(body, i, val);
11504
0
            }
11505
0
            Py_CLEAR(tmp);
11506
0
        }
11507
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11508
0
            return -1;
11509
0
        }
11510
0
        if (tmp == NULL) {
11511
0
            tmp = PyList_New(0);
11512
0
            if (tmp == NULL) {
11513
0
                return -1;
11514
0
            }
11515
0
        }
11516
0
        {
11517
0
            int res;
11518
0
            Py_ssize_t len;
11519
0
            Py_ssize_t i;
11520
0
            if (!PyList_Check(tmp)) {
11521
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11522
0
                goto failed;
11523
0
            }
11524
0
            len = PyList_GET_SIZE(tmp);
11525
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11526
0
            if (decorator_list == NULL) goto failed;
11527
0
            for (i = 0; i < len; i++) {
11528
0
                expr_ty val;
11529
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11530
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11531
0
                    goto failed;
11532
0
                }
11533
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11534
0
                _Py_LeaveRecursiveCall();
11535
0
                Py_DECREF(tmp2);
11536
0
                if (res != 0) goto failed;
11537
0
                if (len != PyList_GET_SIZE(tmp)) {
11538
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11539
0
                    goto failed;
11540
0
                }
11541
0
                asdl_seq_SET(decorator_list, i, val);
11542
0
            }
11543
0
            Py_CLEAR(tmp);
11544
0
        }
11545
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11546
0
            return -1;
11547
0
        }
11548
0
        if (tmp == NULL || tmp == Py_None) {
11549
0
            Py_CLEAR(tmp);
11550
0
            returns = NULL;
11551
0
        }
11552
0
        else {
11553
0
            int res;
11554
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11555
0
                goto failed;
11556
0
            }
11557
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11558
0
            _Py_LeaveRecursiveCall();
11559
0
            if (res != 0) goto failed;
11560
0
            Py_CLEAR(tmp);
11561
0
        }
11562
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11563
0
            return -1;
11564
0
        }
11565
0
        if (tmp == NULL || tmp == Py_None) {
11566
0
            Py_CLEAR(tmp);
11567
0
            type_comment = NULL;
11568
0
        }
11569
0
        else {
11570
0
            int res;
11571
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11572
0
                goto failed;
11573
0
            }
11574
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11575
0
            _Py_LeaveRecursiveCall();
11576
0
            if (res != 0) goto failed;
11577
0
            Py_CLEAR(tmp);
11578
0
        }
11579
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11580
0
            return -1;
11581
0
        }
11582
0
        if (tmp == NULL) {
11583
0
            tmp = PyList_New(0);
11584
0
            if (tmp == NULL) {
11585
0
                return -1;
11586
0
            }
11587
0
        }
11588
0
        {
11589
0
            int res;
11590
0
            Py_ssize_t len;
11591
0
            Py_ssize_t i;
11592
0
            if (!PyList_Check(tmp)) {
11593
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11594
0
                goto failed;
11595
0
            }
11596
0
            len = PyList_GET_SIZE(tmp);
11597
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11598
0
            if (type_params == NULL) goto failed;
11599
0
            for (i = 0; i < len; i++) {
11600
0
                type_param_ty val;
11601
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11602
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11603
0
                    goto failed;
11604
0
                }
11605
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11606
0
                _Py_LeaveRecursiveCall();
11607
0
                Py_DECREF(tmp2);
11608
0
                if (res != 0) goto failed;
11609
0
                if (len != PyList_GET_SIZE(tmp)) {
11610
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11611
0
                    goto failed;
11612
0
                }
11613
0
                asdl_seq_SET(type_params, i, val);
11614
0
            }
11615
0
            Py_CLEAR(tmp);
11616
0
        }
11617
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11618
0
                                       returns, type_comment, type_params,
11619
0
                                       lineno, col_offset, end_lineno,
11620
0
                                       end_col_offset, arena);
11621
0
        if (*out == NULL) goto failed;
11622
0
        return 0;
11623
0
    }
11624
0
    tp = state->ClassDef_type;
11625
0
    isinstance = PyObject_IsInstance(obj, tp);
11626
0
    if (isinstance == -1) {
11627
0
        return -1;
11628
0
    }
11629
0
    if (isinstance) {
11630
0
        identifier name;
11631
0
        asdl_expr_seq* bases;
11632
0
        asdl_keyword_seq* keywords;
11633
0
        asdl_stmt_seq* body;
11634
0
        asdl_expr_seq* decorator_list;
11635
0
        asdl_type_param_seq* type_params;
11636
11637
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11638
0
            return -1;
11639
0
        }
11640
0
        if (tmp == NULL) {
11641
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11642
0
            return -1;
11643
0
        }
11644
0
        else {
11645
0
            int res;
11646
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11647
0
                goto failed;
11648
0
            }
11649
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11650
0
            _Py_LeaveRecursiveCall();
11651
0
            if (res != 0) goto failed;
11652
0
            Py_CLEAR(tmp);
11653
0
        }
11654
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11655
0
            return -1;
11656
0
        }
11657
0
        if (tmp == NULL) {
11658
0
            tmp = PyList_New(0);
11659
0
            if (tmp == NULL) {
11660
0
                return -1;
11661
0
            }
11662
0
        }
11663
0
        {
11664
0
            int res;
11665
0
            Py_ssize_t len;
11666
0
            Py_ssize_t i;
11667
0
            if (!PyList_Check(tmp)) {
11668
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11669
0
                goto failed;
11670
0
            }
11671
0
            len = PyList_GET_SIZE(tmp);
11672
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11673
0
            if (bases == NULL) goto failed;
11674
0
            for (i = 0; i < len; i++) {
11675
0
                expr_ty val;
11676
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11677
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11678
0
                    goto failed;
11679
0
                }
11680
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11681
0
                _Py_LeaveRecursiveCall();
11682
0
                Py_DECREF(tmp2);
11683
0
                if (res != 0) goto failed;
11684
0
                if (len != PyList_GET_SIZE(tmp)) {
11685
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11686
0
                    goto failed;
11687
0
                }
11688
0
                asdl_seq_SET(bases, i, val);
11689
0
            }
11690
0
            Py_CLEAR(tmp);
11691
0
        }
11692
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11693
0
            return -1;
11694
0
        }
11695
0
        if (tmp == NULL) {
11696
0
            tmp = PyList_New(0);
11697
0
            if (tmp == NULL) {
11698
0
                return -1;
11699
0
            }
11700
0
        }
11701
0
        {
11702
0
            int res;
11703
0
            Py_ssize_t len;
11704
0
            Py_ssize_t i;
11705
0
            if (!PyList_Check(tmp)) {
11706
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11707
0
                goto failed;
11708
0
            }
11709
0
            len = PyList_GET_SIZE(tmp);
11710
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11711
0
            if (keywords == NULL) goto failed;
11712
0
            for (i = 0; i < len; i++) {
11713
0
                keyword_ty val;
11714
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11715
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11716
0
                    goto failed;
11717
0
                }
11718
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
11719
0
                _Py_LeaveRecursiveCall();
11720
0
                Py_DECREF(tmp2);
11721
0
                if (res != 0) goto failed;
11722
0
                if (len != PyList_GET_SIZE(tmp)) {
11723
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11724
0
                    goto failed;
11725
0
                }
11726
0
                asdl_seq_SET(keywords, i, val);
11727
0
            }
11728
0
            Py_CLEAR(tmp);
11729
0
        }
11730
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11731
0
            return -1;
11732
0
        }
11733
0
        if (tmp == NULL) {
11734
0
            tmp = PyList_New(0);
11735
0
            if (tmp == NULL) {
11736
0
                return -1;
11737
0
            }
11738
0
        }
11739
0
        {
11740
0
            int res;
11741
0
            Py_ssize_t len;
11742
0
            Py_ssize_t i;
11743
0
            if (!PyList_Check(tmp)) {
11744
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11745
0
                goto failed;
11746
0
            }
11747
0
            len = PyList_GET_SIZE(tmp);
11748
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11749
0
            if (body == NULL) goto failed;
11750
0
            for (i = 0; i < len; i++) {
11751
0
                stmt_ty val;
11752
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11753
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11754
0
                    goto failed;
11755
0
                }
11756
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11757
0
                _Py_LeaveRecursiveCall();
11758
0
                Py_DECREF(tmp2);
11759
0
                if (res != 0) goto failed;
11760
0
                if (len != PyList_GET_SIZE(tmp)) {
11761
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11762
0
                    goto failed;
11763
0
                }
11764
0
                asdl_seq_SET(body, i, val);
11765
0
            }
11766
0
            Py_CLEAR(tmp);
11767
0
        }
11768
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11769
0
            return -1;
11770
0
        }
11771
0
        if (tmp == NULL) {
11772
0
            tmp = PyList_New(0);
11773
0
            if (tmp == NULL) {
11774
0
                return -1;
11775
0
            }
11776
0
        }
11777
0
        {
11778
0
            int res;
11779
0
            Py_ssize_t len;
11780
0
            Py_ssize_t i;
11781
0
            if (!PyList_Check(tmp)) {
11782
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11783
0
                goto failed;
11784
0
            }
11785
0
            len = PyList_GET_SIZE(tmp);
11786
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11787
0
            if (decorator_list == NULL) goto failed;
11788
0
            for (i = 0; i < len; i++) {
11789
0
                expr_ty val;
11790
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11791
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11792
0
                    goto failed;
11793
0
                }
11794
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11795
0
                _Py_LeaveRecursiveCall();
11796
0
                Py_DECREF(tmp2);
11797
0
                if (res != 0) goto failed;
11798
0
                if (len != PyList_GET_SIZE(tmp)) {
11799
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11800
0
                    goto failed;
11801
0
                }
11802
0
                asdl_seq_SET(decorator_list, i, val);
11803
0
            }
11804
0
            Py_CLEAR(tmp);
11805
0
        }
11806
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11807
0
            return -1;
11808
0
        }
11809
0
        if (tmp == NULL) {
11810
0
            tmp = PyList_New(0);
11811
0
            if (tmp == NULL) {
11812
0
                return -1;
11813
0
            }
11814
0
        }
11815
0
        {
11816
0
            int res;
11817
0
            Py_ssize_t len;
11818
0
            Py_ssize_t i;
11819
0
            if (!PyList_Check(tmp)) {
11820
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11821
0
                goto failed;
11822
0
            }
11823
0
            len = PyList_GET_SIZE(tmp);
11824
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11825
0
            if (type_params == NULL) goto failed;
11826
0
            for (i = 0; i < len; i++) {
11827
0
                type_param_ty val;
11828
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11829
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11830
0
                    goto failed;
11831
0
                }
11832
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11833
0
                _Py_LeaveRecursiveCall();
11834
0
                Py_DECREF(tmp2);
11835
0
                if (res != 0) goto failed;
11836
0
                if (len != PyList_GET_SIZE(tmp)) {
11837
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11838
0
                    goto failed;
11839
0
                }
11840
0
                asdl_seq_SET(type_params, i, val);
11841
0
            }
11842
0
            Py_CLEAR(tmp);
11843
0
        }
11844
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11845
0
                               type_params, lineno, col_offset, end_lineno,
11846
0
                               end_col_offset, arena);
11847
0
        if (*out == NULL) goto failed;
11848
0
        return 0;
11849
0
    }
11850
0
    tp = state->Return_type;
11851
0
    isinstance = PyObject_IsInstance(obj, tp);
11852
0
    if (isinstance == -1) {
11853
0
        return -1;
11854
0
    }
11855
0
    if (isinstance) {
11856
0
        expr_ty value;
11857
11858
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11859
0
            return -1;
11860
0
        }
11861
0
        if (tmp == NULL || tmp == Py_None) {
11862
0
            Py_CLEAR(tmp);
11863
0
            value = NULL;
11864
0
        }
11865
0
        else {
11866
0
            int res;
11867
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11868
0
                goto failed;
11869
0
            }
11870
0
            res = obj2ast_expr(state, tmp, &value, arena);
11871
0
            _Py_LeaveRecursiveCall();
11872
0
            if (res != 0) goto failed;
11873
0
            Py_CLEAR(tmp);
11874
0
        }
11875
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11876
0
                             end_col_offset, arena);
11877
0
        if (*out == NULL) goto failed;
11878
0
        return 0;
11879
0
    }
11880
0
    tp = state->Delete_type;
11881
0
    isinstance = PyObject_IsInstance(obj, tp);
11882
0
    if (isinstance == -1) {
11883
0
        return -1;
11884
0
    }
11885
0
    if (isinstance) {
11886
0
        asdl_expr_seq* targets;
11887
11888
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11889
0
            return -1;
11890
0
        }
11891
0
        if (tmp == NULL) {
11892
0
            tmp = PyList_New(0);
11893
0
            if (tmp == NULL) {
11894
0
                return -1;
11895
0
            }
11896
0
        }
11897
0
        {
11898
0
            int res;
11899
0
            Py_ssize_t len;
11900
0
            Py_ssize_t i;
11901
0
            if (!PyList_Check(tmp)) {
11902
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11903
0
                goto failed;
11904
0
            }
11905
0
            len = PyList_GET_SIZE(tmp);
11906
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11907
0
            if (targets == NULL) goto failed;
11908
0
            for (i = 0; i < len; i++) {
11909
0
                expr_ty val;
11910
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11911
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11912
0
                    goto failed;
11913
0
                }
11914
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11915
0
                _Py_LeaveRecursiveCall();
11916
0
                Py_DECREF(tmp2);
11917
0
                if (res != 0) goto failed;
11918
0
                if (len != PyList_GET_SIZE(tmp)) {
11919
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11920
0
                    goto failed;
11921
0
                }
11922
0
                asdl_seq_SET(targets, i, val);
11923
0
            }
11924
0
            Py_CLEAR(tmp);
11925
0
        }
11926
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11927
0
                             end_col_offset, arena);
11928
0
        if (*out == NULL) goto failed;
11929
0
        return 0;
11930
0
    }
11931
0
    tp = state->Assign_type;
11932
0
    isinstance = PyObject_IsInstance(obj, tp);
11933
0
    if (isinstance == -1) {
11934
0
        return -1;
11935
0
    }
11936
0
    if (isinstance) {
11937
0
        asdl_expr_seq* targets;
11938
0
        expr_ty value;
11939
0
        string type_comment;
11940
11941
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11942
0
            return -1;
11943
0
        }
11944
0
        if (tmp == NULL) {
11945
0
            tmp = PyList_New(0);
11946
0
            if (tmp == NULL) {
11947
0
                return -1;
11948
0
            }
11949
0
        }
11950
0
        {
11951
0
            int res;
11952
0
            Py_ssize_t len;
11953
0
            Py_ssize_t i;
11954
0
            if (!PyList_Check(tmp)) {
11955
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11956
0
                goto failed;
11957
0
            }
11958
0
            len = PyList_GET_SIZE(tmp);
11959
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11960
0
            if (targets == NULL) goto failed;
11961
0
            for (i = 0; i < len; i++) {
11962
0
                expr_ty val;
11963
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11964
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11965
0
                    goto failed;
11966
0
                }
11967
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11968
0
                _Py_LeaveRecursiveCall();
11969
0
                Py_DECREF(tmp2);
11970
0
                if (res != 0) goto failed;
11971
0
                if (len != PyList_GET_SIZE(tmp)) {
11972
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
11973
0
                    goto failed;
11974
0
                }
11975
0
                asdl_seq_SET(targets, i, val);
11976
0
            }
11977
0
            Py_CLEAR(tmp);
11978
0
        }
11979
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11980
0
            return -1;
11981
0
        }
11982
0
        if (tmp == NULL) {
11983
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11984
0
            return -1;
11985
0
        }
11986
0
        else {
11987
0
            int res;
11988
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11989
0
                goto failed;
11990
0
            }
11991
0
            res = obj2ast_expr(state, tmp, &value, arena);
11992
0
            _Py_LeaveRecursiveCall();
11993
0
            if (res != 0) goto failed;
11994
0
            Py_CLEAR(tmp);
11995
0
        }
11996
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11997
0
            return -1;
11998
0
        }
11999
0
        if (tmp == NULL || tmp == Py_None) {
12000
0
            Py_CLEAR(tmp);
12001
0
            type_comment = NULL;
12002
0
        }
12003
0
        else {
12004
0
            int res;
12005
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12006
0
                goto failed;
12007
0
            }
12008
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12009
0
            _Py_LeaveRecursiveCall();
12010
0
            if (res != 0) goto failed;
12011
0
            Py_CLEAR(tmp);
12012
0
        }
12013
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
12014
0
                             end_lineno, end_col_offset, arena);
12015
0
        if (*out == NULL) goto failed;
12016
0
        return 0;
12017
0
    }
12018
0
    tp = state->TypeAlias_type;
12019
0
    isinstance = PyObject_IsInstance(obj, tp);
12020
0
    if (isinstance == -1) {
12021
0
        return -1;
12022
0
    }
12023
0
    if (isinstance) {
12024
0
        expr_ty name;
12025
0
        asdl_type_param_seq* type_params;
12026
0
        expr_ty value;
12027
12028
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12029
0
            return -1;
12030
0
        }
12031
0
        if (tmp == NULL) {
12032
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12033
0
            return -1;
12034
0
        }
12035
0
        else {
12036
0
            int res;
12037
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12038
0
                goto failed;
12039
0
            }
12040
0
            res = obj2ast_expr(state, tmp, &name, arena);
12041
0
            _Py_LeaveRecursiveCall();
12042
0
            if (res != 0) goto failed;
12043
0
            Py_CLEAR(tmp);
12044
0
        }
12045
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12046
0
            return -1;
12047
0
        }
12048
0
        if (tmp == NULL) {
12049
0
            tmp = PyList_New(0);
12050
0
            if (tmp == NULL) {
12051
0
                return -1;
12052
0
            }
12053
0
        }
12054
0
        {
12055
0
            int res;
12056
0
            Py_ssize_t len;
12057
0
            Py_ssize_t i;
12058
0
            if (!PyList_Check(tmp)) {
12059
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12060
0
                goto failed;
12061
0
            }
12062
0
            len = PyList_GET_SIZE(tmp);
12063
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12064
0
            if (type_params == NULL) goto failed;
12065
0
            for (i = 0; i < len; i++) {
12066
0
                type_param_ty val;
12067
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12068
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12069
0
                    goto failed;
12070
0
                }
12071
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
12072
0
                _Py_LeaveRecursiveCall();
12073
0
                Py_DECREF(tmp2);
12074
0
                if (res != 0) goto failed;
12075
0
                if (len != PyList_GET_SIZE(tmp)) {
12076
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12077
0
                    goto failed;
12078
0
                }
12079
0
                asdl_seq_SET(type_params, i, val);
12080
0
            }
12081
0
            Py_CLEAR(tmp);
12082
0
        }
12083
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12084
0
            return -1;
12085
0
        }
12086
0
        if (tmp == NULL) {
12087
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12088
0
            return -1;
12089
0
        }
12090
0
        else {
12091
0
            int res;
12092
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12093
0
                goto failed;
12094
0
            }
12095
0
            res = obj2ast_expr(state, tmp, &value, arena);
12096
0
            _Py_LeaveRecursiveCall();
12097
0
            if (res != 0) goto failed;
12098
0
            Py_CLEAR(tmp);
12099
0
        }
12100
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12101
0
                                end_lineno, end_col_offset, arena);
12102
0
        if (*out == NULL) goto failed;
12103
0
        return 0;
12104
0
    }
12105
0
    tp = state->AugAssign_type;
12106
0
    isinstance = PyObject_IsInstance(obj, tp);
12107
0
    if (isinstance == -1) {
12108
0
        return -1;
12109
0
    }
12110
0
    if (isinstance) {
12111
0
        expr_ty target;
12112
0
        operator_ty op;
12113
0
        expr_ty value;
12114
12115
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12116
0
            return -1;
12117
0
        }
12118
0
        if (tmp == NULL) {
12119
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12120
0
            return -1;
12121
0
        }
12122
0
        else {
12123
0
            int res;
12124
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12125
0
                goto failed;
12126
0
            }
12127
0
            res = obj2ast_expr(state, tmp, &target, arena);
12128
0
            _Py_LeaveRecursiveCall();
12129
0
            if (res != 0) goto failed;
12130
0
            Py_CLEAR(tmp);
12131
0
        }
12132
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12133
0
            return -1;
12134
0
        }
12135
0
        if (tmp == NULL) {
12136
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12137
0
            return -1;
12138
0
        }
12139
0
        else {
12140
0
            int res;
12141
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12142
0
                goto failed;
12143
0
            }
12144
0
            res = obj2ast_operator(state, tmp, &op, arena);
12145
0
            _Py_LeaveRecursiveCall();
12146
0
            if (res != 0) goto failed;
12147
0
            Py_CLEAR(tmp);
12148
0
        }
12149
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12150
0
            return -1;
12151
0
        }
12152
0
        if (tmp == NULL) {
12153
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12154
0
            return -1;
12155
0
        }
12156
0
        else {
12157
0
            int res;
12158
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12159
0
                goto failed;
12160
0
            }
12161
0
            res = obj2ast_expr(state, tmp, &value, arena);
12162
0
            _Py_LeaveRecursiveCall();
12163
0
            if (res != 0) goto failed;
12164
0
            Py_CLEAR(tmp);
12165
0
        }
12166
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12167
0
                                end_lineno, end_col_offset, arena);
12168
0
        if (*out == NULL) goto failed;
12169
0
        return 0;
12170
0
    }
12171
0
    tp = state->AnnAssign_type;
12172
0
    isinstance = PyObject_IsInstance(obj, tp);
12173
0
    if (isinstance == -1) {
12174
0
        return -1;
12175
0
    }
12176
0
    if (isinstance) {
12177
0
        expr_ty target;
12178
0
        expr_ty annotation;
12179
0
        expr_ty value;
12180
0
        int simple;
12181
12182
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12183
0
            return -1;
12184
0
        }
12185
0
        if (tmp == NULL) {
12186
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12187
0
            return -1;
12188
0
        }
12189
0
        else {
12190
0
            int res;
12191
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12192
0
                goto failed;
12193
0
            }
12194
0
            res = obj2ast_expr(state, tmp, &target, arena);
12195
0
            _Py_LeaveRecursiveCall();
12196
0
            if (res != 0) goto failed;
12197
0
            Py_CLEAR(tmp);
12198
0
        }
12199
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12200
0
            return -1;
12201
0
        }
12202
0
        if (tmp == NULL) {
12203
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12204
0
            return -1;
12205
0
        }
12206
0
        else {
12207
0
            int res;
12208
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12209
0
                goto failed;
12210
0
            }
12211
0
            res = obj2ast_expr(state, tmp, &annotation, arena);
12212
0
            _Py_LeaveRecursiveCall();
12213
0
            if (res != 0) goto failed;
12214
0
            Py_CLEAR(tmp);
12215
0
        }
12216
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12217
0
            return -1;
12218
0
        }
12219
0
        if (tmp == NULL || tmp == Py_None) {
12220
0
            Py_CLEAR(tmp);
12221
0
            value = NULL;
12222
0
        }
12223
0
        else {
12224
0
            int res;
12225
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12226
0
                goto failed;
12227
0
            }
12228
0
            res = obj2ast_expr(state, tmp, &value, arena);
12229
0
            _Py_LeaveRecursiveCall();
12230
0
            if (res != 0) goto failed;
12231
0
            Py_CLEAR(tmp);
12232
0
        }
12233
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
12234
0
            return -1;
12235
0
        }
12236
0
        if (tmp == NULL) {
12237
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12238
0
            return -1;
12239
0
        }
12240
0
        else {
12241
0
            int res;
12242
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12243
0
                goto failed;
12244
0
            }
12245
0
            res = obj2ast_int(state, tmp, &simple, arena);
12246
0
            _Py_LeaveRecursiveCall();
12247
0
            if (res != 0) goto failed;
12248
0
            Py_CLEAR(tmp);
12249
0
        }
12250
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12251
0
                                col_offset, end_lineno, end_col_offset, arena);
12252
0
        if (*out == NULL) goto failed;
12253
0
        return 0;
12254
0
    }
12255
0
    tp = state->For_type;
12256
0
    isinstance = PyObject_IsInstance(obj, tp);
12257
0
    if (isinstance == -1) {
12258
0
        return -1;
12259
0
    }
12260
0
    if (isinstance) {
12261
0
        expr_ty target;
12262
0
        expr_ty iter;
12263
0
        asdl_stmt_seq* body;
12264
0
        asdl_stmt_seq* orelse;
12265
0
        string type_comment;
12266
12267
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12268
0
            return -1;
12269
0
        }
12270
0
        if (tmp == NULL) {
12271
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12272
0
            return -1;
12273
0
        }
12274
0
        else {
12275
0
            int res;
12276
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12277
0
                goto failed;
12278
0
            }
12279
0
            res = obj2ast_expr(state, tmp, &target, arena);
12280
0
            _Py_LeaveRecursiveCall();
12281
0
            if (res != 0) goto failed;
12282
0
            Py_CLEAR(tmp);
12283
0
        }
12284
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12285
0
            return -1;
12286
0
        }
12287
0
        if (tmp == NULL) {
12288
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12289
0
            return -1;
12290
0
        }
12291
0
        else {
12292
0
            int res;
12293
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12294
0
                goto failed;
12295
0
            }
12296
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12297
0
            _Py_LeaveRecursiveCall();
12298
0
            if (res != 0) goto failed;
12299
0
            Py_CLEAR(tmp);
12300
0
        }
12301
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12302
0
            return -1;
12303
0
        }
12304
0
        if (tmp == NULL) {
12305
0
            tmp = PyList_New(0);
12306
0
            if (tmp == NULL) {
12307
0
                return -1;
12308
0
            }
12309
0
        }
12310
0
        {
12311
0
            int res;
12312
0
            Py_ssize_t len;
12313
0
            Py_ssize_t i;
12314
0
            if (!PyList_Check(tmp)) {
12315
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12316
0
                goto failed;
12317
0
            }
12318
0
            len = PyList_GET_SIZE(tmp);
12319
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12320
0
            if (body == NULL) goto failed;
12321
0
            for (i = 0; i < len; i++) {
12322
0
                stmt_ty val;
12323
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12324
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12325
0
                    goto failed;
12326
0
                }
12327
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12328
0
                _Py_LeaveRecursiveCall();
12329
0
                Py_DECREF(tmp2);
12330
0
                if (res != 0) goto failed;
12331
0
                if (len != PyList_GET_SIZE(tmp)) {
12332
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12333
0
                    goto failed;
12334
0
                }
12335
0
                asdl_seq_SET(body, i, val);
12336
0
            }
12337
0
            Py_CLEAR(tmp);
12338
0
        }
12339
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12340
0
            return -1;
12341
0
        }
12342
0
        if (tmp == NULL) {
12343
0
            tmp = PyList_New(0);
12344
0
            if (tmp == NULL) {
12345
0
                return -1;
12346
0
            }
12347
0
        }
12348
0
        {
12349
0
            int res;
12350
0
            Py_ssize_t len;
12351
0
            Py_ssize_t i;
12352
0
            if (!PyList_Check(tmp)) {
12353
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12354
0
                goto failed;
12355
0
            }
12356
0
            len = PyList_GET_SIZE(tmp);
12357
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12358
0
            if (orelse == NULL) goto failed;
12359
0
            for (i = 0; i < len; i++) {
12360
0
                stmt_ty val;
12361
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12362
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12363
0
                    goto failed;
12364
0
                }
12365
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12366
0
                _Py_LeaveRecursiveCall();
12367
0
                Py_DECREF(tmp2);
12368
0
                if (res != 0) goto failed;
12369
0
                if (len != PyList_GET_SIZE(tmp)) {
12370
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12371
0
                    goto failed;
12372
0
                }
12373
0
                asdl_seq_SET(orelse, i, val);
12374
0
            }
12375
0
            Py_CLEAR(tmp);
12376
0
        }
12377
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12378
0
            return -1;
12379
0
        }
12380
0
        if (tmp == NULL || tmp == Py_None) {
12381
0
            Py_CLEAR(tmp);
12382
0
            type_comment = NULL;
12383
0
        }
12384
0
        else {
12385
0
            int res;
12386
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12387
0
                goto failed;
12388
0
            }
12389
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12390
0
            _Py_LeaveRecursiveCall();
12391
0
            if (res != 0) goto failed;
12392
0
            Py_CLEAR(tmp);
12393
0
        }
12394
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12395
0
                          col_offset, end_lineno, end_col_offset, arena);
12396
0
        if (*out == NULL) goto failed;
12397
0
        return 0;
12398
0
    }
12399
0
    tp = state->AsyncFor_type;
12400
0
    isinstance = PyObject_IsInstance(obj, tp);
12401
0
    if (isinstance == -1) {
12402
0
        return -1;
12403
0
    }
12404
0
    if (isinstance) {
12405
0
        expr_ty target;
12406
0
        expr_ty iter;
12407
0
        asdl_stmt_seq* body;
12408
0
        asdl_stmt_seq* orelse;
12409
0
        string type_comment;
12410
12411
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12412
0
            return -1;
12413
0
        }
12414
0
        if (tmp == NULL) {
12415
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12416
0
            return -1;
12417
0
        }
12418
0
        else {
12419
0
            int res;
12420
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12421
0
                goto failed;
12422
0
            }
12423
0
            res = obj2ast_expr(state, tmp, &target, arena);
12424
0
            _Py_LeaveRecursiveCall();
12425
0
            if (res != 0) goto failed;
12426
0
            Py_CLEAR(tmp);
12427
0
        }
12428
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12429
0
            return -1;
12430
0
        }
12431
0
        if (tmp == NULL) {
12432
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12433
0
            return -1;
12434
0
        }
12435
0
        else {
12436
0
            int res;
12437
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12438
0
                goto failed;
12439
0
            }
12440
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12441
0
            _Py_LeaveRecursiveCall();
12442
0
            if (res != 0) goto failed;
12443
0
            Py_CLEAR(tmp);
12444
0
        }
12445
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12446
0
            return -1;
12447
0
        }
12448
0
        if (tmp == NULL) {
12449
0
            tmp = PyList_New(0);
12450
0
            if (tmp == NULL) {
12451
0
                return -1;
12452
0
            }
12453
0
        }
12454
0
        {
12455
0
            int res;
12456
0
            Py_ssize_t len;
12457
0
            Py_ssize_t i;
12458
0
            if (!PyList_Check(tmp)) {
12459
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12460
0
                goto failed;
12461
0
            }
12462
0
            len = PyList_GET_SIZE(tmp);
12463
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12464
0
            if (body == NULL) goto failed;
12465
0
            for (i = 0; i < len; i++) {
12466
0
                stmt_ty val;
12467
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12468
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12469
0
                    goto failed;
12470
0
                }
12471
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12472
0
                _Py_LeaveRecursiveCall();
12473
0
                Py_DECREF(tmp2);
12474
0
                if (res != 0) goto failed;
12475
0
                if (len != PyList_GET_SIZE(tmp)) {
12476
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12477
0
                    goto failed;
12478
0
                }
12479
0
                asdl_seq_SET(body, i, val);
12480
0
            }
12481
0
            Py_CLEAR(tmp);
12482
0
        }
12483
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12484
0
            return -1;
12485
0
        }
12486
0
        if (tmp == NULL) {
12487
0
            tmp = PyList_New(0);
12488
0
            if (tmp == NULL) {
12489
0
                return -1;
12490
0
            }
12491
0
        }
12492
0
        {
12493
0
            int res;
12494
0
            Py_ssize_t len;
12495
0
            Py_ssize_t i;
12496
0
            if (!PyList_Check(tmp)) {
12497
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12498
0
                goto failed;
12499
0
            }
12500
0
            len = PyList_GET_SIZE(tmp);
12501
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12502
0
            if (orelse == NULL) goto failed;
12503
0
            for (i = 0; i < len; i++) {
12504
0
                stmt_ty val;
12505
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12506
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12507
0
                    goto failed;
12508
0
                }
12509
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12510
0
                _Py_LeaveRecursiveCall();
12511
0
                Py_DECREF(tmp2);
12512
0
                if (res != 0) goto failed;
12513
0
                if (len != PyList_GET_SIZE(tmp)) {
12514
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12515
0
                    goto failed;
12516
0
                }
12517
0
                asdl_seq_SET(orelse, i, val);
12518
0
            }
12519
0
            Py_CLEAR(tmp);
12520
0
        }
12521
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12522
0
            return -1;
12523
0
        }
12524
0
        if (tmp == NULL || tmp == Py_None) {
12525
0
            Py_CLEAR(tmp);
12526
0
            type_comment = NULL;
12527
0
        }
12528
0
        else {
12529
0
            int res;
12530
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12531
0
                goto failed;
12532
0
            }
12533
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12534
0
            _Py_LeaveRecursiveCall();
12535
0
            if (res != 0) goto failed;
12536
0
            Py_CLEAR(tmp);
12537
0
        }
12538
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12539
0
                               lineno, col_offset, end_lineno, end_col_offset,
12540
0
                               arena);
12541
0
        if (*out == NULL) goto failed;
12542
0
        return 0;
12543
0
    }
12544
0
    tp = state->While_type;
12545
0
    isinstance = PyObject_IsInstance(obj, tp);
12546
0
    if (isinstance == -1) {
12547
0
        return -1;
12548
0
    }
12549
0
    if (isinstance) {
12550
0
        expr_ty test;
12551
0
        asdl_stmt_seq* body;
12552
0
        asdl_stmt_seq* orelse;
12553
12554
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12555
0
            return -1;
12556
0
        }
12557
0
        if (tmp == NULL) {
12558
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12559
0
            return -1;
12560
0
        }
12561
0
        else {
12562
0
            int res;
12563
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12564
0
                goto failed;
12565
0
            }
12566
0
            res = obj2ast_expr(state, tmp, &test, arena);
12567
0
            _Py_LeaveRecursiveCall();
12568
0
            if (res != 0) goto failed;
12569
0
            Py_CLEAR(tmp);
12570
0
        }
12571
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12572
0
            return -1;
12573
0
        }
12574
0
        if (tmp == NULL) {
12575
0
            tmp = PyList_New(0);
12576
0
            if (tmp == NULL) {
12577
0
                return -1;
12578
0
            }
12579
0
        }
12580
0
        {
12581
0
            int res;
12582
0
            Py_ssize_t len;
12583
0
            Py_ssize_t i;
12584
0
            if (!PyList_Check(tmp)) {
12585
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12586
0
                goto failed;
12587
0
            }
12588
0
            len = PyList_GET_SIZE(tmp);
12589
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12590
0
            if (body == NULL) goto failed;
12591
0
            for (i = 0; i < len; i++) {
12592
0
                stmt_ty val;
12593
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12594
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12595
0
                    goto failed;
12596
0
                }
12597
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12598
0
                _Py_LeaveRecursiveCall();
12599
0
                Py_DECREF(tmp2);
12600
0
                if (res != 0) goto failed;
12601
0
                if (len != PyList_GET_SIZE(tmp)) {
12602
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12603
0
                    goto failed;
12604
0
                }
12605
0
                asdl_seq_SET(body, i, val);
12606
0
            }
12607
0
            Py_CLEAR(tmp);
12608
0
        }
12609
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12610
0
            return -1;
12611
0
        }
12612
0
        if (tmp == NULL) {
12613
0
            tmp = PyList_New(0);
12614
0
            if (tmp == NULL) {
12615
0
                return -1;
12616
0
            }
12617
0
        }
12618
0
        {
12619
0
            int res;
12620
0
            Py_ssize_t len;
12621
0
            Py_ssize_t i;
12622
0
            if (!PyList_Check(tmp)) {
12623
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12624
0
                goto failed;
12625
0
            }
12626
0
            len = PyList_GET_SIZE(tmp);
12627
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12628
0
            if (orelse == NULL) goto failed;
12629
0
            for (i = 0; i < len; i++) {
12630
0
                stmt_ty val;
12631
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12632
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12633
0
                    goto failed;
12634
0
                }
12635
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12636
0
                _Py_LeaveRecursiveCall();
12637
0
                Py_DECREF(tmp2);
12638
0
                if (res != 0) goto failed;
12639
0
                if (len != PyList_GET_SIZE(tmp)) {
12640
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12641
0
                    goto failed;
12642
0
                }
12643
0
                asdl_seq_SET(orelse, i, val);
12644
0
            }
12645
0
            Py_CLEAR(tmp);
12646
0
        }
12647
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12648
0
                            end_col_offset, arena);
12649
0
        if (*out == NULL) goto failed;
12650
0
        return 0;
12651
0
    }
12652
0
    tp = state->If_type;
12653
0
    isinstance = PyObject_IsInstance(obj, tp);
12654
0
    if (isinstance == -1) {
12655
0
        return -1;
12656
0
    }
12657
0
    if (isinstance) {
12658
0
        expr_ty test;
12659
0
        asdl_stmt_seq* body;
12660
0
        asdl_stmt_seq* orelse;
12661
12662
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12663
0
            return -1;
12664
0
        }
12665
0
        if (tmp == NULL) {
12666
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12667
0
            return -1;
12668
0
        }
12669
0
        else {
12670
0
            int res;
12671
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12672
0
                goto failed;
12673
0
            }
12674
0
            res = obj2ast_expr(state, tmp, &test, arena);
12675
0
            _Py_LeaveRecursiveCall();
12676
0
            if (res != 0) goto failed;
12677
0
            Py_CLEAR(tmp);
12678
0
        }
12679
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12680
0
            return -1;
12681
0
        }
12682
0
        if (tmp == NULL) {
12683
0
            tmp = PyList_New(0);
12684
0
            if (tmp == NULL) {
12685
0
                return -1;
12686
0
            }
12687
0
        }
12688
0
        {
12689
0
            int res;
12690
0
            Py_ssize_t len;
12691
0
            Py_ssize_t i;
12692
0
            if (!PyList_Check(tmp)) {
12693
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12694
0
                goto failed;
12695
0
            }
12696
0
            len = PyList_GET_SIZE(tmp);
12697
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12698
0
            if (body == NULL) goto failed;
12699
0
            for (i = 0; i < len; i++) {
12700
0
                stmt_ty val;
12701
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12702
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12703
0
                    goto failed;
12704
0
                }
12705
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12706
0
                _Py_LeaveRecursiveCall();
12707
0
                Py_DECREF(tmp2);
12708
0
                if (res != 0) goto failed;
12709
0
                if (len != PyList_GET_SIZE(tmp)) {
12710
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12711
0
                    goto failed;
12712
0
                }
12713
0
                asdl_seq_SET(body, i, val);
12714
0
            }
12715
0
            Py_CLEAR(tmp);
12716
0
        }
12717
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12718
0
            return -1;
12719
0
        }
12720
0
        if (tmp == NULL) {
12721
0
            tmp = PyList_New(0);
12722
0
            if (tmp == NULL) {
12723
0
                return -1;
12724
0
            }
12725
0
        }
12726
0
        {
12727
0
            int res;
12728
0
            Py_ssize_t len;
12729
0
            Py_ssize_t i;
12730
0
            if (!PyList_Check(tmp)) {
12731
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12732
0
                goto failed;
12733
0
            }
12734
0
            len = PyList_GET_SIZE(tmp);
12735
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12736
0
            if (orelse == NULL) goto failed;
12737
0
            for (i = 0; i < len; i++) {
12738
0
                stmt_ty val;
12739
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12740
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12741
0
                    goto failed;
12742
0
                }
12743
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12744
0
                _Py_LeaveRecursiveCall();
12745
0
                Py_DECREF(tmp2);
12746
0
                if (res != 0) goto failed;
12747
0
                if (len != PyList_GET_SIZE(tmp)) {
12748
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12749
0
                    goto failed;
12750
0
                }
12751
0
                asdl_seq_SET(orelse, i, val);
12752
0
            }
12753
0
            Py_CLEAR(tmp);
12754
0
        }
12755
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12756
0
                         end_col_offset, arena);
12757
0
        if (*out == NULL) goto failed;
12758
0
        return 0;
12759
0
    }
12760
0
    tp = state->With_type;
12761
0
    isinstance = PyObject_IsInstance(obj, tp);
12762
0
    if (isinstance == -1) {
12763
0
        return -1;
12764
0
    }
12765
0
    if (isinstance) {
12766
0
        asdl_withitem_seq* items;
12767
0
        asdl_stmt_seq* body;
12768
0
        string type_comment;
12769
12770
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12771
0
            return -1;
12772
0
        }
12773
0
        if (tmp == NULL) {
12774
0
            tmp = PyList_New(0);
12775
0
            if (tmp == NULL) {
12776
0
                return -1;
12777
0
            }
12778
0
        }
12779
0
        {
12780
0
            int res;
12781
0
            Py_ssize_t len;
12782
0
            Py_ssize_t i;
12783
0
            if (!PyList_Check(tmp)) {
12784
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12785
0
                goto failed;
12786
0
            }
12787
0
            len = PyList_GET_SIZE(tmp);
12788
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12789
0
            if (items == NULL) goto failed;
12790
0
            for (i = 0; i < len; i++) {
12791
0
                withitem_ty val;
12792
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12793
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12794
0
                    goto failed;
12795
0
                }
12796
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12797
0
                _Py_LeaveRecursiveCall();
12798
0
                Py_DECREF(tmp2);
12799
0
                if (res != 0) goto failed;
12800
0
                if (len != PyList_GET_SIZE(tmp)) {
12801
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12802
0
                    goto failed;
12803
0
                }
12804
0
                asdl_seq_SET(items, i, val);
12805
0
            }
12806
0
            Py_CLEAR(tmp);
12807
0
        }
12808
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12809
0
            return -1;
12810
0
        }
12811
0
        if (tmp == NULL) {
12812
0
            tmp = PyList_New(0);
12813
0
            if (tmp == NULL) {
12814
0
                return -1;
12815
0
            }
12816
0
        }
12817
0
        {
12818
0
            int res;
12819
0
            Py_ssize_t len;
12820
0
            Py_ssize_t i;
12821
0
            if (!PyList_Check(tmp)) {
12822
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12823
0
                goto failed;
12824
0
            }
12825
0
            len = PyList_GET_SIZE(tmp);
12826
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12827
0
            if (body == NULL) goto failed;
12828
0
            for (i = 0; i < len; i++) {
12829
0
                stmt_ty val;
12830
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12831
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12832
0
                    goto failed;
12833
0
                }
12834
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12835
0
                _Py_LeaveRecursiveCall();
12836
0
                Py_DECREF(tmp2);
12837
0
                if (res != 0) goto failed;
12838
0
                if (len != PyList_GET_SIZE(tmp)) {
12839
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12840
0
                    goto failed;
12841
0
                }
12842
0
                asdl_seq_SET(body, i, val);
12843
0
            }
12844
0
            Py_CLEAR(tmp);
12845
0
        }
12846
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12847
0
            return -1;
12848
0
        }
12849
0
        if (tmp == NULL || tmp == Py_None) {
12850
0
            Py_CLEAR(tmp);
12851
0
            type_comment = NULL;
12852
0
        }
12853
0
        else {
12854
0
            int res;
12855
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12856
0
                goto failed;
12857
0
            }
12858
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12859
0
            _Py_LeaveRecursiveCall();
12860
0
            if (res != 0) goto failed;
12861
0
            Py_CLEAR(tmp);
12862
0
        }
12863
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12864
0
                           end_lineno, end_col_offset, arena);
12865
0
        if (*out == NULL) goto failed;
12866
0
        return 0;
12867
0
    }
12868
0
    tp = state->AsyncWith_type;
12869
0
    isinstance = PyObject_IsInstance(obj, tp);
12870
0
    if (isinstance == -1) {
12871
0
        return -1;
12872
0
    }
12873
0
    if (isinstance) {
12874
0
        asdl_withitem_seq* items;
12875
0
        asdl_stmt_seq* body;
12876
0
        string type_comment;
12877
12878
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12879
0
            return -1;
12880
0
        }
12881
0
        if (tmp == NULL) {
12882
0
            tmp = PyList_New(0);
12883
0
            if (tmp == NULL) {
12884
0
                return -1;
12885
0
            }
12886
0
        }
12887
0
        {
12888
0
            int res;
12889
0
            Py_ssize_t len;
12890
0
            Py_ssize_t i;
12891
0
            if (!PyList_Check(tmp)) {
12892
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12893
0
                goto failed;
12894
0
            }
12895
0
            len = PyList_GET_SIZE(tmp);
12896
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12897
0
            if (items == NULL) goto failed;
12898
0
            for (i = 0; i < len; i++) {
12899
0
                withitem_ty val;
12900
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12901
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12902
0
                    goto failed;
12903
0
                }
12904
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12905
0
                _Py_LeaveRecursiveCall();
12906
0
                Py_DECREF(tmp2);
12907
0
                if (res != 0) goto failed;
12908
0
                if (len != PyList_GET_SIZE(tmp)) {
12909
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12910
0
                    goto failed;
12911
0
                }
12912
0
                asdl_seq_SET(items, i, val);
12913
0
            }
12914
0
            Py_CLEAR(tmp);
12915
0
        }
12916
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12917
0
            return -1;
12918
0
        }
12919
0
        if (tmp == NULL) {
12920
0
            tmp = PyList_New(0);
12921
0
            if (tmp == NULL) {
12922
0
                return -1;
12923
0
            }
12924
0
        }
12925
0
        {
12926
0
            int res;
12927
0
            Py_ssize_t len;
12928
0
            Py_ssize_t i;
12929
0
            if (!PyList_Check(tmp)) {
12930
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12931
0
                goto failed;
12932
0
            }
12933
0
            len = PyList_GET_SIZE(tmp);
12934
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12935
0
            if (body == NULL) goto failed;
12936
0
            for (i = 0; i < len; i++) {
12937
0
                stmt_ty val;
12938
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12939
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12940
0
                    goto failed;
12941
0
                }
12942
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12943
0
                _Py_LeaveRecursiveCall();
12944
0
                Py_DECREF(tmp2);
12945
0
                if (res != 0) goto failed;
12946
0
                if (len != PyList_GET_SIZE(tmp)) {
12947
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12948
0
                    goto failed;
12949
0
                }
12950
0
                asdl_seq_SET(body, i, val);
12951
0
            }
12952
0
            Py_CLEAR(tmp);
12953
0
        }
12954
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12955
0
            return -1;
12956
0
        }
12957
0
        if (tmp == NULL || tmp == Py_None) {
12958
0
            Py_CLEAR(tmp);
12959
0
            type_comment = NULL;
12960
0
        }
12961
0
        else {
12962
0
            int res;
12963
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12964
0
                goto failed;
12965
0
            }
12966
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12967
0
            _Py_LeaveRecursiveCall();
12968
0
            if (res != 0) goto failed;
12969
0
            Py_CLEAR(tmp);
12970
0
        }
12971
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12972
0
                                end_lineno, end_col_offset, arena);
12973
0
        if (*out == NULL) goto failed;
12974
0
        return 0;
12975
0
    }
12976
0
    tp = state->Match_type;
12977
0
    isinstance = PyObject_IsInstance(obj, tp);
12978
0
    if (isinstance == -1) {
12979
0
        return -1;
12980
0
    }
12981
0
    if (isinstance) {
12982
0
        expr_ty subject;
12983
0
        asdl_match_case_seq* cases;
12984
12985
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
12986
0
            return -1;
12987
0
        }
12988
0
        if (tmp == NULL) {
12989
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
12990
0
            return -1;
12991
0
        }
12992
0
        else {
12993
0
            int res;
12994
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
12995
0
                goto failed;
12996
0
            }
12997
0
            res = obj2ast_expr(state, tmp, &subject, arena);
12998
0
            _Py_LeaveRecursiveCall();
12999
0
            if (res != 0) goto failed;
13000
0
            Py_CLEAR(tmp);
13001
0
        }
13002
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
13003
0
            return -1;
13004
0
        }
13005
0
        if (tmp == NULL) {
13006
0
            tmp = PyList_New(0);
13007
0
            if (tmp == NULL) {
13008
0
                return -1;
13009
0
            }
13010
0
        }
13011
0
        {
13012
0
            int res;
13013
0
            Py_ssize_t len;
13014
0
            Py_ssize_t i;
13015
0
            if (!PyList_Check(tmp)) {
13016
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13017
0
                goto failed;
13018
0
            }
13019
0
            len = PyList_GET_SIZE(tmp);
13020
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13021
0
            if (cases == NULL) goto failed;
13022
0
            for (i = 0; i < len; i++) {
13023
0
                match_case_ty val;
13024
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13025
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13026
0
                    goto failed;
13027
0
                }
13028
0
                res = obj2ast_match_case(state, tmp2, &val, arena);
13029
0
                _Py_LeaveRecursiveCall();
13030
0
                Py_DECREF(tmp2);
13031
0
                if (res != 0) goto failed;
13032
0
                if (len != PyList_GET_SIZE(tmp)) {
13033
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13034
0
                    goto failed;
13035
0
                }
13036
0
                asdl_seq_SET(cases, i, val);
13037
0
            }
13038
0
            Py_CLEAR(tmp);
13039
0
        }
13040
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13041
0
                            end_col_offset, arena);
13042
0
        if (*out == NULL) goto failed;
13043
0
        return 0;
13044
0
    }
13045
0
    tp = state->Raise_type;
13046
0
    isinstance = PyObject_IsInstance(obj, tp);
13047
0
    if (isinstance == -1) {
13048
0
        return -1;
13049
0
    }
13050
0
    if (isinstance) {
13051
0
        expr_ty exc;
13052
0
        expr_ty cause;
13053
13054
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13055
0
            return -1;
13056
0
        }
13057
0
        if (tmp == NULL || tmp == Py_None) {
13058
0
            Py_CLEAR(tmp);
13059
0
            exc = NULL;
13060
0
        }
13061
0
        else {
13062
0
            int res;
13063
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13064
0
                goto failed;
13065
0
            }
13066
0
            res = obj2ast_expr(state, tmp, &exc, arena);
13067
0
            _Py_LeaveRecursiveCall();
13068
0
            if (res != 0) goto failed;
13069
0
            Py_CLEAR(tmp);
13070
0
        }
13071
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13072
0
            return -1;
13073
0
        }
13074
0
        if (tmp == NULL || tmp == Py_None) {
13075
0
            Py_CLEAR(tmp);
13076
0
            cause = NULL;
13077
0
        }
13078
0
        else {
13079
0
            int res;
13080
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13081
0
                goto failed;
13082
0
            }
13083
0
            res = obj2ast_expr(state, tmp, &cause, arena);
13084
0
            _Py_LeaveRecursiveCall();
13085
0
            if (res != 0) goto failed;
13086
0
            Py_CLEAR(tmp);
13087
0
        }
13088
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13089
0
                            end_col_offset, arena);
13090
0
        if (*out == NULL) goto failed;
13091
0
        return 0;
13092
0
    }
13093
0
    tp = state->Try_type;
13094
0
    isinstance = PyObject_IsInstance(obj, tp);
13095
0
    if (isinstance == -1) {
13096
0
        return -1;
13097
0
    }
13098
0
    if (isinstance) {
13099
0
        asdl_stmt_seq* body;
13100
0
        asdl_excepthandler_seq* handlers;
13101
0
        asdl_stmt_seq* orelse;
13102
0
        asdl_stmt_seq* finalbody;
13103
13104
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13105
0
            return -1;
13106
0
        }
13107
0
        if (tmp == NULL) {
13108
0
            tmp = PyList_New(0);
13109
0
            if (tmp == NULL) {
13110
0
                return -1;
13111
0
            }
13112
0
        }
13113
0
        {
13114
0
            int res;
13115
0
            Py_ssize_t len;
13116
0
            Py_ssize_t i;
13117
0
            if (!PyList_Check(tmp)) {
13118
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13119
0
                goto failed;
13120
0
            }
13121
0
            len = PyList_GET_SIZE(tmp);
13122
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13123
0
            if (body == NULL) goto failed;
13124
0
            for (i = 0; i < len; i++) {
13125
0
                stmt_ty val;
13126
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13127
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13128
0
                    goto failed;
13129
0
                }
13130
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13131
0
                _Py_LeaveRecursiveCall();
13132
0
                Py_DECREF(tmp2);
13133
0
                if (res != 0) goto failed;
13134
0
                if (len != PyList_GET_SIZE(tmp)) {
13135
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13136
0
                    goto failed;
13137
0
                }
13138
0
                asdl_seq_SET(body, i, val);
13139
0
            }
13140
0
            Py_CLEAR(tmp);
13141
0
        }
13142
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13143
0
            return -1;
13144
0
        }
13145
0
        if (tmp == NULL) {
13146
0
            tmp = PyList_New(0);
13147
0
            if (tmp == NULL) {
13148
0
                return -1;
13149
0
            }
13150
0
        }
13151
0
        {
13152
0
            int res;
13153
0
            Py_ssize_t len;
13154
0
            Py_ssize_t i;
13155
0
            if (!PyList_Check(tmp)) {
13156
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13157
0
                goto failed;
13158
0
            }
13159
0
            len = PyList_GET_SIZE(tmp);
13160
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13161
0
            if (handlers == NULL) goto failed;
13162
0
            for (i = 0; i < len; i++) {
13163
0
                excepthandler_ty val;
13164
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13165
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13166
0
                    goto failed;
13167
0
                }
13168
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13169
0
                _Py_LeaveRecursiveCall();
13170
0
                Py_DECREF(tmp2);
13171
0
                if (res != 0) goto failed;
13172
0
                if (len != PyList_GET_SIZE(tmp)) {
13173
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13174
0
                    goto failed;
13175
0
                }
13176
0
                asdl_seq_SET(handlers, i, val);
13177
0
            }
13178
0
            Py_CLEAR(tmp);
13179
0
        }
13180
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13181
0
            return -1;
13182
0
        }
13183
0
        if (tmp == NULL) {
13184
0
            tmp = PyList_New(0);
13185
0
            if (tmp == NULL) {
13186
0
                return -1;
13187
0
            }
13188
0
        }
13189
0
        {
13190
0
            int res;
13191
0
            Py_ssize_t len;
13192
0
            Py_ssize_t i;
13193
0
            if (!PyList_Check(tmp)) {
13194
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13195
0
                goto failed;
13196
0
            }
13197
0
            len = PyList_GET_SIZE(tmp);
13198
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13199
0
            if (orelse == NULL) goto failed;
13200
0
            for (i = 0; i < len; i++) {
13201
0
                stmt_ty val;
13202
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13203
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13204
0
                    goto failed;
13205
0
                }
13206
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13207
0
                _Py_LeaveRecursiveCall();
13208
0
                Py_DECREF(tmp2);
13209
0
                if (res != 0) goto failed;
13210
0
                if (len != PyList_GET_SIZE(tmp)) {
13211
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13212
0
                    goto failed;
13213
0
                }
13214
0
                asdl_seq_SET(orelse, i, val);
13215
0
            }
13216
0
            Py_CLEAR(tmp);
13217
0
        }
13218
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13219
0
            return -1;
13220
0
        }
13221
0
        if (tmp == NULL) {
13222
0
            tmp = PyList_New(0);
13223
0
            if (tmp == NULL) {
13224
0
                return -1;
13225
0
            }
13226
0
        }
13227
0
        {
13228
0
            int res;
13229
0
            Py_ssize_t len;
13230
0
            Py_ssize_t i;
13231
0
            if (!PyList_Check(tmp)) {
13232
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13233
0
                goto failed;
13234
0
            }
13235
0
            len = PyList_GET_SIZE(tmp);
13236
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13237
0
            if (finalbody == NULL) goto failed;
13238
0
            for (i = 0; i < len; i++) {
13239
0
                stmt_ty val;
13240
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13241
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13242
0
                    goto failed;
13243
0
                }
13244
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13245
0
                _Py_LeaveRecursiveCall();
13246
0
                Py_DECREF(tmp2);
13247
0
                if (res != 0) goto failed;
13248
0
                if (len != PyList_GET_SIZE(tmp)) {
13249
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13250
0
                    goto failed;
13251
0
                }
13252
0
                asdl_seq_SET(finalbody, i, val);
13253
0
            }
13254
0
            Py_CLEAR(tmp);
13255
0
        }
13256
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13257
0
                          col_offset, end_lineno, end_col_offset, arena);
13258
0
        if (*out == NULL) goto failed;
13259
0
        return 0;
13260
0
    }
13261
0
    tp = state->TryStar_type;
13262
0
    isinstance = PyObject_IsInstance(obj, tp);
13263
0
    if (isinstance == -1) {
13264
0
        return -1;
13265
0
    }
13266
0
    if (isinstance) {
13267
0
        asdl_stmt_seq* body;
13268
0
        asdl_excepthandler_seq* handlers;
13269
0
        asdl_stmt_seq* orelse;
13270
0
        asdl_stmt_seq* finalbody;
13271
13272
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13273
0
            return -1;
13274
0
        }
13275
0
        if (tmp == NULL) {
13276
0
            tmp = PyList_New(0);
13277
0
            if (tmp == NULL) {
13278
0
                return -1;
13279
0
            }
13280
0
        }
13281
0
        {
13282
0
            int res;
13283
0
            Py_ssize_t len;
13284
0
            Py_ssize_t i;
13285
0
            if (!PyList_Check(tmp)) {
13286
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13287
0
                goto failed;
13288
0
            }
13289
0
            len = PyList_GET_SIZE(tmp);
13290
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13291
0
            if (body == NULL) goto failed;
13292
0
            for (i = 0; i < len; i++) {
13293
0
                stmt_ty val;
13294
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13295
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13296
0
                    goto failed;
13297
0
                }
13298
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13299
0
                _Py_LeaveRecursiveCall();
13300
0
                Py_DECREF(tmp2);
13301
0
                if (res != 0) goto failed;
13302
0
                if (len != PyList_GET_SIZE(tmp)) {
13303
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13304
0
                    goto failed;
13305
0
                }
13306
0
                asdl_seq_SET(body, i, val);
13307
0
            }
13308
0
            Py_CLEAR(tmp);
13309
0
        }
13310
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13311
0
            return -1;
13312
0
        }
13313
0
        if (tmp == NULL) {
13314
0
            tmp = PyList_New(0);
13315
0
            if (tmp == NULL) {
13316
0
                return -1;
13317
0
            }
13318
0
        }
13319
0
        {
13320
0
            int res;
13321
0
            Py_ssize_t len;
13322
0
            Py_ssize_t i;
13323
0
            if (!PyList_Check(tmp)) {
13324
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13325
0
                goto failed;
13326
0
            }
13327
0
            len = PyList_GET_SIZE(tmp);
13328
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13329
0
            if (handlers == NULL) goto failed;
13330
0
            for (i = 0; i < len; i++) {
13331
0
                excepthandler_ty val;
13332
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13333
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13334
0
                    goto failed;
13335
0
                }
13336
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13337
0
                _Py_LeaveRecursiveCall();
13338
0
                Py_DECREF(tmp2);
13339
0
                if (res != 0) goto failed;
13340
0
                if (len != PyList_GET_SIZE(tmp)) {
13341
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13342
0
                    goto failed;
13343
0
                }
13344
0
                asdl_seq_SET(handlers, i, val);
13345
0
            }
13346
0
            Py_CLEAR(tmp);
13347
0
        }
13348
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13349
0
            return -1;
13350
0
        }
13351
0
        if (tmp == NULL) {
13352
0
            tmp = PyList_New(0);
13353
0
            if (tmp == NULL) {
13354
0
                return -1;
13355
0
            }
13356
0
        }
13357
0
        {
13358
0
            int res;
13359
0
            Py_ssize_t len;
13360
0
            Py_ssize_t i;
13361
0
            if (!PyList_Check(tmp)) {
13362
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13363
0
                goto failed;
13364
0
            }
13365
0
            len = PyList_GET_SIZE(tmp);
13366
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13367
0
            if (orelse == NULL) goto failed;
13368
0
            for (i = 0; i < len; i++) {
13369
0
                stmt_ty val;
13370
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13371
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13372
0
                    goto failed;
13373
0
                }
13374
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13375
0
                _Py_LeaveRecursiveCall();
13376
0
                Py_DECREF(tmp2);
13377
0
                if (res != 0) goto failed;
13378
0
                if (len != PyList_GET_SIZE(tmp)) {
13379
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13380
0
                    goto failed;
13381
0
                }
13382
0
                asdl_seq_SET(orelse, i, val);
13383
0
            }
13384
0
            Py_CLEAR(tmp);
13385
0
        }
13386
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13387
0
            return -1;
13388
0
        }
13389
0
        if (tmp == NULL) {
13390
0
            tmp = PyList_New(0);
13391
0
            if (tmp == NULL) {
13392
0
                return -1;
13393
0
            }
13394
0
        }
13395
0
        {
13396
0
            int res;
13397
0
            Py_ssize_t len;
13398
0
            Py_ssize_t i;
13399
0
            if (!PyList_Check(tmp)) {
13400
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13401
0
                goto failed;
13402
0
            }
13403
0
            len = PyList_GET_SIZE(tmp);
13404
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13405
0
            if (finalbody == NULL) goto failed;
13406
0
            for (i = 0; i < len; i++) {
13407
0
                stmt_ty val;
13408
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13409
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13410
0
                    goto failed;
13411
0
                }
13412
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13413
0
                _Py_LeaveRecursiveCall();
13414
0
                Py_DECREF(tmp2);
13415
0
                if (res != 0) goto failed;
13416
0
                if (len != PyList_GET_SIZE(tmp)) {
13417
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13418
0
                    goto failed;
13419
0
                }
13420
0
                asdl_seq_SET(finalbody, i, val);
13421
0
            }
13422
0
            Py_CLEAR(tmp);
13423
0
        }
13424
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13425
0
                              col_offset, end_lineno, end_col_offset, arena);
13426
0
        if (*out == NULL) goto failed;
13427
0
        return 0;
13428
0
    }
13429
0
    tp = state->Assert_type;
13430
0
    isinstance = PyObject_IsInstance(obj, tp);
13431
0
    if (isinstance == -1) {
13432
0
        return -1;
13433
0
    }
13434
0
    if (isinstance) {
13435
0
        expr_ty test;
13436
0
        expr_ty msg;
13437
13438
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13439
0
            return -1;
13440
0
        }
13441
0
        if (tmp == NULL) {
13442
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13443
0
            return -1;
13444
0
        }
13445
0
        else {
13446
0
            int res;
13447
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13448
0
                goto failed;
13449
0
            }
13450
0
            res = obj2ast_expr(state, tmp, &test, arena);
13451
0
            _Py_LeaveRecursiveCall();
13452
0
            if (res != 0) goto failed;
13453
0
            Py_CLEAR(tmp);
13454
0
        }
13455
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13456
0
            return -1;
13457
0
        }
13458
0
        if (tmp == NULL || tmp == Py_None) {
13459
0
            Py_CLEAR(tmp);
13460
0
            msg = NULL;
13461
0
        }
13462
0
        else {
13463
0
            int res;
13464
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13465
0
                goto failed;
13466
0
            }
13467
0
            res = obj2ast_expr(state, tmp, &msg, arena);
13468
0
            _Py_LeaveRecursiveCall();
13469
0
            if (res != 0) goto failed;
13470
0
            Py_CLEAR(tmp);
13471
0
        }
13472
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13473
0
                             end_col_offset, arena);
13474
0
        if (*out == NULL) goto failed;
13475
0
        return 0;
13476
0
    }
13477
0
    tp = state->Import_type;
13478
0
    isinstance = PyObject_IsInstance(obj, tp);
13479
0
    if (isinstance == -1) {
13480
0
        return -1;
13481
0
    }
13482
0
    if (isinstance) {
13483
0
        asdl_alias_seq* names;
13484
13485
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13486
0
            return -1;
13487
0
        }
13488
0
        if (tmp == NULL) {
13489
0
            tmp = PyList_New(0);
13490
0
            if (tmp == NULL) {
13491
0
                return -1;
13492
0
            }
13493
0
        }
13494
0
        {
13495
0
            int res;
13496
0
            Py_ssize_t len;
13497
0
            Py_ssize_t i;
13498
0
            if (!PyList_Check(tmp)) {
13499
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13500
0
                goto failed;
13501
0
            }
13502
0
            len = PyList_GET_SIZE(tmp);
13503
0
            names = _Py_asdl_alias_seq_new(len, arena);
13504
0
            if (names == NULL) goto failed;
13505
0
            for (i = 0; i < len; i++) {
13506
0
                alias_ty val;
13507
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13508
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13509
0
                    goto failed;
13510
0
                }
13511
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13512
0
                _Py_LeaveRecursiveCall();
13513
0
                Py_DECREF(tmp2);
13514
0
                if (res != 0) goto failed;
13515
0
                if (len != PyList_GET_SIZE(tmp)) {
13516
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13517
0
                    goto failed;
13518
0
                }
13519
0
                asdl_seq_SET(names, i, val);
13520
0
            }
13521
0
            Py_CLEAR(tmp);
13522
0
        }
13523
0
        *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
13524
0
                             end_col_offset, arena);
13525
0
        if (*out == NULL) goto failed;
13526
0
        return 0;
13527
0
    }
13528
0
    tp = state->ImportFrom_type;
13529
0
    isinstance = PyObject_IsInstance(obj, tp);
13530
0
    if (isinstance == -1) {
13531
0
        return -1;
13532
0
    }
13533
0
    if (isinstance) {
13534
0
        identifier module;
13535
0
        asdl_alias_seq* names;
13536
0
        int level;
13537
13538
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13539
0
            return -1;
13540
0
        }
13541
0
        if (tmp == NULL || tmp == Py_None) {
13542
0
            Py_CLEAR(tmp);
13543
0
            module = NULL;
13544
0
        }
13545
0
        else {
13546
0
            int res;
13547
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13548
0
                goto failed;
13549
0
            }
13550
0
            res = obj2ast_identifier(state, tmp, &module, arena);
13551
0
            _Py_LeaveRecursiveCall();
13552
0
            if (res != 0) goto failed;
13553
0
            Py_CLEAR(tmp);
13554
0
        }
13555
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13556
0
            return -1;
13557
0
        }
13558
0
        if (tmp == NULL) {
13559
0
            tmp = PyList_New(0);
13560
0
            if (tmp == NULL) {
13561
0
                return -1;
13562
0
            }
13563
0
        }
13564
0
        {
13565
0
            int res;
13566
0
            Py_ssize_t len;
13567
0
            Py_ssize_t i;
13568
0
            if (!PyList_Check(tmp)) {
13569
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13570
0
                goto failed;
13571
0
            }
13572
0
            len = PyList_GET_SIZE(tmp);
13573
0
            names = _Py_asdl_alias_seq_new(len, arena);
13574
0
            if (names == NULL) goto failed;
13575
0
            for (i = 0; i < len; i++) {
13576
0
                alias_ty val;
13577
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13578
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13579
0
                    goto failed;
13580
0
                }
13581
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13582
0
                _Py_LeaveRecursiveCall();
13583
0
                Py_DECREF(tmp2);
13584
0
                if (res != 0) goto failed;
13585
0
                if (len != PyList_GET_SIZE(tmp)) {
13586
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13587
0
                    goto failed;
13588
0
                }
13589
0
                asdl_seq_SET(names, i, val);
13590
0
            }
13591
0
            Py_CLEAR(tmp);
13592
0
        }
13593
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13594
0
            return -1;
13595
0
        }
13596
0
        if (tmp == NULL || tmp == Py_None) {
13597
0
            Py_CLEAR(tmp);
13598
0
            level = 0;
13599
0
        }
13600
0
        else {
13601
0
            int res;
13602
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13603
0
                goto failed;
13604
0
            }
13605
0
            res = obj2ast_int(state, tmp, &level, arena);
13606
0
            _Py_LeaveRecursiveCall();
13607
0
            if (res != 0) goto failed;
13608
0
            Py_CLEAR(tmp);
13609
0
        }
13610
0
        *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
13611
0
                                 end_lineno, end_col_offset, arena);
13612
0
        if (*out == NULL) goto failed;
13613
0
        return 0;
13614
0
    }
13615
0
    tp = state->Global_type;
13616
0
    isinstance = PyObject_IsInstance(obj, tp);
13617
0
    if (isinstance == -1) {
13618
0
        return -1;
13619
0
    }
13620
0
    if (isinstance) {
13621
0
        asdl_identifier_seq* names;
13622
13623
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13624
0
            return -1;
13625
0
        }
13626
0
        if (tmp == NULL) {
13627
0
            tmp = PyList_New(0);
13628
0
            if (tmp == NULL) {
13629
0
                return -1;
13630
0
            }
13631
0
        }
13632
0
        {
13633
0
            int res;
13634
0
            Py_ssize_t len;
13635
0
            Py_ssize_t i;
13636
0
            if (!PyList_Check(tmp)) {
13637
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13638
0
                goto failed;
13639
0
            }
13640
0
            len = PyList_GET_SIZE(tmp);
13641
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13642
0
            if (names == NULL) goto failed;
13643
0
            for (i = 0; i < len; i++) {
13644
0
                identifier val;
13645
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13646
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13647
0
                    goto failed;
13648
0
                }
13649
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13650
0
                _Py_LeaveRecursiveCall();
13651
0
                Py_DECREF(tmp2);
13652
0
                if (res != 0) goto failed;
13653
0
                if (len != PyList_GET_SIZE(tmp)) {
13654
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13655
0
                    goto failed;
13656
0
                }
13657
0
                asdl_seq_SET(names, i, val);
13658
0
            }
13659
0
            Py_CLEAR(tmp);
13660
0
        }
13661
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13662
0
                             end_col_offset, arena);
13663
0
        if (*out == NULL) goto failed;
13664
0
        return 0;
13665
0
    }
13666
0
    tp = state->Nonlocal_type;
13667
0
    isinstance = PyObject_IsInstance(obj, tp);
13668
0
    if (isinstance == -1) {
13669
0
        return -1;
13670
0
    }
13671
0
    if (isinstance) {
13672
0
        asdl_identifier_seq* names;
13673
13674
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13675
0
            return -1;
13676
0
        }
13677
0
        if (tmp == NULL) {
13678
0
            tmp = PyList_New(0);
13679
0
            if (tmp == NULL) {
13680
0
                return -1;
13681
0
            }
13682
0
        }
13683
0
        {
13684
0
            int res;
13685
0
            Py_ssize_t len;
13686
0
            Py_ssize_t i;
13687
0
            if (!PyList_Check(tmp)) {
13688
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13689
0
                goto failed;
13690
0
            }
13691
0
            len = PyList_GET_SIZE(tmp);
13692
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13693
0
            if (names == NULL) goto failed;
13694
0
            for (i = 0; i < len; i++) {
13695
0
                identifier val;
13696
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13697
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13698
0
                    goto failed;
13699
0
                }
13700
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13701
0
                _Py_LeaveRecursiveCall();
13702
0
                Py_DECREF(tmp2);
13703
0
                if (res != 0) goto failed;
13704
0
                if (len != PyList_GET_SIZE(tmp)) {
13705
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13706
0
                    goto failed;
13707
0
                }
13708
0
                asdl_seq_SET(names, i, val);
13709
0
            }
13710
0
            Py_CLEAR(tmp);
13711
0
        }
13712
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13713
0
                               end_col_offset, arena);
13714
0
        if (*out == NULL) goto failed;
13715
0
        return 0;
13716
0
    }
13717
0
    tp = state->Expr_type;
13718
0
    isinstance = PyObject_IsInstance(obj, tp);
13719
0
    if (isinstance == -1) {
13720
0
        return -1;
13721
0
    }
13722
0
    if (isinstance) {
13723
0
        expr_ty value;
13724
13725
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13726
0
            return -1;
13727
0
        }
13728
0
        if (tmp == NULL) {
13729
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13730
0
            return -1;
13731
0
        }
13732
0
        else {
13733
0
            int res;
13734
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13735
0
                goto failed;
13736
0
            }
13737
0
            res = obj2ast_expr(state, tmp, &value, arena);
13738
0
            _Py_LeaveRecursiveCall();
13739
0
            if (res != 0) goto failed;
13740
0
            Py_CLEAR(tmp);
13741
0
        }
13742
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13743
0
                           end_col_offset, arena);
13744
0
        if (*out == NULL) goto failed;
13745
0
        return 0;
13746
0
    }
13747
0
    tp = state->Pass_type;
13748
0
    isinstance = PyObject_IsInstance(obj, tp);
13749
0
    if (isinstance == -1) {
13750
0
        return -1;
13751
0
    }
13752
0
    if (isinstance) {
13753
13754
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13755
0
                           arena);
13756
0
        if (*out == NULL) goto failed;
13757
0
        return 0;
13758
0
    }
13759
0
    tp = state->Break_type;
13760
0
    isinstance = PyObject_IsInstance(obj, tp);
13761
0
    if (isinstance == -1) {
13762
0
        return -1;
13763
0
    }
13764
0
    if (isinstance) {
13765
13766
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13767
0
                            arena);
13768
0
        if (*out == NULL) goto failed;
13769
0
        return 0;
13770
0
    }
13771
0
    tp = state->Continue_type;
13772
0
    isinstance = PyObject_IsInstance(obj, tp);
13773
0
    if (isinstance == -1) {
13774
0
        return -1;
13775
0
    }
13776
0
    if (isinstance) {
13777
13778
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13779
0
                               arena);
13780
0
        if (*out == NULL) goto failed;
13781
0
        return 0;
13782
0
    }
13783
13784
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13785
0
    failed:
13786
0
    Py_XDECREF(tmp);
13787
0
    return -1;
13788
0
}
13789
13790
int
13791
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
13792
             arena)
13793
0
{
13794
0
    int isinstance;
13795
13796
0
    PyObject *tmp = NULL;
13797
0
    PyObject *tp;
13798
0
    int lineno;
13799
0
    int col_offset;
13800
0
    int end_lineno;
13801
0
    int end_col_offset;
13802
13803
0
    if (obj == Py_None) {
13804
0
        *out = NULL;
13805
0
        return 0;
13806
0
    }
13807
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13808
0
        return -1;
13809
0
    }
13810
0
    if (tmp == NULL) {
13811
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13812
0
        return -1;
13813
0
    }
13814
0
    else {
13815
0
        int res;
13816
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13817
0
            goto failed;
13818
0
        }
13819
0
        res = obj2ast_int(state, tmp, &lineno, arena);
13820
0
        _Py_LeaveRecursiveCall();
13821
0
        if (res != 0) goto failed;
13822
0
        Py_CLEAR(tmp);
13823
0
    }
13824
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13825
0
        return -1;
13826
0
    }
13827
0
    if (tmp == NULL) {
13828
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13829
0
        return -1;
13830
0
    }
13831
0
    else {
13832
0
        int res;
13833
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13834
0
            goto failed;
13835
0
        }
13836
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
13837
0
        _Py_LeaveRecursiveCall();
13838
0
        if (res != 0) goto failed;
13839
0
        Py_CLEAR(tmp);
13840
0
    }
13841
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13842
0
        return -1;
13843
0
    }
13844
0
    if (tmp == NULL || tmp == Py_None) {
13845
0
        Py_CLEAR(tmp);
13846
0
        end_lineno = lineno;
13847
0
    }
13848
0
    else {
13849
0
        int res;
13850
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13851
0
            goto failed;
13852
0
        }
13853
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
13854
0
        _Py_LeaveRecursiveCall();
13855
0
        if (res != 0) goto failed;
13856
0
        Py_CLEAR(tmp);
13857
0
    }
13858
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13859
0
        return -1;
13860
0
    }
13861
0
    if (tmp == NULL || tmp == Py_None) {
13862
0
        Py_CLEAR(tmp);
13863
0
        end_col_offset = col_offset;
13864
0
    }
13865
0
    else {
13866
0
        int res;
13867
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13868
0
            goto failed;
13869
0
        }
13870
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
13871
0
        _Py_LeaveRecursiveCall();
13872
0
        if (res != 0) goto failed;
13873
0
        Py_CLEAR(tmp);
13874
0
    }
13875
0
    tp = state->BoolOp_type;
13876
0
    isinstance = PyObject_IsInstance(obj, tp);
13877
0
    if (isinstance == -1) {
13878
0
        return -1;
13879
0
    }
13880
0
    if (isinstance) {
13881
0
        boolop_ty op;
13882
0
        asdl_expr_seq* values;
13883
13884
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13885
0
            return -1;
13886
0
        }
13887
0
        if (tmp == NULL) {
13888
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13889
0
            return -1;
13890
0
        }
13891
0
        else {
13892
0
            int res;
13893
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13894
0
                goto failed;
13895
0
            }
13896
0
            res = obj2ast_boolop(state, tmp, &op, arena);
13897
0
            _Py_LeaveRecursiveCall();
13898
0
            if (res != 0) goto failed;
13899
0
            Py_CLEAR(tmp);
13900
0
        }
13901
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13902
0
            return -1;
13903
0
        }
13904
0
        if (tmp == NULL) {
13905
0
            tmp = PyList_New(0);
13906
0
            if (tmp == NULL) {
13907
0
                return -1;
13908
0
            }
13909
0
        }
13910
0
        {
13911
0
            int res;
13912
0
            Py_ssize_t len;
13913
0
            Py_ssize_t i;
13914
0
            if (!PyList_Check(tmp)) {
13915
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13916
0
                goto failed;
13917
0
            }
13918
0
            len = PyList_GET_SIZE(tmp);
13919
0
            values = _Py_asdl_expr_seq_new(len, arena);
13920
0
            if (values == NULL) goto failed;
13921
0
            for (i = 0; i < len; i++) {
13922
0
                expr_ty val;
13923
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13924
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13925
0
                    goto failed;
13926
0
                }
13927
0
                res = obj2ast_expr(state, tmp2, &val, arena);
13928
0
                _Py_LeaveRecursiveCall();
13929
0
                Py_DECREF(tmp2);
13930
0
                if (res != 0) goto failed;
13931
0
                if (len != PyList_GET_SIZE(tmp)) {
13932
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13933
0
                    goto failed;
13934
0
                }
13935
0
                asdl_seq_SET(values, i, val);
13936
0
            }
13937
0
            Py_CLEAR(tmp);
13938
0
        }
13939
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
13940
0
                             end_col_offset, arena);
13941
0
        if (*out == NULL) goto failed;
13942
0
        return 0;
13943
0
    }
13944
0
    tp = state->NamedExpr_type;
13945
0
    isinstance = PyObject_IsInstance(obj, tp);
13946
0
    if (isinstance == -1) {
13947
0
        return -1;
13948
0
    }
13949
0
    if (isinstance) {
13950
0
        expr_ty target;
13951
0
        expr_ty value;
13952
13953
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
13954
0
            return -1;
13955
0
        }
13956
0
        if (tmp == NULL) {
13957
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
13958
0
            return -1;
13959
0
        }
13960
0
        else {
13961
0
            int res;
13962
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13963
0
                goto failed;
13964
0
            }
13965
0
            res = obj2ast_expr(state, tmp, &target, arena);
13966
0
            _Py_LeaveRecursiveCall();
13967
0
            if (res != 0) goto failed;
13968
0
            Py_CLEAR(tmp);
13969
0
        }
13970
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13971
0
            return -1;
13972
0
        }
13973
0
        if (tmp == NULL) {
13974
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
13975
0
            return -1;
13976
0
        }
13977
0
        else {
13978
0
            int res;
13979
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13980
0
                goto failed;
13981
0
            }
13982
0
            res = obj2ast_expr(state, tmp, &value, arena);
13983
0
            _Py_LeaveRecursiveCall();
13984
0
            if (res != 0) goto failed;
13985
0
            Py_CLEAR(tmp);
13986
0
        }
13987
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
13988
0
                                end_col_offset, arena);
13989
0
        if (*out == NULL) goto failed;
13990
0
        return 0;
13991
0
    }
13992
0
    tp = state->BinOp_type;
13993
0
    isinstance = PyObject_IsInstance(obj, tp);
13994
0
    if (isinstance == -1) {
13995
0
        return -1;
13996
0
    }
13997
0
    if (isinstance) {
13998
0
        expr_ty left;
13999
0
        operator_ty op;
14000
0
        expr_ty right;
14001
14002
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14003
0
            return -1;
14004
0
        }
14005
0
        if (tmp == NULL) {
14006
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14007
0
            return -1;
14008
0
        }
14009
0
        else {
14010
0
            int res;
14011
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14012
0
                goto failed;
14013
0
            }
14014
0
            res = obj2ast_expr(state, tmp, &left, arena);
14015
0
            _Py_LeaveRecursiveCall();
14016
0
            if (res != 0) goto failed;
14017
0
            Py_CLEAR(tmp);
14018
0
        }
14019
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14020
0
            return -1;
14021
0
        }
14022
0
        if (tmp == NULL) {
14023
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14024
0
            return -1;
14025
0
        }
14026
0
        else {
14027
0
            int res;
14028
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14029
0
                goto failed;
14030
0
            }
14031
0
            res = obj2ast_operator(state, tmp, &op, arena);
14032
0
            _Py_LeaveRecursiveCall();
14033
0
            if (res != 0) goto failed;
14034
0
            Py_CLEAR(tmp);
14035
0
        }
14036
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14037
0
            return -1;
14038
0
        }
14039
0
        if (tmp == NULL) {
14040
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14041
0
            return -1;
14042
0
        }
14043
0
        else {
14044
0
            int res;
14045
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14046
0
                goto failed;
14047
0
            }
14048
0
            res = obj2ast_expr(state, tmp, &right, arena);
14049
0
            _Py_LeaveRecursiveCall();
14050
0
            if (res != 0) goto failed;
14051
0
            Py_CLEAR(tmp);
14052
0
        }
14053
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14054
0
                            end_col_offset, arena);
14055
0
        if (*out == NULL) goto failed;
14056
0
        return 0;
14057
0
    }
14058
0
    tp = state->UnaryOp_type;
14059
0
    isinstance = PyObject_IsInstance(obj, tp);
14060
0
    if (isinstance == -1) {
14061
0
        return -1;
14062
0
    }
14063
0
    if (isinstance) {
14064
0
        unaryop_ty op;
14065
0
        expr_ty operand;
14066
14067
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14068
0
            return -1;
14069
0
        }
14070
0
        if (tmp == NULL) {
14071
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14072
0
            return -1;
14073
0
        }
14074
0
        else {
14075
0
            int res;
14076
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14077
0
                goto failed;
14078
0
            }
14079
0
            res = obj2ast_unaryop(state, tmp, &op, arena);
14080
0
            _Py_LeaveRecursiveCall();
14081
0
            if (res != 0) goto failed;
14082
0
            Py_CLEAR(tmp);
14083
0
        }
14084
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
14085
0
            return -1;
14086
0
        }
14087
0
        if (tmp == NULL) {
14088
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14089
0
            return -1;
14090
0
        }
14091
0
        else {
14092
0
            int res;
14093
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14094
0
                goto failed;
14095
0
            }
14096
0
            res = obj2ast_expr(state, tmp, &operand, arena);
14097
0
            _Py_LeaveRecursiveCall();
14098
0
            if (res != 0) goto failed;
14099
0
            Py_CLEAR(tmp);
14100
0
        }
14101
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14102
0
                              end_col_offset, arena);
14103
0
        if (*out == NULL) goto failed;
14104
0
        return 0;
14105
0
    }
14106
0
    tp = state->Lambda_type;
14107
0
    isinstance = PyObject_IsInstance(obj, tp);
14108
0
    if (isinstance == -1) {
14109
0
        return -1;
14110
0
    }
14111
0
    if (isinstance) {
14112
0
        arguments_ty args;
14113
0
        expr_ty body;
14114
14115
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14116
0
            return -1;
14117
0
        }
14118
0
        if (tmp == NULL) {
14119
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14120
0
            return -1;
14121
0
        }
14122
0
        else {
14123
0
            int res;
14124
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14125
0
                goto failed;
14126
0
            }
14127
0
            res = obj2ast_arguments(state, tmp, &args, arena);
14128
0
            _Py_LeaveRecursiveCall();
14129
0
            if (res != 0) goto failed;
14130
0
            Py_CLEAR(tmp);
14131
0
        }
14132
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14133
0
            return -1;
14134
0
        }
14135
0
        if (tmp == NULL) {
14136
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14137
0
            return -1;
14138
0
        }
14139
0
        else {
14140
0
            int res;
14141
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14142
0
                goto failed;
14143
0
            }
14144
0
            res = obj2ast_expr(state, tmp, &body, arena);
14145
0
            _Py_LeaveRecursiveCall();
14146
0
            if (res != 0) goto failed;
14147
0
            Py_CLEAR(tmp);
14148
0
        }
14149
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14150
0
                             end_col_offset, arena);
14151
0
        if (*out == NULL) goto failed;
14152
0
        return 0;
14153
0
    }
14154
0
    tp = state->IfExp_type;
14155
0
    isinstance = PyObject_IsInstance(obj, tp);
14156
0
    if (isinstance == -1) {
14157
0
        return -1;
14158
0
    }
14159
0
    if (isinstance) {
14160
0
        expr_ty test;
14161
0
        expr_ty body;
14162
0
        expr_ty orelse;
14163
14164
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14165
0
            return -1;
14166
0
        }
14167
0
        if (tmp == NULL) {
14168
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14169
0
            return -1;
14170
0
        }
14171
0
        else {
14172
0
            int res;
14173
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14174
0
                goto failed;
14175
0
            }
14176
0
            res = obj2ast_expr(state, tmp, &test, arena);
14177
0
            _Py_LeaveRecursiveCall();
14178
0
            if (res != 0) goto failed;
14179
0
            Py_CLEAR(tmp);
14180
0
        }
14181
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14182
0
            return -1;
14183
0
        }
14184
0
        if (tmp == NULL) {
14185
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14186
0
            return -1;
14187
0
        }
14188
0
        else {
14189
0
            int res;
14190
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14191
0
                goto failed;
14192
0
            }
14193
0
            res = obj2ast_expr(state, tmp, &body, arena);
14194
0
            _Py_LeaveRecursiveCall();
14195
0
            if (res != 0) goto failed;
14196
0
            Py_CLEAR(tmp);
14197
0
        }
14198
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14199
0
            return -1;
14200
0
        }
14201
0
        if (tmp == NULL) {
14202
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14203
0
            return -1;
14204
0
        }
14205
0
        else {
14206
0
            int res;
14207
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14208
0
                goto failed;
14209
0
            }
14210
0
            res = obj2ast_expr(state, tmp, &orelse, arena);
14211
0
            _Py_LeaveRecursiveCall();
14212
0
            if (res != 0) goto failed;
14213
0
            Py_CLEAR(tmp);
14214
0
        }
14215
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14216
0
                            end_col_offset, arena);
14217
0
        if (*out == NULL) goto failed;
14218
0
        return 0;
14219
0
    }
14220
0
    tp = state->Dict_type;
14221
0
    isinstance = PyObject_IsInstance(obj, tp);
14222
0
    if (isinstance == -1) {
14223
0
        return -1;
14224
0
    }
14225
0
    if (isinstance) {
14226
0
        asdl_expr_seq* keys;
14227
0
        asdl_expr_seq* values;
14228
14229
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14230
0
            return -1;
14231
0
        }
14232
0
        if (tmp == NULL) {
14233
0
            tmp = PyList_New(0);
14234
0
            if (tmp == NULL) {
14235
0
                return -1;
14236
0
            }
14237
0
        }
14238
0
        {
14239
0
            int res;
14240
0
            Py_ssize_t len;
14241
0
            Py_ssize_t i;
14242
0
            if (!PyList_Check(tmp)) {
14243
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14244
0
                goto failed;
14245
0
            }
14246
0
            len = PyList_GET_SIZE(tmp);
14247
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14248
0
            if (keys == NULL) goto failed;
14249
0
            for (i = 0; i < len; i++) {
14250
0
                expr_ty val;
14251
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14252
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14253
0
                    goto failed;
14254
0
                }
14255
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14256
0
                _Py_LeaveRecursiveCall();
14257
0
                Py_DECREF(tmp2);
14258
0
                if (res != 0) goto failed;
14259
0
                if (len != PyList_GET_SIZE(tmp)) {
14260
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14261
0
                    goto failed;
14262
0
                }
14263
0
                asdl_seq_SET(keys, i, val);
14264
0
            }
14265
0
            Py_CLEAR(tmp);
14266
0
        }
14267
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14268
0
            return -1;
14269
0
        }
14270
0
        if (tmp == NULL) {
14271
0
            tmp = PyList_New(0);
14272
0
            if (tmp == NULL) {
14273
0
                return -1;
14274
0
            }
14275
0
        }
14276
0
        {
14277
0
            int res;
14278
0
            Py_ssize_t len;
14279
0
            Py_ssize_t i;
14280
0
            if (!PyList_Check(tmp)) {
14281
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14282
0
                goto failed;
14283
0
            }
14284
0
            len = PyList_GET_SIZE(tmp);
14285
0
            values = _Py_asdl_expr_seq_new(len, arena);
14286
0
            if (values == NULL) goto failed;
14287
0
            for (i = 0; i < len; i++) {
14288
0
                expr_ty val;
14289
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14290
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14291
0
                    goto failed;
14292
0
                }
14293
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14294
0
                _Py_LeaveRecursiveCall();
14295
0
                Py_DECREF(tmp2);
14296
0
                if (res != 0) goto failed;
14297
0
                if (len != PyList_GET_SIZE(tmp)) {
14298
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14299
0
                    goto failed;
14300
0
                }
14301
0
                asdl_seq_SET(values, i, val);
14302
0
            }
14303
0
            Py_CLEAR(tmp);
14304
0
        }
14305
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14306
0
                           end_col_offset, arena);
14307
0
        if (*out == NULL) goto failed;
14308
0
        return 0;
14309
0
    }
14310
0
    tp = state->Set_type;
14311
0
    isinstance = PyObject_IsInstance(obj, tp);
14312
0
    if (isinstance == -1) {
14313
0
        return -1;
14314
0
    }
14315
0
    if (isinstance) {
14316
0
        asdl_expr_seq* elts;
14317
14318
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14319
0
            return -1;
14320
0
        }
14321
0
        if (tmp == NULL) {
14322
0
            tmp = PyList_New(0);
14323
0
            if (tmp == NULL) {
14324
0
                return -1;
14325
0
            }
14326
0
        }
14327
0
        {
14328
0
            int res;
14329
0
            Py_ssize_t len;
14330
0
            Py_ssize_t i;
14331
0
            if (!PyList_Check(tmp)) {
14332
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14333
0
                goto failed;
14334
0
            }
14335
0
            len = PyList_GET_SIZE(tmp);
14336
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14337
0
            if (elts == NULL) goto failed;
14338
0
            for (i = 0; i < len; i++) {
14339
0
                expr_ty val;
14340
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14341
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14342
0
                    goto failed;
14343
0
                }
14344
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14345
0
                _Py_LeaveRecursiveCall();
14346
0
                Py_DECREF(tmp2);
14347
0
                if (res != 0) goto failed;
14348
0
                if (len != PyList_GET_SIZE(tmp)) {
14349
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14350
0
                    goto failed;
14351
0
                }
14352
0
                asdl_seq_SET(elts, i, val);
14353
0
            }
14354
0
            Py_CLEAR(tmp);
14355
0
        }
14356
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14357
0
                          arena);
14358
0
        if (*out == NULL) goto failed;
14359
0
        return 0;
14360
0
    }
14361
0
    tp = state->ListComp_type;
14362
0
    isinstance = PyObject_IsInstance(obj, tp);
14363
0
    if (isinstance == -1) {
14364
0
        return -1;
14365
0
    }
14366
0
    if (isinstance) {
14367
0
        expr_ty elt;
14368
0
        asdl_comprehension_seq* generators;
14369
14370
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14371
0
            return -1;
14372
0
        }
14373
0
        if (tmp == NULL) {
14374
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14375
0
            return -1;
14376
0
        }
14377
0
        else {
14378
0
            int res;
14379
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14380
0
                goto failed;
14381
0
            }
14382
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14383
0
            _Py_LeaveRecursiveCall();
14384
0
            if (res != 0) goto failed;
14385
0
            Py_CLEAR(tmp);
14386
0
        }
14387
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14388
0
            return -1;
14389
0
        }
14390
0
        if (tmp == NULL) {
14391
0
            tmp = PyList_New(0);
14392
0
            if (tmp == NULL) {
14393
0
                return -1;
14394
0
            }
14395
0
        }
14396
0
        {
14397
0
            int res;
14398
0
            Py_ssize_t len;
14399
0
            Py_ssize_t i;
14400
0
            if (!PyList_Check(tmp)) {
14401
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14402
0
                goto failed;
14403
0
            }
14404
0
            len = PyList_GET_SIZE(tmp);
14405
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14406
0
            if (generators == NULL) goto failed;
14407
0
            for (i = 0; i < len; i++) {
14408
0
                comprehension_ty val;
14409
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14410
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14411
0
                    goto failed;
14412
0
                }
14413
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14414
0
                _Py_LeaveRecursiveCall();
14415
0
                Py_DECREF(tmp2);
14416
0
                if (res != 0) goto failed;
14417
0
                if (len != PyList_GET_SIZE(tmp)) {
14418
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14419
0
                    goto failed;
14420
0
                }
14421
0
                asdl_seq_SET(generators, i, val);
14422
0
            }
14423
0
            Py_CLEAR(tmp);
14424
0
        }
14425
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14426
0
                               end_col_offset, arena);
14427
0
        if (*out == NULL) goto failed;
14428
0
        return 0;
14429
0
    }
14430
0
    tp = state->SetComp_type;
14431
0
    isinstance = PyObject_IsInstance(obj, tp);
14432
0
    if (isinstance == -1) {
14433
0
        return -1;
14434
0
    }
14435
0
    if (isinstance) {
14436
0
        expr_ty elt;
14437
0
        asdl_comprehension_seq* generators;
14438
14439
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14440
0
            return -1;
14441
0
        }
14442
0
        if (tmp == NULL) {
14443
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14444
0
            return -1;
14445
0
        }
14446
0
        else {
14447
0
            int res;
14448
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14449
0
                goto failed;
14450
0
            }
14451
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14452
0
            _Py_LeaveRecursiveCall();
14453
0
            if (res != 0) goto failed;
14454
0
            Py_CLEAR(tmp);
14455
0
        }
14456
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14457
0
            return -1;
14458
0
        }
14459
0
        if (tmp == NULL) {
14460
0
            tmp = PyList_New(0);
14461
0
            if (tmp == NULL) {
14462
0
                return -1;
14463
0
            }
14464
0
        }
14465
0
        {
14466
0
            int res;
14467
0
            Py_ssize_t len;
14468
0
            Py_ssize_t i;
14469
0
            if (!PyList_Check(tmp)) {
14470
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14471
0
                goto failed;
14472
0
            }
14473
0
            len = PyList_GET_SIZE(tmp);
14474
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14475
0
            if (generators == NULL) goto failed;
14476
0
            for (i = 0; i < len; i++) {
14477
0
                comprehension_ty val;
14478
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14479
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14480
0
                    goto failed;
14481
0
                }
14482
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14483
0
                _Py_LeaveRecursiveCall();
14484
0
                Py_DECREF(tmp2);
14485
0
                if (res != 0) goto failed;
14486
0
                if (len != PyList_GET_SIZE(tmp)) {
14487
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14488
0
                    goto failed;
14489
0
                }
14490
0
                asdl_seq_SET(generators, i, val);
14491
0
            }
14492
0
            Py_CLEAR(tmp);
14493
0
        }
14494
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14495
0
                              end_col_offset, arena);
14496
0
        if (*out == NULL) goto failed;
14497
0
        return 0;
14498
0
    }
14499
0
    tp = state->DictComp_type;
14500
0
    isinstance = PyObject_IsInstance(obj, tp);
14501
0
    if (isinstance == -1) {
14502
0
        return -1;
14503
0
    }
14504
0
    if (isinstance) {
14505
0
        expr_ty key;
14506
0
        expr_ty value;
14507
0
        asdl_comprehension_seq* generators;
14508
14509
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14510
0
            return -1;
14511
0
        }
14512
0
        if (tmp == NULL) {
14513
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14514
0
            return -1;
14515
0
        }
14516
0
        else {
14517
0
            int res;
14518
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14519
0
                goto failed;
14520
0
            }
14521
0
            res = obj2ast_expr(state, tmp, &key, arena);
14522
0
            _Py_LeaveRecursiveCall();
14523
0
            if (res != 0) goto failed;
14524
0
            Py_CLEAR(tmp);
14525
0
        }
14526
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14527
0
            return -1;
14528
0
        }
14529
0
        if (tmp == NULL) {
14530
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
14531
0
            return -1;
14532
0
        }
14533
0
        else {
14534
0
            int res;
14535
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14536
0
                goto failed;
14537
0
            }
14538
0
            res = obj2ast_expr(state, tmp, &value, arena);
14539
0
            _Py_LeaveRecursiveCall();
14540
0
            if (res != 0) goto failed;
14541
0
            Py_CLEAR(tmp);
14542
0
        }
14543
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14544
0
            return -1;
14545
0
        }
14546
0
        if (tmp == NULL) {
14547
0
            tmp = PyList_New(0);
14548
0
            if (tmp == NULL) {
14549
0
                return -1;
14550
0
            }
14551
0
        }
14552
0
        {
14553
0
            int res;
14554
0
            Py_ssize_t len;
14555
0
            Py_ssize_t i;
14556
0
            if (!PyList_Check(tmp)) {
14557
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14558
0
                goto failed;
14559
0
            }
14560
0
            len = PyList_GET_SIZE(tmp);
14561
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14562
0
            if (generators == NULL) goto failed;
14563
0
            for (i = 0; i < len; i++) {
14564
0
                comprehension_ty val;
14565
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14566
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14567
0
                    goto failed;
14568
0
                }
14569
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14570
0
                _Py_LeaveRecursiveCall();
14571
0
                Py_DECREF(tmp2);
14572
0
                if (res != 0) goto failed;
14573
0
                if (len != PyList_GET_SIZE(tmp)) {
14574
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14575
0
                    goto failed;
14576
0
                }
14577
0
                asdl_seq_SET(generators, i, val);
14578
0
            }
14579
0
            Py_CLEAR(tmp);
14580
0
        }
14581
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14582
0
                               end_lineno, end_col_offset, arena);
14583
0
        if (*out == NULL) goto failed;
14584
0
        return 0;
14585
0
    }
14586
0
    tp = state->GeneratorExp_type;
14587
0
    isinstance = PyObject_IsInstance(obj, tp);
14588
0
    if (isinstance == -1) {
14589
0
        return -1;
14590
0
    }
14591
0
    if (isinstance) {
14592
0
        expr_ty elt;
14593
0
        asdl_comprehension_seq* generators;
14594
14595
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14596
0
            return -1;
14597
0
        }
14598
0
        if (tmp == NULL) {
14599
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14600
0
            return -1;
14601
0
        }
14602
0
        else {
14603
0
            int res;
14604
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14605
0
                goto failed;
14606
0
            }
14607
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14608
0
            _Py_LeaveRecursiveCall();
14609
0
            if (res != 0) goto failed;
14610
0
            Py_CLEAR(tmp);
14611
0
        }
14612
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14613
0
            return -1;
14614
0
        }
14615
0
        if (tmp == NULL) {
14616
0
            tmp = PyList_New(0);
14617
0
            if (tmp == NULL) {
14618
0
                return -1;
14619
0
            }
14620
0
        }
14621
0
        {
14622
0
            int res;
14623
0
            Py_ssize_t len;
14624
0
            Py_ssize_t i;
14625
0
            if (!PyList_Check(tmp)) {
14626
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14627
0
                goto failed;
14628
0
            }
14629
0
            len = PyList_GET_SIZE(tmp);
14630
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14631
0
            if (generators == NULL) goto failed;
14632
0
            for (i = 0; i < len; i++) {
14633
0
                comprehension_ty val;
14634
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14635
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14636
0
                    goto failed;
14637
0
                }
14638
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14639
0
                _Py_LeaveRecursiveCall();
14640
0
                Py_DECREF(tmp2);
14641
0
                if (res != 0) goto failed;
14642
0
                if (len != PyList_GET_SIZE(tmp)) {
14643
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14644
0
                    goto failed;
14645
0
                }
14646
0
                asdl_seq_SET(generators, i, val);
14647
0
            }
14648
0
            Py_CLEAR(tmp);
14649
0
        }
14650
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14651
0
                                   end_lineno, end_col_offset, arena);
14652
0
        if (*out == NULL) goto failed;
14653
0
        return 0;
14654
0
    }
14655
0
    tp = state->Await_type;
14656
0
    isinstance = PyObject_IsInstance(obj, tp);
14657
0
    if (isinstance == -1) {
14658
0
        return -1;
14659
0
    }
14660
0
    if (isinstance) {
14661
0
        expr_ty value;
14662
14663
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14664
0
            return -1;
14665
0
        }
14666
0
        if (tmp == NULL) {
14667
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14668
0
            return -1;
14669
0
        }
14670
0
        else {
14671
0
            int res;
14672
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14673
0
                goto failed;
14674
0
            }
14675
0
            res = obj2ast_expr(state, tmp, &value, arena);
14676
0
            _Py_LeaveRecursiveCall();
14677
0
            if (res != 0) goto failed;
14678
0
            Py_CLEAR(tmp);
14679
0
        }
14680
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14681
0
                            end_col_offset, arena);
14682
0
        if (*out == NULL) goto failed;
14683
0
        return 0;
14684
0
    }
14685
0
    tp = state->Yield_type;
14686
0
    isinstance = PyObject_IsInstance(obj, tp);
14687
0
    if (isinstance == -1) {
14688
0
        return -1;
14689
0
    }
14690
0
    if (isinstance) {
14691
0
        expr_ty value;
14692
14693
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14694
0
            return -1;
14695
0
        }
14696
0
        if (tmp == NULL || tmp == Py_None) {
14697
0
            Py_CLEAR(tmp);
14698
0
            value = NULL;
14699
0
        }
14700
0
        else {
14701
0
            int res;
14702
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14703
0
                goto failed;
14704
0
            }
14705
0
            res = obj2ast_expr(state, tmp, &value, arena);
14706
0
            _Py_LeaveRecursiveCall();
14707
0
            if (res != 0) goto failed;
14708
0
            Py_CLEAR(tmp);
14709
0
        }
14710
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14711
0
                            end_col_offset, arena);
14712
0
        if (*out == NULL) goto failed;
14713
0
        return 0;
14714
0
    }
14715
0
    tp = state->YieldFrom_type;
14716
0
    isinstance = PyObject_IsInstance(obj, tp);
14717
0
    if (isinstance == -1) {
14718
0
        return -1;
14719
0
    }
14720
0
    if (isinstance) {
14721
0
        expr_ty value;
14722
14723
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14724
0
            return -1;
14725
0
        }
14726
0
        if (tmp == NULL) {
14727
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14728
0
            return -1;
14729
0
        }
14730
0
        else {
14731
0
            int res;
14732
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14733
0
                goto failed;
14734
0
            }
14735
0
            res = obj2ast_expr(state, tmp, &value, arena);
14736
0
            _Py_LeaveRecursiveCall();
14737
0
            if (res != 0) goto failed;
14738
0
            Py_CLEAR(tmp);
14739
0
        }
14740
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14741
0
                                end_col_offset, arena);
14742
0
        if (*out == NULL) goto failed;
14743
0
        return 0;
14744
0
    }
14745
0
    tp = state->Compare_type;
14746
0
    isinstance = PyObject_IsInstance(obj, tp);
14747
0
    if (isinstance == -1) {
14748
0
        return -1;
14749
0
    }
14750
0
    if (isinstance) {
14751
0
        expr_ty left;
14752
0
        asdl_int_seq* ops;
14753
0
        asdl_expr_seq* comparators;
14754
14755
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14756
0
            return -1;
14757
0
        }
14758
0
        if (tmp == NULL) {
14759
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14760
0
            return -1;
14761
0
        }
14762
0
        else {
14763
0
            int res;
14764
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14765
0
                goto failed;
14766
0
            }
14767
0
            res = obj2ast_expr(state, tmp, &left, arena);
14768
0
            _Py_LeaveRecursiveCall();
14769
0
            if (res != 0) goto failed;
14770
0
            Py_CLEAR(tmp);
14771
0
        }
14772
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14773
0
            return -1;
14774
0
        }
14775
0
        if (tmp == NULL) {
14776
0
            tmp = PyList_New(0);
14777
0
            if (tmp == NULL) {
14778
0
                return -1;
14779
0
            }
14780
0
        }
14781
0
        {
14782
0
            int res;
14783
0
            Py_ssize_t len;
14784
0
            Py_ssize_t i;
14785
0
            if (!PyList_Check(tmp)) {
14786
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14787
0
                goto failed;
14788
0
            }
14789
0
            len = PyList_GET_SIZE(tmp);
14790
0
            ops = _Py_asdl_int_seq_new(len, arena);
14791
0
            if (ops == NULL) goto failed;
14792
0
            for (i = 0; i < len; i++) {
14793
0
                cmpop_ty val;
14794
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14795
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14796
0
                    goto failed;
14797
0
                }
14798
0
                res = obj2ast_cmpop(state, tmp2, &val, arena);
14799
0
                _Py_LeaveRecursiveCall();
14800
0
                Py_DECREF(tmp2);
14801
0
                if (res != 0) goto failed;
14802
0
                if (len != PyList_GET_SIZE(tmp)) {
14803
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14804
0
                    goto failed;
14805
0
                }
14806
0
                asdl_seq_SET(ops, i, val);
14807
0
            }
14808
0
            Py_CLEAR(tmp);
14809
0
        }
14810
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14811
0
            return -1;
14812
0
        }
14813
0
        if (tmp == NULL) {
14814
0
            tmp = PyList_New(0);
14815
0
            if (tmp == NULL) {
14816
0
                return -1;
14817
0
            }
14818
0
        }
14819
0
        {
14820
0
            int res;
14821
0
            Py_ssize_t len;
14822
0
            Py_ssize_t i;
14823
0
            if (!PyList_Check(tmp)) {
14824
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14825
0
                goto failed;
14826
0
            }
14827
0
            len = PyList_GET_SIZE(tmp);
14828
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14829
0
            if (comparators == NULL) goto failed;
14830
0
            for (i = 0; i < len; i++) {
14831
0
                expr_ty val;
14832
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14833
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14834
0
                    goto failed;
14835
0
                }
14836
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14837
0
                _Py_LeaveRecursiveCall();
14838
0
                Py_DECREF(tmp2);
14839
0
                if (res != 0) goto failed;
14840
0
                if (len != PyList_GET_SIZE(tmp)) {
14841
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14842
0
                    goto failed;
14843
0
                }
14844
0
                asdl_seq_SET(comparators, i, val);
14845
0
            }
14846
0
            Py_CLEAR(tmp);
14847
0
        }
14848
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14849
0
                              end_lineno, end_col_offset, arena);
14850
0
        if (*out == NULL) goto failed;
14851
0
        return 0;
14852
0
    }
14853
0
    tp = state->Call_type;
14854
0
    isinstance = PyObject_IsInstance(obj, tp);
14855
0
    if (isinstance == -1) {
14856
0
        return -1;
14857
0
    }
14858
0
    if (isinstance) {
14859
0
        expr_ty func;
14860
0
        asdl_expr_seq* args;
14861
0
        asdl_keyword_seq* keywords;
14862
14863
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14864
0
            return -1;
14865
0
        }
14866
0
        if (tmp == NULL) {
14867
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14868
0
            return -1;
14869
0
        }
14870
0
        else {
14871
0
            int res;
14872
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14873
0
                goto failed;
14874
0
            }
14875
0
            res = obj2ast_expr(state, tmp, &func, arena);
14876
0
            _Py_LeaveRecursiveCall();
14877
0
            if (res != 0) goto failed;
14878
0
            Py_CLEAR(tmp);
14879
0
        }
14880
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14881
0
            return -1;
14882
0
        }
14883
0
        if (tmp == NULL) {
14884
0
            tmp = PyList_New(0);
14885
0
            if (tmp == NULL) {
14886
0
                return -1;
14887
0
            }
14888
0
        }
14889
0
        {
14890
0
            int res;
14891
0
            Py_ssize_t len;
14892
0
            Py_ssize_t i;
14893
0
            if (!PyList_Check(tmp)) {
14894
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14895
0
                goto failed;
14896
0
            }
14897
0
            len = PyList_GET_SIZE(tmp);
14898
0
            args = _Py_asdl_expr_seq_new(len, arena);
14899
0
            if (args == NULL) goto failed;
14900
0
            for (i = 0; i < len; i++) {
14901
0
                expr_ty val;
14902
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14903
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14904
0
                    goto failed;
14905
0
                }
14906
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14907
0
                _Py_LeaveRecursiveCall();
14908
0
                Py_DECREF(tmp2);
14909
0
                if (res != 0) goto failed;
14910
0
                if (len != PyList_GET_SIZE(tmp)) {
14911
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14912
0
                    goto failed;
14913
0
                }
14914
0
                asdl_seq_SET(args, i, val);
14915
0
            }
14916
0
            Py_CLEAR(tmp);
14917
0
        }
14918
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14919
0
            return -1;
14920
0
        }
14921
0
        if (tmp == NULL) {
14922
0
            tmp = PyList_New(0);
14923
0
            if (tmp == NULL) {
14924
0
                return -1;
14925
0
            }
14926
0
        }
14927
0
        {
14928
0
            int res;
14929
0
            Py_ssize_t len;
14930
0
            Py_ssize_t i;
14931
0
            if (!PyList_Check(tmp)) {
14932
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14933
0
                goto failed;
14934
0
            }
14935
0
            len = PyList_GET_SIZE(tmp);
14936
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
14937
0
            if (keywords == NULL) goto failed;
14938
0
            for (i = 0; i < len; i++) {
14939
0
                keyword_ty val;
14940
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14941
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14942
0
                    goto failed;
14943
0
                }
14944
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
14945
0
                _Py_LeaveRecursiveCall();
14946
0
                Py_DECREF(tmp2);
14947
0
                if (res != 0) goto failed;
14948
0
                if (len != PyList_GET_SIZE(tmp)) {
14949
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
14950
0
                    goto failed;
14951
0
                }
14952
0
                asdl_seq_SET(keywords, i, val);
14953
0
            }
14954
0
            Py_CLEAR(tmp);
14955
0
        }
14956
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
14957
0
                           end_lineno, end_col_offset, arena);
14958
0
        if (*out == NULL) goto failed;
14959
0
        return 0;
14960
0
    }
14961
0
    tp = state->FormattedValue_type;
14962
0
    isinstance = PyObject_IsInstance(obj, tp);
14963
0
    if (isinstance == -1) {
14964
0
        return -1;
14965
0
    }
14966
0
    if (isinstance) {
14967
0
        expr_ty value;
14968
0
        int conversion;
14969
0
        expr_ty format_spec;
14970
14971
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14972
0
            return -1;
14973
0
        }
14974
0
        if (tmp == NULL) {
14975
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
14976
0
            return -1;
14977
0
        }
14978
0
        else {
14979
0
            int res;
14980
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14981
0
                goto failed;
14982
0
            }
14983
0
            res = obj2ast_expr(state, tmp, &value, arena);
14984
0
            _Py_LeaveRecursiveCall();
14985
0
            if (res != 0) goto failed;
14986
0
            Py_CLEAR(tmp);
14987
0
        }
14988
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
14989
0
            return -1;
14990
0
        }
14991
0
        if (tmp == NULL) {
14992
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
14993
0
            return -1;
14994
0
        }
14995
0
        else {
14996
0
            int res;
14997
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14998
0
                goto failed;
14999
0
            }
15000
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15001
0
            _Py_LeaveRecursiveCall();
15002
0
            if (res != 0) goto failed;
15003
0
            Py_CLEAR(tmp);
15004
0
        }
15005
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15006
0
            return -1;
15007
0
        }
15008
0
        if (tmp == NULL || tmp == Py_None) {
15009
0
            Py_CLEAR(tmp);
15010
0
            format_spec = NULL;
15011
0
        }
15012
0
        else {
15013
0
            int res;
15014
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15015
0
                goto failed;
15016
0
            }
15017
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15018
0
            _Py_LeaveRecursiveCall();
15019
0
            if (res != 0) goto failed;
15020
0
            Py_CLEAR(tmp);
15021
0
        }
15022
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15023
0
                                     col_offset, end_lineno, end_col_offset,
15024
0
                                     arena);
15025
0
        if (*out == NULL) goto failed;
15026
0
        return 0;
15027
0
    }
15028
0
    tp = state->Interpolation_type;
15029
0
    isinstance = PyObject_IsInstance(obj, tp);
15030
0
    if (isinstance == -1) {
15031
0
        return -1;
15032
0
    }
15033
0
    if (isinstance) {
15034
0
        expr_ty value;
15035
0
        constant str;
15036
0
        int conversion;
15037
0
        expr_ty format_spec;
15038
15039
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15040
0
            return -1;
15041
0
        }
15042
0
        if (tmp == NULL) {
15043
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15044
0
            return -1;
15045
0
        }
15046
0
        else {
15047
0
            int res;
15048
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15049
0
                goto failed;
15050
0
            }
15051
0
            res = obj2ast_expr(state, tmp, &value, arena);
15052
0
            _Py_LeaveRecursiveCall();
15053
0
            if (res != 0) goto failed;
15054
0
            Py_CLEAR(tmp);
15055
0
        }
15056
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15057
0
            return -1;
15058
0
        }
15059
0
        if (tmp == NULL) {
15060
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15061
0
            return -1;
15062
0
        }
15063
0
        else {
15064
0
            int res;
15065
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15066
0
                goto failed;
15067
0
            }
15068
0
            res = obj2ast_constant(state, tmp, &str, arena);
15069
0
            _Py_LeaveRecursiveCall();
15070
0
            if (res != 0) goto failed;
15071
0
            Py_CLEAR(tmp);
15072
0
        }
15073
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15074
0
            return -1;
15075
0
        }
15076
0
        if (tmp == NULL) {
15077
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15078
0
            return -1;
15079
0
        }
15080
0
        else {
15081
0
            int res;
15082
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15083
0
                goto failed;
15084
0
            }
15085
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15086
0
            _Py_LeaveRecursiveCall();
15087
0
            if (res != 0) goto failed;
15088
0
            Py_CLEAR(tmp);
15089
0
        }
15090
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15091
0
            return -1;
15092
0
        }
15093
0
        if (tmp == NULL || tmp == Py_None) {
15094
0
            Py_CLEAR(tmp);
15095
0
            format_spec = NULL;
15096
0
        }
15097
0
        else {
15098
0
            int res;
15099
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15100
0
                goto failed;
15101
0
            }
15102
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15103
0
            _Py_LeaveRecursiveCall();
15104
0
            if (res != 0) goto failed;
15105
0
            Py_CLEAR(tmp);
15106
0
        }
15107
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15108
0
                                    lineno, col_offset, end_lineno,
15109
0
                                    end_col_offset, arena);
15110
0
        if (*out == NULL) goto failed;
15111
0
        return 0;
15112
0
    }
15113
0
    tp = state->JoinedStr_type;
15114
0
    isinstance = PyObject_IsInstance(obj, tp);
15115
0
    if (isinstance == -1) {
15116
0
        return -1;
15117
0
    }
15118
0
    if (isinstance) {
15119
0
        asdl_expr_seq* values;
15120
15121
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15122
0
            return -1;
15123
0
        }
15124
0
        if (tmp == NULL) {
15125
0
            tmp = PyList_New(0);
15126
0
            if (tmp == NULL) {
15127
0
                return -1;
15128
0
            }
15129
0
        }
15130
0
        {
15131
0
            int res;
15132
0
            Py_ssize_t len;
15133
0
            Py_ssize_t i;
15134
0
            if (!PyList_Check(tmp)) {
15135
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15136
0
                goto failed;
15137
0
            }
15138
0
            len = PyList_GET_SIZE(tmp);
15139
0
            values = _Py_asdl_expr_seq_new(len, arena);
15140
0
            if (values == NULL) goto failed;
15141
0
            for (i = 0; i < len; i++) {
15142
0
                expr_ty val;
15143
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15144
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15145
0
                    goto failed;
15146
0
                }
15147
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15148
0
                _Py_LeaveRecursiveCall();
15149
0
                Py_DECREF(tmp2);
15150
0
                if (res != 0) goto failed;
15151
0
                if (len != PyList_GET_SIZE(tmp)) {
15152
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15153
0
                    goto failed;
15154
0
                }
15155
0
                asdl_seq_SET(values, i, val);
15156
0
            }
15157
0
            Py_CLEAR(tmp);
15158
0
        }
15159
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15160
0
                                end_col_offset, arena);
15161
0
        if (*out == NULL) goto failed;
15162
0
        return 0;
15163
0
    }
15164
0
    tp = state->TemplateStr_type;
15165
0
    isinstance = PyObject_IsInstance(obj, tp);
15166
0
    if (isinstance == -1) {
15167
0
        return -1;
15168
0
    }
15169
0
    if (isinstance) {
15170
0
        asdl_expr_seq* values;
15171
15172
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15173
0
            return -1;
15174
0
        }
15175
0
        if (tmp == NULL) {
15176
0
            tmp = PyList_New(0);
15177
0
            if (tmp == NULL) {
15178
0
                return -1;
15179
0
            }
15180
0
        }
15181
0
        {
15182
0
            int res;
15183
0
            Py_ssize_t len;
15184
0
            Py_ssize_t i;
15185
0
            if (!PyList_Check(tmp)) {
15186
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15187
0
                goto failed;
15188
0
            }
15189
0
            len = PyList_GET_SIZE(tmp);
15190
0
            values = _Py_asdl_expr_seq_new(len, arena);
15191
0
            if (values == NULL) goto failed;
15192
0
            for (i = 0; i < len; i++) {
15193
0
                expr_ty val;
15194
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15195
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15196
0
                    goto failed;
15197
0
                }
15198
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15199
0
                _Py_LeaveRecursiveCall();
15200
0
                Py_DECREF(tmp2);
15201
0
                if (res != 0) goto failed;
15202
0
                if (len != PyList_GET_SIZE(tmp)) {
15203
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15204
0
                    goto failed;
15205
0
                }
15206
0
                asdl_seq_SET(values, i, val);
15207
0
            }
15208
0
            Py_CLEAR(tmp);
15209
0
        }
15210
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15211
0
                                  end_col_offset, arena);
15212
0
        if (*out == NULL) goto failed;
15213
0
        return 0;
15214
0
    }
15215
0
    tp = state->Constant_type;
15216
0
    isinstance = PyObject_IsInstance(obj, tp);
15217
0
    if (isinstance == -1) {
15218
0
        return -1;
15219
0
    }
15220
0
    if (isinstance) {
15221
0
        constant value;
15222
0
        string kind;
15223
15224
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15225
0
            return -1;
15226
0
        }
15227
0
        if (tmp == NULL) {
15228
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15229
0
            return -1;
15230
0
        }
15231
0
        else {
15232
0
            int res;
15233
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15234
0
                goto failed;
15235
0
            }
15236
0
            res = obj2ast_constant(state, tmp, &value, arena);
15237
0
            _Py_LeaveRecursiveCall();
15238
0
            if (res != 0) goto failed;
15239
0
            Py_CLEAR(tmp);
15240
0
        }
15241
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15242
0
            return -1;
15243
0
        }
15244
0
        if (tmp == NULL || tmp == Py_None) {
15245
0
            Py_CLEAR(tmp);
15246
0
            kind = NULL;
15247
0
        }
15248
0
        else {
15249
0
            int res;
15250
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15251
0
                goto failed;
15252
0
            }
15253
0
            res = obj2ast_string(state, tmp, &kind, arena);
15254
0
            _Py_LeaveRecursiveCall();
15255
0
            if (res != 0) goto failed;
15256
0
            Py_CLEAR(tmp);
15257
0
        }
15258
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15259
0
                               end_col_offset, arena);
15260
0
        if (*out == NULL) goto failed;
15261
0
        return 0;
15262
0
    }
15263
0
    tp = state->Attribute_type;
15264
0
    isinstance = PyObject_IsInstance(obj, tp);
15265
0
    if (isinstance == -1) {
15266
0
        return -1;
15267
0
    }
15268
0
    if (isinstance) {
15269
0
        expr_ty value;
15270
0
        identifier attr;
15271
0
        expr_context_ty ctx;
15272
15273
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15274
0
            return -1;
15275
0
        }
15276
0
        if (tmp == NULL) {
15277
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15278
0
            return -1;
15279
0
        }
15280
0
        else {
15281
0
            int res;
15282
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15283
0
                goto failed;
15284
0
            }
15285
0
            res = obj2ast_expr(state, tmp, &value, arena);
15286
0
            _Py_LeaveRecursiveCall();
15287
0
            if (res != 0) goto failed;
15288
0
            Py_CLEAR(tmp);
15289
0
        }
15290
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15291
0
            return -1;
15292
0
        }
15293
0
        if (tmp == NULL) {
15294
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15295
0
            return -1;
15296
0
        }
15297
0
        else {
15298
0
            int res;
15299
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15300
0
                goto failed;
15301
0
            }
15302
0
            res = obj2ast_identifier(state, tmp, &attr, arena);
15303
0
            _Py_LeaveRecursiveCall();
15304
0
            if (res != 0) goto failed;
15305
0
            Py_CLEAR(tmp);
15306
0
        }
15307
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15308
0
            return -1;
15309
0
        }
15310
0
        if (tmp == NULL) {
15311
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15312
0
            return -1;
15313
0
        }
15314
0
        else {
15315
0
            int res;
15316
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15317
0
                goto failed;
15318
0
            }
15319
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15320
0
            _Py_LeaveRecursiveCall();
15321
0
            if (res != 0) goto failed;
15322
0
            Py_CLEAR(tmp);
15323
0
        }
15324
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15325
0
                                end_lineno, end_col_offset, arena);
15326
0
        if (*out == NULL) goto failed;
15327
0
        return 0;
15328
0
    }
15329
0
    tp = state->Subscript_type;
15330
0
    isinstance = PyObject_IsInstance(obj, tp);
15331
0
    if (isinstance == -1) {
15332
0
        return -1;
15333
0
    }
15334
0
    if (isinstance) {
15335
0
        expr_ty value;
15336
0
        expr_ty slice;
15337
0
        expr_context_ty ctx;
15338
15339
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15340
0
            return -1;
15341
0
        }
15342
0
        if (tmp == NULL) {
15343
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15344
0
            return -1;
15345
0
        }
15346
0
        else {
15347
0
            int res;
15348
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15349
0
                goto failed;
15350
0
            }
15351
0
            res = obj2ast_expr(state, tmp, &value, arena);
15352
0
            _Py_LeaveRecursiveCall();
15353
0
            if (res != 0) goto failed;
15354
0
            Py_CLEAR(tmp);
15355
0
        }
15356
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15357
0
            return -1;
15358
0
        }
15359
0
        if (tmp == NULL) {
15360
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15361
0
            return -1;
15362
0
        }
15363
0
        else {
15364
0
            int res;
15365
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15366
0
                goto failed;
15367
0
            }
15368
0
            res = obj2ast_expr(state, tmp, &slice, arena);
15369
0
            _Py_LeaveRecursiveCall();
15370
0
            if (res != 0) goto failed;
15371
0
            Py_CLEAR(tmp);
15372
0
        }
15373
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15374
0
            return -1;
15375
0
        }
15376
0
        if (tmp == NULL) {
15377
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15378
0
            return -1;
15379
0
        }
15380
0
        else {
15381
0
            int res;
15382
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15383
0
                goto failed;
15384
0
            }
15385
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15386
0
            _Py_LeaveRecursiveCall();
15387
0
            if (res != 0) goto failed;
15388
0
            Py_CLEAR(tmp);
15389
0
        }
15390
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15391
0
                                end_lineno, end_col_offset, arena);
15392
0
        if (*out == NULL) goto failed;
15393
0
        return 0;
15394
0
    }
15395
0
    tp = state->Starred_type;
15396
0
    isinstance = PyObject_IsInstance(obj, tp);
15397
0
    if (isinstance == -1) {
15398
0
        return -1;
15399
0
    }
15400
0
    if (isinstance) {
15401
0
        expr_ty value;
15402
0
        expr_context_ty ctx;
15403
15404
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15405
0
            return -1;
15406
0
        }
15407
0
        if (tmp == NULL) {
15408
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15409
0
            return -1;
15410
0
        }
15411
0
        else {
15412
0
            int res;
15413
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15414
0
                goto failed;
15415
0
            }
15416
0
            res = obj2ast_expr(state, tmp, &value, arena);
15417
0
            _Py_LeaveRecursiveCall();
15418
0
            if (res != 0) goto failed;
15419
0
            Py_CLEAR(tmp);
15420
0
        }
15421
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15422
0
            return -1;
15423
0
        }
15424
0
        if (tmp == NULL) {
15425
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15426
0
            return -1;
15427
0
        }
15428
0
        else {
15429
0
            int res;
15430
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15431
0
                goto failed;
15432
0
            }
15433
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15434
0
            _Py_LeaveRecursiveCall();
15435
0
            if (res != 0) goto failed;
15436
0
            Py_CLEAR(tmp);
15437
0
        }
15438
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15439
0
                              end_col_offset, arena);
15440
0
        if (*out == NULL) goto failed;
15441
0
        return 0;
15442
0
    }
15443
0
    tp = state->Name_type;
15444
0
    isinstance = PyObject_IsInstance(obj, tp);
15445
0
    if (isinstance == -1) {
15446
0
        return -1;
15447
0
    }
15448
0
    if (isinstance) {
15449
0
        identifier id;
15450
0
        expr_context_ty ctx;
15451
15452
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15453
0
            return -1;
15454
0
        }
15455
0
        if (tmp == NULL) {
15456
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15457
0
            return -1;
15458
0
        }
15459
0
        else {
15460
0
            int res;
15461
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15462
0
                goto failed;
15463
0
            }
15464
0
            res = obj2ast_identifier(state, tmp, &id, arena);
15465
0
            _Py_LeaveRecursiveCall();
15466
0
            if (res != 0) goto failed;
15467
0
            Py_CLEAR(tmp);
15468
0
        }
15469
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15470
0
            return -1;
15471
0
        }
15472
0
        if (tmp == NULL) {
15473
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15474
0
            return -1;
15475
0
        }
15476
0
        else {
15477
0
            int res;
15478
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15479
0
                goto failed;
15480
0
            }
15481
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15482
0
            _Py_LeaveRecursiveCall();
15483
0
            if (res != 0) goto failed;
15484
0
            Py_CLEAR(tmp);
15485
0
        }
15486
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15487
0
                           end_col_offset, arena);
15488
0
        if (*out == NULL) goto failed;
15489
0
        return 0;
15490
0
    }
15491
0
    tp = state->List_type;
15492
0
    isinstance = PyObject_IsInstance(obj, tp);
15493
0
    if (isinstance == -1) {
15494
0
        return -1;
15495
0
    }
15496
0
    if (isinstance) {
15497
0
        asdl_expr_seq* elts;
15498
0
        expr_context_ty ctx;
15499
15500
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15501
0
            return -1;
15502
0
        }
15503
0
        if (tmp == NULL) {
15504
0
            tmp = PyList_New(0);
15505
0
            if (tmp == NULL) {
15506
0
                return -1;
15507
0
            }
15508
0
        }
15509
0
        {
15510
0
            int res;
15511
0
            Py_ssize_t len;
15512
0
            Py_ssize_t i;
15513
0
            if (!PyList_Check(tmp)) {
15514
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15515
0
                goto failed;
15516
0
            }
15517
0
            len = PyList_GET_SIZE(tmp);
15518
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15519
0
            if (elts == NULL) goto failed;
15520
0
            for (i = 0; i < len; i++) {
15521
0
                expr_ty val;
15522
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15523
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15524
0
                    goto failed;
15525
0
                }
15526
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15527
0
                _Py_LeaveRecursiveCall();
15528
0
                Py_DECREF(tmp2);
15529
0
                if (res != 0) goto failed;
15530
0
                if (len != PyList_GET_SIZE(tmp)) {
15531
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15532
0
                    goto failed;
15533
0
                }
15534
0
                asdl_seq_SET(elts, i, val);
15535
0
            }
15536
0
            Py_CLEAR(tmp);
15537
0
        }
15538
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15539
0
            return -1;
15540
0
        }
15541
0
        if (tmp == NULL) {
15542
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15543
0
            return -1;
15544
0
        }
15545
0
        else {
15546
0
            int res;
15547
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15548
0
                goto failed;
15549
0
            }
15550
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15551
0
            _Py_LeaveRecursiveCall();
15552
0
            if (res != 0) goto failed;
15553
0
            Py_CLEAR(tmp);
15554
0
        }
15555
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15556
0
                           end_col_offset, arena);
15557
0
        if (*out == NULL) goto failed;
15558
0
        return 0;
15559
0
    }
15560
0
    tp = state->Tuple_type;
15561
0
    isinstance = PyObject_IsInstance(obj, tp);
15562
0
    if (isinstance == -1) {
15563
0
        return -1;
15564
0
    }
15565
0
    if (isinstance) {
15566
0
        asdl_expr_seq* elts;
15567
0
        expr_context_ty ctx;
15568
15569
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15570
0
            return -1;
15571
0
        }
15572
0
        if (tmp == NULL) {
15573
0
            tmp = PyList_New(0);
15574
0
            if (tmp == NULL) {
15575
0
                return -1;
15576
0
            }
15577
0
        }
15578
0
        {
15579
0
            int res;
15580
0
            Py_ssize_t len;
15581
0
            Py_ssize_t i;
15582
0
            if (!PyList_Check(tmp)) {
15583
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15584
0
                goto failed;
15585
0
            }
15586
0
            len = PyList_GET_SIZE(tmp);
15587
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15588
0
            if (elts == NULL) goto failed;
15589
0
            for (i = 0; i < len; i++) {
15590
0
                expr_ty val;
15591
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15592
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15593
0
                    goto failed;
15594
0
                }
15595
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15596
0
                _Py_LeaveRecursiveCall();
15597
0
                Py_DECREF(tmp2);
15598
0
                if (res != 0) goto failed;
15599
0
                if (len != PyList_GET_SIZE(tmp)) {
15600
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15601
0
                    goto failed;
15602
0
                }
15603
0
                asdl_seq_SET(elts, i, val);
15604
0
            }
15605
0
            Py_CLEAR(tmp);
15606
0
        }
15607
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15608
0
            return -1;
15609
0
        }
15610
0
        if (tmp == NULL) {
15611
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15612
0
            return -1;
15613
0
        }
15614
0
        else {
15615
0
            int res;
15616
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15617
0
                goto failed;
15618
0
            }
15619
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15620
0
            _Py_LeaveRecursiveCall();
15621
0
            if (res != 0) goto failed;
15622
0
            Py_CLEAR(tmp);
15623
0
        }
15624
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15625
0
                            end_col_offset, arena);
15626
0
        if (*out == NULL) goto failed;
15627
0
        return 0;
15628
0
    }
15629
0
    tp = state->Slice_type;
15630
0
    isinstance = PyObject_IsInstance(obj, tp);
15631
0
    if (isinstance == -1) {
15632
0
        return -1;
15633
0
    }
15634
0
    if (isinstance) {
15635
0
        expr_ty lower;
15636
0
        expr_ty upper;
15637
0
        expr_ty step;
15638
15639
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15640
0
            return -1;
15641
0
        }
15642
0
        if (tmp == NULL || tmp == Py_None) {
15643
0
            Py_CLEAR(tmp);
15644
0
            lower = NULL;
15645
0
        }
15646
0
        else {
15647
0
            int res;
15648
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15649
0
                goto failed;
15650
0
            }
15651
0
            res = obj2ast_expr(state, tmp, &lower, arena);
15652
0
            _Py_LeaveRecursiveCall();
15653
0
            if (res != 0) goto failed;
15654
0
            Py_CLEAR(tmp);
15655
0
        }
15656
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15657
0
            return -1;
15658
0
        }
15659
0
        if (tmp == NULL || tmp == Py_None) {
15660
0
            Py_CLEAR(tmp);
15661
0
            upper = NULL;
15662
0
        }
15663
0
        else {
15664
0
            int res;
15665
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15666
0
                goto failed;
15667
0
            }
15668
0
            res = obj2ast_expr(state, tmp, &upper, arena);
15669
0
            _Py_LeaveRecursiveCall();
15670
0
            if (res != 0) goto failed;
15671
0
            Py_CLEAR(tmp);
15672
0
        }
15673
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15674
0
            return -1;
15675
0
        }
15676
0
        if (tmp == NULL || tmp == Py_None) {
15677
0
            Py_CLEAR(tmp);
15678
0
            step = NULL;
15679
0
        }
15680
0
        else {
15681
0
            int res;
15682
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15683
0
                goto failed;
15684
0
            }
15685
0
            res = obj2ast_expr(state, tmp, &step, arena);
15686
0
            _Py_LeaveRecursiveCall();
15687
0
            if (res != 0) goto failed;
15688
0
            Py_CLEAR(tmp);
15689
0
        }
15690
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15691
0
                            end_col_offset, arena);
15692
0
        if (*out == NULL) goto failed;
15693
0
        return 0;
15694
0
    }
15695
15696
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15697
0
    failed:
15698
0
    Py_XDECREF(tmp);
15699
0
    return -1;
15700
0
}
15701
15702
int
15703
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15704
                     out, PyArena* arena)
15705
0
{
15706
0
    int isinstance;
15707
15708
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15709
0
    if (isinstance == -1) {
15710
0
        return -1;
15711
0
    }
15712
0
    if (isinstance) {
15713
0
        *out = Load;
15714
0
        return 0;
15715
0
    }
15716
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15717
0
    if (isinstance == -1) {
15718
0
        return -1;
15719
0
    }
15720
0
    if (isinstance) {
15721
0
        *out = Store;
15722
0
        return 0;
15723
0
    }
15724
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15725
0
    if (isinstance == -1) {
15726
0
        return -1;
15727
0
    }
15728
0
    if (isinstance) {
15729
0
        *out = Del;
15730
0
        return 0;
15731
0
    }
15732
15733
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15734
0
    return -1;
15735
0
}
15736
15737
int
15738
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
15739
               arena)
15740
0
{
15741
0
    int isinstance;
15742
15743
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15744
0
    if (isinstance == -1) {
15745
0
        return -1;
15746
0
    }
15747
0
    if (isinstance) {
15748
0
        *out = And;
15749
0
        return 0;
15750
0
    }
15751
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15752
0
    if (isinstance == -1) {
15753
0
        return -1;
15754
0
    }
15755
0
    if (isinstance) {
15756
0
        *out = Or;
15757
0
        return 0;
15758
0
    }
15759
15760
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15761
0
    return -1;
15762
0
}
15763
15764
int
15765
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15766
                 PyArena* arena)
15767
0
{
15768
0
    int isinstance;
15769
15770
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15771
0
    if (isinstance == -1) {
15772
0
        return -1;
15773
0
    }
15774
0
    if (isinstance) {
15775
0
        *out = Add;
15776
0
        return 0;
15777
0
    }
15778
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15779
0
    if (isinstance == -1) {
15780
0
        return -1;
15781
0
    }
15782
0
    if (isinstance) {
15783
0
        *out = Sub;
15784
0
        return 0;
15785
0
    }
15786
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15787
0
    if (isinstance == -1) {
15788
0
        return -1;
15789
0
    }
15790
0
    if (isinstance) {
15791
0
        *out = Mult;
15792
0
        return 0;
15793
0
    }
15794
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15795
0
    if (isinstance == -1) {
15796
0
        return -1;
15797
0
    }
15798
0
    if (isinstance) {
15799
0
        *out = MatMult;
15800
0
        return 0;
15801
0
    }
15802
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15803
0
    if (isinstance == -1) {
15804
0
        return -1;
15805
0
    }
15806
0
    if (isinstance) {
15807
0
        *out = Div;
15808
0
        return 0;
15809
0
    }
15810
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15811
0
    if (isinstance == -1) {
15812
0
        return -1;
15813
0
    }
15814
0
    if (isinstance) {
15815
0
        *out = Mod;
15816
0
        return 0;
15817
0
    }
15818
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15819
0
    if (isinstance == -1) {
15820
0
        return -1;
15821
0
    }
15822
0
    if (isinstance) {
15823
0
        *out = Pow;
15824
0
        return 0;
15825
0
    }
15826
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15827
0
    if (isinstance == -1) {
15828
0
        return -1;
15829
0
    }
15830
0
    if (isinstance) {
15831
0
        *out = LShift;
15832
0
        return 0;
15833
0
    }
15834
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15835
0
    if (isinstance == -1) {
15836
0
        return -1;
15837
0
    }
15838
0
    if (isinstance) {
15839
0
        *out = RShift;
15840
0
        return 0;
15841
0
    }
15842
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15843
0
    if (isinstance == -1) {
15844
0
        return -1;
15845
0
    }
15846
0
    if (isinstance) {
15847
0
        *out = BitOr;
15848
0
        return 0;
15849
0
    }
15850
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15851
0
    if (isinstance == -1) {
15852
0
        return -1;
15853
0
    }
15854
0
    if (isinstance) {
15855
0
        *out = BitXor;
15856
0
        return 0;
15857
0
    }
15858
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15859
0
    if (isinstance == -1) {
15860
0
        return -1;
15861
0
    }
15862
0
    if (isinstance) {
15863
0
        *out = BitAnd;
15864
0
        return 0;
15865
0
    }
15866
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15867
0
    if (isinstance == -1) {
15868
0
        return -1;
15869
0
    }
15870
0
    if (isinstance) {
15871
0
        *out = FloorDiv;
15872
0
        return 0;
15873
0
    }
15874
15875
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15876
0
    return -1;
15877
0
}
15878
15879
int
15880
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
15881
                PyArena* arena)
15882
0
{
15883
0
    int isinstance;
15884
15885
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15886
0
    if (isinstance == -1) {
15887
0
        return -1;
15888
0
    }
15889
0
    if (isinstance) {
15890
0
        *out = Invert;
15891
0
        return 0;
15892
0
    }
15893
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15894
0
    if (isinstance == -1) {
15895
0
        return -1;
15896
0
    }
15897
0
    if (isinstance) {
15898
0
        *out = Not;
15899
0
        return 0;
15900
0
    }
15901
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15902
0
    if (isinstance == -1) {
15903
0
        return -1;
15904
0
    }
15905
0
    if (isinstance) {
15906
0
        *out = UAdd;
15907
0
        return 0;
15908
0
    }
15909
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15910
0
    if (isinstance == -1) {
15911
0
        return -1;
15912
0
    }
15913
0
    if (isinstance) {
15914
0
        *out = USub;
15915
0
        return 0;
15916
0
    }
15917
15918
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15919
0
    return -1;
15920
0
}
15921
15922
int
15923
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
15924
              arena)
15925
0
{
15926
0
    int isinstance;
15927
15928
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15929
0
    if (isinstance == -1) {
15930
0
        return -1;
15931
0
    }
15932
0
    if (isinstance) {
15933
0
        *out = Eq;
15934
0
        return 0;
15935
0
    }
15936
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
15937
0
    if (isinstance == -1) {
15938
0
        return -1;
15939
0
    }
15940
0
    if (isinstance) {
15941
0
        *out = NotEq;
15942
0
        return 0;
15943
0
    }
15944
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
15945
0
    if (isinstance == -1) {
15946
0
        return -1;
15947
0
    }
15948
0
    if (isinstance) {
15949
0
        *out = Lt;
15950
0
        return 0;
15951
0
    }
15952
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
15953
0
    if (isinstance == -1) {
15954
0
        return -1;
15955
0
    }
15956
0
    if (isinstance) {
15957
0
        *out = LtE;
15958
0
        return 0;
15959
0
    }
15960
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
15961
0
    if (isinstance == -1) {
15962
0
        return -1;
15963
0
    }
15964
0
    if (isinstance) {
15965
0
        *out = Gt;
15966
0
        return 0;
15967
0
    }
15968
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
15969
0
    if (isinstance == -1) {
15970
0
        return -1;
15971
0
    }
15972
0
    if (isinstance) {
15973
0
        *out = GtE;
15974
0
        return 0;
15975
0
    }
15976
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
15977
0
    if (isinstance == -1) {
15978
0
        return -1;
15979
0
    }
15980
0
    if (isinstance) {
15981
0
        *out = Is;
15982
0
        return 0;
15983
0
    }
15984
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
15985
0
    if (isinstance == -1) {
15986
0
        return -1;
15987
0
    }
15988
0
    if (isinstance) {
15989
0
        *out = IsNot;
15990
0
        return 0;
15991
0
    }
15992
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
15993
0
    if (isinstance == -1) {
15994
0
        return -1;
15995
0
    }
15996
0
    if (isinstance) {
15997
0
        *out = In;
15998
0
        return 0;
15999
0
    }
16000
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16001
0
    if (isinstance == -1) {
16002
0
        return -1;
16003
0
    }
16004
0
    if (isinstance) {
16005
0
        *out = NotIn;
16006
0
        return 0;
16007
0
    }
16008
16009
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16010
0
    return -1;
16011
0
}
16012
16013
int
16014
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16015
                      out, PyArena* arena)
16016
0
{
16017
0
    PyObject* tmp = NULL;
16018
0
    expr_ty target;
16019
0
    expr_ty iter;
16020
0
    asdl_expr_seq* ifs;
16021
0
    int is_async;
16022
16023
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16024
0
        return -1;
16025
0
    }
16026
0
    if (tmp == NULL) {
16027
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16028
0
        return -1;
16029
0
    }
16030
0
    else {
16031
0
        int res;
16032
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16033
0
            goto failed;
16034
0
        }
16035
0
        res = obj2ast_expr(state, tmp, &target, arena);
16036
0
        _Py_LeaveRecursiveCall();
16037
0
        if (res != 0) goto failed;
16038
0
        Py_CLEAR(tmp);
16039
0
    }
16040
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16041
0
        return -1;
16042
0
    }
16043
0
    if (tmp == NULL) {
16044
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16045
0
        return -1;
16046
0
    }
16047
0
    else {
16048
0
        int res;
16049
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16050
0
            goto failed;
16051
0
        }
16052
0
        res = obj2ast_expr(state, tmp, &iter, arena);
16053
0
        _Py_LeaveRecursiveCall();
16054
0
        if (res != 0) goto failed;
16055
0
        Py_CLEAR(tmp);
16056
0
    }
16057
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16058
0
        return -1;
16059
0
    }
16060
0
    if (tmp == NULL) {
16061
0
        tmp = PyList_New(0);
16062
0
        if (tmp == NULL) {
16063
0
            return -1;
16064
0
        }
16065
0
    }
16066
0
    {
16067
0
        int res;
16068
0
        Py_ssize_t len;
16069
0
        Py_ssize_t i;
16070
0
        if (!PyList_Check(tmp)) {
16071
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16072
0
            goto failed;
16073
0
        }
16074
0
        len = PyList_GET_SIZE(tmp);
16075
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16076
0
        if (ifs == NULL) goto failed;
16077
0
        for (i = 0; i < len; i++) {
16078
0
            expr_ty val;
16079
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16080
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16081
0
                goto failed;
16082
0
            }
16083
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16084
0
            _Py_LeaveRecursiveCall();
16085
0
            Py_DECREF(tmp2);
16086
0
            if (res != 0) goto failed;
16087
0
            if (len != PyList_GET_SIZE(tmp)) {
16088
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16089
0
                goto failed;
16090
0
            }
16091
0
            asdl_seq_SET(ifs, i, val);
16092
0
        }
16093
0
        Py_CLEAR(tmp);
16094
0
    }
16095
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16096
0
        return -1;
16097
0
    }
16098
0
    if (tmp == NULL) {
16099
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16100
0
        return -1;
16101
0
    }
16102
0
    else {
16103
0
        int res;
16104
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16105
0
            goto failed;
16106
0
        }
16107
0
        res = obj2ast_int(state, tmp, &is_async, arena);
16108
0
        _Py_LeaveRecursiveCall();
16109
0
        if (res != 0) goto failed;
16110
0
        Py_CLEAR(tmp);
16111
0
    }
16112
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16113
0
    if (*out == NULL) goto failed;
16114
0
    return 0;
16115
0
failed:
16116
0
    Py_XDECREF(tmp);
16117
0
    return -1;
16118
0
}
16119
16120
int
16121
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16122
                      out, PyArena* arena)
16123
0
{
16124
0
    int isinstance;
16125
16126
0
    PyObject *tmp = NULL;
16127
0
    PyObject *tp;
16128
0
    int lineno;
16129
0
    int col_offset;
16130
0
    int end_lineno;
16131
0
    int end_col_offset;
16132
16133
0
    if (obj == Py_None) {
16134
0
        *out = NULL;
16135
0
        return 0;
16136
0
    }
16137
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16138
0
        return -1;
16139
0
    }
16140
0
    if (tmp == NULL) {
16141
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16142
0
        return -1;
16143
0
    }
16144
0
    else {
16145
0
        int res;
16146
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16147
0
            goto failed;
16148
0
        }
16149
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16150
0
        _Py_LeaveRecursiveCall();
16151
0
        if (res != 0) goto failed;
16152
0
        Py_CLEAR(tmp);
16153
0
    }
16154
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16155
0
        return -1;
16156
0
    }
16157
0
    if (tmp == NULL) {
16158
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16159
0
        return -1;
16160
0
    }
16161
0
    else {
16162
0
        int res;
16163
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16164
0
            goto failed;
16165
0
        }
16166
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16167
0
        _Py_LeaveRecursiveCall();
16168
0
        if (res != 0) goto failed;
16169
0
        Py_CLEAR(tmp);
16170
0
    }
16171
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16172
0
        return -1;
16173
0
    }
16174
0
    if (tmp == NULL || tmp == Py_None) {
16175
0
        Py_CLEAR(tmp);
16176
0
        end_lineno = lineno;
16177
0
    }
16178
0
    else {
16179
0
        int res;
16180
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16181
0
            goto failed;
16182
0
        }
16183
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16184
0
        _Py_LeaveRecursiveCall();
16185
0
        if (res != 0) goto failed;
16186
0
        Py_CLEAR(tmp);
16187
0
    }
16188
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16189
0
        return -1;
16190
0
    }
16191
0
    if (tmp == NULL || tmp == Py_None) {
16192
0
        Py_CLEAR(tmp);
16193
0
        end_col_offset = col_offset;
16194
0
    }
16195
0
    else {
16196
0
        int res;
16197
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16198
0
            goto failed;
16199
0
        }
16200
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16201
0
        _Py_LeaveRecursiveCall();
16202
0
        if (res != 0) goto failed;
16203
0
        Py_CLEAR(tmp);
16204
0
    }
16205
0
    tp = state->ExceptHandler_type;
16206
0
    isinstance = PyObject_IsInstance(obj, tp);
16207
0
    if (isinstance == -1) {
16208
0
        return -1;
16209
0
    }
16210
0
    if (isinstance) {
16211
0
        expr_ty type;
16212
0
        identifier name;
16213
0
        asdl_stmt_seq* body;
16214
16215
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16216
0
            return -1;
16217
0
        }
16218
0
        if (tmp == NULL || tmp == Py_None) {
16219
0
            Py_CLEAR(tmp);
16220
0
            type = NULL;
16221
0
        }
16222
0
        else {
16223
0
            int res;
16224
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16225
0
                goto failed;
16226
0
            }
16227
0
            res = obj2ast_expr(state, tmp, &type, arena);
16228
0
            _Py_LeaveRecursiveCall();
16229
0
            if (res != 0) goto failed;
16230
0
            Py_CLEAR(tmp);
16231
0
        }
16232
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16233
0
            return -1;
16234
0
        }
16235
0
        if (tmp == NULL || tmp == Py_None) {
16236
0
            Py_CLEAR(tmp);
16237
0
            name = NULL;
16238
0
        }
16239
0
        else {
16240
0
            int res;
16241
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16242
0
                goto failed;
16243
0
            }
16244
0
            res = obj2ast_identifier(state, tmp, &name, arena);
16245
0
            _Py_LeaveRecursiveCall();
16246
0
            if (res != 0) goto failed;
16247
0
            Py_CLEAR(tmp);
16248
0
        }
16249
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16250
0
            return -1;
16251
0
        }
16252
0
        if (tmp == NULL) {
16253
0
            tmp = PyList_New(0);
16254
0
            if (tmp == NULL) {
16255
0
                return -1;
16256
0
            }
16257
0
        }
16258
0
        {
16259
0
            int res;
16260
0
            Py_ssize_t len;
16261
0
            Py_ssize_t i;
16262
0
            if (!PyList_Check(tmp)) {
16263
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16264
0
                goto failed;
16265
0
            }
16266
0
            len = PyList_GET_SIZE(tmp);
16267
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16268
0
            if (body == NULL) goto failed;
16269
0
            for (i = 0; i < len; i++) {
16270
0
                stmt_ty val;
16271
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16272
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16273
0
                    goto failed;
16274
0
                }
16275
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
16276
0
                _Py_LeaveRecursiveCall();
16277
0
                Py_DECREF(tmp2);
16278
0
                if (res != 0) goto failed;
16279
0
                if (len != PyList_GET_SIZE(tmp)) {
16280
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16281
0
                    goto failed;
16282
0
                }
16283
0
                asdl_seq_SET(body, i, val);
16284
0
            }
16285
0
            Py_CLEAR(tmp);
16286
0
        }
16287
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16288
0
                                    end_lineno, end_col_offset, arena);
16289
0
        if (*out == NULL) goto failed;
16290
0
        return 0;
16291
0
    }
16292
16293
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16294
0
    failed:
16295
0
    Py_XDECREF(tmp);
16296
0
    return -1;
16297
0
}
16298
16299
int
16300
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16301
                  PyArena* arena)
16302
0
{
16303
0
    PyObject* tmp = NULL;
16304
0
    asdl_arg_seq* posonlyargs;
16305
0
    asdl_arg_seq* args;
16306
0
    arg_ty vararg;
16307
0
    asdl_arg_seq* kwonlyargs;
16308
0
    asdl_expr_seq* kw_defaults;
16309
0
    arg_ty kwarg;
16310
0
    asdl_expr_seq* defaults;
16311
16312
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16313
0
        return -1;
16314
0
    }
16315
0
    if (tmp == NULL) {
16316
0
        tmp = PyList_New(0);
16317
0
        if (tmp == NULL) {
16318
0
            return -1;
16319
0
        }
16320
0
    }
16321
0
    {
16322
0
        int res;
16323
0
        Py_ssize_t len;
16324
0
        Py_ssize_t i;
16325
0
        if (!PyList_Check(tmp)) {
16326
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16327
0
            goto failed;
16328
0
        }
16329
0
        len = PyList_GET_SIZE(tmp);
16330
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16331
0
        if (posonlyargs == NULL) goto failed;
16332
0
        for (i = 0; i < len; i++) {
16333
0
            arg_ty val;
16334
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16335
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16336
0
                goto failed;
16337
0
            }
16338
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16339
0
            _Py_LeaveRecursiveCall();
16340
0
            Py_DECREF(tmp2);
16341
0
            if (res != 0) goto failed;
16342
0
            if (len != PyList_GET_SIZE(tmp)) {
16343
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16344
0
                goto failed;
16345
0
            }
16346
0
            asdl_seq_SET(posonlyargs, i, val);
16347
0
        }
16348
0
        Py_CLEAR(tmp);
16349
0
    }
16350
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16351
0
        return -1;
16352
0
    }
16353
0
    if (tmp == NULL) {
16354
0
        tmp = PyList_New(0);
16355
0
        if (tmp == NULL) {
16356
0
            return -1;
16357
0
        }
16358
0
    }
16359
0
    {
16360
0
        int res;
16361
0
        Py_ssize_t len;
16362
0
        Py_ssize_t i;
16363
0
        if (!PyList_Check(tmp)) {
16364
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16365
0
            goto failed;
16366
0
        }
16367
0
        len = PyList_GET_SIZE(tmp);
16368
0
        args = _Py_asdl_arg_seq_new(len, arena);
16369
0
        if (args == NULL) goto failed;
16370
0
        for (i = 0; i < len; i++) {
16371
0
            arg_ty val;
16372
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16373
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16374
0
                goto failed;
16375
0
            }
16376
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16377
0
            _Py_LeaveRecursiveCall();
16378
0
            Py_DECREF(tmp2);
16379
0
            if (res != 0) goto failed;
16380
0
            if (len != PyList_GET_SIZE(tmp)) {
16381
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16382
0
                goto failed;
16383
0
            }
16384
0
            asdl_seq_SET(args, i, val);
16385
0
        }
16386
0
        Py_CLEAR(tmp);
16387
0
    }
16388
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16389
0
        return -1;
16390
0
    }
16391
0
    if (tmp == NULL || tmp == Py_None) {
16392
0
        Py_CLEAR(tmp);
16393
0
        vararg = NULL;
16394
0
    }
16395
0
    else {
16396
0
        int res;
16397
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16398
0
            goto failed;
16399
0
        }
16400
0
        res = obj2ast_arg(state, tmp, &vararg, arena);
16401
0
        _Py_LeaveRecursiveCall();
16402
0
        if (res != 0) goto failed;
16403
0
        Py_CLEAR(tmp);
16404
0
    }
16405
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16406
0
        return -1;
16407
0
    }
16408
0
    if (tmp == NULL) {
16409
0
        tmp = PyList_New(0);
16410
0
        if (tmp == NULL) {
16411
0
            return -1;
16412
0
        }
16413
0
    }
16414
0
    {
16415
0
        int res;
16416
0
        Py_ssize_t len;
16417
0
        Py_ssize_t i;
16418
0
        if (!PyList_Check(tmp)) {
16419
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16420
0
            goto failed;
16421
0
        }
16422
0
        len = PyList_GET_SIZE(tmp);
16423
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16424
0
        if (kwonlyargs == NULL) goto failed;
16425
0
        for (i = 0; i < len; i++) {
16426
0
            arg_ty val;
16427
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16428
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16429
0
                goto failed;
16430
0
            }
16431
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16432
0
            _Py_LeaveRecursiveCall();
16433
0
            Py_DECREF(tmp2);
16434
0
            if (res != 0) goto failed;
16435
0
            if (len != PyList_GET_SIZE(tmp)) {
16436
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16437
0
                goto failed;
16438
0
            }
16439
0
            asdl_seq_SET(kwonlyargs, i, val);
16440
0
        }
16441
0
        Py_CLEAR(tmp);
16442
0
    }
16443
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16444
0
        return -1;
16445
0
    }
16446
0
    if (tmp == NULL) {
16447
0
        tmp = PyList_New(0);
16448
0
        if (tmp == NULL) {
16449
0
            return -1;
16450
0
        }
16451
0
    }
16452
0
    {
16453
0
        int res;
16454
0
        Py_ssize_t len;
16455
0
        Py_ssize_t i;
16456
0
        if (!PyList_Check(tmp)) {
16457
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16458
0
            goto failed;
16459
0
        }
16460
0
        len = PyList_GET_SIZE(tmp);
16461
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16462
0
        if (kw_defaults == NULL) goto failed;
16463
0
        for (i = 0; i < len; i++) {
16464
0
            expr_ty val;
16465
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16466
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16467
0
                goto failed;
16468
0
            }
16469
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16470
0
            _Py_LeaveRecursiveCall();
16471
0
            Py_DECREF(tmp2);
16472
0
            if (res != 0) goto failed;
16473
0
            if (len != PyList_GET_SIZE(tmp)) {
16474
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16475
0
                goto failed;
16476
0
            }
16477
0
            asdl_seq_SET(kw_defaults, i, val);
16478
0
        }
16479
0
        Py_CLEAR(tmp);
16480
0
    }
16481
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16482
0
        return -1;
16483
0
    }
16484
0
    if (tmp == NULL || tmp == Py_None) {
16485
0
        Py_CLEAR(tmp);
16486
0
        kwarg = NULL;
16487
0
    }
16488
0
    else {
16489
0
        int res;
16490
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16491
0
            goto failed;
16492
0
        }
16493
0
        res = obj2ast_arg(state, tmp, &kwarg, arena);
16494
0
        _Py_LeaveRecursiveCall();
16495
0
        if (res != 0) goto failed;
16496
0
        Py_CLEAR(tmp);
16497
0
    }
16498
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16499
0
        return -1;
16500
0
    }
16501
0
    if (tmp == NULL) {
16502
0
        tmp = PyList_New(0);
16503
0
        if (tmp == NULL) {
16504
0
            return -1;
16505
0
        }
16506
0
    }
16507
0
    {
16508
0
        int res;
16509
0
        Py_ssize_t len;
16510
0
        Py_ssize_t i;
16511
0
        if (!PyList_Check(tmp)) {
16512
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16513
0
            goto failed;
16514
0
        }
16515
0
        len = PyList_GET_SIZE(tmp);
16516
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16517
0
        if (defaults == NULL) goto failed;
16518
0
        for (i = 0; i < len; i++) {
16519
0
            expr_ty val;
16520
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16521
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16522
0
                goto failed;
16523
0
            }
16524
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16525
0
            _Py_LeaveRecursiveCall();
16526
0
            Py_DECREF(tmp2);
16527
0
            if (res != 0) goto failed;
16528
0
            if (len != PyList_GET_SIZE(tmp)) {
16529
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16530
0
                goto failed;
16531
0
            }
16532
0
            asdl_seq_SET(defaults, i, val);
16533
0
        }
16534
0
        Py_CLEAR(tmp);
16535
0
    }
16536
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16537
0
                            kwarg, defaults, arena);
16538
0
    if (*out == NULL) goto failed;
16539
0
    return 0;
16540
0
failed:
16541
0
    Py_XDECREF(tmp);
16542
0
    return -1;
16543
0
}
16544
16545
int
16546
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
16547
0
{
16548
0
    PyObject* tmp = NULL;
16549
0
    identifier arg;
16550
0
    expr_ty annotation;
16551
0
    string type_comment;
16552
0
    int lineno;
16553
0
    int col_offset;
16554
0
    int end_lineno;
16555
0
    int end_col_offset;
16556
16557
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16558
0
        return -1;
16559
0
    }
16560
0
    if (tmp == NULL) {
16561
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16562
0
        return -1;
16563
0
    }
16564
0
    else {
16565
0
        int res;
16566
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16567
0
            goto failed;
16568
0
        }
16569
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16570
0
        _Py_LeaveRecursiveCall();
16571
0
        if (res != 0) goto failed;
16572
0
        Py_CLEAR(tmp);
16573
0
    }
16574
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16575
0
        return -1;
16576
0
    }
16577
0
    if (tmp == NULL || tmp == Py_None) {
16578
0
        Py_CLEAR(tmp);
16579
0
        annotation = NULL;
16580
0
    }
16581
0
    else {
16582
0
        int res;
16583
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16584
0
            goto failed;
16585
0
        }
16586
0
        res = obj2ast_expr(state, tmp, &annotation, arena);
16587
0
        _Py_LeaveRecursiveCall();
16588
0
        if (res != 0) goto failed;
16589
0
        Py_CLEAR(tmp);
16590
0
    }
16591
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16592
0
        return -1;
16593
0
    }
16594
0
    if (tmp == NULL || tmp == Py_None) {
16595
0
        Py_CLEAR(tmp);
16596
0
        type_comment = NULL;
16597
0
    }
16598
0
    else {
16599
0
        int res;
16600
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16601
0
            goto failed;
16602
0
        }
16603
0
        res = obj2ast_string(state, tmp, &type_comment, arena);
16604
0
        _Py_LeaveRecursiveCall();
16605
0
        if (res != 0) goto failed;
16606
0
        Py_CLEAR(tmp);
16607
0
    }
16608
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16609
0
        return -1;
16610
0
    }
16611
0
    if (tmp == NULL) {
16612
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16613
0
        return -1;
16614
0
    }
16615
0
    else {
16616
0
        int res;
16617
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16618
0
            goto failed;
16619
0
        }
16620
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16621
0
        _Py_LeaveRecursiveCall();
16622
0
        if (res != 0) goto failed;
16623
0
        Py_CLEAR(tmp);
16624
0
    }
16625
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16626
0
        return -1;
16627
0
    }
16628
0
    if (tmp == NULL) {
16629
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16630
0
        return -1;
16631
0
    }
16632
0
    else {
16633
0
        int res;
16634
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16635
0
            goto failed;
16636
0
        }
16637
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16638
0
        _Py_LeaveRecursiveCall();
16639
0
        if (res != 0) goto failed;
16640
0
        Py_CLEAR(tmp);
16641
0
    }
16642
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16643
0
        return -1;
16644
0
    }
16645
0
    if (tmp == NULL || tmp == Py_None) {
16646
0
        Py_CLEAR(tmp);
16647
0
        end_lineno = lineno;
16648
0
    }
16649
0
    else {
16650
0
        int res;
16651
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16652
0
            goto failed;
16653
0
        }
16654
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16655
0
        _Py_LeaveRecursiveCall();
16656
0
        if (res != 0) goto failed;
16657
0
        Py_CLEAR(tmp);
16658
0
    }
16659
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16660
0
        return -1;
16661
0
    }
16662
0
    if (tmp == NULL || tmp == Py_None) {
16663
0
        Py_CLEAR(tmp);
16664
0
        end_col_offset = col_offset;
16665
0
    }
16666
0
    else {
16667
0
        int res;
16668
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16669
0
            goto failed;
16670
0
        }
16671
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16672
0
        _Py_LeaveRecursiveCall();
16673
0
        if (res != 0) goto failed;
16674
0
        Py_CLEAR(tmp);
16675
0
    }
16676
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16677
0
                      end_lineno, end_col_offset, arena);
16678
0
    if (*out == NULL) goto failed;
16679
0
    return 0;
16680
0
failed:
16681
0
    Py_XDECREF(tmp);
16682
0
    return -1;
16683
0
}
16684
16685
int
16686
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
16687
                PyArena* arena)
16688
0
{
16689
0
    PyObject* tmp = NULL;
16690
0
    identifier arg;
16691
0
    expr_ty value;
16692
0
    int lineno;
16693
0
    int col_offset;
16694
0
    int end_lineno;
16695
0
    int end_col_offset;
16696
16697
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16698
0
        return -1;
16699
0
    }
16700
0
    if (tmp == NULL || tmp == Py_None) {
16701
0
        Py_CLEAR(tmp);
16702
0
        arg = NULL;
16703
0
    }
16704
0
    else {
16705
0
        int res;
16706
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16707
0
            goto failed;
16708
0
        }
16709
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16710
0
        _Py_LeaveRecursiveCall();
16711
0
        if (res != 0) goto failed;
16712
0
        Py_CLEAR(tmp);
16713
0
    }
16714
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16715
0
        return -1;
16716
0
    }
16717
0
    if (tmp == NULL) {
16718
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16719
0
        return -1;
16720
0
    }
16721
0
    else {
16722
0
        int res;
16723
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16724
0
            goto failed;
16725
0
        }
16726
0
        res = obj2ast_expr(state, tmp, &value, arena);
16727
0
        _Py_LeaveRecursiveCall();
16728
0
        if (res != 0) goto failed;
16729
0
        Py_CLEAR(tmp);
16730
0
    }
16731
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16732
0
        return -1;
16733
0
    }
16734
0
    if (tmp == NULL) {
16735
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16736
0
        return -1;
16737
0
    }
16738
0
    else {
16739
0
        int res;
16740
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16741
0
            goto failed;
16742
0
        }
16743
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16744
0
        _Py_LeaveRecursiveCall();
16745
0
        if (res != 0) goto failed;
16746
0
        Py_CLEAR(tmp);
16747
0
    }
16748
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16749
0
        return -1;
16750
0
    }
16751
0
    if (tmp == NULL) {
16752
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16753
0
        return -1;
16754
0
    }
16755
0
    else {
16756
0
        int res;
16757
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16758
0
            goto failed;
16759
0
        }
16760
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16761
0
        _Py_LeaveRecursiveCall();
16762
0
        if (res != 0) goto failed;
16763
0
        Py_CLEAR(tmp);
16764
0
    }
16765
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16766
0
        return -1;
16767
0
    }
16768
0
    if (tmp == NULL || tmp == Py_None) {
16769
0
        Py_CLEAR(tmp);
16770
0
        end_lineno = lineno;
16771
0
    }
16772
0
    else {
16773
0
        int res;
16774
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16775
0
            goto failed;
16776
0
        }
16777
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16778
0
        _Py_LeaveRecursiveCall();
16779
0
        if (res != 0) goto failed;
16780
0
        Py_CLEAR(tmp);
16781
0
    }
16782
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16783
0
        return -1;
16784
0
    }
16785
0
    if (tmp == NULL || tmp == Py_None) {
16786
0
        Py_CLEAR(tmp);
16787
0
        end_col_offset = col_offset;
16788
0
    }
16789
0
    else {
16790
0
        int res;
16791
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16792
0
            goto failed;
16793
0
        }
16794
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16795
0
        _Py_LeaveRecursiveCall();
16796
0
        if (res != 0) goto failed;
16797
0
        Py_CLEAR(tmp);
16798
0
    }
16799
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16800
0
                          end_col_offset, arena);
16801
0
    if (*out == NULL) goto failed;
16802
0
    return 0;
16803
0
failed:
16804
0
    Py_XDECREF(tmp);
16805
0
    return -1;
16806
0
}
16807
16808
int
16809
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
16810
              arena)
16811
0
{
16812
0
    PyObject* tmp = NULL;
16813
0
    identifier name;
16814
0
    identifier asname;
16815
0
    int lineno;
16816
0
    int col_offset;
16817
0
    int end_lineno;
16818
0
    int end_col_offset;
16819
16820
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16821
0
        return -1;
16822
0
    }
16823
0
    if (tmp == NULL) {
16824
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16825
0
        return -1;
16826
0
    }
16827
0
    else {
16828
0
        int res;
16829
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16830
0
            goto failed;
16831
0
        }
16832
0
        res = obj2ast_identifier(state, tmp, &name, arena);
16833
0
        _Py_LeaveRecursiveCall();
16834
0
        if (res != 0) goto failed;
16835
0
        Py_CLEAR(tmp);
16836
0
    }
16837
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16838
0
        return -1;
16839
0
    }
16840
0
    if (tmp == NULL || tmp == Py_None) {
16841
0
        Py_CLEAR(tmp);
16842
0
        asname = NULL;
16843
0
    }
16844
0
    else {
16845
0
        int res;
16846
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16847
0
            goto failed;
16848
0
        }
16849
0
        res = obj2ast_identifier(state, tmp, &asname, arena);
16850
0
        _Py_LeaveRecursiveCall();
16851
0
        if (res != 0) goto failed;
16852
0
        Py_CLEAR(tmp);
16853
0
    }
16854
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16855
0
        return -1;
16856
0
    }
16857
0
    if (tmp == NULL) {
16858
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16859
0
        return -1;
16860
0
    }
16861
0
    else {
16862
0
        int res;
16863
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16864
0
            goto failed;
16865
0
        }
16866
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16867
0
        _Py_LeaveRecursiveCall();
16868
0
        if (res != 0) goto failed;
16869
0
        Py_CLEAR(tmp);
16870
0
    }
16871
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16872
0
        return -1;
16873
0
    }
16874
0
    if (tmp == NULL) {
16875
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16876
0
        return -1;
16877
0
    }
16878
0
    else {
16879
0
        int res;
16880
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16881
0
            goto failed;
16882
0
        }
16883
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16884
0
        _Py_LeaveRecursiveCall();
16885
0
        if (res != 0) goto failed;
16886
0
        Py_CLEAR(tmp);
16887
0
    }
16888
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16889
0
        return -1;
16890
0
    }
16891
0
    if (tmp == NULL || tmp == Py_None) {
16892
0
        Py_CLEAR(tmp);
16893
0
        end_lineno = lineno;
16894
0
    }
16895
0
    else {
16896
0
        int res;
16897
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16898
0
            goto failed;
16899
0
        }
16900
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16901
0
        _Py_LeaveRecursiveCall();
16902
0
        if (res != 0) goto failed;
16903
0
        Py_CLEAR(tmp);
16904
0
    }
16905
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16906
0
        return -1;
16907
0
    }
16908
0
    if (tmp == NULL || tmp == Py_None) {
16909
0
        Py_CLEAR(tmp);
16910
0
        end_col_offset = col_offset;
16911
0
    }
16912
0
    else {
16913
0
        int res;
16914
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16915
0
            goto failed;
16916
0
        }
16917
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16918
0
        _Py_LeaveRecursiveCall();
16919
0
        if (res != 0) goto failed;
16920
0
        Py_CLEAR(tmp);
16921
0
    }
16922
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16923
0
                        end_col_offset, arena);
16924
0
    if (*out == NULL) goto failed;
16925
0
    return 0;
16926
0
failed:
16927
0
    Py_XDECREF(tmp);
16928
0
    return -1;
16929
0
}
16930
16931
int
16932
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
16933
                 PyArena* arena)
16934
0
{
16935
0
    PyObject* tmp = NULL;
16936
0
    expr_ty context_expr;
16937
0
    expr_ty optional_vars;
16938
16939
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
16940
0
        return -1;
16941
0
    }
16942
0
    if (tmp == NULL) {
16943
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
16944
0
        return -1;
16945
0
    }
16946
0
    else {
16947
0
        int res;
16948
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16949
0
            goto failed;
16950
0
        }
16951
0
        res = obj2ast_expr(state, tmp, &context_expr, arena);
16952
0
        _Py_LeaveRecursiveCall();
16953
0
        if (res != 0) goto failed;
16954
0
        Py_CLEAR(tmp);
16955
0
    }
16956
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
16957
0
        return -1;
16958
0
    }
16959
0
    if (tmp == NULL || tmp == Py_None) {
16960
0
        Py_CLEAR(tmp);
16961
0
        optional_vars = NULL;
16962
0
    }
16963
0
    else {
16964
0
        int res;
16965
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16966
0
            goto failed;
16967
0
        }
16968
0
        res = obj2ast_expr(state, tmp, &optional_vars, arena);
16969
0
        _Py_LeaveRecursiveCall();
16970
0
        if (res != 0) goto failed;
16971
0
        Py_CLEAR(tmp);
16972
0
    }
16973
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
16974
0
    if (*out == NULL) goto failed;
16975
0
    return 0;
16976
0
failed:
16977
0
    Py_XDECREF(tmp);
16978
0
    return -1;
16979
0
}
16980
16981
int
16982
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
16983
                   PyArena* arena)
16984
0
{
16985
0
    PyObject* tmp = NULL;
16986
0
    pattern_ty pattern;
16987
0
    expr_ty guard;
16988
0
    asdl_stmt_seq* body;
16989
16990
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
16991
0
        return -1;
16992
0
    }
16993
0
    if (tmp == NULL) {
16994
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
16995
0
        return -1;
16996
0
    }
16997
0
    else {
16998
0
        int res;
16999
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17000
0
            goto failed;
17001
0
        }
17002
0
        res = obj2ast_pattern(state, tmp, &pattern, arena);
17003
0
        _Py_LeaveRecursiveCall();
17004
0
        if (res != 0) goto failed;
17005
0
        Py_CLEAR(tmp);
17006
0
    }
17007
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17008
0
        return -1;
17009
0
    }
17010
0
    if (tmp == NULL || tmp == Py_None) {
17011
0
        Py_CLEAR(tmp);
17012
0
        guard = NULL;
17013
0
    }
17014
0
    else {
17015
0
        int res;
17016
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17017
0
            goto failed;
17018
0
        }
17019
0
        res = obj2ast_expr(state, tmp, &guard, arena);
17020
0
        _Py_LeaveRecursiveCall();
17021
0
        if (res != 0) goto failed;
17022
0
        Py_CLEAR(tmp);
17023
0
    }
17024
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17025
0
        return -1;
17026
0
    }
17027
0
    if (tmp == NULL) {
17028
0
        tmp = PyList_New(0);
17029
0
        if (tmp == NULL) {
17030
0
            return -1;
17031
0
        }
17032
0
    }
17033
0
    {
17034
0
        int res;
17035
0
        Py_ssize_t len;
17036
0
        Py_ssize_t i;
17037
0
        if (!PyList_Check(tmp)) {
17038
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17039
0
            goto failed;
17040
0
        }
17041
0
        len = PyList_GET_SIZE(tmp);
17042
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17043
0
        if (body == NULL) goto failed;
17044
0
        for (i = 0; i < len; i++) {
17045
0
            stmt_ty val;
17046
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17047
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17048
0
                goto failed;
17049
0
            }
17050
0
            res = obj2ast_stmt(state, tmp2, &val, arena);
17051
0
            _Py_LeaveRecursiveCall();
17052
0
            Py_DECREF(tmp2);
17053
0
            if (res != 0) goto failed;
17054
0
            if (len != PyList_GET_SIZE(tmp)) {
17055
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17056
0
                goto failed;
17057
0
            }
17058
0
            asdl_seq_SET(body, i, val);
17059
0
        }
17060
0
        Py_CLEAR(tmp);
17061
0
    }
17062
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17063
0
    if (*out == NULL) goto failed;
17064
0
    return 0;
17065
0
failed:
17066
0
    Py_XDECREF(tmp);
17067
0
    return -1;
17068
0
}
17069
17070
int
17071
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
17072
                PyArena* arena)
17073
0
{
17074
0
    int isinstance;
17075
17076
0
    PyObject *tmp = NULL;
17077
0
    PyObject *tp;
17078
0
    int lineno;
17079
0
    int col_offset;
17080
0
    int end_lineno;
17081
0
    int end_col_offset;
17082
17083
0
    if (obj == Py_None) {
17084
0
        *out = NULL;
17085
0
        return 0;
17086
0
    }
17087
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17088
0
        return -1;
17089
0
    }
17090
0
    if (tmp == NULL) {
17091
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17092
0
        return -1;
17093
0
    }
17094
0
    else {
17095
0
        int res;
17096
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17097
0
            goto failed;
17098
0
        }
17099
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17100
0
        _Py_LeaveRecursiveCall();
17101
0
        if (res != 0) goto failed;
17102
0
        Py_CLEAR(tmp);
17103
0
    }
17104
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17105
0
        return -1;
17106
0
    }
17107
0
    if (tmp == NULL) {
17108
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17109
0
        return -1;
17110
0
    }
17111
0
    else {
17112
0
        int res;
17113
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17114
0
            goto failed;
17115
0
        }
17116
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17117
0
        _Py_LeaveRecursiveCall();
17118
0
        if (res != 0) goto failed;
17119
0
        Py_CLEAR(tmp);
17120
0
    }
17121
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17122
0
        return -1;
17123
0
    }
17124
0
    if (tmp == NULL) {
17125
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17126
0
        return -1;
17127
0
    }
17128
0
    else {
17129
0
        int res;
17130
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17131
0
            goto failed;
17132
0
        }
17133
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17134
0
        _Py_LeaveRecursiveCall();
17135
0
        if (res != 0) goto failed;
17136
0
        Py_CLEAR(tmp);
17137
0
    }
17138
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17139
0
        return -1;
17140
0
    }
17141
0
    if (tmp == NULL) {
17142
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17143
0
        return -1;
17144
0
    }
17145
0
    else {
17146
0
        int res;
17147
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17148
0
            goto failed;
17149
0
        }
17150
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17151
0
        _Py_LeaveRecursiveCall();
17152
0
        if (res != 0) goto failed;
17153
0
        Py_CLEAR(tmp);
17154
0
    }
17155
0
    tp = state->MatchValue_type;
17156
0
    isinstance = PyObject_IsInstance(obj, tp);
17157
0
    if (isinstance == -1) {
17158
0
        return -1;
17159
0
    }
17160
0
    if (isinstance) {
17161
0
        expr_ty value;
17162
17163
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17164
0
            return -1;
17165
0
        }
17166
0
        if (tmp == NULL) {
17167
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17168
0
            return -1;
17169
0
        }
17170
0
        else {
17171
0
            int res;
17172
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17173
0
                goto failed;
17174
0
            }
17175
0
            res = obj2ast_expr(state, tmp, &value, arena);
17176
0
            _Py_LeaveRecursiveCall();
17177
0
            if (res != 0) goto failed;
17178
0
            Py_CLEAR(tmp);
17179
0
        }
17180
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17181
0
                                 end_col_offset, arena);
17182
0
        if (*out == NULL) goto failed;
17183
0
        return 0;
17184
0
    }
17185
0
    tp = state->MatchSingleton_type;
17186
0
    isinstance = PyObject_IsInstance(obj, tp);
17187
0
    if (isinstance == -1) {
17188
0
        return -1;
17189
0
    }
17190
0
    if (isinstance) {
17191
0
        constant value;
17192
17193
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17194
0
            return -1;
17195
0
        }
17196
0
        if (tmp == NULL) {
17197
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17198
0
            return -1;
17199
0
        }
17200
0
        else {
17201
0
            int res;
17202
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17203
0
                goto failed;
17204
0
            }
17205
0
            res = obj2ast_constant(state, tmp, &value, arena);
17206
0
            _Py_LeaveRecursiveCall();
17207
0
            if (res != 0) goto failed;
17208
0
            Py_CLEAR(tmp);
17209
0
        }
17210
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17211
0
                                     end_col_offset, arena);
17212
0
        if (*out == NULL) goto failed;
17213
0
        return 0;
17214
0
    }
17215
0
    tp = state->MatchSequence_type;
17216
0
    isinstance = PyObject_IsInstance(obj, tp);
17217
0
    if (isinstance == -1) {
17218
0
        return -1;
17219
0
    }
17220
0
    if (isinstance) {
17221
0
        asdl_pattern_seq* patterns;
17222
17223
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17224
0
            return -1;
17225
0
        }
17226
0
        if (tmp == NULL) {
17227
0
            tmp = PyList_New(0);
17228
0
            if (tmp == NULL) {
17229
0
                return -1;
17230
0
            }
17231
0
        }
17232
0
        {
17233
0
            int res;
17234
0
            Py_ssize_t len;
17235
0
            Py_ssize_t i;
17236
0
            if (!PyList_Check(tmp)) {
17237
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17238
0
                goto failed;
17239
0
            }
17240
0
            len = PyList_GET_SIZE(tmp);
17241
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17242
0
            if (patterns == NULL) goto failed;
17243
0
            for (i = 0; i < len; i++) {
17244
0
                pattern_ty val;
17245
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17246
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17247
0
                    goto failed;
17248
0
                }
17249
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17250
0
                _Py_LeaveRecursiveCall();
17251
0
                Py_DECREF(tmp2);
17252
0
                if (res != 0) goto failed;
17253
0
                if (len != PyList_GET_SIZE(tmp)) {
17254
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17255
0
                    goto failed;
17256
0
                }
17257
0
                asdl_seq_SET(patterns, i, val);
17258
0
            }
17259
0
            Py_CLEAR(tmp);
17260
0
        }
17261
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17262
0
                                    end_col_offset, arena);
17263
0
        if (*out == NULL) goto failed;
17264
0
        return 0;
17265
0
    }
17266
0
    tp = state->MatchMapping_type;
17267
0
    isinstance = PyObject_IsInstance(obj, tp);
17268
0
    if (isinstance == -1) {
17269
0
        return -1;
17270
0
    }
17271
0
    if (isinstance) {
17272
0
        asdl_expr_seq* keys;
17273
0
        asdl_pattern_seq* patterns;
17274
0
        identifier rest;
17275
17276
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17277
0
            return -1;
17278
0
        }
17279
0
        if (tmp == NULL) {
17280
0
            tmp = PyList_New(0);
17281
0
            if (tmp == NULL) {
17282
0
                return -1;
17283
0
            }
17284
0
        }
17285
0
        {
17286
0
            int res;
17287
0
            Py_ssize_t len;
17288
0
            Py_ssize_t i;
17289
0
            if (!PyList_Check(tmp)) {
17290
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17291
0
                goto failed;
17292
0
            }
17293
0
            len = PyList_GET_SIZE(tmp);
17294
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17295
0
            if (keys == NULL) goto failed;
17296
0
            for (i = 0; i < len; i++) {
17297
0
                expr_ty val;
17298
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17299
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17300
0
                    goto failed;
17301
0
                }
17302
0
                res = obj2ast_expr(state, tmp2, &val, arena);
17303
0
                _Py_LeaveRecursiveCall();
17304
0
                Py_DECREF(tmp2);
17305
0
                if (res != 0) goto failed;
17306
0
                if (len != PyList_GET_SIZE(tmp)) {
17307
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17308
0
                    goto failed;
17309
0
                }
17310
0
                asdl_seq_SET(keys, i, val);
17311
0
            }
17312
0
            Py_CLEAR(tmp);
17313
0
        }
17314
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17315
0
            return -1;
17316
0
        }
17317
0
        if (tmp == NULL) {
17318
0
            tmp = PyList_New(0);
17319
0
            if (tmp == NULL) {
17320
0
                return -1;
17321
0
            }
17322
0
        }
17323
0
        {
17324
0
            int res;
17325
0
            Py_ssize_t len;
17326
0
            Py_ssize_t i;
17327
0
            if (!PyList_Check(tmp)) {
17328
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17329
0
                goto failed;
17330
0
            }
17331
0
            len = PyList_GET_SIZE(tmp);
17332
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17333
0
            if (patterns == NULL) goto failed;
17334
0
            for (i = 0; i < len; i++) {
17335
0
                pattern_ty val;
17336
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17337
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17338
0
                    goto failed;
17339
0
                }
17340
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17341
0
                _Py_LeaveRecursiveCall();
17342
0
                Py_DECREF(tmp2);
17343
0
                if (res != 0) goto failed;
17344
0
                if (len != PyList_GET_SIZE(tmp)) {
17345
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17346
0
                    goto failed;
17347
0
                }
17348
0
                asdl_seq_SET(patterns, i, val);
17349
0
            }
17350
0
            Py_CLEAR(tmp);
17351
0
        }
17352
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17353
0
            return -1;
17354
0
        }
17355
0
        if (tmp == NULL || tmp == Py_None) {
17356
0
            Py_CLEAR(tmp);
17357
0
            rest = NULL;
17358
0
        }
17359
0
        else {
17360
0
            int res;
17361
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17362
0
                goto failed;
17363
0
            }
17364
0
            res = obj2ast_identifier(state, tmp, &rest, arena);
17365
0
            _Py_LeaveRecursiveCall();
17366
0
            if (res != 0) goto failed;
17367
0
            Py_CLEAR(tmp);
17368
0
        }
17369
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17370
0
                                   end_lineno, end_col_offset, arena);
17371
0
        if (*out == NULL) goto failed;
17372
0
        return 0;
17373
0
    }
17374
0
    tp = state->MatchClass_type;
17375
0
    isinstance = PyObject_IsInstance(obj, tp);
17376
0
    if (isinstance == -1) {
17377
0
        return -1;
17378
0
    }
17379
0
    if (isinstance) {
17380
0
        expr_ty cls;
17381
0
        asdl_pattern_seq* patterns;
17382
0
        asdl_identifier_seq* kwd_attrs;
17383
0
        asdl_pattern_seq* kwd_patterns;
17384
17385
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17386
0
            return -1;
17387
0
        }
17388
0
        if (tmp == NULL) {
17389
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17390
0
            return -1;
17391
0
        }
17392
0
        else {
17393
0
            int res;
17394
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17395
0
                goto failed;
17396
0
            }
17397
0
            res = obj2ast_expr(state, tmp, &cls, arena);
17398
0
            _Py_LeaveRecursiveCall();
17399
0
            if (res != 0) goto failed;
17400
0
            Py_CLEAR(tmp);
17401
0
        }
17402
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17403
0
            return -1;
17404
0
        }
17405
0
        if (tmp == NULL) {
17406
0
            tmp = PyList_New(0);
17407
0
            if (tmp == NULL) {
17408
0
                return -1;
17409
0
            }
17410
0
        }
17411
0
        {
17412
0
            int res;
17413
0
            Py_ssize_t len;
17414
0
            Py_ssize_t i;
17415
0
            if (!PyList_Check(tmp)) {
17416
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17417
0
                goto failed;
17418
0
            }
17419
0
            len = PyList_GET_SIZE(tmp);
17420
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17421
0
            if (patterns == NULL) goto failed;
17422
0
            for (i = 0; i < len; i++) {
17423
0
                pattern_ty val;
17424
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17425
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17426
0
                    goto failed;
17427
0
                }
17428
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17429
0
                _Py_LeaveRecursiveCall();
17430
0
                Py_DECREF(tmp2);
17431
0
                if (res != 0) goto failed;
17432
0
                if (len != PyList_GET_SIZE(tmp)) {
17433
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17434
0
                    goto failed;
17435
0
                }
17436
0
                asdl_seq_SET(patterns, i, val);
17437
0
            }
17438
0
            Py_CLEAR(tmp);
17439
0
        }
17440
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17441
0
            return -1;
17442
0
        }
17443
0
        if (tmp == NULL) {
17444
0
            tmp = PyList_New(0);
17445
0
            if (tmp == NULL) {
17446
0
                return -1;
17447
0
            }
17448
0
        }
17449
0
        {
17450
0
            int res;
17451
0
            Py_ssize_t len;
17452
0
            Py_ssize_t i;
17453
0
            if (!PyList_Check(tmp)) {
17454
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17455
0
                goto failed;
17456
0
            }
17457
0
            len = PyList_GET_SIZE(tmp);
17458
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17459
0
            if (kwd_attrs == NULL) goto failed;
17460
0
            for (i = 0; i < len; i++) {
17461
0
                identifier val;
17462
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17463
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17464
0
                    goto failed;
17465
0
                }
17466
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
17467
0
                _Py_LeaveRecursiveCall();
17468
0
                Py_DECREF(tmp2);
17469
0
                if (res != 0) goto failed;
17470
0
                if (len != PyList_GET_SIZE(tmp)) {
17471
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17472
0
                    goto failed;
17473
0
                }
17474
0
                asdl_seq_SET(kwd_attrs, i, val);
17475
0
            }
17476
0
            Py_CLEAR(tmp);
17477
0
        }
17478
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17479
0
            return -1;
17480
0
        }
17481
0
        if (tmp == NULL) {
17482
0
            tmp = PyList_New(0);
17483
0
            if (tmp == NULL) {
17484
0
                return -1;
17485
0
            }
17486
0
        }
17487
0
        {
17488
0
            int res;
17489
0
            Py_ssize_t len;
17490
0
            Py_ssize_t i;
17491
0
            if (!PyList_Check(tmp)) {
17492
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17493
0
                goto failed;
17494
0
            }
17495
0
            len = PyList_GET_SIZE(tmp);
17496
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17497
0
            if (kwd_patterns == NULL) goto failed;
17498
0
            for (i = 0; i < len; i++) {
17499
0
                pattern_ty val;
17500
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17501
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17502
0
                    goto failed;
17503
0
                }
17504
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17505
0
                _Py_LeaveRecursiveCall();
17506
0
                Py_DECREF(tmp2);
17507
0
                if (res != 0) goto failed;
17508
0
                if (len != PyList_GET_SIZE(tmp)) {
17509
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17510
0
                    goto failed;
17511
0
                }
17512
0
                asdl_seq_SET(kwd_patterns, i, val);
17513
0
            }
17514
0
            Py_CLEAR(tmp);
17515
0
        }
17516
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17517
0
                                 lineno, col_offset, end_lineno,
17518
0
                                 end_col_offset, arena);
17519
0
        if (*out == NULL) goto failed;
17520
0
        return 0;
17521
0
    }
17522
0
    tp = state->MatchStar_type;
17523
0
    isinstance = PyObject_IsInstance(obj, tp);
17524
0
    if (isinstance == -1) {
17525
0
        return -1;
17526
0
    }
17527
0
    if (isinstance) {
17528
0
        identifier name;
17529
17530
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17531
0
            return -1;
17532
0
        }
17533
0
        if (tmp == NULL || tmp == Py_None) {
17534
0
            Py_CLEAR(tmp);
17535
0
            name = NULL;
17536
0
        }
17537
0
        else {
17538
0
            int res;
17539
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17540
0
                goto failed;
17541
0
            }
17542
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17543
0
            _Py_LeaveRecursiveCall();
17544
0
            if (res != 0) goto failed;
17545
0
            Py_CLEAR(tmp);
17546
0
        }
17547
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17548
0
                                end_col_offset, arena);
17549
0
        if (*out == NULL) goto failed;
17550
0
        return 0;
17551
0
    }
17552
0
    tp = state->MatchAs_type;
17553
0
    isinstance = PyObject_IsInstance(obj, tp);
17554
0
    if (isinstance == -1) {
17555
0
        return -1;
17556
0
    }
17557
0
    if (isinstance) {
17558
0
        pattern_ty pattern;
17559
0
        identifier name;
17560
17561
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17562
0
            return -1;
17563
0
        }
17564
0
        if (tmp == NULL || tmp == Py_None) {
17565
0
            Py_CLEAR(tmp);
17566
0
            pattern = NULL;
17567
0
        }
17568
0
        else {
17569
0
            int res;
17570
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17571
0
                goto failed;
17572
0
            }
17573
0
            res = obj2ast_pattern(state, tmp, &pattern, arena);
17574
0
            _Py_LeaveRecursiveCall();
17575
0
            if (res != 0) goto failed;
17576
0
            Py_CLEAR(tmp);
17577
0
        }
17578
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17579
0
            return -1;
17580
0
        }
17581
0
        if (tmp == NULL || tmp == Py_None) {
17582
0
            Py_CLEAR(tmp);
17583
0
            name = NULL;
17584
0
        }
17585
0
        else {
17586
0
            int res;
17587
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17588
0
                goto failed;
17589
0
            }
17590
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17591
0
            _Py_LeaveRecursiveCall();
17592
0
            if (res != 0) goto failed;
17593
0
            Py_CLEAR(tmp);
17594
0
        }
17595
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17596
0
                              end_col_offset, arena);
17597
0
        if (*out == NULL) goto failed;
17598
0
        return 0;
17599
0
    }
17600
0
    tp = state->MatchOr_type;
17601
0
    isinstance = PyObject_IsInstance(obj, tp);
17602
0
    if (isinstance == -1) {
17603
0
        return -1;
17604
0
    }
17605
0
    if (isinstance) {
17606
0
        asdl_pattern_seq* patterns;
17607
17608
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17609
0
            return -1;
17610
0
        }
17611
0
        if (tmp == NULL) {
17612
0
            tmp = PyList_New(0);
17613
0
            if (tmp == NULL) {
17614
0
                return -1;
17615
0
            }
17616
0
        }
17617
0
        {
17618
0
            int res;
17619
0
            Py_ssize_t len;
17620
0
            Py_ssize_t i;
17621
0
            if (!PyList_Check(tmp)) {
17622
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17623
0
                goto failed;
17624
0
            }
17625
0
            len = PyList_GET_SIZE(tmp);
17626
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17627
0
            if (patterns == NULL) goto failed;
17628
0
            for (i = 0; i < len; i++) {
17629
0
                pattern_ty val;
17630
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17631
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17632
0
                    goto failed;
17633
0
                }
17634
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17635
0
                _Py_LeaveRecursiveCall();
17636
0
                Py_DECREF(tmp2);
17637
0
                if (res != 0) goto failed;
17638
0
                if (len != PyList_GET_SIZE(tmp)) {
17639
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17640
0
                    goto failed;
17641
0
                }
17642
0
                asdl_seq_SET(patterns, i, val);
17643
0
            }
17644
0
            Py_CLEAR(tmp);
17645
0
        }
17646
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17647
0
                              end_col_offset, arena);
17648
0
        if (*out == NULL) goto failed;
17649
0
        return 0;
17650
0
    }
17651
17652
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17653
0
    failed:
17654
0
    Py_XDECREF(tmp);
17655
0
    return -1;
17656
0
}
17657
17658
int
17659
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17660
                    out, PyArena* arena)
17661
0
{
17662
0
    int isinstance;
17663
17664
0
    PyObject *tmp = NULL;
17665
0
    PyObject *tp;
17666
17667
0
    if (obj == Py_None) {
17668
0
        *out = NULL;
17669
0
        return 0;
17670
0
    }
17671
0
    tp = state->TypeIgnore_type;
17672
0
    isinstance = PyObject_IsInstance(obj, tp);
17673
0
    if (isinstance == -1) {
17674
0
        return -1;
17675
0
    }
17676
0
    if (isinstance) {
17677
0
        int lineno;
17678
0
        string tag;
17679
17680
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17681
0
            return -1;
17682
0
        }
17683
0
        if (tmp == NULL) {
17684
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17685
0
            return -1;
17686
0
        }
17687
0
        else {
17688
0
            int res;
17689
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17690
0
                goto failed;
17691
0
            }
17692
0
            res = obj2ast_int(state, tmp, &lineno, arena);
17693
0
            _Py_LeaveRecursiveCall();
17694
0
            if (res != 0) goto failed;
17695
0
            Py_CLEAR(tmp);
17696
0
        }
17697
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17698
0
            return -1;
17699
0
        }
17700
0
        if (tmp == NULL) {
17701
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17702
0
            return -1;
17703
0
        }
17704
0
        else {
17705
0
            int res;
17706
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17707
0
                goto failed;
17708
0
            }
17709
0
            res = obj2ast_string(state, tmp, &tag, arena);
17710
0
            _Py_LeaveRecursiveCall();
17711
0
            if (res != 0) goto failed;
17712
0
            Py_CLEAR(tmp);
17713
0
        }
17714
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17715
0
        if (*out == NULL) goto failed;
17716
0
        return 0;
17717
0
    }
17718
17719
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17720
0
    failed:
17721
0
    Py_XDECREF(tmp);
17722
0
    return -1;
17723
0
}
17724
17725
int
17726
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17727
                   PyArena* arena)
17728
0
{
17729
0
    int isinstance;
17730
17731
0
    PyObject *tmp = NULL;
17732
0
    PyObject *tp;
17733
0
    int lineno;
17734
0
    int col_offset;
17735
0
    int end_lineno;
17736
0
    int end_col_offset;
17737
17738
0
    if (obj == Py_None) {
17739
0
        *out = NULL;
17740
0
        return 0;
17741
0
    }
17742
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17743
0
        return -1;
17744
0
    }
17745
0
    if (tmp == NULL) {
17746
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17747
0
        return -1;
17748
0
    }
17749
0
    else {
17750
0
        int res;
17751
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17752
0
            goto failed;
17753
0
        }
17754
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17755
0
        _Py_LeaveRecursiveCall();
17756
0
        if (res != 0) goto failed;
17757
0
        Py_CLEAR(tmp);
17758
0
    }
17759
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17760
0
        return -1;
17761
0
    }
17762
0
    if (tmp == NULL) {
17763
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17764
0
        return -1;
17765
0
    }
17766
0
    else {
17767
0
        int res;
17768
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17769
0
            goto failed;
17770
0
        }
17771
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17772
0
        _Py_LeaveRecursiveCall();
17773
0
        if (res != 0) goto failed;
17774
0
        Py_CLEAR(tmp);
17775
0
    }
17776
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17777
0
        return -1;
17778
0
    }
17779
0
    if (tmp == NULL) {
17780
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17781
0
        return -1;
17782
0
    }
17783
0
    else {
17784
0
        int res;
17785
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17786
0
            goto failed;
17787
0
        }
17788
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17789
0
        _Py_LeaveRecursiveCall();
17790
0
        if (res != 0) goto failed;
17791
0
        Py_CLEAR(tmp);
17792
0
    }
17793
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17794
0
        return -1;
17795
0
    }
17796
0
    if (tmp == NULL) {
17797
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17798
0
        return -1;
17799
0
    }
17800
0
    else {
17801
0
        int res;
17802
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17803
0
            goto failed;
17804
0
        }
17805
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17806
0
        _Py_LeaveRecursiveCall();
17807
0
        if (res != 0) goto failed;
17808
0
        Py_CLEAR(tmp);
17809
0
    }
17810
0
    tp = state->TypeVar_type;
17811
0
    isinstance = PyObject_IsInstance(obj, tp);
17812
0
    if (isinstance == -1) {
17813
0
        return -1;
17814
0
    }
17815
0
    if (isinstance) {
17816
0
        identifier name;
17817
0
        expr_ty bound;
17818
0
        expr_ty default_value;
17819
17820
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17821
0
            return -1;
17822
0
        }
17823
0
        if (tmp == NULL) {
17824
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17825
0
            return -1;
17826
0
        }
17827
0
        else {
17828
0
            int res;
17829
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17830
0
                goto failed;
17831
0
            }
17832
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17833
0
            _Py_LeaveRecursiveCall();
17834
0
            if (res != 0) goto failed;
17835
0
            Py_CLEAR(tmp);
17836
0
        }
17837
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17838
0
            return -1;
17839
0
        }
17840
0
        if (tmp == NULL || tmp == Py_None) {
17841
0
            Py_CLEAR(tmp);
17842
0
            bound = NULL;
17843
0
        }
17844
0
        else {
17845
0
            int res;
17846
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17847
0
                goto failed;
17848
0
            }
17849
0
            res = obj2ast_expr(state, tmp, &bound, arena);
17850
0
            _Py_LeaveRecursiveCall();
17851
0
            if (res != 0) goto failed;
17852
0
            Py_CLEAR(tmp);
17853
0
        }
17854
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17855
0
            return -1;
17856
0
        }
17857
0
        if (tmp == NULL || tmp == Py_None) {
17858
0
            Py_CLEAR(tmp);
17859
0
            default_value = NULL;
17860
0
        }
17861
0
        else {
17862
0
            int res;
17863
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17864
0
                goto failed;
17865
0
            }
17866
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17867
0
            _Py_LeaveRecursiveCall();
17868
0
            if (res != 0) goto failed;
17869
0
            Py_CLEAR(tmp);
17870
0
        }
17871
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17872
0
                              end_lineno, end_col_offset, arena);
17873
0
        if (*out == NULL) goto failed;
17874
0
        return 0;
17875
0
    }
17876
0
    tp = state->ParamSpec_type;
17877
0
    isinstance = PyObject_IsInstance(obj, tp);
17878
0
    if (isinstance == -1) {
17879
0
        return -1;
17880
0
    }
17881
0
    if (isinstance) {
17882
0
        identifier name;
17883
0
        expr_ty default_value;
17884
17885
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17886
0
            return -1;
17887
0
        }
17888
0
        if (tmp == NULL) {
17889
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17890
0
            return -1;
17891
0
        }
17892
0
        else {
17893
0
            int res;
17894
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17895
0
                goto failed;
17896
0
            }
17897
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17898
0
            _Py_LeaveRecursiveCall();
17899
0
            if (res != 0) goto failed;
17900
0
            Py_CLEAR(tmp);
17901
0
        }
17902
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17903
0
            return -1;
17904
0
        }
17905
0
        if (tmp == NULL || tmp == Py_None) {
17906
0
            Py_CLEAR(tmp);
17907
0
            default_value = NULL;
17908
0
        }
17909
0
        else {
17910
0
            int res;
17911
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17912
0
                goto failed;
17913
0
            }
17914
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17915
0
            _Py_LeaveRecursiveCall();
17916
0
            if (res != 0) goto failed;
17917
0
            Py_CLEAR(tmp);
17918
0
        }
17919
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
17920
0
                                end_lineno, end_col_offset, arena);
17921
0
        if (*out == NULL) goto failed;
17922
0
        return 0;
17923
0
    }
17924
0
    tp = state->TypeVarTuple_type;
17925
0
    isinstance = PyObject_IsInstance(obj, tp);
17926
0
    if (isinstance == -1) {
17927
0
        return -1;
17928
0
    }
17929
0
    if (isinstance) {
17930
0
        identifier name;
17931
0
        expr_ty default_value;
17932
17933
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17934
0
            return -1;
17935
0
        }
17936
0
        if (tmp == NULL) {
17937
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
17938
0
            return -1;
17939
0
        }
17940
0
        else {
17941
0
            int res;
17942
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17943
0
                goto failed;
17944
0
            }
17945
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17946
0
            _Py_LeaveRecursiveCall();
17947
0
            if (res != 0) goto failed;
17948
0
            Py_CLEAR(tmp);
17949
0
        }
17950
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17951
0
            return -1;
17952
0
        }
17953
0
        if (tmp == NULL || tmp == Py_None) {
17954
0
            Py_CLEAR(tmp);
17955
0
            default_value = NULL;
17956
0
        }
17957
0
        else {
17958
0
            int res;
17959
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17960
0
                goto failed;
17961
0
            }
17962
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17963
0
            _Py_LeaveRecursiveCall();
17964
0
            if (res != 0) goto failed;
17965
0
            Py_CLEAR(tmp);
17966
0
        }
17967
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
17968
0
                                   end_lineno, end_col_offset, arena);
17969
0
        if (*out == NULL) goto failed;
17970
0
        return 0;
17971
0
    }
17972
17973
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
17974
0
    failed:
17975
0
    Py_XDECREF(tmp);
17976
0
    return -1;
17977
0
}
17978
17979
17980
static int
17981
astmodule_exec(PyObject *m)
17982
1
{
17983
1
    struct ast_state *state = get_ast_state();
17984
1
    if (state == NULL) {
17985
0
        return -1;
17986
0
    }
17987
1
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
17988
0
        return -1;
17989
0
    }
17990
1
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
17991
0
        return -1;
17992
0
    }
17993
1
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
17994
0
        return -1;
17995
0
    }
17996
1
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
17997
0
        return -1;
17998
0
    }
17999
1
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18000
0
        return -1;
18001
0
    }
18002
1
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18003
0
        return -1;
18004
0
    }
18005
1
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18006
0
        return -1;
18007
0
    }
18008
1
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18009
0
        return -1;
18010
0
    }
18011
1
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18012
0
        return -1;
18013
0
    }
18014
1
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18015
0
        {
18016
0
        return -1;
18017
0
    }
18018
1
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18019
0
        return -1;
18020
0
    }
18021
1
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18022
0
        return -1;
18023
0
    }
18024
1
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18025
1
        state->AsyncFunctionDef_type) < 0) {
18026
0
        return -1;
18027
0
    }
18028
1
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18029
0
        return -1;
18030
0
    }
18031
1
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18032
0
        return -1;
18033
0
    }
18034
1
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18035
0
        return -1;
18036
0
    }
18037
1
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18038
0
        return -1;
18039
0
    }
18040
1
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18041
0
        return -1;
18042
0
    }
18043
1
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18044
0
        return -1;
18045
0
    }
18046
1
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18047
0
        return -1;
18048
0
    }
18049
1
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18050
0
        return -1;
18051
0
    }
18052
1
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18053
0
        return -1;
18054
0
    }
18055
1
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18056
0
        return -1;
18057
0
    }
18058
1
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18059
0
        return -1;
18060
0
    }
18061
1
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18062
0
        return -1;
18063
0
    }
18064
1
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18065
0
        return -1;
18066
0
    }
18067
1
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18068
0
        return -1;
18069
0
    }
18070
1
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18071
0
        return -1;
18072
0
    }
18073
1
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18074
0
        return -1;
18075
0
    }
18076
1
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18077
0
        return -1;
18078
0
    }
18079
1
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18080
0
        return -1;
18081
0
    }
18082
1
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18083
0
        return -1;
18084
0
    }
18085
1
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18086
0
        return -1;
18087
0
    }
18088
1
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18089
0
        return -1;
18090
0
    }
18091
1
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18092
0
        return -1;
18093
0
    }
18094
1
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18095
0
        return -1;
18096
0
    }
18097
1
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18098
0
        return -1;
18099
0
    }
18100
1
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18101
0
        return -1;
18102
0
    }
18103
1
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18104
0
        return -1;
18105
0
    }
18106
1
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18107
0
        return -1;
18108
0
    }
18109
1
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18110
0
        return -1;
18111
0
    }
18112
1
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18113
0
        return -1;
18114
0
    }
18115
1
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18116
0
        return -1;
18117
0
    }
18118
1
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18119
0
        return -1;
18120
0
    }
18121
1
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18122
0
        return -1;
18123
0
    }
18124
1
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18125
0
        return -1;
18126
0
    }
18127
1
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18128
0
        return -1;
18129
0
    }
18130
1
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18131
0
        return -1;
18132
0
    }
18133
1
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18134
0
        return -1;
18135
0
    }
18136
1
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18137
0
        return -1;
18138
0
    }
18139
1
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18140
0
        return -1;
18141
0
    }
18142
1
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18143
0
        {
18144
0
        return -1;
18145
0
    }
18146
1
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18147
0
        return -1;
18148
0
    }
18149
1
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18150
0
        return -1;
18151
0
    }
18152
1
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18153
0
        return -1;
18154
0
    }
18155
1
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18156
0
        return -1;
18157
0
    }
18158
1
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18159
0
        return -1;
18160
0
    }
18161
1
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18162
1
        < 0) {
18163
0
        return -1;
18164
0
    }
18165
1
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18166
1
        0) {
18167
0
        return -1;
18168
0
    }
18169
1
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18170
0
        return -1;
18171
0
    }
18172
1
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18173
0
        return -1;
18174
0
    }
18175
1
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18176
0
        return -1;
18177
0
    }
18178
1
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18179
0
        return -1;
18180
0
    }
18181
1
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18182
0
        return -1;
18183
0
    }
18184
1
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18185
0
        return -1;
18186
0
    }
18187
1
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18188
0
        return -1;
18189
0
    }
18190
1
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18191
0
        return -1;
18192
0
    }
18193
1
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18194
0
        return -1;
18195
0
    }
18196
1
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18197
0
        return -1;
18198
0
    }
18199
1
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18200
0
        {
18201
0
        return -1;
18202
0
    }
18203
1
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18204
0
        return -1;
18205
0
    }
18206
1
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18207
0
        return -1;
18208
0
    }
18209
1
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18210
0
        return -1;
18211
0
    }
18212
1
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18213
0
        return -1;
18214
0
    }
18215
1
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18216
0
        return -1;
18217
0
    }
18218
1
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18219
0
        return -1;
18220
0
    }
18221
1
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18222
0
        return -1;
18223
0
    }
18224
1
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18225
0
        return -1;
18226
0
    }
18227
1
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18228
0
        return -1;
18229
0
    }
18230
1
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18231
0
        return -1;
18232
0
    }
18233
1
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18234
0
        return -1;
18235
0
    }
18236
1
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18237
0
        return -1;
18238
0
    }
18239
1
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18240
0
        return -1;
18241
0
    }
18242
1
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18243
0
        return -1;
18244
0
    }
18245
1
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18246
0
        return -1;
18247
0
    }
18248
1
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18249
0
        return -1;
18250
0
    }
18251
1
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18252
0
        return -1;
18253
0
    }
18254
1
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18255
0
        return -1;
18256
0
    }
18257
1
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18258
0
        return -1;
18259
0
    }
18260
1
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18261
0
        return -1;
18262
0
    }
18263
1
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18264
0
        return -1;
18265
0
    }
18266
1
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18267
0
        return -1;
18268
0
    }
18269
1
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18270
0
        return -1;
18271
0
    }
18272
1
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18273
0
        return -1;
18274
0
    }
18275
1
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18276
0
        return -1;
18277
0
    }
18278
1
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18279
0
        return -1;
18280
0
    }
18281
1
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18282
0
        return -1;
18283
0
    }
18284
1
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18285
0
        return -1;
18286
0
    }
18287
1
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18288
0
        return -1;
18289
0
    }
18290
1
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18291
0
        return -1;
18292
0
    }
18293
1
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18294
0
        return -1;
18295
0
    }
18296
1
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18297
0
        return -1;
18298
0
    }
18299
1
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18300
0
        return -1;
18301
0
    }
18302
1
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18303
0
        return -1;
18304
0
    }
18305
1
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18306
0
        return -1;
18307
0
    }
18308
1
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18309
0
        return -1;
18310
0
    }
18311
1
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18312
1
        0) {
18313
0
        return -1;
18314
0
    }
18315
1
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18316
1
        0) {
18317
0
        return -1;
18318
0
    }
18319
1
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18320
1
        0) {
18321
0
        return -1;
18322
0
    }
18323
1
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18324
0
        return -1;
18325
0
    }
18326
1
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18327
0
        return -1;
18328
0
    }
18329
1
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18330
0
        return -1;
18331
0
    }
18332
1
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18333
0
        return -1;
18334
0
    }
18335
1
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18336
0
        return -1;
18337
0
    }
18338
1
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18339
0
        return -1;
18340
0
    }
18341
1
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18342
0
        return -1;
18343
0
    }
18344
1
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18345
0
        return -1;
18346
0
    }
18347
1
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18348
1
        < 0) {
18349
0
        return -1;
18350
0
    }
18351
1
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18352
1
        0) {
18353
0
        return -1;
18354
0
    }
18355
1
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18356
0
        {
18357
0
        return -1;
18358
0
    }
18359
1
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18360
0
        return -1;
18361
0
    }
18362
1
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18363
0
        return -1;
18364
0
    }
18365
1
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18366
0
        return -1;
18367
0
    }
18368
1
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18369
0
        return -1;
18370
0
    }
18371
1
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18372
0
        return -1;
18373
0
    }
18374
1
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18375
0
        return -1;
18376
0
    }
18377
1
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18378
0
        return -1;
18379
0
    }
18380
1
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18381
0
        return -1;
18382
0
    }
18383
1
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18384
0
        return -1;
18385
0
    }
18386
1
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18387
0
        {
18388
0
        return -1;
18389
0
    }
18390
1
    return 0;
18391
1
}
18392
18393
static PyModuleDef_Slot astmodule_slots[] = {
18394
    {Py_mod_exec, astmodule_exec},
18395
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18396
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18397
    {0, NULL}
18398
};
18399
18400
static struct PyModuleDef _astmodule = {
18401
    PyModuleDef_HEAD_INIT,
18402
    .m_name = "_ast",
18403
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18404
    .m_size = 0,
18405
    .m_slots = astmodule_slots,
18406
};
18407
18408
PyMODINIT_FUNC
18409
PyInit__ast(void)
18410
1
{
18411
1
    return PyModuleDef_Init(&_astmodule);
18412
1
}
18413
18414
18415
PyObject* PyAST_mod2obj(mod_ty t)
18416
7
{
18417
7
    struct ast_state *state = get_ast_state();
18418
7
    if (state == NULL) {
18419
0
        return NULL;
18420
0
    }
18421
7
    PyObject *result = ast2obj_mod(state, t);
18422
18423
7
    return result;
18424
7
}
18425
18426
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18427
int PyAst_CheckMode(PyObject *ast, int mode)
18428
0
{
18429
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18430
18431
0
    struct ast_state *state = get_ast_state();
18432
0
    if (state == NULL) {
18433
0
        return -1;
18434
0
    }
18435
18436
0
    PyObject *req_type[3];
18437
0
    req_type[0] = state->Module_type;
18438
0
    req_type[1] = state->Expression_type;
18439
0
    req_type[2] = state->Interactive_type;
18440
18441
0
    assert(0 <= mode && mode <= 2);
18442
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18443
0
    if (isinstance == -1) {
18444
0
        return -1;
18445
0
    }
18446
0
    if (!isinstance) {
18447
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18448
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18449
0
        return -1;
18450
0
    }
18451
0
    return 0;
18452
0
}
18453
18454
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18455
0
{
18456
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18457
0
        return NULL;
18458
0
    }
18459
18460
0
    struct ast_state *state = get_ast_state();
18461
0
    if (state == NULL) {
18462
0
        return NULL;
18463
0
    }
18464
18465
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18466
0
        return NULL;
18467
0
    }
18468
18469
0
    mod_ty res = NULL;
18470
0
    if (obj2ast_mod(state, ast, &res, arena) != 0)
18471
0
        return NULL;
18472
0
    else
18473
0
        return res;
18474
0
}
18475
18476
int PyAST_Check(PyObject* obj)
18477
16
{
18478
16
    struct ast_state *state = get_ast_state();
18479
16
    if (state == NULL) {
18480
0
        return -1;
18481
0
    }
18482
16
    return PyObject_IsInstance(obj, state->AST_type);
18483
16
}
18484
18485