Line data Source code
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_interp.h" // _PyInterpreterState.ast
8 : #include "pycore_pystate.h" // _PyInterpreterState_GET()
9 : #include "structmember.h"
10 : #include <stddef.h>
11 :
12 : // Forward declaration
13 : static int init_types(struct ast_state *state);
14 :
15 : static struct ast_state*
16 49131 : get_ast_state(void)
17 : {
18 49131 : PyInterpreterState *interp = _PyInterpreterState_GET();
19 49131 : struct ast_state *state = &interp->ast;
20 49131 : if (!init_types(state)) {
21 0 : return NULL;
22 : }
23 49131 : return state;
24 : }
25 :
26 3120 : void _PyAST_Fini(PyInterpreterState *interp)
27 : {
28 3120 : struct ast_state *state = &interp->ast;
29 :
30 3120 : Py_CLEAR(state->AST_type);
31 3120 : Py_CLEAR(state->Add_singleton);
32 3120 : Py_CLEAR(state->Add_type);
33 3120 : Py_CLEAR(state->And_singleton);
34 3120 : Py_CLEAR(state->And_type);
35 3120 : Py_CLEAR(state->AnnAssign_type);
36 3120 : Py_CLEAR(state->Assert_type);
37 3120 : Py_CLEAR(state->Assign_type);
38 3120 : Py_CLEAR(state->AsyncFor_type);
39 3120 : Py_CLEAR(state->AsyncFunctionDef_type);
40 3120 : Py_CLEAR(state->AsyncWith_type);
41 3120 : Py_CLEAR(state->Attribute_type);
42 3120 : Py_CLEAR(state->AugAssign_type);
43 3120 : Py_CLEAR(state->Await_type);
44 3120 : Py_CLEAR(state->BinOp_type);
45 3120 : Py_CLEAR(state->BitAnd_singleton);
46 3120 : Py_CLEAR(state->BitAnd_type);
47 3120 : Py_CLEAR(state->BitOr_singleton);
48 3120 : Py_CLEAR(state->BitOr_type);
49 3120 : Py_CLEAR(state->BitXor_singleton);
50 3120 : Py_CLEAR(state->BitXor_type);
51 3120 : Py_CLEAR(state->BoolOp_type);
52 3120 : Py_CLEAR(state->Break_type);
53 3120 : Py_CLEAR(state->Call_type);
54 3120 : Py_CLEAR(state->ClassDef_type);
55 3120 : Py_CLEAR(state->Compare_type);
56 3120 : Py_CLEAR(state->Constant_type);
57 3120 : Py_CLEAR(state->Continue_type);
58 3120 : Py_CLEAR(state->Del_singleton);
59 3120 : Py_CLEAR(state->Del_type);
60 3120 : Py_CLEAR(state->Delete_type);
61 3120 : Py_CLEAR(state->DictComp_type);
62 3120 : Py_CLEAR(state->Dict_type);
63 3120 : Py_CLEAR(state->Div_singleton);
64 3120 : Py_CLEAR(state->Div_type);
65 3120 : Py_CLEAR(state->Eq_singleton);
66 3120 : Py_CLEAR(state->Eq_type);
67 3120 : Py_CLEAR(state->ExceptHandler_type);
68 3120 : Py_CLEAR(state->Expr_type);
69 3120 : Py_CLEAR(state->Expression_type);
70 3120 : Py_CLEAR(state->FloorDiv_singleton);
71 3120 : Py_CLEAR(state->FloorDiv_type);
72 3120 : Py_CLEAR(state->For_type);
73 3120 : Py_CLEAR(state->FormattedValue_type);
74 3120 : Py_CLEAR(state->FunctionDef_type);
75 3120 : Py_CLEAR(state->FunctionType_type);
76 3120 : Py_CLEAR(state->GeneratorExp_type);
77 3120 : Py_CLEAR(state->Global_type);
78 3120 : Py_CLEAR(state->GtE_singleton);
79 3120 : Py_CLEAR(state->GtE_type);
80 3120 : Py_CLEAR(state->Gt_singleton);
81 3120 : Py_CLEAR(state->Gt_type);
82 3120 : Py_CLEAR(state->IfExp_type);
83 3120 : Py_CLEAR(state->If_type);
84 3120 : Py_CLEAR(state->ImportFrom_type);
85 3120 : Py_CLEAR(state->Import_type);
86 3120 : Py_CLEAR(state->In_singleton);
87 3120 : Py_CLEAR(state->In_type);
88 3120 : Py_CLEAR(state->Interactive_type);
89 3120 : Py_CLEAR(state->Invert_singleton);
90 3120 : Py_CLEAR(state->Invert_type);
91 3120 : Py_CLEAR(state->IsNot_singleton);
92 3120 : Py_CLEAR(state->IsNot_type);
93 3120 : Py_CLEAR(state->Is_singleton);
94 3120 : Py_CLEAR(state->Is_type);
95 3120 : Py_CLEAR(state->JoinedStr_type);
96 3120 : Py_CLEAR(state->LShift_singleton);
97 3120 : Py_CLEAR(state->LShift_type);
98 3120 : Py_CLEAR(state->Lambda_type);
99 3120 : Py_CLEAR(state->ListComp_type);
100 3120 : Py_CLEAR(state->List_type);
101 3120 : Py_CLEAR(state->Load_singleton);
102 3120 : Py_CLEAR(state->Load_type);
103 3120 : Py_CLEAR(state->LtE_singleton);
104 3120 : Py_CLEAR(state->LtE_type);
105 3120 : Py_CLEAR(state->Lt_singleton);
106 3120 : Py_CLEAR(state->Lt_type);
107 3120 : Py_CLEAR(state->MatMult_singleton);
108 3120 : Py_CLEAR(state->MatMult_type);
109 3120 : Py_CLEAR(state->MatchAs_type);
110 3120 : Py_CLEAR(state->MatchClass_type);
111 3120 : Py_CLEAR(state->MatchMapping_type);
112 3120 : Py_CLEAR(state->MatchOr_type);
113 3120 : Py_CLEAR(state->MatchSequence_type);
114 3120 : Py_CLEAR(state->MatchSingleton_type);
115 3120 : Py_CLEAR(state->MatchStar_type);
116 3120 : Py_CLEAR(state->MatchValue_type);
117 3120 : Py_CLEAR(state->Match_type);
118 3120 : Py_CLEAR(state->Mod_singleton);
119 3120 : Py_CLEAR(state->Mod_type);
120 3120 : Py_CLEAR(state->Module_type);
121 3120 : Py_CLEAR(state->Mult_singleton);
122 3120 : Py_CLEAR(state->Mult_type);
123 3120 : Py_CLEAR(state->Name_type);
124 3120 : Py_CLEAR(state->NamedExpr_type);
125 3120 : Py_CLEAR(state->Nonlocal_type);
126 3120 : Py_CLEAR(state->NotEq_singleton);
127 3120 : Py_CLEAR(state->NotEq_type);
128 3120 : Py_CLEAR(state->NotIn_singleton);
129 3120 : Py_CLEAR(state->NotIn_type);
130 3120 : Py_CLEAR(state->Not_singleton);
131 3120 : Py_CLEAR(state->Not_type);
132 3120 : Py_CLEAR(state->Or_singleton);
133 3120 : Py_CLEAR(state->Or_type);
134 3120 : Py_CLEAR(state->Pass_type);
135 3120 : Py_CLEAR(state->Pow_singleton);
136 3120 : Py_CLEAR(state->Pow_type);
137 3120 : Py_CLEAR(state->RShift_singleton);
138 3120 : Py_CLEAR(state->RShift_type);
139 3120 : Py_CLEAR(state->Raise_type);
140 3120 : Py_CLEAR(state->Return_type);
141 3120 : Py_CLEAR(state->SetComp_type);
142 3120 : Py_CLEAR(state->Set_type);
143 3120 : Py_CLEAR(state->Slice_type);
144 3120 : Py_CLEAR(state->Starred_type);
145 3120 : Py_CLEAR(state->Store_singleton);
146 3120 : Py_CLEAR(state->Store_type);
147 3120 : Py_CLEAR(state->Sub_singleton);
148 3120 : Py_CLEAR(state->Sub_type);
149 3120 : Py_CLEAR(state->Subscript_type);
150 3120 : Py_CLEAR(state->TryStar_type);
151 3120 : Py_CLEAR(state->Try_type);
152 3120 : Py_CLEAR(state->Tuple_type);
153 3120 : Py_CLEAR(state->TypeIgnore_type);
154 3120 : Py_CLEAR(state->UAdd_singleton);
155 3120 : Py_CLEAR(state->UAdd_type);
156 3120 : Py_CLEAR(state->USub_singleton);
157 3120 : Py_CLEAR(state->USub_type);
158 3120 : Py_CLEAR(state->UnaryOp_type);
159 3120 : Py_CLEAR(state->While_type);
160 3120 : Py_CLEAR(state->With_type);
161 3120 : Py_CLEAR(state->YieldFrom_type);
162 3120 : Py_CLEAR(state->Yield_type);
163 3120 : Py_CLEAR(state->__dict__);
164 3120 : Py_CLEAR(state->__doc__);
165 3120 : Py_CLEAR(state->__match_args__);
166 3120 : Py_CLEAR(state->__module__);
167 3120 : Py_CLEAR(state->_attributes);
168 3120 : Py_CLEAR(state->_fields);
169 3120 : Py_CLEAR(state->alias_type);
170 3120 : Py_CLEAR(state->annotation);
171 3120 : Py_CLEAR(state->arg);
172 3120 : Py_CLEAR(state->arg_type);
173 3120 : Py_CLEAR(state->args);
174 3120 : Py_CLEAR(state->argtypes);
175 3120 : Py_CLEAR(state->arguments_type);
176 3120 : Py_CLEAR(state->asname);
177 3120 : Py_CLEAR(state->ast);
178 3120 : Py_CLEAR(state->attr);
179 3120 : Py_CLEAR(state->bases);
180 3120 : Py_CLEAR(state->body);
181 3120 : Py_CLEAR(state->boolop_type);
182 3120 : Py_CLEAR(state->cases);
183 3120 : Py_CLEAR(state->cause);
184 3120 : Py_CLEAR(state->cls);
185 3120 : Py_CLEAR(state->cmpop_type);
186 3120 : Py_CLEAR(state->col_offset);
187 3120 : Py_CLEAR(state->comparators);
188 3120 : Py_CLEAR(state->comprehension_type);
189 3120 : Py_CLEAR(state->context_expr);
190 3120 : Py_CLEAR(state->conversion);
191 3120 : Py_CLEAR(state->ctx);
192 3120 : Py_CLEAR(state->decorator_list);
193 3120 : Py_CLEAR(state->defaults);
194 3120 : Py_CLEAR(state->elt);
195 3120 : Py_CLEAR(state->elts);
196 3120 : Py_CLEAR(state->end_col_offset);
197 3120 : Py_CLEAR(state->end_lineno);
198 3120 : Py_CLEAR(state->exc);
199 3120 : Py_CLEAR(state->excepthandler_type);
200 3120 : Py_CLEAR(state->expr_context_type);
201 3120 : Py_CLEAR(state->expr_type);
202 3120 : Py_CLEAR(state->finalbody);
203 3120 : Py_CLEAR(state->format_spec);
204 3120 : Py_CLEAR(state->func);
205 3120 : Py_CLEAR(state->generators);
206 3120 : Py_CLEAR(state->guard);
207 3120 : Py_CLEAR(state->handlers);
208 3120 : Py_CLEAR(state->id);
209 3120 : Py_CLEAR(state->ifs);
210 3120 : Py_CLEAR(state->is_async);
211 3120 : Py_CLEAR(state->items);
212 3120 : Py_CLEAR(state->iter);
213 3120 : Py_CLEAR(state->key);
214 3120 : Py_CLEAR(state->keys);
215 3120 : Py_CLEAR(state->keyword_type);
216 3120 : Py_CLEAR(state->keywords);
217 3120 : Py_CLEAR(state->kind);
218 3120 : Py_CLEAR(state->kw_defaults);
219 3120 : Py_CLEAR(state->kwarg);
220 3120 : Py_CLEAR(state->kwd_attrs);
221 3120 : Py_CLEAR(state->kwd_patterns);
222 3120 : Py_CLEAR(state->kwonlyargs);
223 3120 : Py_CLEAR(state->left);
224 3120 : Py_CLEAR(state->level);
225 3120 : Py_CLEAR(state->lineno);
226 3120 : Py_CLEAR(state->lower);
227 3120 : Py_CLEAR(state->match_case_type);
228 3120 : Py_CLEAR(state->mod_type);
229 3120 : Py_CLEAR(state->module);
230 3120 : Py_CLEAR(state->msg);
231 3120 : Py_CLEAR(state->name);
232 3120 : Py_CLEAR(state->names);
233 3120 : Py_CLEAR(state->op);
234 3120 : Py_CLEAR(state->operand);
235 3120 : Py_CLEAR(state->operator_type);
236 3120 : Py_CLEAR(state->ops);
237 3120 : Py_CLEAR(state->optional_vars);
238 3120 : Py_CLEAR(state->orelse);
239 3120 : Py_CLEAR(state->pattern);
240 3120 : Py_CLEAR(state->pattern_type);
241 3120 : Py_CLEAR(state->patterns);
242 3120 : Py_CLEAR(state->posonlyargs);
243 3120 : Py_CLEAR(state->rest);
244 3120 : Py_CLEAR(state->returns);
245 3120 : Py_CLEAR(state->right);
246 3120 : Py_CLEAR(state->simple);
247 3120 : Py_CLEAR(state->slice);
248 3120 : Py_CLEAR(state->step);
249 3120 : Py_CLEAR(state->stmt_type);
250 3120 : Py_CLEAR(state->subject);
251 3120 : Py_CLEAR(state->tag);
252 3120 : Py_CLEAR(state->target);
253 3120 : Py_CLEAR(state->targets);
254 3120 : Py_CLEAR(state->test);
255 3120 : Py_CLEAR(state->type);
256 3120 : Py_CLEAR(state->type_comment);
257 3120 : Py_CLEAR(state->type_ignore_type);
258 3120 : Py_CLEAR(state->type_ignores);
259 3120 : Py_CLEAR(state->unaryop_type);
260 3120 : Py_CLEAR(state->upper);
261 3120 : Py_CLEAR(state->value);
262 3120 : Py_CLEAR(state->values);
263 3120 : Py_CLEAR(state->vararg);
264 3120 : Py_CLEAR(state->withitem_type);
265 :
266 : #if !defined(NDEBUG)
267 3120 : state->initialized = -1;
268 : #else
269 : state->initialized = 0;
270 : #endif
271 3120 : }
272 :
273 1477 : static int init_identifiers(struct ast_state *state)
274 : {
275 1477 : if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return 0;
276 1477 : if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return 0;
277 1477 : if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return 0;
278 1477 : if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return 0;
279 1477 : if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return 0;
280 1477 : if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return 0;
281 1477 : if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return 0;
282 1477 : if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return 0;
283 1477 : if ((state->args = PyUnicode_InternFromString("args")) == NULL) return 0;
284 1477 : if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return 0;
285 1477 : if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return 0;
286 1477 : if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return 0;
287 1477 : if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0;
288 1477 : if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0;
289 1477 : if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0;
290 1477 : if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0;
291 1477 : if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0;
292 1477 : if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return 0;
293 1477 : if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return 0;
294 1477 : if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return 0;
295 1477 : if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return 0;
296 1477 : if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return 0;
297 1477 : if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return 0;
298 1477 : if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return 0;
299 1477 : if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return 0;
300 1477 : if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return 0;
301 1477 : if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return 0;
302 1477 : if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return 0;
303 1477 : if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return 0;
304 1477 : if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return 0;
305 1477 : if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return 0;
306 1477 : if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return 0;
307 1477 : if ((state->func = PyUnicode_InternFromString("func")) == NULL) return 0;
308 1477 : if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return 0;
309 1477 : if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return 0;
310 1477 : if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return 0;
311 1477 : if ((state->id = PyUnicode_InternFromString("id")) == NULL) return 0;
312 1477 : if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return 0;
313 1477 : if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return 0;
314 1477 : if ((state->items = PyUnicode_InternFromString("items")) == NULL) return 0;
315 1477 : if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return 0;
316 1477 : if ((state->key = PyUnicode_InternFromString("key")) == NULL) return 0;
317 1477 : if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return 0;
318 1477 : if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return 0;
319 1477 : if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return 0;
320 1477 : if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return 0;
321 1477 : if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return 0;
322 1477 : if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return 0;
323 1477 : if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return 0;
324 1477 : if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return 0;
325 1477 : if ((state->left = PyUnicode_InternFromString("left")) == NULL) return 0;
326 1477 : if ((state->level = PyUnicode_InternFromString("level")) == NULL) return 0;
327 1477 : if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return 0;
328 1477 : if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return 0;
329 1477 : if ((state->module = PyUnicode_InternFromString("module")) == NULL) return 0;
330 1477 : if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return 0;
331 1477 : if ((state->name = PyUnicode_InternFromString("name")) == NULL) return 0;
332 1477 : if ((state->names = PyUnicode_InternFromString("names")) == NULL) return 0;
333 1477 : if ((state->op = PyUnicode_InternFromString("op")) == NULL) return 0;
334 1477 : if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return 0;
335 1477 : if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return 0;
336 1477 : if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0;
337 1477 : if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0;
338 1477 : if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0;
339 1477 : if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return 0;
340 1477 : if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0;
341 1477 : if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return 0;
342 1477 : if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0;
343 1477 : if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0;
344 1477 : if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return 0;
345 1477 : if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return 0;
346 1477 : if ((state->step = PyUnicode_InternFromString("step")) == NULL) return 0;
347 1477 : if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return 0;
348 1477 : if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return 0;
349 1477 : if ((state->target = PyUnicode_InternFromString("target")) == NULL) return 0;
350 1477 : if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return 0;
351 1477 : if ((state->test = PyUnicode_InternFromString("test")) == NULL) return 0;
352 1477 : if ((state->type = PyUnicode_InternFromString("type")) == NULL) return 0;
353 1477 : if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return 0;
354 1477 : if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return 0;
355 1477 : if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return 0;
356 1477 : if ((state->value = PyUnicode_InternFromString("value")) == NULL) return 0;
357 1477 : if ((state->values = PyUnicode_InternFromString("values")) == NULL) return 0;
358 1477 : if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return 0;
359 1477 : return 1;
360 : };
361 :
362 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
363 41148 : GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
364 1420150 : GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
365 612 : GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
366 1487 : GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
367 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
368 1145370 : GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
369 137402 : GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
370 1333 : GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
371 394 : GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
372 29 : GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
373 414 : GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
374 597 : GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
375 :
376 : static PyObject* ast2obj_mod(struct ast_state *state, void*);
377 : static const char * const Module_fields[]={
378 : "body",
379 : "type_ignores",
380 : };
381 : static const char * const Interactive_fields[]={
382 : "body",
383 : };
384 : static const char * const Expression_fields[]={
385 : "body",
386 : };
387 : static const char * const FunctionType_fields[]={
388 : "argtypes",
389 : "returns",
390 : };
391 : static const char * const stmt_attributes[] = {
392 : "lineno",
393 : "col_offset",
394 : "end_lineno",
395 : "end_col_offset",
396 : };
397 : static PyObject* ast2obj_stmt(struct ast_state *state, void*);
398 : static const char * const FunctionDef_fields[]={
399 : "name",
400 : "args",
401 : "body",
402 : "decorator_list",
403 : "returns",
404 : "type_comment",
405 : };
406 : static const char * const AsyncFunctionDef_fields[]={
407 : "name",
408 : "args",
409 : "body",
410 : "decorator_list",
411 : "returns",
412 : "type_comment",
413 : };
414 : static const char * const ClassDef_fields[]={
415 : "name",
416 : "bases",
417 : "keywords",
418 : "body",
419 : "decorator_list",
420 : };
421 : static const char * const Return_fields[]={
422 : "value",
423 : };
424 : static const char * const Delete_fields[]={
425 : "targets",
426 : };
427 : static const char * const Assign_fields[]={
428 : "targets",
429 : "value",
430 : "type_comment",
431 : };
432 : static const char * const AugAssign_fields[]={
433 : "target",
434 : "op",
435 : "value",
436 : };
437 : static const char * const AnnAssign_fields[]={
438 : "target",
439 : "annotation",
440 : "value",
441 : "simple",
442 : };
443 : static const char * const For_fields[]={
444 : "target",
445 : "iter",
446 : "body",
447 : "orelse",
448 : "type_comment",
449 : };
450 : static const char * const AsyncFor_fields[]={
451 : "target",
452 : "iter",
453 : "body",
454 : "orelse",
455 : "type_comment",
456 : };
457 : static const char * const While_fields[]={
458 : "test",
459 : "body",
460 : "orelse",
461 : };
462 : static const char * const If_fields[]={
463 : "test",
464 : "body",
465 : "orelse",
466 : };
467 : static const char * const With_fields[]={
468 : "items",
469 : "body",
470 : "type_comment",
471 : };
472 : static const char * const AsyncWith_fields[]={
473 : "items",
474 : "body",
475 : "type_comment",
476 : };
477 : static const char * const Match_fields[]={
478 : "subject",
479 : "cases",
480 : };
481 : static const char * const Raise_fields[]={
482 : "exc",
483 : "cause",
484 : };
485 : static const char * const Try_fields[]={
486 : "body",
487 : "handlers",
488 : "orelse",
489 : "finalbody",
490 : };
491 : static const char * const TryStar_fields[]={
492 : "body",
493 : "handlers",
494 : "orelse",
495 : "finalbody",
496 : };
497 : static const char * const Assert_fields[]={
498 : "test",
499 : "msg",
500 : };
501 : static const char * const Import_fields[]={
502 : "names",
503 : };
504 : static const char * const ImportFrom_fields[]={
505 : "module",
506 : "names",
507 : "level",
508 : };
509 : static const char * const Global_fields[]={
510 : "names",
511 : };
512 : static const char * const Nonlocal_fields[]={
513 : "names",
514 : };
515 : static const char * const Expr_fields[]={
516 : "value",
517 : };
518 : static const char * const expr_attributes[] = {
519 : "lineno",
520 : "col_offset",
521 : "end_lineno",
522 : "end_col_offset",
523 : };
524 : static PyObject* ast2obj_expr(struct ast_state *state, void*);
525 : static const char * const BoolOp_fields[]={
526 : "op",
527 : "values",
528 : };
529 : static const char * const NamedExpr_fields[]={
530 : "target",
531 : "value",
532 : };
533 : static const char * const BinOp_fields[]={
534 : "left",
535 : "op",
536 : "right",
537 : };
538 : static const char * const UnaryOp_fields[]={
539 : "op",
540 : "operand",
541 : };
542 : static const char * const Lambda_fields[]={
543 : "args",
544 : "body",
545 : };
546 : static const char * const IfExp_fields[]={
547 : "test",
548 : "body",
549 : "orelse",
550 : };
551 : static const char * const Dict_fields[]={
552 : "keys",
553 : "values",
554 : };
555 : static const char * const Set_fields[]={
556 : "elts",
557 : };
558 : static const char * const ListComp_fields[]={
559 : "elt",
560 : "generators",
561 : };
562 : static const char * const SetComp_fields[]={
563 : "elt",
564 : "generators",
565 : };
566 : static const char * const DictComp_fields[]={
567 : "key",
568 : "value",
569 : "generators",
570 : };
571 : static const char * const GeneratorExp_fields[]={
572 : "elt",
573 : "generators",
574 : };
575 : static const char * const Await_fields[]={
576 : "value",
577 : };
578 : static const char * const Yield_fields[]={
579 : "value",
580 : };
581 : static const char * const YieldFrom_fields[]={
582 : "value",
583 : };
584 : static const char * const Compare_fields[]={
585 : "left",
586 : "ops",
587 : "comparators",
588 : };
589 : static const char * const Call_fields[]={
590 : "func",
591 : "args",
592 : "keywords",
593 : };
594 : static const char * const FormattedValue_fields[]={
595 : "value",
596 : "conversion",
597 : "format_spec",
598 : };
599 : static const char * const JoinedStr_fields[]={
600 : "values",
601 : };
602 : static const char * const Constant_fields[]={
603 : "value",
604 : "kind",
605 : };
606 : static const char * const Attribute_fields[]={
607 : "value",
608 : "attr",
609 : "ctx",
610 : };
611 : static const char * const Subscript_fields[]={
612 : "value",
613 : "slice",
614 : "ctx",
615 : };
616 : static const char * const Starred_fields[]={
617 : "value",
618 : "ctx",
619 : };
620 : static const char * const Name_fields[]={
621 : "id",
622 : "ctx",
623 : };
624 : static const char * const List_fields[]={
625 : "elts",
626 : "ctx",
627 : };
628 : static const char * const Tuple_fields[]={
629 : "elts",
630 : "ctx",
631 : };
632 : static const char * const Slice_fields[]={
633 : "lower",
634 : "upper",
635 : "step",
636 : };
637 : static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
638 : static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
639 : static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
640 : static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
641 : static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
642 : static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
643 : static const char * const comprehension_fields[]={
644 : "target",
645 : "iter",
646 : "ifs",
647 : "is_async",
648 : };
649 : static const char * const excepthandler_attributes[] = {
650 : "lineno",
651 : "col_offset",
652 : "end_lineno",
653 : "end_col_offset",
654 : };
655 : static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
656 : static const char * const ExceptHandler_fields[]={
657 : "type",
658 : "name",
659 : "body",
660 : };
661 : static PyObject* ast2obj_arguments(struct ast_state *state, void*);
662 : static const char * const arguments_fields[]={
663 : "posonlyargs",
664 : "args",
665 : "vararg",
666 : "kwonlyargs",
667 : "kw_defaults",
668 : "kwarg",
669 : "defaults",
670 : };
671 : static PyObject* ast2obj_arg(struct ast_state *state, void*);
672 : static const char * const arg_attributes[] = {
673 : "lineno",
674 : "col_offset",
675 : "end_lineno",
676 : "end_col_offset",
677 : };
678 : static const char * const arg_fields[]={
679 : "arg",
680 : "annotation",
681 : "type_comment",
682 : };
683 : static PyObject* ast2obj_keyword(struct ast_state *state, void*);
684 : static const char * const keyword_attributes[] = {
685 : "lineno",
686 : "col_offset",
687 : "end_lineno",
688 : "end_col_offset",
689 : };
690 : static const char * const keyword_fields[]={
691 : "arg",
692 : "value",
693 : };
694 : static PyObject* ast2obj_alias(struct ast_state *state, void*);
695 : static const char * const alias_attributes[] = {
696 : "lineno",
697 : "col_offset",
698 : "end_lineno",
699 : "end_col_offset",
700 : };
701 : static const char * const alias_fields[]={
702 : "name",
703 : "asname",
704 : };
705 : static PyObject* ast2obj_withitem(struct ast_state *state, void*);
706 : static const char * const withitem_fields[]={
707 : "context_expr",
708 : "optional_vars",
709 : };
710 : static PyObject* ast2obj_match_case(struct ast_state *state, void*);
711 : static const char * const match_case_fields[]={
712 : "pattern",
713 : "guard",
714 : "body",
715 : };
716 : static const char * const pattern_attributes[] = {
717 : "lineno",
718 : "col_offset",
719 : "end_lineno",
720 : "end_col_offset",
721 : };
722 : static PyObject* ast2obj_pattern(struct ast_state *state, void*);
723 : static const char * const MatchValue_fields[]={
724 : "value",
725 : };
726 : static const char * const MatchSingleton_fields[]={
727 : "value",
728 : };
729 : static const char * const MatchSequence_fields[]={
730 : "patterns",
731 : };
732 : static const char * const MatchMapping_fields[]={
733 : "keys",
734 : "patterns",
735 : "rest",
736 : };
737 : static const char * const MatchClass_fields[]={
738 : "cls",
739 : "patterns",
740 : "kwd_attrs",
741 : "kwd_patterns",
742 : };
743 : static const char * const MatchStar_fields[]={
744 : "name",
745 : };
746 : static const char * const MatchAs_fields[]={
747 : "pattern",
748 : "name",
749 : };
750 : static const char * const MatchOr_fields[]={
751 : "patterns",
752 : };
753 : static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
754 : static const char * const TypeIgnore_fields[]={
755 : "lineno",
756 : "tag",
757 : };
758 :
759 :
760 :
761 : typedef struct {
762 : PyObject_HEAD
763 : PyObject *dict;
764 : } AST_object;
765 :
766 : static void
767 4884410 : ast_dealloc(AST_object *self)
768 : {
769 : /* bpo-31095: UnTrack is needed before calling any callbacks */
770 4884410 : PyTypeObject *tp = Py_TYPE(self);
771 4884410 : PyObject_GC_UnTrack(self);
772 4884410 : Py_CLEAR(self->dict);
773 4884410 : freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
774 4884410 : assert(free_func != NULL);
775 4884410 : free_func(self);
776 4884410 : Py_DECREF(tp);
777 4884410 : }
778 :
779 : static int
780 19773200 : ast_traverse(AST_object *self, visitproc visit, void *arg)
781 : {
782 19773200 : Py_VISIT(Py_TYPE(self));
783 19773200 : Py_VISIT(self->dict);
784 19773200 : return 0;
785 : }
786 :
787 : static int
788 8 : ast_clear(AST_object *self)
789 : {
790 8 : Py_CLEAR(self->dict);
791 8 : return 0;
792 : }
793 :
794 : static int
795 3255 : ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
796 : {
797 3255 : struct ast_state *state = get_ast_state();
798 3255 : if (state == NULL) {
799 0 : return -1;
800 : }
801 :
802 3255 : Py_ssize_t i, numfields = 0;
803 3255 : int res = -1;
804 : PyObject *key, *value, *fields;
805 3255 : if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
806 0 : goto cleanup;
807 : }
808 3255 : if (fields) {
809 3255 : numfields = PySequence_Size(fields);
810 3255 : if (numfields == -1) {
811 0 : goto cleanup;
812 : }
813 : }
814 :
815 3255 : res = 0; /* if no error occurs, this stays 0 to the end */
816 3255 : if (numfields < PyTuple_GET_SIZE(args)) {
817 5 : PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
818 : "%zd positional argument%s",
819 : _PyType_Name(Py_TYPE(self)),
820 : numfields, numfields == 1 ? "" : "s");
821 5 : res = -1;
822 5 : goto cleanup;
823 : }
824 4953 : for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
825 : /* cannot be reached when fields is NULL */
826 1703 : PyObject *name = PySequence_GetItem(fields, i);
827 1703 : if (!name) {
828 0 : res = -1;
829 0 : goto cleanup;
830 : }
831 1703 : res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
832 1703 : Py_DECREF(name);
833 1703 : if (res < 0) {
834 0 : goto cleanup;
835 : }
836 : }
837 3250 : if (kw) {
838 237 : i = 0; /* needed by PyDict_Next */
839 558 : while (PyDict_Next(kw, &i, &key, &value)) {
840 322 : int contains = PySequence_Contains(fields, key);
841 322 : if (contains == -1) {
842 0 : res = -1;
843 0 : goto cleanup;
844 322 : } else if (contains == 1) {
845 218 : Py_ssize_t p = PySequence_Index(fields, key);
846 218 : if (p == -1) {
847 0 : res = -1;
848 0 : goto cleanup;
849 : }
850 218 : if (p < PyTuple_GET_SIZE(args)) {
851 1 : PyErr_Format(PyExc_TypeError,
852 : "%.400s got multiple values for argument '%U'",
853 1 : Py_TYPE(self)->tp_name, key);
854 1 : res = -1;
855 1 : goto cleanup;
856 : }
857 : }
858 321 : res = PyObject_SetAttr(self, key, value);
859 321 : if (res < 0) {
860 0 : goto cleanup;
861 : }
862 : }
863 : }
864 3249 : cleanup:
865 3255 : Py_XDECREF(fields);
866 3255 : return res;
867 : }
868 :
869 : /* Pickling support */
870 : static PyObject *
871 1851 : ast_type_reduce(PyObject *self, PyObject *unused)
872 : {
873 1851 : struct ast_state *state = get_ast_state();
874 1851 : if (state == NULL) {
875 0 : return NULL;
876 : }
877 :
878 : PyObject *dict;
879 1851 : if (_PyObject_LookupAttr(self, state->__dict__, &dict) < 0) {
880 0 : return NULL;
881 : }
882 1851 : if (dict) {
883 1851 : return Py_BuildValue("O()N", Py_TYPE(self), dict);
884 : }
885 0 : return Py_BuildValue("O()", Py_TYPE(self));
886 : }
887 :
888 : static PyMemberDef ast_type_members[] = {
889 : {"__dictoffset__", T_PYSSIZET, offsetof(AST_object, dict), READONLY},
890 : {NULL} /* Sentinel */
891 : };
892 :
893 : static PyMethodDef ast_type_methods[] = {
894 : {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
895 : {NULL}
896 : };
897 :
898 : static PyGetSetDef ast_type_getsets[] = {
899 : {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
900 : {NULL}
901 : };
902 :
903 : static PyType_Slot AST_type_slots[] = {
904 : {Py_tp_dealloc, ast_dealloc},
905 : {Py_tp_getattro, PyObject_GenericGetAttr},
906 : {Py_tp_setattro, PyObject_GenericSetAttr},
907 : {Py_tp_traverse, ast_traverse},
908 : {Py_tp_clear, ast_clear},
909 : {Py_tp_members, ast_type_members},
910 : {Py_tp_methods, ast_type_methods},
911 : {Py_tp_getset, ast_type_getsets},
912 : {Py_tp_init, ast_type_init},
913 : {Py_tp_alloc, PyType_GenericAlloc},
914 : {Py_tp_new, PyType_GenericNew},
915 : {Py_tp_free, PyObject_GC_Del},
916 : {0, 0},
917 : };
918 :
919 : static PyType_Spec AST_type_spec = {
920 : "ast.AST",
921 : sizeof(AST_object),
922 : 0,
923 : Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
924 : AST_type_slots
925 : };
926 :
927 : static PyObject *
928 174286 : make_type(struct ast_state *state, const char *type, PyObject* base,
929 : const char* const* fields, int num_fields, const char *doc)
930 : {
931 : PyObject *fnames, *result;
932 : int i;
933 174286 : fnames = PyTuple_New(num_fields);
934 174286 : if (!fnames) return NULL;
935 437192 : for (i = 0; i < num_fields; i++) {
936 262906 : PyObject *field = PyUnicode_InternFromString(fields[i]);
937 262906 : if (!field) {
938 0 : Py_DECREF(fnames);
939 0 : return NULL;
940 : }
941 262906 : PyTuple_SET_ITEM(fnames, i, field);
942 : }
943 174286 : result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
944 : type, base,
945 : state->_fields, fnames,
946 : state->__match_args__, fnames,
947 : state->__module__,
948 : state->ast,
949 : state->__doc__, doc);
950 174286 : Py_DECREF(fnames);
951 174286 : return result;
952 : }
953 :
954 : static int
955 26586 : add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
956 : {
957 : int i, result;
958 26586 : PyObject *s, *l = PyTuple_New(num_fields);
959 26586 : if (!l)
960 0 : return 0;
961 67942 : for (i = 0; i < num_fields; i++) {
962 41356 : s = PyUnicode_InternFromString(attrs[i]);
963 41356 : if (!s) {
964 0 : Py_DECREF(l);
965 0 : return 0;
966 : }
967 41356 : PyTuple_SET_ITEM(l, i, s);
968 : }
969 26586 : result = PyObject_SetAttr(type, state->_attributes, l) >= 0;
970 26586 : Py_DECREF(l);
971 26586 : return result;
972 : }
973 :
974 : /* Conversion AST -> Python */
975 :
976 2372860 : static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq, PyObject* (*func)(struct ast_state *state, void*))
977 : {
978 2372860 : Py_ssize_t i, n = asdl_seq_LEN(seq);
979 2372860 : PyObject *result = PyList_New(n);
980 : PyObject *value;
981 2372860 : if (!result)
982 0 : return NULL;
983 5076920 : for (i = 0; i < n; i++) {
984 2704060 : value = func(state, asdl_seq_GET_UNTYPED(seq, i));
985 2704060 : if (!value) {
986 0 : Py_DECREF(result);
987 0 : return NULL;
988 : }
989 2704060 : PyList_SET_ITEM(result, i, value);
990 : }
991 2372860 : return result;
992 : }
993 :
994 4783760 : static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
995 : {
996 4783760 : if (!o)
997 1529080 : o = Py_None;
998 4783760 : Py_INCREF((PyObject*)o);
999 4783760 : return (PyObject*)o;
1000 : }
1001 : #define ast2obj_constant ast2obj_object
1002 : #define ast2obj_identifier ast2obj_object
1003 : #define ast2obj_string ast2obj_object
1004 :
1005 18842700 : static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
1006 : {
1007 18842700 : return PyLong_FromLong(b);
1008 : }
1009 :
1010 : /* Conversion Python -> AST */
1011 :
1012 183586 : static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1013 : {
1014 183586 : if (obj == Py_None)
1015 0 : obj = NULL;
1016 183586 : if (obj) {
1017 183586 : if (_PyArena_AddPyObject(arena, obj) < 0) {
1018 0 : *out = NULL;
1019 0 : return -1;
1020 : }
1021 183586 : Py_INCREF(obj);
1022 : }
1023 183586 : *out = obj;
1024 183586 : return 0;
1025 : }
1026 :
1027 46674 : static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1028 : {
1029 46674 : if (_PyArena_AddPyObject(arena, obj) < 0) {
1030 0 : *out = NULL;
1031 0 : return -1;
1032 : }
1033 46674 : Py_INCREF(obj);
1034 46674 : *out = obj;
1035 46674 : return 0;
1036 : }
1037 :
1038 183587 : static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1039 : {
1040 183587 : if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
1041 1 : PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
1042 1 : return 1;
1043 : }
1044 183586 : return obj2ast_object(state, obj, out, arena);
1045 : }
1046 :
1047 0 : static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1048 : {
1049 0 : if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
1050 0 : PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
1051 0 : return 1;
1052 : }
1053 0 : return obj2ast_object(state, obj, out, arena);
1054 : }
1055 :
1056 1437810 : static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
1057 : {
1058 : int i;
1059 1437810 : if (!PyLong_Check(obj)) {
1060 1 : PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
1061 1 : return 1;
1062 : }
1063 :
1064 1437810 : i = _PyLong_AsInt(obj);
1065 1437810 : if (i == -1 && PyErr_Occurred())
1066 0 : return 1;
1067 1437810 : *out = i;
1068 1437810 : return 0;
1069 : }
1070 :
1071 1477 : static int add_ast_fields(struct ast_state *state)
1072 : {
1073 : PyObject *empty_tuple;
1074 1477 : empty_tuple = PyTuple_New(0);
1075 2954 : if (!empty_tuple ||
1076 2954 : PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
1077 2954 : PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
1078 1477 : PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
1079 0 : Py_XDECREF(empty_tuple);
1080 0 : return -1;
1081 : }
1082 1477 : Py_DECREF(empty_tuple);
1083 1477 : return 0;
1084 : }
1085 :
1086 :
1087 :
1088 : static int
1089 49131 : init_types(struct ast_state *state)
1090 : {
1091 : // init_types() must not be called after _PyAST_Fini()
1092 : // has been called
1093 49131 : assert(state->initialized >= 0);
1094 :
1095 49131 : if (state->initialized) {
1096 47654 : return 1;
1097 : }
1098 1477 : if (init_identifiers(state) < 0) {
1099 0 : return 0;
1100 : }
1101 1477 : state->AST_type = PyType_FromSpec(&AST_type_spec);
1102 1477 : if (!state->AST_type) {
1103 0 : return 0;
1104 : }
1105 1477 : if (add_ast_fields(state) < 0) {
1106 0 : return 0;
1107 : }
1108 1477 : state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
1109 : "mod = Module(stmt* body, type_ignore* type_ignores)\n"
1110 : " | Interactive(stmt* body)\n"
1111 : " | Expression(expr body)\n"
1112 : " | FunctionType(expr* argtypes, expr returns)");
1113 1477 : if (!state->mod_type) return 0;
1114 1477 : if (!add_attributes(state, state->mod_type, NULL, 0)) return 0;
1115 1477 : state->Module_type = make_type(state, "Module", state->mod_type,
1116 : Module_fields, 2,
1117 : "Module(stmt* body, type_ignore* type_ignores)");
1118 1477 : if (!state->Module_type) return 0;
1119 1477 : state->Interactive_type = make_type(state, "Interactive", state->mod_type,
1120 : Interactive_fields, 1,
1121 : "Interactive(stmt* body)");
1122 1477 : if (!state->Interactive_type) return 0;
1123 1477 : state->Expression_type = make_type(state, "Expression", state->mod_type,
1124 : Expression_fields, 1,
1125 : "Expression(expr body)");
1126 1477 : if (!state->Expression_type) return 0;
1127 1477 : state->FunctionType_type = make_type(state, "FunctionType",
1128 : state->mod_type, FunctionType_fields,
1129 : 2,
1130 : "FunctionType(expr* argtypes, expr returns)");
1131 1477 : if (!state->FunctionType_type) return 0;
1132 1477 : state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
1133 : "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n"
1134 : " | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n"
1135 : " | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)\n"
1136 : " | Return(expr? value)\n"
1137 : " | Delete(expr* targets)\n"
1138 : " | Assign(expr* targets, expr value, string? type_comment)\n"
1139 : " | AugAssign(expr target, operator op, expr value)\n"
1140 : " | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
1141 : " | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
1142 : " | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
1143 : " | While(expr test, stmt* body, stmt* orelse)\n"
1144 : " | If(expr test, stmt* body, stmt* orelse)\n"
1145 : " | With(withitem* items, stmt* body, string? type_comment)\n"
1146 : " | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
1147 : " | Match(expr subject, match_case* cases)\n"
1148 : " | Raise(expr? exc, expr? cause)\n"
1149 : " | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
1150 : " | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
1151 : " | Assert(expr test, expr? msg)\n"
1152 : " | Import(alias* names)\n"
1153 : " | ImportFrom(identifier? module, alias* names, int? level)\n"
1154 : " | Global(identifier* names)\n"
1155 : " | Nonlocal(identifier* names)\n"
1156 : " | Expr(expr value)\n"
1157 : " | Pass\n"
1158 : " | Break\n"
1159 : " | Continue");
1160 1477 : if (!state->stmt_type) return 0;
1161 1477 : if (!add_attributes(state, state->stmt_type, stmt_attributes, 4)) return 0;
1162 1477 : if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
1163 0 : return 0;
1164 1477 : if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
1165 : -1)
1166 0 : return 0;
1167 1477 : state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
1168 : FunctionDef_fields, 6,
1169 : "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)");
1170 1477 : if (!state->FunctionDef_type) return 0;
1171 1477 : if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
1172 : -1)
1173 0 : return 0;
1174 1477 : if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
1175 : == -1)
1176 0 : return 0;
1177 1477 : state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
1178 : state->stmt_type,
1179 : AsyncFunctionDef_fields, 6,
1180 : "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)");
1181 1477 : if (!state->AsyncFunctionDef_type) return 0;
1182 1477 : if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
1183 : == -1)
1184 0 : return 0;
1185 1477 : if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
1186 : Py_None) == -1)
1187 0 : return 0;
1188 1477 : state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
1189 : ClassDef_fields, 5,
1190 : "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)");
1191 1477 : if (!state->ClassDef_type) return 0;
1192 1477 : state->Return_type = make_type(state, "Return", state->stmt_type,
1193 : Return_fields, 1,
1194 : "Return(expr? value)");
1195 1477 : if (!state->Return_type) return 0;
1196 1477 : if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
1197 0 : return 0;
1198 1477 : state->Delete_type = make_type(state, "Delete", state->stmt_type,
1199 : Delete_fields, 1,
1200 : "Delete(expr* targets)");
1201 1477 : if (!state->Delete_type) return 0;
1202 1477 : state->Assign_type = make_type(state, "Assign", state->stmt_type,
1203 : Assign_fields, 3,
1204 : "Assign(expr* targets, expr value, string? type_comment)");
1205 1477 : if (!state->Assign_type) return 0;
1206 1477 : if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
1207 : -1)
1208 0 : return 0;
1209 1477 : state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
1210 : AugAssign_fields, 3,
1211 : "AugAssign(expr target, operator op, expr value)");
1212 1477 : if (!state->AugAssign_type) return 0;
1213 1477 : state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
1214 : AnnAssign_fields, 4,
1215 : "AnnAssign(expr target, expr annotation, expr? value, int simple)");
1216 1477 : if (!state->AnnAssign_type) return 0;
1217 1477 : if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
1218 0 : return 0;
1219 1477 : state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
1220 : "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
1221 1477 : if (!state->For_type) return 0;
1222 1477 : if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
1223 0 : return 0;
1224 1477 : state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
1225 : AsyncFor_fields, 5,
1226 : "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
1227 1477 : if (!state->AsyncFor_type) return 0;
1228 1477 : if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
1229 : -1)
1230 0 : return 0;
1231 1477 : state->While_type = make_type(state, "While", state->stmt_type,
1232 : While_fields, 3,
1233 : "While(expr test, stmt* body, stmt* orelse)");
1234 1477 : if (!state->While_type) return 0;
1235 1477 : state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
1236 : "If(expr test, stmt* body, stmt* orelse)");
1237 1477 : if (!state->If_type) return 0;
1238 1477 : state->With_type = make_type(state, "With", state->stmt_type, With_fields,
1239 : 3,
1240 : "With(withitem* items, stmt* body, string? type_comment)");
1241 1477 : if (!state->With_type) return 0;
1242 1477 : if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
1243 0 : return 0;
1244 1477 : state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
1245 : AsyncWith_fields, 3,
1246 : "AsyncWith(withitem* items, stmt* body, string? type_comment)");
1247 1477 : if (!state->AsyncWith_type) return 0;
1248 1477 : if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
1249 : == -1)
1250 0 : return 0;
1251 1477 : state->Match_type = make_type(state, "Match", state->stmt_type,
1252 : Match_fields, 2,
1253 : "Match(expr subject, match_case* cases)");
1254 1477 : if (!state->Match_type) return 0;
1255 1477 : state->Raise_type = make_type(state, "Raise", state->stmt_type,
1256 : Raise_fields, 2,
1257 : "Raise(expr? exc, expr? cause)");
1258 1477 : if (!state->Raise_type) return 0;
1259 1477 : if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
1260 0 : return 0;
1261 1477 : if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
1262 0 : return 0;
1263 1477 : state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
1264 : "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
1265 1477 : if (!state->Try_type) return 0;
1266 1477 : state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
1267 : TryStar_fields, 4,
1268 : "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
1269 1477 : if (!state->TryStar_type) return 0;
1270 1477 : state->Assert_type = make_type(state, "Assert", state->stmt_type,
1271 : Assert_fields, 2,
1272 : "Assert(expr test, expr? msg)");
1273 1477 : if (!state->Assert_type) return 0;
1274 1477 : if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
1275 0 : return 0;
1276 1477 : state->Import_type = make_type(state, "Import", state->stmt_type,
1277 : Import_fields, 1,
1278 : "Import(alias* names)");
1279 1477 : if (!state->Import_type) return 0;
1280 1477 : state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
1281 : ImportFrom_fields, 3,
1282 : "ImportFrom(identifier? module, alias* names, int? level)");
1283 1477 : if (!state->ImportFrom_type) return 0;
1284 1477 : if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
1285 0 : return 0;
1286 1477 : if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
1287 0 : return 0;
1288 1477 : state->Global_type = make_type(state, "Global", state->stmt_type,
1289 : Global_fields, 1,
1290 : "Global(identifier* names)");
1291 1477 : if (!state->Global_type) return 0;
1292 1477 : state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
1293 : Nonlocal_fields, 1,
1294 : "Nonlocal(identifier* names)");
1295 1477 : if (!state->Nonlocal_type) return 0;
1296 1477 : state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
1297 : 1,
1298 : "Expr(expr value)");
1299 1477 : if (!state->Expr_type) return 0;
1300 1477 : state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
1301 : "Pass");
1302 1477 : if (!state->Pass_type) return 0;
1303 1477 : state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
1304 : "Break");
1305 1477 : if (!state->Break_type) return 0;
1306 1477 : state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
1307 : 0,
1308 : "Continue");
1309 1477 : if (!state->Continue_type) return 0;
1310 1477 : state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
1311 : "expr = BoolOp(boolop op, expr* values)\n"
1312 : " | NamedExpr(expr target, expr value)\n"
1313 : " | BinOp(expr left, operator op, expr right)\n"
1314 : " | UnaryOp(unaryop op, expr operand)\n"
1315 : " | Lambda(arguments args, expr body)\n"
1316 : " | IfExp(expr test, expr body, expr orelse)\n"
1317 : " | Dict(expr* keys, expr* values)\n"
1318 : " | Set(expr* elts)\n"
1319 : " | ListComp(expr elt, comprehension* generators)\n"
1320 : " | SetComp(expr elt, comprehension* generators)\n"
1321 : " | DictComp(expr key, expr value, comprehension* generators)\n"
1322 : " | GeneratorExp(expr elt, comprehension* generators)\n"
1323 : " | Await(expr value)\n"
1324 : " | Yield(expr? value)\n"
1325 : " | YieldFrom(expr value)\n"
1326 : " | Compare(expr left, cmpop* ops, expr* comparators)\n"
1327 : " | Call(expr func, expr* args, keyword* keywords)\n"
1328 : " | FormattedValue(expr value, int conversion, expr? format_spec)\n"
1329 : " | JoinedStr(expr* values)\n"
1330 : " | Constant(constant value, string? kind)\n"
1331 : " | Attribute(expr value, identifier attr, expr_context ctx)\n"
1332 : " | Subscript(expr value, expr slice, expr_context ctx)\n"
1333 : " | Starred(expr value, expr_context ctx)\n"
1334 : " | Name(identifier id, expr_context ctx)\n"
1335 : " | List(expr* elts, expr_context ctx)\n"
1336 : " | Tuple(expr* elts, expr_context ctx)\n"
1337 : " | Slice(expr? lower, expr? upper, expr? step)");
1338 1477 : if (!state->expr_type) return 0;
1339 1477 : if (!add_attributes(state, state->expr_type, expr_attributes, 4)) return 0;
1340 1477 : if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
1341 0 : return 0;
1342 1477 : if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
1343 : -1)
1344 0 : return 0;
1345 1477 : state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
1346 : BoolOp_fields, 2,
1347 : "BoolOp(boolop op, expr* values)");
1348 1477 : if (!state->BoolOp_type) return 0;
1349 1477 : state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
1350 : NamedExpr_fields, 2,
1351 : "NamedExpr(expr target, expr value)");
1352 1477 : if (!state->NamedExpr_type) return 0;
1353 1477 : state->BinOp_type = make_type(state, "BinOp", state->expr_type,
1354 : BinOp_fields, 3,
1355 : "BinOp(expr left, operator op, expr right)");
1356 1477 : if (!state->BinOp_type) return 0;
1357 1477 : state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
1358 : UnaryOp_fields, 2,
1359 : "UnaryOp(unaryop op, expr operand)");
1360 1477 : if (!state->UnaryOp_type) return 0;
1361 1477 : state->Lambda_type = make_type(state, "Lambda", state->expr_type,
1362 : Lambda_fields, 2,
1363 : "Lambda(arguments args, expr body)");
1364 1477 : if (!state->Lambda_type) return 0;
1365 1477 : state->IfExp_type = make_type(state, "IfExp", state->expr_type,
1366 : IfExp_fields, 3,
1367 : "IfExp(expr test, expr body, expr orelse)");
1368 1477 : if (!state->IfExp_type) return 0;
1369 1477 : state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
1370 : 2,
1371 : "Dict(expr* keys, expr* values)");
1372 1477 : if (!state->Dict_type) return 0;
1373 1477 : state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
1374 : "Set(expr* elts)");
1375 1477 : if (!state->Set_type) return 0;
1376 1477 : state->ListComp_type = make_type(state, "ListComp", state->expr_type,
1377 : ListComp_fields, 2,
1378 : "ListComp(expr elt, comprehension* generators)");
1379 1477 : if (!state->ListComp_type) return 0;
1380 1477 : state->SetComp_type = make_type(state, "SetComp", state->expr_type,
1381 : SetComp_fields, 2,
1382 : "SetComp(expr elt, comprehension* generators)");
1383 1477 : if (!state->SetComp_type) return 0;
1384 1477 : state->DictComp_type = make_type(state, "DictComp", state->expr_type,
1385 : DictComp_fields, 3,
1386 : "DictComp(expr key, expr value, comprehension* generators)");
1387 1477 : if (!state->DictComp_type) return 0;
1388 1477 : state->GeneratorExp_type = make_type(state, "GeneratorExp",
1389 : state->expr_type, GeneratorExp_fields,
1390 : 2,
1391 : "GeneratorExp(expr elt, comprehension* generators)");
1392 1477 : if (!state->GeneratorExp_type) return 0;
1393 1477 : state->Await_type = make_type(state, "Await", state->expr_type,
1394 : Await_fields, 1,
1395 : "Await(expr value)");
1396 1477 : if (!state->Await_type) return 0;
1397 1477 : state->Yield_type = make_type(state, "Yield", state->expr_type,
1398 : Yield_fields, 1,
1399 : "Yield(expr? value)");
1400 1477 : if (!state->Yield_type) return 0;
1401 1477 : if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
1402 0 : return 0;
1403 1477 : state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
1404 : YieldFrom_fields, 1,
1405 : "YieldFrom(expr value)");
1406 1477 : if (!state->YieldFrom_type) return 0;
1407 1477 : state->Compare_type = make_type(state, "Compare", state->expr_type,
1408 : Compare_fields, 3,
1409 : "Compare(expr left, cmpop* ops, expr* comparators)");
1410 1477 : if (!state->Compare_type) return 0;
1411 1477 : state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
1412 : 3,
1413 : "Call(expr func, expr* args, keyword* keywords)");
1414 1477 : if (!state->Call_type) return 0;
1415 1477 : state->FormattedValue_type = make_type(state, "FormattedValue",
1416 : state->expr_type,
1417 : FormattedValue_fields, 3,
1418 : "FormattedValue(expr value, int conversion, expr? format_spec)");
1419 1477 : if (!state->FormattedValue_type) return 0;
1420 1477 : if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
1421 : Py_None) == -1)
1422 0 : return 0;
1423 1477 : state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
1424 : JoinedStr_fields, 1,
1425 : "JoinedStr(expr* values)");
1426 1477 : if (!state->JoinedStr_type) return 0;
1427 1477 : state->Constant_type = make_type(state, "Constant", state->expr_type,
1428 : Constant_fields, 2,
1429 : "Constant(constant value, string? kind)");
1430 1477 : if (!state->Constant_type) return 0;
1431 1477 : if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
1432 0 : return 0;
1433 1477 : state->Attribute_type = make_type(state, "Attribute", state->expr_type,
1434 : Attribute_fields, 3,
1435 : "Attribute(expr value, identifier attr, expr_context ctx)");
1436 1477 : if (!state->Attribute_type) return 0;
1437 1477 : state->Subscript_type = make_type(state, "Subscript", state->expr_type,
1438 : Subscript_fields, 3,
1439 : "Subscript(expr value, expr slice, expr_context ctx)");
1440 1477 : if (!state->Subscript_type) return 0;
1441 1477 : state->Starred_type = make_type(state, "Starred", state->expr_type,
1442 : Starred_fields, 2,
1443 : "Starred(expr value, expr_context ctx)");
1444 1477 : if (!state->Starred_type) return 0;
1445 1477 : state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
1446 : 2,
1447 : "Name(identifier id, expr_context ctx)");
1448 1477 : if (!state->Name_type) return 0;
1449 1477 : state->List_type = make_type(state, "List", state->expr_type, List_fields,
1450 : 2,
1451 : "List(expr* elts, expr_context ctx)");
1452 1477 : if (!state->List_type) return 0;
1453 1477 : state->Tuple_type = make_type(state, "Tuple", state->expr_type,
1454 : Tuple_fields, 2,
1455 : "Tuple(expr* elts, expr_context ctx)");
1456 1477 : if (!state->Tuple_type) return 0;
1457 1477 : state->Slice_type = make_type(state, "Slice", state->expr_type,
1458 : Slice_fields, 3,
1459 : "Slice(expr? lower, expr? upper, expr? step)");
1460 1477 : if (!state->Slice_type) return 0;
1461 1477 : if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
1462 0 : return 0;
1463 1477 : if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
1464 0 : return 0;
1465 1477 : if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
1466 0 : return 0;
1467 1477 : state->expr_context_type = make_type(state, "expr_context",
1468 : state->AST_type, NULL, 0,
1469 : "expr_context = Load | Store | Del");
1470 1477 : if (!state->expr_context_type) return 0;
1471 1477 : if (!add_attributes(state, state->expr_context_type, NULL, 0)) return 0;
1472 1477 : state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
1473 : 0,
1474 : "Load");
1475 1477 : if (!state->Load_type) return 0;
1476 1477 : state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
1477 : NULL, NULL);
1478 1477 : if (!state->Load_singleton) return 0;
1479 1477 : state->Store_type = make_type(state, "Store", state->expr_context_type,
1480 : NULL, 0,
1481 : "Store");
1482 1477 : if (!state->Store_type) return 0;
1483 2954 : state->Store_singleton = PyType_GenericNew((PyTypeObject
1484 1477 : *)state->Store_type, NULL, NULL);
1485 1477 : if (!state->Store_singleton) return 0;
1486 1477 : state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
1487 : "Del");
1488 1477 : if (!state->Del_type) return 0;
1489 1477 : state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
1490 : NULL, NULL);
1491 1477 : if (!state->Del_singleton) return 0;
1492 1477 : state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
1493 : "boolop = And | Or");
1494 1477 : if (!state->boolop_type) return 0;
1495 1477 : if (!add_attributes(state, state->boolop_type, NULL, 0)) return 0;
1496 1477 : state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
1497 : "And");
1498 1477 : if (!state->And_type) return 0;
1499 1477 : state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
1500 : NULL, NULL);
1501 1477 : if (!state->And_singleton) return 0;
1502 1477 : state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
1503 : "Or");
1504 1477 : if (!state->Or_type) return 0;
1505 1477 : state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
1506 : NULL, NULL);
1507 1477 : if (!state->Or_singleton) return 0;
1508 1477 : state->operator_type = make_type(state, "operator", state->AST_type, NULL,
1509 : 0,
1510 : "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
1511 1477 : if (!state->operator_type) return 0;
1512 1477 : if (!add_attributes(state, state->operator_type, NULL, 0)) return 0;
1513 1477 : state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
1514 : "Add");
1515 1477 : if (!state->Add_type) return 0;
1516 1477 : state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
1517 : NULL, NULL);
1518 1477 : if (!state->Add_singleton) return 0;
1519 1477 : state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
1520 : "Sub");
1521 1477 : if (!state->Sub_type) return 0;
1522 1477 : state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
1523 : NULL, NULL);
1524 1477 : if (!state->Sub_singleton) return 0;
1525 1477 : state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
1526 : "Mult");
1527 1477 : if (!state->Mult_type) return 0;
1528 1477 : state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
1529 : NULL, NULL);
1530 1477 : if (!state->Mult_singleton) return 0;
1531 1477 : state->MatMult_type = make_type(state, "MatMult", state->operator_type,
1532 : NULL, 0,
1533 : "MatMult");
1534 1477 : if (!state->MatMult_type) return 0;
1535 2954 : state->MatMult_singleton = PyType_GenericNew((PyTypeObject
1536 1477 : *)state->MatMult_type, NULL,
1537 : NULL);
1538 1477 : if (!state->MatMult_singleton) return 0;
1539 1477 : state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
1540 : "Div");
1541 1477 : if (!state->Div_type) return 0;
1542 1477 : state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
1543 : NULL, NULL);
1544 1477 : if (!state->Div_singleton) return 0;
1545 1477 : state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
1546 : "Mod");
1547 1477 : if (!state->Mod_type) return 0;
1548 1477 : state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
1549 : NULL, NULL);
1550 1477 : if (!state->Mod_singleton) return 0;
1551 1477 : state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
1552 : "Pow");
1553 1477 : if (!state->Pow_type) return 0;
1554 1477 : state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
1555 : NULL, NULL);
1556 1477 : if (!state->Pow_singleton) return 0;
1557 1477 : state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
1558 : 0,
1559 : "LShift");
1560 1477 : if (!state->LShift_type) return 0;
1561 2954 : state->LShift_singleton = PyType_GenericNew((PyTypeObject
1562 1477 : *)state->LShift_type, NULL,
1563 : NULL);
1564 1477 : if (!state->LShift_singleton) return 0;
1565 1477 : state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
1566 : 0,
1567 : "RShift");
1568 1477 : if (!state->RShift_type) return 0;
1569 2954 : state->RShift_singleton = PyType_GenericNew((PyTypeObject
1570 1477 : *)state->RShift_type, NULL,
1571 : NULL);
1572 1477 : if (!state->RShift_singleton) return 0;
1573 1477 : state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
1574 : "BitOr");
1575 1477 : if (!state->BitOr_type) return 0;
1576 2954 : state->BitOr_singleton = PyType_GenericNew((PyTypeObject
1577 1477 : *)state->BitOr_type, NULL, NULL);
1578 1477 : if (!state->BitOr_singleton) return 0;
1579 1477 : state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
1580 : 0,
1581 : "BitXor");
1582 1477 : if (!state->BitXor_type) return 0;
1583 2954 : state->BitXor_singleton = PyType_GenericNew((PyTypeObject
1584 1477 : *)state->BitXor_type, NULL,
1585 : NULL);
1586 1477 : if (!state->BitXor_singleton) return 0;
1587 1477 : state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
1588 : 0,
1589 : "BitAnd");
1590 1477 : if (!state->BitAnd_type) return 0;
1591 2954 : state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
1592 1477 : *)state->BitAnd_type, NULL,
1593 : NULL);
1594 1477 : if (!state->BitAnd_singleton) return 0;
1595 1477 : state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
1596 : NULL, 0,
1597 : "FloorDiv");
1598 1477 : if (!state->FloorDiv_type) return 0;
1599 2954 : state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
1600 1477 : *)state->FloorDiv_type, NULL,
1601 : NULL);
1602 1477 : if (!state->FloorDiv_singleton) return 0;
1603 1477 : state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
1604 : "unaryop = Invert | Not | UAdd | USub");
1605 1477 : if (!state->unaryop_type) return 0;
1606 1477 : if (!add_attributes(state, state->unaryop_type, NULL, 0)) return 0;
1607 1477 : state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
1608 : 0,
1609 : "Invert");
1610 1477 : if (!state->Invert_type) return 0;
1611 2954 : state->Invert_singleton = PyType_GenericNew((PyTypeObject
1612 1477 : *)state->Invert_type, NULL,
1613 : NULL);
1614 1477 : if (!state->Invert_singleton) return 0;
1615 1477 : state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
1616 : "Not");
1617 1477 : if (!state->Not_type) return 0;
1618 1477 : state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
1619 : NULL, NULL);
1620 1477 : if (!state->Not_singleton) return 0;
1621 1477 : state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
1622 : "UAdd");
1623 1477 : if (!state->UAdd_type) return 0;
1624 1477 : state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
1625 : NULL, NULL);
1626 1477 : if (!state->UAdd_singleton) return 0;
1627 1477 : state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
1628 : "USub");
1629 1477 : if (!state->USub_type) return 0;
1630 1477 : state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
1631 : NULL, NULL);
1632 1477 : if (!state->USub_singleton) return 0;
1633 1477 : state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
1634 : "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
1635 1477 : if (!state->cmpop_type) return 0;
1636 1477 : if (!add_attributes(state, state->cmpop_type, NULL, 0)) return 0;
1637 1477 : state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
1638 : "Eq");
1639 1477 : if (!state->Eq_type) return 0;
1640 1477 : state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
1641 : NULL, NULL);
1642 1477 : if (!state->Eq_singleton) return 0;
1643 1477 : state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
1644 : "NotEq");
1645 1477 : if (!state->NotEq_type) return 0;
1646 2954 : state->NotEq_singleton = PyType_GenericNew((PyTypeObject
1647 1477 : *)state->NotEq_type, NULL, NULL);
1648 1477 : if (!state->NotEq_singleton) return 0;
1649 1477 : state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
1650 : "Lt");
1651 1477 : if (!state->Lt_type) return 0;
1652 1477 : state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
1653 : NULL, NULL);
1654 1477 : if (!state->Lt_singleton) return 0;
1655 1477 : state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
1656 : "LtE");
1657 1477 : if (!state->LtE_type) return 0;
1658 1477 : state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
1659 : NULL, NULL);
1660 1477 : if (!state->LtE_singleton) return 0;
1661 1477 : state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
1662 : "Gt");
1663 1477 : if (!state->Gt_type) return 0;
1664 1477 : state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
1665 : NULL, NULL);
1666 1477 : if (!state->Gt_singleton) return 0;
1667 1477 : state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
1668 : "GtE");
1669 1477 : if (!state->GtE_type) return 0;
1670 1477 : state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
1671 : NULL, NULL);
1672 1477 : if (!state->GtE_singleton) return 0;
1673 1477 : state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
1674 : "Is");
1675 1477 : if (!state->Is_type) return 0;
1676 1477 : state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
1677 : NULL, NULL);
1678 1477 : if (!state->Is_singleton) return 0;
1679 1477 : state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
1680 : "IsNot");
1681 1477 : if (!state->IsNot_type) return 0;
1682 2954 : state->IsNot_singleton = PyType_GenericNew((PyTypeObject
1683 1477 : *)state->IsNot_type, NULL, NULL);
1684 1477 : if (!state->IsNot_singleton) return 0;
1685 1477 : state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
1686 : "In");
1687 1477 : if (!state->In_type) return 0;
1688 1477 : state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
1689 : NULL, NULL);
1690 1477 : if (!state->In_singleton) return 0;
1691 1477 : state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
1692 : "NotIn");
1693 1477 : if (!state->NotIn_type) return 0;
1694 2954 : state->NotIn_singleton = PyType_GenericNew((PyTypeObject
1695 1477 : *)state->NotIn_type, NULL, NULL);
1696 1477 : if (!state->NotIn_singleton) return 0;
1697 1477 : state->comprehension_type = make_type(state, "comprehension",
1698 : state->AST_type,
1699 : comprehension_fields, 4,
1700 : "comprehension(expr target, expr iter, expr* ifs, int is_async)");
1701 1477 : if (!state->comprehension_type) return 0;
1702 1477 : if (!add_attributes(state, state->comprehension_type, NULL, 0)) return 0;
1703 1477 : state->excepthandler_type = make_type(state, "excepthandler",
1704 : state->AST_type, NULL, 0,
1705 : "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
1706 1477 : if (!state->excepthandler_type) return 0;
1707 1477 : if (!add_attributes(state, state->excepthandler_type,
1708 0 : excepthandler_attributes, 4)) return 0;
1709 1477 : if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
1710 : == -1)
1711 0 : return 0;
1712 1477 : if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
1713 : Py_None) == -1)
1714 0 : return 0;
1715 1477 : state->ExceptHandler_type = make_type(state, "ExceptHandler",
1716 : state->excepthandler_type,
1717 : ExceptHandler_fields, 3,
1718 : "ExceptHandler(expr? type, identifier? name, stmt* body)");
1719 1477 : if (!state->ExceptHandler_type) return 0;
1720 1477 : if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
1721 0 : return 0;
1722 1477 : if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
1723 0 : return 0;
1724 1477 : state->arguments_type = make_type(state, "arguments", state->AST_type,
1725 : arguments_fields, 7,
1726 : "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults, arg? kwarg, expr* defaults)");
1727 1477 : if (!state->arguments_type) return 0;
1728 1477 : if (!add_attributes(state, state->arguments_type, NULL, 0)) return 0;
1729 1477 : if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
1730 0 : return 0;
1731 1477 : if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
1732 0 : return 0;
1733 1477 : state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
1734 : "arg(identifier arg, expr? annotation, string? type_comment)");
1735 1477 : if (!state->arg_type) return 0;
1736 1477 : if (!add_attributes(state, state->arg_type, arg_attributes, 4)) return 0;
1737 1477 : if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
1738 0 : return 0;
1739 1477 : if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
1740 0 : return 0;
1741 1477 : if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
1742 0 : return 0;
1743 1477 : if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
1744 0 : return 0;
1745 1477 : state->keyword_type = make_type(state, "keyword", state->AST_type,
1746 : keyword_fields, 2,
1747 : "keyword(identifier? arg, expr value)");
1748 1477 : if (!state->keyword_type) return 0;
1749 1477 : if (!add_attributes(state, state->keyword_type, keyword_attributes, 4))
1750 0 : return 0;
1751 1477 : if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
1752 0 : return 0;
1753 1477 : if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
1754 0 : return 0;
1755 1477 : if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
1756 : == -1)
1757 0 : return 0;
1758 1477 : state->alias_type = make_type(state, "alias", state->AST_type,
1759 : alias_fields, 2,
1760 : "alias(identifier name, identifier? asname)");
1761 1477 : if (!state->alias_type) return 0;
1762 1477 : if (!add_attributes(state, state->alias_type, alias_attributes, 4)) return
1763 0 : 0;
1764 1477 : if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
1765 0 : return 0;
1766 1477 : if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
1767 0 : return 0;
1768 1477 : if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
1769 : -1)
1770 0 : return 0;
1771 1477 : state->withitem_type = make_type(state, "withitem", state->AST_type,
1772 : withitem_fields, 2,
1773 : "withitem(expr context_expr, expr? optional_vars)");
1774 1477 : if (!state->withitem_type) return 0;
1775 1477 : if (!add_attributes(state, state->withitem_type, NULL, 0)) return 0;
1776 1477 : if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
1777 : == -1)
1778 0 : return 0;
1779 1477 : state->match_case_type = make_type(state, "match_case", state->AST_type,
1780 : match_case_fields, 3,
1781 : "match_case(pattern pattern, expr? guard, stmt* body)");
1782 1477 : if (!state->match_case_type) return 0;
1783 1477 : if (!add_attributes(state, state->match_case_type, NULL, 0)) return 0;
1784 1477 : if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
1785 0 : return 0;
1786 1477 : state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
1787 : "pattern = MatchValue(expr value)\n"
1788 : " | MatchSingleton(constant value)\n"
1789 : " | MatchSequence(pattern* patterns)\n"
1790 : " | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
1791 : " | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
1792 : " | MatchStar(identifier? name)\n"
1793 : " | MatchAs(pattern? pattern, identifier? name)\n"
1794 : " | MatchOr(pattern* patterns)");
1795 1477 : if (!state->pattern_type) return 0;
1796 1477 : if (!add_attributes(state, state->pattern_type, pattern_attributes, 4))
1797 0 : return 0;
1798 1477 : state->MatchValue_type = make_type(state, "MatchValue",
1799 : state->pattern_type, MatchValue_fields,
1800 : 1,
1801 : "MatchValue(expr value)");
1802 1477 : if (!state->MatchValue_type) return 0;
1803 1477 : state->MatchSingleton_type = make_type(state, "MatchSingleton",
1804 : state->pattern_type,
1805 : MatchSingleton_fields, 1,
1806 : "MatchSingleton(constant value)");
1807 1477 : if (!state->MatchSingleton_type) return 0;
1808 1477 : state->MatchSequence_type = make_type(state, "MatchSequence",
1809 : state->pattern_type,
1810 : MatchSequence_fields, 1,
1811 : "MatchSequence(pattern* patterns)");
1812 1477 : if (!state->MatchSequence_type) return 0;
1813 1477 : state->MatchMapping_type = make_type(state, "MatchMapping",
1814 : state->pattern_type,
1815 : MatchMapping_fields, 3,
1816 : "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
1817 1477 : if (!state->MatchMapping_type) return 0;
1818 1477 : if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
1819 0 : return 0;
1820 1477 : state->MatchClass_type = make_type(state, "MatchClass",
1821 : state->pattern_type, MatchClass_fields,
1822 : 4,
1823 : "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
1824 1477 : if (!state->MatchClass_type) return 0;
1825 1477 : state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
1826 : MatchStar_fields, 1,
1827 : "MatchStar(identifier? name)");
1828 1477 : if (!state->MatchStar_type) return 0;
1829 1477 : if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
1830 0 : return 0;
1831 1477 : state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
1832 : MatchAs_fields, 2,
1833 : "MatchAs(pattern? pattern, identifier? name)");
1834 1477 : if (!state->MatchAs_type) return 0;
1835 1477 : if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
1836 0 : return 0;
1837 1477 : if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
1838 0 : return 0;
1839 1477 : state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
1840 : MatchOr_fields, 1,
1841 : "MatchOr(pattern* patterns)");
1842 1477 : if (!state->MatchOr_type) return 0;
1843 1477 : state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
1844 : NULL, 0,
1845 : "type_ignore = TypeIgnore(int lineno, string tag)");
1846 1477 : if (!state->type_ignore_type) return 0;
1847 1477 : if (!add_attributes(state, state->type_ignore_type, NULL, 0)) return 0;
1848 1477 : state->TypeIgnore_type = make_type(state, "TypeIgnore",
1849 : state->type_ignore_type,
1850 : TypeIgnore_fields, 2,
1851 : "TypeIgnore(int lineno, string tag)");
1852 1477 : if (!state->TypeIgnore_type) return 0;
1853 :
1854 1477 : state->initialized = 1;
1855 1477 : return 1;
1856 : }
1857 :
1858 : static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
1859 : PyArena* arena);
1860 : static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
1861 : PyArena* arena);
1862 : static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
1863 : PyArena* arena);
1864 : static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
1865 : expr_context_ty* out, PyArena* arena);
1866 : static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
1867 : out, PyArena* arena);
1868 : static int obj2ast_operator(struct ast_state *state, PyObject* obj,
1869 : operator_ty* out, PyArena* arena);
1870 : static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
1871 : out, PyArena* arena);
1872 : static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
1873 : PyArena* arena);
1874 : static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
1875 : comprehension_ty* out, PyArena* arena);
1876 : static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
1877 : excepthandler_ty* out, PyArena* arena);
1878 : static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
1879 : arguments_ty* out, PyArena* arena);
1880 : static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
1881 : PyArena* arena);
1882 : static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
1883 : out, PyArena* arena);
1884 : static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
1885 : PyArena* arena);
1886 : static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
1887 : withitem_ty* out, PyArena* arena);
1888 : static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
1889 : match_case_ty* out, PyArena* arena);
1890 : static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
1891 : out, PyArena* arena);
1892 : static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
1893 : type_ignore_ty* out, PyArena* arena);
1894 :
1895 : mod_ty
1896 48772 : _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
1897 : PyArena *arena)
1898 : {
1899 : mod_ty p;
1900 48772 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1901 48772 : if (!p)
1902 0 : return NULL;
1903 48772 : p->kind = Module_kind;
1904 48772 : p->v.Module.body = body;
1905 48772 : p->v.Module.type_ignores = type_ignores;
1906 48772 : return p;
1907 : }
1908 :
1909 : mod_ty
1910 4165 : _PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
1911 : {
1912 : mod_ty p;
1913 4165 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1914 4165 : if (!p)
1915 0 : return NULL;
1916 4165 : p->kind = Interactive_kind;
1917 4165 : p->v.Interactive.body = body;
1918 4165 : return p;
1919 : }
1920 :
1921 : mod_ty
1922 73366 : _PyAST_Expression(expr_ty body, PyArena *arena)
1923 : {
1924 : mod_ty p;
1925 73366 : if (!body) {
1926 0 : PyErr_SetString(PyExc_ValueError,
1927 : "field 'body' is required for Expression");
1928 0 : return NULL;
1929 : }
1930 73366 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1931 73366 : if (!p)
1932 0 : return NULL;
1933 73366 : p->kind = Expression_kind;
1934 73366 : p->v.Expression.body = body;
1935 73366 : return p;
1936 : }
1937 :
1938 : mod_ty
1939 12 : _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
1940 : {
1941 : mod_ty p;
1942 12 : if (!returns) {
1943 0 : PyErr_SetString(PyExc_ValueError,
1944 : "field 'returns' is required for FunctionType");
1945 0 : return NULL;
1946 : }
1947 12 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1948 12 : if (!p)
1949 0 : return NULL;
1950 12 : p->kind = FunctionType_kind;
1951 12 : p->v.FunctionType.argtypes = argtypes;
1952 12 : p->v.FunctionType.returns = returns;
1953 12 : return p;
1954 : }
1955 :
1956 : stmt_ty
1957 377257 : _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
1958 : asdl_expr_seq * decorator_list, expr_ty returns, string
1959 : type_comment, int lineno, int col_offset, int end_lineno,
1960 : int end_col_offset, PyArena *arena)
1961 : {
1962 : stmt_ty p;
1963 377257 : if (!name) {
1964 0 : PyErr_SetString(PyExc_ValueError,
1965 : "field 'name' is required for FunctionDef");
1966 0 : return NULL;
1967 : }
1968 377257 : if (!args) {
1969 0 : PyErr_SetString(PyExc_ValueError,
1970 : "field 'args' is required for FunctionDef");
1971 0 : return NULL;
1972 : }
1973 377257 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
1974 377257 : if (!p)
1975 0 : return NULL;
1976 377257 : p->kind = FunctionDef_kind;
1977 377257 : p->v.FunctionDef.name = name;
1978 377257 : p->v.FunctionDef.args = args;
1979 377257 : p->v.FunctionDef.body = body;
1980 377257 : p->v.FunctionDef.decorator_list = decorator_list;
1981 377257 : p->v.FunctionDef.returns = returns;
1982 377257 : p->v.FunctionDef.type_comment = type_comment;
1983 377257 : p->lineno = lineno;
1984 377257 : p->col_offset = col_offset;
1985 377257 : p->end_lineno = end_lineno;
1986 377257 : p->end_col_offset = end_col_offset;
1987 377257 : return p;
1988 : }
1989 :
1990 : stmt_ty
1991 3894 : _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
1992 : body, asdl_expr_seq * decorator_list, expr_ty returns,
1993 : string type_comment, int lineno, int col_offset, int
1994 : end_lineno, int end_col_offset, PyArena *arena)
1995 : {
1996 : stmt_ty p;
1997 3894 : if (!name) {
1998 0 : PyErr_SetString(PyExc_ValueError,
1999 : "field 'name' is required for AsyncFunctionDef");
2000 0 : return NULL;
2001 : }
2002 3894 : if (!args) {
2003 0 : PyErr_SetString(PyExc_ValueError,
2004 : "field 'args' is required for AsyncFunctionDef");
2005 0 : return NULL;
2006 : }
2007 3894 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2008 3894 : if (!p)
2009 0 : return NULL;
2010 3894 : p->kind = AsyncFunctionDef_kind;
2011 3894 : p->v.AsyncFunctionDef.name = name;
2012 3894 : p->v.AsyncFunctionDef.args = args;
2013 3894 : p->v.AsyncFunctionDef.body = body;
2014 3894 : p->v.AsyncFunctionDef.decorator_list = decorator_list;
2015 3894 : p->v.AsyncFunctionDef.returns = returns;
2016 3894 : p->v.AsyncFunctionDef.type_comment = type_comment;
2017 3894 : p->lineno = lineno;
2018 3894 : p->col_offset = col_offset;
2019 3894 : p->end_lineno = end_lineno;
2020 3894 : p->end_col_offset = end_col_offset;
2021 3894 : return p;
2022 : }
2023 :
2024 : stmt_ty
2025 60776 : _PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
2026 : keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
2027 : int lineno, int col_offset, int end_lineno, int end_col_offset,
2028 : PyArena *arena)
2029 : {
2030 : stmt_ty p;
2031 60776 : if (!name) {
2032 0 : PyErr_SetString(PyExc_ValueError,
2033 : "field 'name' is required for ClassDef");
2034 0 : return NULL;
2035 : }
2036 60776 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2037 60776 : if (!p)
2038 0 : return NULL;
2039 60776 : p->kind = ClassDef_kind;
2040 60776 : p->v.ClassDef.name = name;
2041 60776 : p->v.ClassDef.bases = bases;
2042 60776 : p->v.ClassDef.keywords = keywords;
2043 60776 : p->v.ClassDef.body = body;
2044 60776 : p->v.ClassDef.decorator_list = decorator_list;
2045 60776 : p->lineno = lineno;
2046 60776 : p->col_offset = col_offset;
2047 60776 : p->end_lineno = end_lineno;
2048 60776 : p->end_col_offset = end_col_offset;
2049 60776 : return p;
2050 : }
2051 :
2052 : stmt_ty
2053 248362 : _PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
2054 : end_col_offset, PyArena *arena)
2055 : {
2056 : stmt_ty p;
2057 248362 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2058 248362 : if (!p)
2059 0 : return NULL;
2060 248362 : p->kind = Return_kind;
2061 248362 : p->v.Return.value = value;
2062 248362 : p->lineno = lineno;
2063 248362 : p->col_offset = col_offset;
2064 248362 : p->end_lineno = end_lineno;
2065 248362 : p->end_col_offset = end_col_offset;
2066 248362 : return p;
2067 : }
2068 :
2069 : stmt_ty
2070 9122 : _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
2071 : end_lineno, int end_col_offset, PyArena *arena)
2072 : {
2073 : stmt_ty p;
2074 9122 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2075 9122 : if (!p)
2076 0 : return NULL;
2077 9122 : p->kind = Delete_kind;
2078 9122 : p->v.Delete.targets = targets;
2079 9122 : p->lineno = lineno;
2080 9122 : p->col_offset = col_offset;
2081 9122 : p->end_lineno = end_lineno;
2082 9122 : p->end_col_offset = end_col_offset;
2083 9122 : return p;
2084 : }
2085 :
2086 : stmt_ty
2087 828756 : _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
2088 : lineno, int col_offset, int end_lineno, int end_col_offset,
2089 : PyArena *arena)
2090 : {
2091 : stmt_ty p;
2092 828756 : if (!value) {
2093 0 : PyErr_SetString(PyExc_ValueError,
2094 : "field 'value' is required for Assign");
2095 0 : return NULL;
2096 : }
2097 828756 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2098 828756 : if (!p)
2099 0 : return NULL;
2100 828756 : p->kind = Assign_kind;
2101 828756 : p->v.Assign.targets = targets;
2102 828756 : p->v.Assign.value = value;
2103 828756 : p->v.Assign.type_comment = type_comment;
2104 828756 : p->lineno = lineno;
2105 828756 : p->col_offset = col_offset;
2106 828756 : p->end_lineno = end_lineno;
2107 828756 : p->end_col_offset = end_col_offset;
2108 828756 : return p;
2109 : }
2110 :
2111 : stmt_ty
2112 26551 : _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
2113 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2114 : {
2115 : stmt_ty p;
2116 26551 : if (!target) {
2117 0 : PyErr_SetString(PyExc_ValueError,
2118 : "field 'target' is required for AugAssign");
2119 0 : return NULL;
2120 : }
2121 26551 : if (!op) {
2122 0 : PyErr_SetString(PyExc_ValueError,
2123 : "field 'op' is required for AugAssign");
2124 0 : return NULL;
2125 : }
2126 26551 : if (!value) {
2127 0 : PyErr_SetString(PyExc_ValueError,
2128 : "field 'value' is required for AugAssign");
2129 0 : return NULL;
2130 : }
2131 26551 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2132 26551 : if (!p)
2133 0 : return NULL;
2134 26551 : p->kind = AugAssign_kind;
2135 26551 : p->v.AugAssign.target = target;
2136 26551 : p->v.AugAssign.op = op;
2137 26551 : p->v.AugAssign.value = value;
2138 26551 : p->lineno = lineno;
2139 26551 : p->col_offset = col_offset;
2140 26551 : p->end_lineno = end_lineno;
2141 26551 : p->end_col_offset = end_col_offset;
2142 26551 : return p;
2143 : }
2144 :
2145 : stmt_ty
2146 11492 : _PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
2147 : int lineno, int col_offset, int end_lineno, int
2148 : end_col_offset, PyArena *arena)
2149 : {
2150 : stmt_ty p;
2151 11492 : if (!target) {
2152 0 : PyErr_SetString(PyExc_ValueError,
2153 : "field 'target' is required for AnnAssign");
2154 0 : return NULL;
2155 : }
2156 11492 : if (!annotation) {
2157 0 : PyErr_SetString(PyExc_ValueError,
2158 : "field 'annotation' is required for AnnAssign");
2159 0 : return NULL;
2160 : }
2161 11492 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2162 11492 : if (!p)
2163 0 : return NULL;
2164 11492 : p->kind = AnnAssign_kind;
2165 11492 : p->v.AnnAssign.target = target;
2166 11492 : p->v.AnnAssign.annotation = annotation;
2167 11492 : p->v.AnnAssign.value = value;
2168 11492 : p->v.AnnAssign.simple = simple;
2169 11492 : p->lineno = lineno;
2170 11492 : p->col_offset = col_offset;
2171 11492 : p->end_lineno = end_lineno;
2172 11492 : p->end_col_offset = end_col_offset;
2173 11492 : return p;
2174 : }
2175 :
2176 : stmt_ty
2177 62858 : _PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
2178 : orelse, string type_comment, int lineno, int col_offset, int
2179 : end_lineno, int end_col_offset, PyArena *arena)
2180 : {
2181 : stmt_ty p;
2182 62858 : if (!target) {
2183 0 : PyErr_SetString(PyExc_ValueError,
2184 : "field 'target' is required for For");
2185 0 : return NULL;
2186 : }
2187 62858 : if (!iter) {
2188 0 : PyErr_SetString(PyExc_ValueError,
2189 : "field 'iter' is required for For");
2190 0 : return NULL;
2191 : }
2192 62858 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2193 62858 : if (!p)
2194 0 : return NULL;
2195 62858 : p->kind = For_kind;
2196 62858 : p->v.For.target = target;
2197 62858 : p->v.For.iter = iter;
2198 62858 : p->v.For.body = body;
2199 62858 : p->v.For.orelse = orelse;
2200 62858 : p->v.For.type_comment = type_comment;
2201 62858 : p->lineno = lineno;
2202 62858 : p->col_offset = col_offset;
2203 62858 : p->end_lineno = end_lineno;
2204 62858 : p->end_col_offset = end_col_offset;
2205 62858 : return p;
2206 : }
2207 :
2208 : stmt_ty
2209 197 : _PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
2210 : asdl_stmt_seq * orelse, string type_comment, int lineno, int
2211 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2212 : {
2213 : stmt_ty p;
2214 197 : if (!target) {
2215 0 : PyErr_SetString(PyExc_ValueError,
2216 : "field 'target' is required for AsyncFor");
2217 0 : return NULL;
2218 : }
2219 197 : if (!iter) {
2220 0 : PyErr_SetString(PyExc_ValueError,
2221 : "field 'iter' is required for AsyncFor");
2222 0 : return NULL;
2223 : }
2224 197 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2225 197 : if (!p)
2226 0 : return NULL;
2227 197 : p->kind = AsyncFor_kind;
2228 197 : p->v.AsyncFor.target = target;
2229 197 : p->v.AsyncFor.iter = iter;
2230 197 : p->v.AsyncFor.body = body;
2231 197 : p->v.AsyncFor.orelse = orelse;
2232 197 : p->v.AsyncFor.type_comment = type_comment;
2233 197 : p->lineno = lineno;
2234 197 : p->col_offset = col_offset;
2235 197 : p->end_lineno = end_lineno;
2236 197 : p->end_col_offset = end_col_offset;
2237 197 : return p;
2238 : }
2239 :
2240 : stmt_ty
2241 12180 : _PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
2242 : lineno, int col_offset, int end_lineno, int end_col_offset,
2243 : PyArena *arena)
2244 : {
2245 : stmt_ty p;
2246 12180 : if (!test) {
2247 0 : PyErr_SetString(PyExc_ValueError,
2248 : "field 'test' is required for While");
2249 0 : return NULL;
2250 : }
2251 12180 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2252 12180 : if (!p)
2253 0 : return NULL;
2254 12180 : p->kind = While_kind;
2255 12180 : p->v.While.test = test;
2256 12180 : p->v.While.body = body;
2257 12180 : p->v.While.orelse = orelse;
2258 12180 : p->lineno = lineno;
2259 12180 : p->col_offset = col_offset;
2260 12180 : p->end_lineno = end_lineno;
2261 12180 : p->end_col_offset = end_col_offset;
2262 12180 : return p;
2263 : }
2264 :
2265 : stmt_ty
2266 534343 : _PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
2267 : lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
2268 : *arena)
2269 : {
2270 : stmt_ty p;
2271 534343 : if (!test) {
2272 0 : PyErr_SetString(PyExc_ValueError,
2273 : "field 'test' is required for If");
2274 0 : return NULL;
2275 : }
2276 534343 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2277 534343 : if (!p)
2278 0 : return NULL;
2279 534343 : p->kind = If_kind;
2280 534343 : p->v.If.test = test;
2281 534343 : p->v.If.body = body;
2282 534343 : p->v.If.orelse = orelse;
2283 534343 : p->lineno = lineno;
2284 534343 : p->col_offset = col_offset;
2285 534343 : p->end_lineno = end_lineno;
2286 534343 : p->end_col_offset = end_col_offset;
2287 534343 : return p;
2288 : }
2289 :
2290 : stmt_ty
2291 38968 : _PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
2292 : type_comment, int lineno, int col_offset, int end_lineno, int
2293 : end_col_offset, PyArena *arena)
2294 : {
2295 : stmt_ty p;
2296 38968 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2297 38968 : if (!p)
2298 0 : return NULL;
2299 38968 : p->kind = With_kind;
2300 38968 : p->v.With.items = items;
2301 38968 : p->v.With.body = body;
2302 38968 : p->v.With.type_comment = type_comment;
2303 38968 : p->lineno = lineno;
2304 38968 : p->col_offset = col_offset;
2305 38968 : p->end_lineno = end_lineno;
2306 38968 : p->end_col_offset = end_col_offset;
2307 38968 : return p;
2308 : }
2309 :
2310 : stmt_ty
2311 380 : _PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
2312 : type_comment, int lineno, int col_offset, int end_lineno, int
2313 : end_col_offset, PyArena *arena)
2314 : {
2315 : stmt_ty p;
2316 380 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2317 380 : if (!p)
2318 0 : return NULL;
2319 380 : p->kind = AsyncWith_kind;
2320 380 : p->v.AsyncWith.items = items;
2321 380 : p->v.AsyncWith.body = body;
2322 380 : p->v.AsyncWith.type_comment = type_comment;
2323 380 : p->lineno = lineno;
2324 380 : p->col_offset = col_offset;
2325 380 : p->end_lineno = end_lineno;
2326 380 : p->end_col_offset = end_col_offset;
2327 380 : return p;
2328 : }
2329 :
2330 : stmt_ty
2331 1247 : _PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
2332 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2333 : {
2334 : stmt_ty p;
2335 1247 : if (!subject) {
2336 0 : PyErr_SetString(PyExc_ValueError,
2337 : "field 'subject' is required for Match");
2338 0 : return NULL;
2339 : }
2340 1247 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2341 1247 : if (!p)
2342 0 : return NULL;
2343 1247 : p->kind = Match_kind;
2344 1247 : p->v.Match.subject = subject;
2345 1247 : p->v.Match.cases = cases;
2346 1247 : p->lineno = lineno;
2347 1247 : p->col_offset = col_offset;
2348 1247 : p->end_lineno = end_lineno;
2349 1247 : p->end_col_offset = end_col_offset;
2350 1247 : return p;
2351 : }
2352 :
2353 : stmt_ty
2354 63708 : _PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
2355 : end_lineno, int end_col_offset, PyArena *arena)
2356 : {
2357 : stmt_ty p;
2358 63708 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2359 63708 : if (!p)
2360 0 : return NULL;
2361 63708 : p->kind = Raise_kind;
2362 63708 : p->v.Raise.exc = exc;
2363 63708 : p->v.Raise.cause = cause;
2364 63708 : p->lineno = lineno;
2365 63708 : p->col_offset = col_offset;
2366 63708 : p->end_lineno = end_lineno;
2367 63708 : p->end_col_offset = end_col_offset;
2368 63708 : return p;
2369 : }
2370 :
2371 : stmt_ty
2372 50781 : _PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
2373 : asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
2374 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2375 : {
2376 : stmt_ty p;
2377 50781 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2378 50781 : if (!p)
2379 0 : return NULL;
2380 50781 : p->kind = Try_kind;
2381 50781 : p->v.Try.body = body;
2382 50781 : p->v.Try.handlers = handlers;
2383 50781 : p->v.Try.orelse = orelse;
2384 50781 : p->v.Try.finalbody = finalbody;
2385 50781 : p->lineno = lineno;
2386 50781 : p->col_offset = col_offset;
2387 50781 : p->end_lineno = end_lineno;
2388 50781 : p->end_col_offset = end_col_offset;
2389 50781 : return p;
2390 : }
2391 :
2392 : stmt_ty
2393 269 : _PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
2394 : asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
2395 : int col_offset, int end_lineno, int end_col_offset, PyArena
2396 : *arena)
2397 : {
2398 : stmt_ty p;
2399 269 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2400 269 : if (!p)
2401 0 : return NULL;
2402 269 : p->kind = TryStar_kind;
2403 269 : p->v.TryStar.body = body;
2404 269 : p->v.TryStar.handlers = handlers;
2405 269 : p->v.TryStar.orelse = orelse;
2406 269 : p->v.TryStar.finalbody = finalbody;
2407 269 : p->lineno = lineno;
2408 269 : p->col_offset = col_offset;
2409 269 : p->end_lineno = end_lineno;
2410 269 : p->end_col_offset = end_col_offset;
2411 269 : return p;
2412 : }
2413 :
2414 : stmt_ty
2415 10003 : _PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
2416 : end_lineno, int end_col_offset, PyArena *arena)
2417 : {
2418 : stmt_ty p;
2419 10003 : if (!test) {
2420 0 : PyErr_SetString(PyExc_ValueError,
2421 : "field 'test' is required for Assert");
2422 0 : return NULL;
2423 : }
2424 10003 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2425 10003 : if (!p)
2426 0 : return NULL;
2427 10003 : p->kind = Assert_kind;
2428 10003 : p->v.Assert.test = test;
2429 10003 : p->v.Assert.msg = msg;
2430 10003 : p->lineno = lineno;
2431 10003 : p->col_offset = col_offset;
2432 10003 : p->end_lineno = end_lineno;
2433 10003 : p->end_col_offset = end_col_offset;
2434 10003 : return p;
2435 : }
2436 :
2437 : stmt_ty
2438 46134 : _PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
2439 : end_lineno, int end_col_offset, PyArena *arena)
2440 : {
2441 : stmt_ty p;
2442 46134 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2443 46134 : if (!p)
2444 0 : return NULL;
2445 46134 : p->kind = Import_kind;
2446 46134 : p->v.Import.names = names;
2447 46134 : p->lineno = lineno;
2448 46134 : p->col_offset = col_offset;
2449 46134 : p->end_lineno = end_lineno;
2450 46134 : p->end_col_offset = end_col_offset;
2451 46134 : return p;
2452 : }
2453 :
2454 : stmt_ty
2455 46503 : _PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
2456 : lineno, int col_offset, int end_lineno, int end_col_offset,
2457 : PyArena *arena)
2458 : {
2459 : stmt_ty p;
2460 46503 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2461 46503 : if (!p)
2462 0 : return NULL;
2463 46503 : p->kind = ImportFrom_kind;
2464 46503 : p->v.ImportFrom.module = module;
2465 46503 : p->v.ImportFrom.names = names;
2466 46503 : p->v.ImportFrom.level = level;
2467 46503 : p->lineno = lineno;
2468 46503 : p->col_offset = col_offset;
2469 46503 : p->end_lineno = end_lineno;
2470 46503 : p->end_col_offset = end_col_offset;
2471 46503 : return p;
2472 : }
2473 :
2474 : stmt_ty
2475 1905 : _PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
2476 : end_lineno, int end_col_offset, PyArena *arena)
2477 : {
2478 : stmt_ty p;
2479 1905 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2480 1905 : if (!p)
2481 0 : return NULL;
2482 1905 : p->kind = Global_kind;
2483 1905 : p->v.Global.names = names;
2484 1905 : p->lineno = lineno;
2485 1905 : p->col_offset = col_offset;
2486 1905 : p->end_lineno = end_lineno;
2487 1905 : p->end_col_offset = end_col_offset;
2488 1905 : return p;
2489 : }
2490 :
2491 : stmt_ty
2492 948 : _PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
2493 : end_lineno, int end_col_offset, PyArena *arena)
2494 : {
2495 : stmt_ty p;
2496 948 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2497 948 : if (!p)
2498 0 : return NULL;
2499 948 : p->kind = Nonlocal_kind;
2500 948 : p->v.Nonlocal.names = names;
2501 948 : p->lineno = lineno;
2502 948 : p->col_offset = col_offset;
2503 948 : p->end_lineno = end_lineno;
2504 948 : p->end_col_offset = end_col_offset;
2505 948 : return p;
2506 : }
2507 :
2508 : stmt_ty
2509 890497 : _PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
2510 : end_col_offset, PyArena *arena)
2511 : {
2512 : stmt_ty p;
2513 890497 : if (!value) {
2514 0 : PyErr_SetString(PyExc_ValueError,
2515 : "field 'value' is required for Expr");
2516 0 : return NULL;
2517 : }
2518 890497 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2519 890497 : if (!p)
2520 0 : return NULL;
2521 890497 : p->kind = Expr_kind;
2522 890497 : p->v.Expr.value = value;
2523 890497 : p->lineno = lineno;
2524 890497 : p->col_offset = col_offset;
2525 890497 : p->end_lineno = end_lineno;
2526 890497 : p->end_col_offset = end_col_offset;
2527 890497 : return p;
2528 : }
2529 :
2530 : stmt_ty
2531 28174 : _PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
2532 : PyArena *arena)
2533 : {
2534 : stmt_ty p;
2535 28174 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2536 28174 : if (!p)
2537 0 : return NULL;
2538 28174 : p->kind = Pass_kind;
2539 28174 : p->lineno = lineno;
2540 28174 : p->col_offset = col_offset;
2541 28174 : p->end_lineno = end_lineno;
2542 28174 : p->end_col_offset = end_col_offset;
2543 28174 : return p;
2544 : }
2545 :
2546 : stmt_ty
2547 10257 : _PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
2548 : PyArena *arena)
2549 : {
2550 : stmt_ty p;
2551 10257 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2552 10257 : if (!p)
2553 0 : return NULL;
2554 10257 : p->kind = Break_kind;
2555 10257 : p->lineno = lineno;
2556 10257 : p->col_offset = col_offset;
2557 10257 : p->end_lineno = end_lineno;
2558 10257 : p->end_col_offset = end_col_offset;
2559 10257 : return p;
2560 : }
2561 :
2562 : stmt_ty
2563 8976 : _PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
2564 : PyArena *arena)
2565 : {
2566 : stmt_ty p;
2567 8976 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2568 8976 : if (!p)
2569 0 : return NULL;
2570 8976 : p->kind = Continue_kind;
2571 8976 : p->lineno = lineno;
2572 8976 : p->col_offset = col_offset;
2573 8976 : p->end_lineno = end_lineno;
2574 8976 : p->end_col_offset = end_col_offset;
2575 8976 : return p;
2576 : }
2577 :
2578 : expr_ty
2579 67631 : _PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
2580 : int end_lineno, int end_col_offset, PyArena *arena)
2581 : {
2582 : expr_ty p;
2583 67631 : if (!op) {
2584 0 : PyErr_SetString(PyExc_ValueError,
2585 : "field 'op' is required for BoolOp");
2586 0 : return NULL;
2587 : }
2588 67631 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2589 67631 : if (!p)
2590 0 : return NULL;
2591 67631 : p->kind = BoolOp_kind;
2592 67631 : p->v.BoolOp.op = op;
2593 67631 : p->v.BoolOp.values = values;
2594 67631 : p->lineno = lineno;
2595 67631 : p->col_offset = col_offset;
2596 67631 : p->end_lineno = end_lineno;
2597 67631 : p->end_col_offset = end_col_offset;
2598 67631 : return p;
2599 : }
2600 :
2601 : expr_ty
2602 3731 : _PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
2603 : end_lineno, int end_col_offset, PyArena *arena)
2604 : {
2605 : expr_ty p;
2606 3731 : if (!target) {
2607 0 : PyErr_SetString(PyExc_ValueError,
2608 : "field 'target' is required for NamedExpr");
2609 0 : return NULL;
2610 : }
2611 3731 : if (!value) {
2612 0 : PyErr_SetString(PyExc_ValueError,
2613 : "field 'value' is required for NamedExpr");
2614 0 : return NULL;
2615 : }
2616 3731 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2617 3731 : if (!p)
2618 0 : return NULL;
2619 3731 : p->kind = NamedExpr_kind;
2620 3731 : p->v.NamedExpr.target = target;
2621 3731 : p->v.NamedExpr.value = value;
2622 3731 : p->lineno = lineno;
2623 3731 : p->col_offset = col_offset;
2624 3731 : p->end_lineno = end_lineno;
2625 3731 : p->end_col_offset = end_col_offset;
2626 3731 : return p;
2627 : }
2628 :
2629 : expr_ty
2630 581793 : _PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
2631 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2632 : {
2633 : expr_ty p;
2634 581793 : if (!left) {
2635 0 : PyErr_SetString(PyExc_ValueError,
2636 : "field 'left' is required for BinOp");
2637 0 : return NULL;
2638 : }
2639 581793 : if (!op) {
2640 0 : PyErr_SetString(PyExc_ValueError,
2641 : "field 'op' is required for BinOp");
2642 0 : return NULL;
2643 : }
2644 581793 : if (!right) {
2645 0 : PyErr_SetString(PyExc_ValueError,
2646 : "field 'right' is required for BinOp");
2647 0 : return NULL;
2648 : }
2649 581793 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2650 581793 : if (!p)
2651 0 : return NULL;
2652 581793 : p->kind = BinOp_kind;
2653 581793 : p->v.BinOp.left = left;
2654 581793 : p->v.BinOp.op = op;
2655 581793 : p->v.BinOp.right = right;
2656 581793 : p->lineno = lineno;
2657 581793 : p->col_offset = col_offset;
2658 581793 : p->end_lineno = end_lineno;
2659 581793 : p->end_col_offset = end_col_offset;
2660 581793 : return p;
2661 : }
2662 :
2663 : expr_ty
2664 106195 : _PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
2665 : end_lineno, int end_col_offset, PyArena *arena)
2666 : {
2667 : expr_ty p;
2668 106195 : if (!op) {
2669 0 : PyErr_SetString(PyExc_ValueError,
2670 : "field 'op' is required for UnaryOp");
2671 0 : return NULL;
2672 : }
2673 106195 : if (!operand) {
2674 0 : PyErr_SetString(PyExc_ValueError,
2675 : "field 'operand' is required for UnaryOp");
2676 0 : return NULL;
2677 : }
2678 106195 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2679 106195 : if (!p)
2680 0 : return NULL;
2681 106195 : p->kind = UnaryOp_kind;
2682 106195 : p->v.UnaryOp.op = op;
2683 106195 : p->v.UnaryOp.operand = operand;
2684 106195 : p->lineno = lineno;
2685 106195 : p->col_offset = col_offset;
2686 106195 : p->end_lineno = end_lineno;
2687 106195 : p->end_col_offset = end_col_offset;
2688 106195 : return p;
2689 : }
2690 :
2691 : expr_ty
2692 37658 : _PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
2693 : end_lineno, int end_col_offset, PyArena *arena)
2694 : {
2695 : expr_ty p;
2696 37658 : if (!args) {
2697 0 : PyErr_SetString(PyExc_ValueError,
2698 : "field 'args' is required for Lambda");
2699 0 : return NULL;
2700 : }
2701 37658 : if (!body) {
2702 0 : PyErr_SetString(PyExc_ValueError,
2703 : "field 'body' is required for Lambda");
2704 0 : return NULL;
2705 : }
2706 37658 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2707 37658 : if (!p)
2708 0 : return NULL;
2709 37658 : p->kind = Lambda_kind;
2710 37658 : p->v.Lambda.args = args;
2711 37658 : p->v.Lambda.body = body;
2712 37658 : p->lineno = lineno;
2713 37658 : p->col_offset = col_offset;
2714 37658 : p->end_lineno = end_lineno;
2715 37658 : p->end_col_offset = end_col_offset;
2716 37658 : return p;
2717 : }
2718 :
2719 : expr_ty
2720 11339 : _PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
2721 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2722 : {
2723 : expr_ty p;
2724 11339 : if (!test) {
2725 0 : PyErr_SetString(PyExc_ValueError,
2726 : "field 'test' is required for IfExp");
2727 0 : return NULL;
2728 : }
2729 11339 : if (!body) {
2730 0 : PyErr_SetString(PyExc_ValueError,
2731 : "field 'body' is required for IfExp");
2732 0 : return NULL;
2733 : }
2734 11339 : if (!orelse) {
2735 0 : PyErr_SetString(PyExc_ValueError,
2736 : "field 'orelse' is required for IfExp");
2737 0 : return NULL;
2738 : }
2739 11339 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2740 11339 : if (!p)
2741 0 : return NULL;
2742 11339 : p->kind = IfExp_kind;
2743 11339 : p->v.IfExp.test = test;
2744 11339 : p->v.IfExp.body = body;
2745 11339 : p->v.IfExp.orelse = orelse;
2746 11339 : p->lineno = lineno;
2747 11339 : p->col_offset = col_offset;
2748 11339 : p->end_lineno = end_lineno;
2749 11339 : p->end_col_offset = end_col_offset;
2750 11339 : return p;
2751 : }
2752 :
2753 : expr_ty
2754 99817 : _PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
2755 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2756 : {
2757 : expr_ty p;
2758 99817 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2759 99817 : if (!p)
2760 0 : return NULL;
2761 99817 : p->kind = Dict_kind;
2762 99817 : p->v.Dict.keys = keys;
2763 99817 : p->v.Dict.values = values;
2764 99817 : p->lineno = lineno;
2765 99817 : p->col_offset = col_offset;
2766 99817 : p->end_lineno = end_lineno;
2767 99817 : p->end_col_offset = end_col_offset;
2768 99817 : return p;
2769 : }
2770 :
2771 : expr_ty
2772 8485 : _PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
2773 : int end_col_offset, PyArena *arena)
2774 : {
2775 : expr_ty p;
2776 8485 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2777 8485 : if (!p)
2778 0 : return NULL;
2779 8485 : p->kind = Set_kind;
2780 8485 : p->v.Set.elts = elts;
2781 8485 : p->lineno = lineno;
2782 8485 : p->col_offset = col_offset;
2783 8485 : p->end_lineno = end_lineno;
2784 8485 : p->end_col_offset = end_col_offset;
2785 8485 : return p;
2786 : }
2787 :
2788 : expr_ty
2789 29652 : _PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
2790 : int col_offset, int end_lineno, int end_col_offset, PyArena
2791 : *arena)
2792 : {
2793 : expr_ty p;
2794 29652 : if (!elt) {
2795 0 : PyErr_SetString(PyExc_ValueError,
2796 : "field 'elt' is required for ListComp");
2797 0 : return NULL;
2798 : }
2799 29652 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2800 29652 : if (!p)
2801 0 : return NULL;
2802 29652 : p->kind = ListComp_kind;
2803 29652 : p->v.ListComp.elt = elt;
2804 29652 : p->v.ListComp.generators = generators;
2805 29652 : p->lineno = lineno;
2806 29652 : p->col_offset = col_offset;
2807 29652 : p->end_lineno = end_lineno;
2808 29652 : p->end_col_offset = end_col_offset;
2809 29652 : return p;
2810 : }
2811 :
2812 : expr_ty
2813 1542 : _PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
2814 : int col_offset, int end_lineno, int end_col_offset, PyArena
2815 : *arena)
2816 : {
2817 : expr_ty p;
2818 1542 : if (!elt) {
2819 0 : PyErr_SetString(PyExc_ValueError,
2820 : "field 'elt' is required for SetComp");
2821 0 : return NULL;
2822 : }
2823 1542 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2824 1542 : if (!p)
2825 0 : return NULL;
2826 1542 : p->kind = SetComp_kind;
2827 1542 : p->v.SetComp.elt = elt;
2828 1542 : p->v.SetComp.generators = generators;
2829 1542 : p->lineno = lineno;
2830 1542 : p->col_offset = col_offset;
2831 1542 : p->end_lineno = end_lineno;
2832 1542 : p->end_col_offset = end_col_offset;
2833 1542 : return p;
2834 : }
2835 :
2836 : expr_ty
2837 3825 : _PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
2838 : generators, int lineno, int col_offset, int end_lineno, int
2839 : end_col_offset, PyArena *arena)
2840 : {
2841 : expr_ty p;
2842 3825 : if (!key) {
2843 0 : PyErr_SetString(PyExc_ValueError,
2844 : "field 'key' is required for DictComp");
2845 0 : return NULL;
2846 : }
2847 3825 : if (!value) {
2848 0 : PyErr_SetString(PyExc_ValueError,
2849 : "field 'value' is required for DictComp");
2850 0 : return NULL;
2851 : }
2852 3825 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2853 3825 : if (!p)
2854 0 : return NULL;
2855 3825 : p->kind = DictComp_kind;
2856 3825 : p->v.DictComp.key = key;
2857 3825 : p->v.DictComp.value = value;
2858 3825 : p->v.DictComp.generators = generators;
2859 3825 : p->lineno = lineno;
2860 3825 : p->col_offset = col_offset;
2861 3825 : p->end_lineno = end_lineno;
2862 3825 : p->end_col_offset = end_col_offset;
2863 3825 : return p;
2864 : }
2865 :
2866 : expr_ty
2867 15406 : _PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
2868 : lineno, int col_offset, int end_lineno, int end_col_offset,
2869 : PyArena *arena)
2870 : {
2871 : expr_ty p;
2872 15406 : if (!elt) {
2873 0 : PyErr_SetString(PyExc_ValueError,
2874 : "field 'elt' is required for GeneratorExp");
2875 0 : return NULL;
2876 : }
2877 15406 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2878 15406 : if (!p)
2879 0 : return NULL;
2880 15406 : p->kind = GeneratorExp_kind;
2881 15406 : p->v.GeneratorExp.elt = elt;
2882 15406 : p->v.GeneratorExp.generators = generators;
2883 15406 : p->lineno = lineno;
2884 15406 : p->col_offset = col_offset;
2885 15406 : p->end_lineno = end_lineno;
2886 15406 : p->end_col_offset = end_col_offset;
2887 15406 : return p;
2888 : }
2889 :
2890 : expr_ty
2891 2388 : _PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
2892 : end_col_offset, PyArena *arena)
2893 : {
2894 : expr_ty p;
2895 2388 : if (!value) {
2896 0 : PyErr_SetString(PyExc_ValueError,
2897 : "field 'value' is required for Await");
2898 0 : return NULL;
2899 : }
2900 2388 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2901 2388 : if (!p)
2902 0 : return NULL;
2903 2388 : p->kind = Await_kind;
2904 2388 : p->v.Await.value = value;
2905 2388 : p->lineno = lineno;
2906 2388 : p->col_offset = col_offset;
2907 2388 : p->end_lineno = end_lineno;
2908 2388 : p->end_col_offset = end_col_offset;
2909 2388 : return p;
2910 : }
2911 :
2912 : expr_ty
2913 14001 : _PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
2914 : end_col_offset, PyArena *arena)
2915 : {
2916 : expr_ty p;
2917 14001 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2918 14001 : if (!p)
2919 0 : return NULL;
2920 14001 : p->kind = Yield_kind;
2921 14001 : p->v.Yield.value = value;
2922 14001 : p->lineno = lineno;
2923 14001 : p->col_offset = col_offset;
2924 14001 : p->end_lineno = end_lineno;
2925 14001 : p->end_col_offset = end_col_offset;
2926 14001 : return p;
2927 : }
2928 :
2929 : expr_ty
2930 2320 : _PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
2931 : end_col_offset, PyArena *arena)
2932 : {
2933 : expr_ty p;
2934 2320 : if (!value) {
2935 1 : PyErr_SetString(PyExc_ValueError,
2936 : "field 'value' is required for YieldFrom");
2937 1 : return NULL;
2938 : }
2939 2319 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2940 2319 : if (!p)
2941 0 : return NULL;
2942 2319 : p->kind = YieldFrom_kind;
2943 2319 : p->v.YieldFrom.value = value;
2944 2319 : p->lineno = lineno;
2945 2319 : p->col_offset = col_offset;
2946 2319 : p->end_lineno = end_lineno;
2947 2319 : p->end_col_offset = end_col_offset;
2948 2319 : return p;
2949 : }
2950 :
2951 : expr_ty
2952 250967 : _PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
2953 : int lineno, int col_offset, int end_lineno, int end_col_offset,
2954 : PyArena *arena)
2955 : {
2956 : expr_ty p;
2957 250967 : if (!left) {
2958 0 : PyErr_SetString(PyExc_ValueError,
2959 : "field 'left' is required for Compare");
2960 0 : return NULL;
2961 : }
2962 250967 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2963 250967 : if (!p)
2964 0 : return NULL;
2965 250967 : p->kind = Compare_kind;
2966 250967 : p->v.Compare.left = left;
2967 250967 : p->v.Compare.ops = ops;
2968 250967 : p->v.Compare.comparators = comparators;
2969 250967 : p->lineno = lineno;
2970 250967 : p->col_offset = col_offset;
2971 250967 : p->end_lineno = end_lineno;
2972 250967 : p->end_col_offset = end_col_offset;
2973 250967 : return p;
2974 : }
2975 :
2976 : expr_ty
2977 3643620 : _PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
2978 : int lineno, int col_offset, int end_lineno, int end_col_offset,
2979 : PyArena *arena)
2980 : {
2981 : expr_ty p;
2982 3643620 : if (!func) {
2983 0 : PyErr_SetString(PyExc_ValueError,
2984 : "field 'func' is required for Call");
2985 0 : return NULL;
2986 : }
2987 3643620 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2988 3643620 : if (!p)
2989 0 : return NULL;
2990 3643620 : p->kind = Call_kind;
2991 3643620 : p->v.Call.func = func;
2992 3643620 : p->v.Call.args = args;
2993 3643620 : p->v.Call.keywords = keywords;
2994 3643620 : p->lineno = lineno;
2995 3643620 : p->col_offset = col_offset;
2996 3643620 : p->end_lineno = end_lineno;
2997 3643620 : p->end_col_offset = end_col_offset;
2998 3643620 : return p;
2999 : }
3000 :
3001 : expr_ty
3002 124632 : _PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
3003 : lineno, int col_offset, int end_lineno, int
3004 : end_col_offset, PyArena *arena)
3005 : {
3006 : expr_ty p;
3007 124632 : if (!value) {
3008 0 : PyErr_SetString(PyExc_ValueError,
3009 : "field 'value' is required for FormattedValue");
3010 0 : return NULL;
3011 : }
3012 124632 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3013 124632 : if (!p)
3014 0 : return NULL;
3015 124632 : p->kind = FormattedValue_kind;
3016 124632 : p->v.FormattedValue.value = value;
3017 124632 : p->v.FormattedValue.conversion = conversion;
3018 124632 : p->v.FormattedValue.format_spec = format_spec;
3019 124632 : p->lineno = lineno;
3020 124632 : p->col_offset = col_offset;
3021 124632 : p->end_lineno = end_lineno;
3022 124632 : p->end_col_offset = end_col_offset;
3023 124632 : return p;
3024 : }
3025 :
3026 : expr_ty
3027 34620 : _PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
3028 : end_lineno, int end_col_offset, PyArena *arena)
3029 : {
3030 : expr_ty p;
3031 34620 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3032 34620 : if (!p)
3033 0 : return NULL;
3034 34620 : p->kind = JoinedStr_kind;
3035 34620 : p->v.JoinedStr.values = values;
3036 34620 : p->lineno = lineno;
3037 34620 : p->col_offset = col_offset;
3038 34620 : p->end_lineno = end_lineno;
3039 34620 : p->end_col_offset = end_col_offset;
3040 34620 : return p;
3041 : }
3042 :
3043 : expr_ty
3044 8265320 : _PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
3045 : end_lineno, int end_col_offset, PyArena *arena)
3046 : {
3047 : expr_ty p;
3048 8265320 : if (!value) {
3049 0 : PyErr_SetString(PyExc_ValueError,
3050 : "field 'value' is required for Constant");
3051 0 : return NULL;
3052 : }
3053 8265320 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3054 8265320 : if (!p)
3055 0 : return NULL;
3056 8265320 : p->kind = Constant_kind;
3057 8265320 : p->v.Constant.value = value;
3058 8265320 : p->v.Constant.kind = kind;
3059 8265320 : p->lineno = lineno;
3060 8265320 : p->col_offset = col_offset;
3061 8265320 : p->end_lineno = end_lineno;
3062 8265320 : p->end_col_offset = end_col_offset;
3063 8265320 : return p;
3064 : }
3065 :
3066 : expr_ty
3067 3435390 : _PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
3068 : lineno, int col_offset, int end_lineno, int end_col_offset,
3069 : PyArena *arena)
3070 : {
3071 : expr_ty p;
3072 3435390 : if (!value) {
3073 0 : PyErr_SetString(PyExc_ValueError,
3074 : "field 'value' is required for Attribute");
3075 0 : return NULL;
3076 : }
3077 3435390 : if (!attr) {
3078 0 : PyErr_SetString(PyExc_ValueError,
3079 : "field 'attr' is required for Attribute");
3080 0 : return NULL;
3081 : }
3082 3435390 : if (!ctx) {
3083 0 : PyErr_SetString(PyExc_ValueError,
3084 : "field 'ctx' is required for Attribute");
3085 0 : return NULL;
3086 : }
3087 3435390 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3088 3435390 : if (!p)
3089 0 : return NULL;
3090 3435390 : p->kind = Attribute_kind;
3091 3435390 : p->v.Attribute.value = value;
3092 3435390 : p->v.Attribute.attr = attr;
3093 3435390 : p->v.Attribute.ctx = ctx;
3094 3435390 : p->lineno = lineno;
3095 3435390 : p->col_offset = col_offset;
3096 3435390 : p->end_lineno = end_lineno;
3097 3435390 : p->end_col_offset = end_col_offset;
3098 3435390 : return p;
3099 : }
3100 :
3101 : expr_ty
3102 925292 : _PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
3103 : int col_offset, int end_lineno, int end_col_offset, PyArena
3104 : *arena)
3105 : {
3106 : expr_ty p;
3107 925292 : if (!value) {
3108 0 : PyErr_SetString(PyExc_ValueError,
3109 : "field 'value' is required for Subscript");
3110 0 : return NULL;
3111 : }
3112 925292 : if (!slice) {
3113 0 : PyErr_SetString(PyExc_ValueError,
3114 : "field 'slice' is required for Subscript");
3115 0 : return NULL;
3116 : }
3117 925292 : if (!ctx) {
3118 0 : PyErr_SetString(PyExc_ValueError,
3119 : "field 'ctx' is required for Subscript");
3120 0 : return NULL;
3121 : }
3122 925292 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3123 925292 : if (!p)
3124 0 : return NULL;
3125 925292 : p->kind = Subscript_kind;
3126 925292 : p->v.Subscript.value = value;
3127 925292 : p->v.Subscript.slice = slice;
3128 925292 : p->v.Subscript.ctx = ctx;
3129 925292 : p->lineno = lineno;
3130 925292 : p->col_offset = col_offset;
3131 925292 : p->end_lineno = end_lineno;
3132 925292 : p->end_col_offset = end_col_offset;
3133 925292 : return p;
3134 : }
3135 :
3136 : expr_ty
3137 16445 : _PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
3138 : int end_lineno, int end_col_offset, PyArena *arena)
3139 : {
3140 : expr_ty p;
3141 16445 : if (!value) {
3142 0 : PyErr_SetString(PyExc_ValueError,
3143 : "field 'value' is required for Starred");
3144 0 : return NULL;
3145 : }
3146 16445 : if (!ctx) {
3147 0 : PyErr_SetString(PyExc_ValueError,
3148 : "field 'ctx' is required for Starred");
3149 0 : return NULL;
3150 : }
3151 16445 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3152 16445 : if (!p)
3153 0 : return NULL;
3154 16445 : p->kind = Starred_kind;
3155 16445 : p->v.Starred.value = value;
3156 16445 : p->v.Starred.ctx = ctx;
3157 16445 : p->lineno = lineno;
3158 16445 : p->col_offset = col_offset;
3159 16445 : p->end_lineno = end_lineno;
3160 16445 : p->end_col_offset = end_col_offset;
3161 16445 : return p;
3162 : }
3163 :
3164 : expr_ty
3165 37078400 : _PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
3166 : end_lineno, int end_col_offset, PyArena *arena)
3167 : {
3168 : expr_ty p;
3169 37078400 : if (!id) {
3170 0 : PyErr_SetString(PyExc_ValueError,
3171 : "field 'id' is required for Name");
3172 0 : return NULL;
3173 : }
3174 37078400 : if (!ctx) {
3175 0 : PyErr_SetString(PyExc_ValueError,
3176 : "field 'ctx' is required for Name");
3177 0 : return NULL;
3178 : }
3179 37078400 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3180 37078400 : if (!p)
3181 0 : return NULL;
3182 37078400 : p->kind = Name_kind;
3183 37078400 : p->v.Name.id = id;
3184 37078400 : p->v.Name.ctx = ctx;
3185 37078400 : p->lineno = lineno;
3186 37078400 : p->col_offset = col_offset;
3187 37078400 : p->end_lineno = end_lineno;
3188 37078400 : p->end_col_offset = end_col_offset;
3189 37078400 : return p;
3190 : }
3191 :
3192 : expr_ty
3193 254619 : _PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
3194 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3195 : {
3196 : expr_ty p;
3197 254619 : if (!ctx) {
3198 0 : PyErr_SetString(PyExc_ValueError,
3199 : "field 'ctx' is required for List");
3200 0 : return NULL;
3201 : }
3202 254619 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3203 254619 : if (!p)
3204 0 : return NULL;
3205 254619 : p->kind = List_kind;
3206 254619 : p->v.List.elts = elts;
3207 254619 : p->v.List.ctx = ctx;
3208 254619 : p->lineno = lineno;
3209 254619 : p->col_offset = col_offset;
3210 254619 : p->end_lineno = end_lineno;
3211 254619 : p->end_col_offset = end_col_offset;
3212 254619 : return p;
3213 : }
3214 :
3215 : expr_ty
3216 687231 : _PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
3217 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3218 : {
3219 : expr_ty p;
3220 687231 : if (!ctx) {
3221 0 : PyErr_SetString(PyExc_ValueError,
3222 : "field 'ctx' is required for Tuple");
3223 0 : return NULL;
3224 : }
3225 687231 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3226 687231 : if (!p)
3227 0 : return NULL;
3228 687231 : p->kind = Tuple_kind;
3229 687231 : p->v.Tuple.elts = elts;
3230 687231 : p->v.Tuple.ctx = ctx;
3231 687231 : p->lineno = lineno;
3232 687231 : p->col_offset = col_offset;
3233 687231 : p->end_lineno = end_lineno;
3234 687231 : p->end_col_offset = end_col_offset;
3235 687231 : return p;
3236 : }
3237 :
3238 : expr_ty
3239 70447 : _PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
3240 : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3241 : {
3242 : expr_ty p;
3243 70447 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3244 70447 : if (!p)
3245 0 : return NULL;
3246 70447 : p->kind = Slice_kind;
3247 70447 : p->v.Slice.lower = lower;
3248 70447 : p->v.Slice.upper = upper;
3249 70447 : p->v.Slice.step = step;
3250 70447 : p->lineno = lineno;
3251 70447 : p->col_offset = col_offset;
3252 70447 : p->end_lineno = end_lineno;
3253 70447 : p->end_col_offset = end_col_offset;
3254 70447 : return p;
3255 : }
3256 :
3257 : comprehension_ty
3258 52526 : _PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
3259 : is_async, PyArena *arena)
3260 : {
3261 : comprehension_ty p;
3262 52526 : if (!target) {
3263 0 : PyErr_SetString(PyExc_ValueError,
3264 : "field 'target' is required for comprehension");
3265 0 : return NULL;
3266 : }
3267 52526 : if (!iter) {
3268 0 : PyErr_SetString(PyExc_ValueError,
3269 : "field 'iter' is required for comprehension");
3270 0 : return NULL;
3271 : }
3272 52526 : p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
3273 52526 : if (!p)
3274 0 : return NULL;
3275 52526 : p->target = target;
3276 52526 : p->iter = iter;
3277 52526 : p->ifs = ifs;
3278 52526 : p->is_async = is_async;
3279 52526 : return p;
3280 : }
3281 :
3282 : excepthandler_ty
3283 46271 : _PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
3284 : lineno, int col_offset, int end_lineno, int
3285 : end_col_offset, PyArena *arena)
3286 : {
3287 : excepthandler_ty p;
3288 46271 : p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
3289 46271 : if (!p)
3290 0 : return NULL;
3291 46271 : p->kind = ExceptHandler_kind;
3292 46271 : p->v.ExceptHandler.type = type;
3293 46271 : p->v.ExceptHandler.name = name;
3294 46271 : p->v.ExceptHandler.body = body;
3295 46271 : p->lineno = lineno;
3296 46271 : p->col_offset = col_offset;
3297 46271 : p->end_lineno = end_lineno;
3298 46271 : p->end_col_offset = end_col_offset;
3299 46271 : return p;
3300 : }
3301 :
3302 : arguments_ty
3303 387621 : _PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
3304 : vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
3305 : kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
3306 : *arena)
3307 : {
3308 : arguments_ty p;
3309 387621 : p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
3310 387621 : if (!p)
3311 0 : return NULL;
3312 387621 : p->posonlyargs = posonlyargs;
3313 387621 : p->args = args;
3314 387621 : p->vararg = vararg;
3315 387621 : p->kwonlyargs = kwonlyargs;
3316 387621 : p->kw_defaults = kw_defaults;
3317 387621 : p->kwarg = kwarg;
3318 387621 : p->defaults = defaults;
3319 387621 : return p;
3320 : }
3321 :
3322 : arg_ty
3323 5480920 : _PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
3324 : int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3325 : {
3326 : arg_ty p;
3327 5480920 : if (!arg) {
3328 0 : PyErr_SetString(PyExc_ValueError,
3329 : "field 'arg' is required for arg");
3330 0 : return NULL;
3331 : }
3332 5480920 : p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
3333 5480920 : if (!p)
3334 0 : return NULL;
3335 5480920 : p->arg = arg;
3336 5480920 : p->annotation = annotation;
3337 5480920 : p->type_comment = type_comment;
3338 5480920 : p->lineno = lineno;
3339 5480920 : p->col_offset = col_offset;
3340 5480920 : p->end_lineno = end_lineno;
3341 5480920 : p->end_col_offset = end_col_offset;
3342 5480920 : return p;
3343 : }
3344 :
3345 : keyword_ty
3346 360403 : _PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
3347 : end_lineno, int end_col_offset, PyArena *arena)
3348 : {
3349 : keyword_ty p;
3350 360403 : if (!value) {
3351 0 : PyErr_SetString(PyExc_ValueError,
3352 : "field 'value' is required for keyword");
3353 0 : return NULL;
3354 : }
3355 360403 : p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
3356 360403 : if (!p)
3357 0 : return NULL;
3358 360403 : p->arg = arg;
3359 360403 : p->value = value;
3360 360403 : p->lineno = lineno;
3361 360403 : p->col_offset = col_offset;
3362 360403 : p->end_lineno = end_lineno;
3363 360403 : p->end_col_offset = end_col_offset;
3364 360403 : return p;
3365 : }
3366 :
3367 : alias_ty
3368 126672 : _PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
3369 : int end_lineno, int end_col_offset, PyArena *arena)
3370 : {
3371 : alias_ty p;
3372 126672 : if (!name) {
3373 0 : PyErr_SetString(PyExc_ValueError,
3374 : "field 'name' is required for alias");
3375 0 : return NULL;
3376 : }
3377 126672 : p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
3378 126672 : if (!p)
3379 0 : return NULL;
3380 126672 : p->name = name;
3381 126672 : p->asname = asname;
3382 126672 : p->lineno = lineno;
3383 126672 : p->col_offset = col_offset;
3384 126672 : p->end_lineno = end_lineno;
3385 126672 : p->end_col_offset = end_col_offset;
3386 126672 : return p;
3387 : }
3388 :
3389 : withitem_ty
3390 40259 : _PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
3391 : {
3392 : withitem_ty p;
3393 40259 : if (!context_expr) {
3394 0 : PyErr_SetString(PyExc_ValueError,
3395 : "field 'context_expr' is required for withitem");
3396 0 : return NULL;
3397 : }
3398 40259 : p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
3399 40259 : if (!p)
3400 0 : return NULL;
3401 40259 : p->context_expr = context_expr;
3402 40259 : p->optional_vars = optional_vars;
3403 40259 : return p;
3404 : }
3405 :
3406 : match_case_ty
3407 1808 : _PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
3408 : PyArena *arena)
3409 : {
3410 : match_case_ty p;
3411 1808 : if (!pattern) {
3412 0 : PyErr_SetString(PyExc_ValueError,
3413 : "field 'pattern' is required for match_case");
3414 0 : return NULL;
3415 : }
3416 1808 : p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
3417 1808 : if (!p)
3418 0 : return NULL;
3419 1808 : p->pattern = pattern;
3420 1808 : p->guard = guard;
3421 1808 : p->body = body;
3422 1808 : return p;
3423 : }
3424 :
3425 : pattern_ty
3426 1561 : _PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
3427 : int end_col_offset, PyArena *arena)
3428 : {
3429 : pattern_ty p;
3430 1561 : if (!value) {
3431 0 : PyErr_SetString(PyExc_ValueError,
3432 : "field 'value' is required for MatchValue");
3433 0 : return NULL;
3434 : }
3435 1561 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3436 1561 : if (!p)
3437 0 : return NULL;
3438 1561 : p->kind = MatchValue_kind;
3439 1561 : p->v.MatchValue.value = value;
3440 1561 : p->lineno = lineno;
3441 1561 : p->col_offset = col_offset;
3442 1561 : p->end_lineno = end_lineno;
3443 1561 : p->end_col_offset = end_col_offset;
3444 1561 : return p;
3445 : }
3446 :
3447 : pattern_ty
3448 68 : _PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
3449 : end_lineno, int end_col_offset, PyArena *arena)
3450 : {
3451 : pattern_ty p;
3452 68 : if (!value) {
3453 0 : PyErr_SetString(PyExc_ValueError,
3454 : "field 'value' is required for MatchSingleton");
3455 0 : return NULL;
3456 : }
3457 68 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3458 68 : if (!p)
3459 0 : return NULL;
3460 68 : p->kind = MatchSingleton_kind;
3461 68 : p->v.MatchSingleton.value = value;
3462 68 : p->lineno = lineno;
3463 68 : p->col_offset = col_offset;
3464 68 : p->end_lineno = end_lineno;
3465 68 : p->end_col_offset = end_col_offset;
3466 68 : return p;
3467 : }
3468 :
3469 : pattern_ty
3470 763 : _PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
3471 : int end_lineno, int end_col_offset, PyArena *arena)
3472 : {
3473 : pattern_ty p;
3474 763 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3475 763 : if (!p)
3476 0 : return NULL;
3477 763 : p->kind = MatchSequence_kind;
3478 763 : p->v.MatchSequence.patterns = patterns;
3479 763 : p->lineno = lineno;
3480 763 : p->col_offset = col_offset;
3481 763 : p->end_lineno = end_lineno;
3482 763 : p->end_col_offset = end_col_offset;
3483 763 : return p;
3484 : }
3485 :
3486 : pattern_ty
3487 433 : _PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
3488 : identifier rest, int lineno, int col_offset, int
3489 : end_lineno, int end_col_offset, PyArena *arena)
3490 : {
3491 : pattern_ty p;
3492 433 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3493 433 : if (!p)
3494 0 : return NULL;
3495 433 : p->kind = MatchMapping_kind;
3496 433 : p->v.MatchMapping.keys = keys;
3497 433 : p->v.MatchMapping.patterns = patterns;
3498 433 : p->v.MatchMapping.rest = rest;
3499 433 : p->lineno = lineno;
3500 433 : p->col_offset = col_offset;
3501 433 : p->end_lineno = end_lineno;
3502 433 : p->end_col_offset = end_col_offset;
3503 433 : return p;
3504 : }
3505 :
3506 : pattern_ty
3507 298 : _PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
3508 : * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
3509 : col_offset, int end_lineno, int end_col_offset, PyArena
3510 : *arena)
3511 : {
3512 : pattern_ty p;
3513 298 : if (!cls) {
3514 0 : PyErr_SetString(PyExc_ValueError,
3515 : "field 'cls' is required for MatchClass");
3516 0 : return NULL;
3517 : }
3518 298 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3519 298 : if (!p)
3520 0 : return NULL;
3521 298 : p->kind = MatchClass_kind;
3522 298 : p->v.MatchClass.cls = cls;
3523 298 : p->v.MatchClass.patterns = patterns;
3524 298 : p->v.MatchClass.kwd_attrs = kwd_attrs;
3525 298 : p->v.MatchClass.kwd_patterns = kwd_patterns;
3526 298 : p->lineno = lineno;
3527 298 : p->col_offset = col_offset;
3528 298 : p->end_lineno = end_lineno;
3529 298 : p->end_col_offset = end_col_offset;
3530 298 : return p;
3531 : }
3532 :
3533 : pattern_ty
3534 179 : _PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
3535 : int end_col_offset, PyArena *arena)
3536 : {
3537 : pattern_ty p;
3538 179 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3539 179 : if (!p)
3540 0 : return NULL;
3541 179 : p->kind = MatchStar_kind;
3542 179 : p->v.MatchStar.name = name;
3543 179 : p->lineno = lineno;
3544 179 : p->col_offset = col_offset;
3545 179 : p->end_lineno = end_lineno;
3546 179 : p->end_col_offset = end_col_offset;
3547 179 : return p;
3548 : }
3549 :
3550 : pattern_ty
3551 1532 : _PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
3552 : int end_lineno, int end_col_offset, PyArena *arena)
3553 : {
3554 : pattern_ty p;
3555 1532 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3556 1532 : if (!p)
3557 0 : return NULL;
3558 1532 : p->kind = MatchAs_kind;
3559 1532 : p->v.MatchAs.pattern = pattern;
3560 1532 : p->v.MatchAs.name = name;
3561 1532 : p->lineno = lineno;
3562 1532 : p->col_offset = col_offset;
3563 1532 : p->end_lineno = end_lineno;
3564 1532 : p->end_col_offset = end_col_offset;
3565 1532 : return p;
3566 : }
3567 :
3568 : pattern_ty
3569 693 : _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
3570 : end_lineno, int end_col_offset, PyArena *arena)
3571 : {
3572 : pattern_ty p;
3573 693 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3574 693 : if (!p)
3575 0 : return NULL;
3576 693 : p->kind = MatchOr_kind;
3577 693 : p->v.MatchOr.patterns = patterns;
3578 693 : p->lineno = lineno;
3579 693 : p->col_offset = col_offset;
3580 693 : p->end_lineno = end_lineno;
3581 693 : p->end_col_offset = end_col_offset;
3582 693 : return p;
3583 : }
3584 :
3585 : type_ignore_ty
3586 74 : _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
3587 : {
3588 : type_ignore_ty p;
3589 74 : if (!tag) {
3590 0 : PyErr_SetString(PyExc_ValueError,
3591 : "field 'tag' is required for TypeIgnore");
3592 0 : return NULL;
3593 : }
3594 74 : p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
3595 74 : if (!p)
3596 0 : return NULL;
3597 74 : p->kind = TypeIgnore_kind;
3598 74 : p->v.TypeIgnore.lineno = lineno;
3599 74 : p->v.TypeIgnore.tag = tag;
3600 74 : return p;
3601 : }
3602 :
3603 :
3604 : PyObject*
3605 10978 : ast2obj_mod(struct ast_state *state, void* _o)
3606 : {
3607 10978 : mod_ty o = (mod_ty)_o;
3608 10978 : PyObject *result = NULL, *value = NULL;
3609 : PyTypeObject *tp;
3610 10978 : if (!o) {
3611 0 : Py_RETURN_NONE;
3612 : }
3613 10978 : switch (o->kind) {
3614 10030 : case Module_kind:
3615 10030 : tp = (PyTypeObject *)state->Module_type;
3616 10030 : result = PyType_GenericNew(tp, NULL, NULL);
3617 10030 : if (!result) goto failed;
3618 10030 : value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
3619 10030 : if (!value) goto failed;
3620 10030 : if (PyObject_SetAttr(result, state->body, value) == -1)
3621 0 : goto failed;
3622 10030 : Py_DECREF(value);
3623 10030 : value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
3624 : ast2obj_type_ignore);
3625 10030 : if (!value) goto failed;
3626 10030 : if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
3627 0 : goto failed;
3628 10030 : Py_DECREF(value);
3629 10030 : break;
3630 1 : case Interactive_kind:
3631 1 : tp = (PyTypeObject *)state->Interactive_type;
3632 1 : result = PyType_GenericNew(tp, NULL, NULL);
3633 1 : if (!result) goto failed;
3634 1 : value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
3635 : ast2obj_stmt);
3636 1 : if (!value) goto failed;
3637 1 : if (PyObject_SetAttr(result, state->body, value) == -1)
3638 0 : goto failed;
3639 1 : Py_DECREF(value);
3640 1 : break;
3641 935 : case Expression_kind:
3642 935 : tp = (PyTypeObject *)state->Expression_type;
3643 935 : result = PyType_GenericNew(tp, NULL, NULL);
3644 935 : if (!result) goto failed;
3645 935 : value = ast2obj_expr(state, o->v.Expression.body);
3646 935 : if (!value) goto failed;
3647 935 : if (PyObject_SetAttr(result, state->body, value) == -1)
3648 0 : goto failed;
3649 935 : Py_DECREF(value);
3650 935 : break;
3651 12 : case FunctionType_kind:
3652 12 : tp = (PyTypeObject *)state->FunctionType_type;
3653 12 : result = PyType_GenericNew(tp, NULL, NULL);
3654 12 : if (!result) goto failed;
3655 12 : value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
3656 : ast2obj_expr);
3657 12 : if (!value) goto failed;
3658 12 : if (PyObject_SetAttr(result, state->argtypes, value) == -1)
3659 0 : goto failed;
3660 12 : Py_DECREF(value);
3661 12 : value = ast2obj_expr(state, o->v.FunctionType.returns);
3662 12 : if (!value) goto failed;
3663 12 : if (PyObject_SetAttr(result, state->returns, value) == -1)
3664 0 : goto failed;
3665 12 : Py_DECREF(value);
3666 12 : break;
3667 : }
3668 10978 : return result;
3669 0 : failed:
3670 0 : Py_XDECREF(value);
3671 0 : Py_XDECREF(result);
3672 0 : return NULL;
3673 : }
3674 :
3675 : PyObject*
3676 727431 : ast2obj_stmt(struct ast_state *state, void* _o)
3677 : {
3678 727431 : stmt_ty o = (stmt_ty)_o;
3679 727431 : PyObject *result = NULL, *value = NULL;
3680 : PyTypeObject *tp;
3681 727431 : if (!o) {
3682 0 : Py_RETURN_NONE;
3683 : }
3684 727431 : switch (o->kind) {
3685 87846 : case FunctionDef_kind:
3686 87846 : tp = (PyTypeObject *)state->FunctionDef_type;
3687 87846 : result = PyType_GenericNew(tp, NULL, NULL);
3688 87846 : if (!result) goto failed;
3689 87846 : value = ast2obj_identifier(state, o->v.FunctionDef.name);
3690 87846 : if (!value) goto failed;
3691 87846 : if (PyObject_SetAttr(result, state->name, value) == -1)
3692 0 : goto failed;
3693 87846 : Py_DECREF(value);
3694 87846 : value = ast2obj_arguments(state, o->v.FunctionDef.args);
3695 87846 : if (!value) goto failed;
3696 87846 : if (PyObject_SetAttr(result, state->args, value) == -1)
3697 0 : goto failed;
3698 87846 : Py_DECREF(value);
3699 87846 : value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
3700 : ast2obj_stmt);
3701 87846 : if (!value) goto failed;
3702 87846 : if (PyObject_SetAttr(result, state->body, value) == -1)
3703 0 : goto failed;
3704 87846 : Py_DECREF(value);
3705 87846 : value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
3706 : ast2obj_expr);
3707 87846 : if (!value) goto failed;
3708 87846 : if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3709 0 : goto failed;
3710 87846 : Py_DECREF(value);
3711 87846 : value = ast2obj_expr(state, o->v.FunctionDef.returns);
3712 87846 : if (!value) goto failed;
3713 87846 : if (PyObject_SetAttr(result, state->returns, value) == -1)
3714 0 : goto failed;
3715 87846 : Py_DECREF(value);
3716 87846 : value = ast2obj_string(state, o->v.FunctionDef.type_comment);
3717 87846 : if (!value) goto failed;
3718 87846 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3719 0 : goto failed;
3720 87846 : Py_DECREF(value);
3721 87846 : break;
3722 1161 : case AsyncFunctionDef_kind:
3723 1161 : tp = (PyTypeObject *)state->AsyncFunctionDef_type;
3724 1161 : result = PyType_GenericNew(tp, NULL, NULL);
3725 1161 : if (!result) goto failed;
3726 1161 : value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
3727 1161 : if (!value) goto failed;
3728 1161 : if (PyObject_SetAttr(result, state->name, value) == -1)
3729 0 : goto failed;
3730 1161 : Py_DECREF(value);
3731 1161 : value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
3732 1161 : if (!value) goto failed;
3733 1161 : if (PyObject_SetAttr(result, state->args, value) == -1)
3734 0 : goto failed;
3735 1161 : Py_DECREF(value);
3736 1161 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
3737 : ast2obj_stmt);
3738 1161 : if (!value) goto failed;
3739 1161 : if (PyObject_SetAttr(result, state->body, value) == -1)
3740 0 : goto failed;
3741 1161 : Py_DECREF(value);
3742 1161 : value = ast2obj_list(state,
3743 1161 : (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
3744 : ast2obj_expr);
3745 1161 : if (!value) goto failed;
3746 1161 : if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3747 0 : goto failed;
3748 1161 : Py_DECREF(value);
3749 1161 : value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
3750 1161 : if (!value) goto failed;
3751 1161 : if (PyObject_SetAttr(result, state->returns, value) == -1)
3752 0 : goto failed;
3753 1161 : Py_DECREF(value);
3754 1161 : value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
3755 1161 : if (!value) goto failed;
3756 1161 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3757 0 : goto failed;
3758 1161 : Py_DECREF(value);
3759 1161 : break;
3760 19848 : case ClassDef_kind:
3761 19848 : tp = (PyTypeObject *)state->ClassDef_type;
3762 19848 : result = PyType_GenericNew(tp, NULL, NULL);
3763 19848 : if (!result) goto failed;
3764 19848 : value = ast2obj_identifier(state, o->v.ClassDef.name);
3765 19848 : if (!value) goto failed;
3766 19848 : if (PyObject_SetAttr(result, state->name, value) == -1)
3767 0 : goto failed;
3768 19848 : Py_DECREF(value);
3769 19848 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
3770 : ast2obj_expr);
3771 19848 : if (!value) goto failed;
3772 19848 : if (PyObject_SetAttr(result, state->bases, value) == -1)
3773 0 : goto failed;
3774 19848 : Py_DECREF(value);
3775 19848 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
3776 : ast2obj_keyword);
3777 19848 : if (!value) goto failed;
3778 19848 : if (PyObject_SetAttr(result, state->keywords, value) == -1)
3779 0 : goto failed;
3780 19848 : Py_DECREF(value);
3781 19848 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
3782 : ast2obj_stmt);
3783 19848 : if (!value) goto failed;
3784 19848 : if (PyObject_SetAttr(result, state->body, value) == -1)
3785 0 : goto failed;
3786 19848 : Py_DECREF(value);
3787 19848 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
3788 : ast2obj_expr);
3789 19848 : if (!value) goto failed;
3790 19848 : if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3791 0 : goto failed;
3792 19848 : Py_DECREF(value);
3793 19848 : break;
3794 35981 : case Return_kind:
3795 35981 : tp = (PyTypeObject *)state->Return_type;
3796 35981 : result = PyType_GenericNew(tp, NULL, NULL);
3797 35981 : if (!result) goto failed;
3798 35981 : value = ast2obj_expr(state, o->v.Return.value);
3799 35981 : if (!value) goto failed;
3800 35981 : if (PyObject_SetAttr(result, state->value, value) == -1)
3801 0 : goto failed;
3802 35981 : Py_DECREF(value);
3803 35981 : break;
3804 2664 : case Delete_kind:
3805 2664 : tp = (PyTypeObject *)state->Delete_type;
3806 2664 : result = PyType_GenericNew(tp, NULL, NULL);
3807 2664 : if (!result) goto failed;
3808 2664 : value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
3809 : ast2obj_expr);
3810 2664 : if (!value) goto failed;
3811 2664 : if (PyObject_SetAttr(result, state->targets, value) == -1)
3812 0 : goto failed;
3813 2664 : Py_DECREF(value);
3814 2664 : break;
3815 193088 : case Assign_kind:
3816 193088 : tp = (PyTypeObject *)state->Assign_type;
3817 193088 : result = PyType_GenericNew(tp, NULL, NULL);
3818 193088 : if (!result) goto failed;
3819 193088 : value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
3820 : ast2obj_expr);
3821 193088 : if (!value) goto failed;
3822 193088 : if (PyObject_SetAttr(result, state->targets, value) == -1)
3823 0 : goto failed;
3824 193088 : Py_DECREF(value);
3825 193088 : value = ast2obj_expr(state, o->v.Assign.value);
3826 193088 : if (!value) goto failed;
3827 193088 : if (PyObject_SetAttr(result, state->value, value) == -1)
3828 0 : goto failed;
3829 193088 : Py_DECREF(value);
3830 193088 : value = ast2obj_string(state, o->v.Assign.type_comment);
3831 193088 : if (!value) goto failed;
3832 193088 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3833 0 : goto failed;
3834 193088 : Py_DECREF(value);
3835 193088 : break;
3836 5052 : case AugAssign_kind:
3837 5052 : tp = (PyTypeObject *)state->AugAssign_type;
3838 5052 : result = PyType_GenericNew(tp, NULL, NULL);
3839 5052 : if (!result) goto failed;
3840 5052 : value = ast2obj_expr(state, o->v.AugAssign.target);
3841 5052 : if (!value) goto failed;
3842 5052 : if (PyObject_SetAttr(result, state->target, value) == -1)
3843 0 : goto failed;
3844 5052 : Py_DECREF(value);
3845 5052 : value = ast2obj_operator(state, o->v.AugAssign.op);
3846 5052 : if (!value) goto failed;
3847 5052 : if (PyObject_SetAttr(result, state->op, value) == -1)
3848 0 : goto failed;
3849 5052 : Py_DECREF(value);
3850 5052 : value = ast2obj_expr(state, o->v.AugAssign.value);
3851 5052 : if (!value) goto failed;
3852 5052 : if (PyObject_SetAttr(result, state->value, value) == -1)
3853 0 : goto failed;
3854 5052 : Py_DECREF(value);
3855 5052 : break;
3856 1614 : case AnnAssign_kind:
3857 1614 : tp = (PyTypeObject *)state->AnnAssign_type;
3858 1614 : result = PyType_GenericNew(tp, NULL, NULL);
3859 1614 : if (!result) goto failed;
3860 1614 : value = ast2obj_expr(state, o->v.AnnAssign.target);
3861 1614 : if (!value) goto failed;
3862 1614 : if (PyObject_SetAttr(result, state->target, value) == -1)
3863 0 : goto failed;
3864 1614 : Py_DECREF(value);
3865 1614 : value = ast2obj_expr(state, o->v.AnnAssign.annotation);
3866 1614 : if (!value) goto failed;
3867 1614 : if (PyObject_SetAttr(result, state->annotation, value) == -1)
3868 0 : goto failed;
3869 1614 : Py_DECREF(value);
3870 1614 : value = ast2obj_expr(state, o->v.AnnAssign.value);
3871 1614 : if (!value) goto failed;
3872 1614 : if (PyObject_SetAttr(result, state->value, value) == -1)
3873 0 : goto failed;
3874 1614 : Py_DECREF(value);
3875 1614 : value = ast2obj_int(state, o->v.AnnAssign.simple);
3876 1614 : if (!value) goto failed;
3877 1614 : if (PyObject_SetAttr(result, state->simple, value) == -1)
3878 0 : goto failed;
3879 1614 : Py_DECREF(value);
3880 1614 : break;
3881 16551 : case For_kind:
3882 16551 : tp = (PyTypeObject *)state->For_type;
3883 16551 : result = PyType_GenericNew(tp, NULL, NULL);
3884 16551 : if (!result) goto failed;
3885 16551 : value = ast2obj_expr(state, o->v.For.target);
3886 16551 : if (!value) goto failed;
3887 16551 : if (PyObject_SetAttr(result, state->target, value) == -1)
3888 0 : goto failed;
3889 16551 : Py_DECREF(value);
3890 16551 : value = ast2obj_expr(state, o->v.For.iter);
3891 16551 : if (!value) goto failed;
3892 16551 : if (PyObject_SetAttr(result, state->iter, value) == -1)
3893 0 : goto failed;
3894 16551 : Py_DECREF(value);
3895 16551 : value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
3896 16551 : if (!value) goto failed;
3897 16551 : if (PyObject_SetAttr(result, state->body, value) == -1)
3898 0 : goto failed;
3899 16551 : Py_DECREF(value);
3900 16551 : value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
3901 16551 : if (!value) goto failed;
3902 16551 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3903 0 : goto failed;
3904 16551 : Py_DECREF(value);
3905 16551 : value = ast2obj_string(state, o->v.For.type_comment);
3906 16551 : if (!value) goto failed;
3907 16551 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3908 0 : goto failed;
3909 16551 : Py_DECREF(value);
3910 16551 : break;
3911 115 : case AsyncFor_kind:
3912 115 : tp = (PyTypeObject *)state->AsyncFor_type;
3913 115 : result = PyType_GenericNew(tp, NULL, NULL);
3914 115 : if (!result) goto failed;
3915 115 : value = ast2obj_expr(state, o->v.AsyncFor.target);
3916 115 : if (!value) goto failed;
3917 115 : if (PyObject_SetAttr(result, state->target, value) == -1)
3918 0 : goto failed;
3919 115 : Py_DECREF(value);
3920 115 : value = ast2obj_expr(state, o->v.AsyncFor.iter);
3921 115 : if (!value) goto failed;
3922 115 : if (PyObject_SetAttr(result, state->iter, value) == -1)
3923 0 : goto failed;
3924 115 : Py_DECREF(value);
3925 115 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
3926 : ast2obj_stmt);
3927 115 : if (!value) goto failed;
3928 115 : if (PyObject_SetAttr(result, state->body, value) == -1)
3929 0 : goto failed;
3930 115 : Py_DECREF(value);
3931 115 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
3932 : ast2obj_stmt);
3933 115 : if (!value) goto failed;
3934 115 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3935 0 : goto failed;
3936 115 : Py_DECREF(value);
3937 115 : value = ast2obj_string(state, o->v.AsyncFor.type_comment);
3938 115 : if (!value) goto failed;
3939 115 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3940 0 : goto failed;
3941 115 : Py_DECREF(value);
3942 115 : break;
3943 2223 : case While_kind:
3944 2223 : tp = (PyTypeObject *)state->While_type;
3945 2223 : result = PyType_GenericNew(tp, NULL, NULL);
3946 2223 : if (!result) goto failed;
3947 2223 : value = ast2obj_expr(state, o->v.While.test);
3948 2223 : if (!value) goto failed;
3949 2223 : if (PyObject_SetAttr(result, state->test, value) == -1)
3950 0 : goto failed;
3951 2223 : Py_DECREF(value);
3952 2223 : value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
3953 2223 : if (!value) goto failed;
3954 2223 : if (PyObject_SetAttr(result, state->body, value) == -1)
3955 0 : goto failed;
3956 2223 : Py_DECREF(value);
3957 2223 : value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
3958 2223 : if (!value) goto failed;
3959 2223 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3960 0 : goto failed;
3961 2223 : Py_DECREF(value);
3962 2223 : break;
3963 49555 : case If_kind:
3964 49555 : tp = (PyTypeObject *)state->If_type;
3965 49555 : result = PyType_GenericNew(tp, NULL, NULL);
3966 49555 : if (!result) goto failed;
3967 49555 : value = ast2obj_expr(state, o->v.If.test);
3968 49555 : if (!value) goto failed;
3969 49555 : if (PyObject_SetAttr(result, state->test, value) == -1)
3970 0 : goto failed;
3971 49555 : Py_DECREF(value);
3972 49555 : value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
3973 49555 : if (!value) goto failed;
3974 49555 : if (PyObject_SetAttr(result, state->body, value) == -1)
3975 0 : goto failed;
3976 49555 : Py_DECREF(value);
3977 49555 : value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
3978 49555 : if (!value) goto failed;
3979 49555 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3980 0 : goto failed;
3981 49555 : Py_DECREF(value);
3982 49555 : break;
3983 18332 : case With_kind:
3984 18332 : tp = (PyTypeObject *)state->With_type;
3985 18332 : result = PyType_GenericNew(tp, NULL, NULL);
3986 18332 : if (!result) goto failed;
3987 18332 : value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
3988 : ast2obj_withitem);
3989 18332 : if (!value) goto failed;
3990 18332 : if (PyObject_SetAttr(result, state->items, value) == -1)
3991 0 : goto failed;
3992 18332 : Py_DECREF(value);
3993 18332 : value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
3994 18332 : if (!value) goto failed;
3995 18332 : if (PyObject_SetAttr(result, state->body, value) == -1)
3996 0 : goto failed;
3997 18332 : Py_DECREF(value);
3998 18332 : value = ast2obj_string(state, o->v.With.type_comment);
3999 18332 : if (!value) goto failed;
4000 18332 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4001 0 : goto failed;
4002 18332 : Py_DECREF(value);
4003 18332 : break;
4004 155 : case AsyncWith_kind:
4005 155 : tp = (PyTypeObject *)state->AsyncWith_type;
4006 155 : result = PyType_GenericNew(tp, NULL, NULL);
4007 155 : if (!result) goto failed;
4008 155 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
4009 : ast2obj_withitem);
4010 155 : if (!value) goto failed;
4011 155 : if (PyObject_SetAttr(result, state->items, value) == -1)
4012 0 : goto failed;
4013 155 : Py_DECREF(value);
4014 155 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
4015 : ast2obj_stmt);
4016 155 : if (!value) goto failed;
4017 155 : if (PyObject_SetAttr(result, state->body, value) == -1)
4018 0 : goto failed;
4019 155 : Py_DECREF(value);
4020 155 : value = ast2obj_string(state, o->v.AsyncWith.type_comment);
4021 155 : if (!value) goto failed;
4022 155 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4023 0 : goto failed;
4024 155 : Py_DECREF(value);
4025 155 : break;
4026 542 : case Match_kind:
4027 542 : tp = (PyTypeObject *)state->Match_type;
4028 542 : result = PyType_GenericNew(tp, NULL, NULL);
4029 542 : if (!result) goto failed;
4030 542 : value = ast2obj_expr(state, o->v.Match.subject);
4031 542 : if (!value) goto failed;
4032 542 : if (PyObject_SetAttr(result, state->subject, value) == -1)
4033 0 : goto failed;
4034 542 : Py_DECREF(value);
4035 542 : value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
4036 : ast2obj_match_case);
4037 542 : if (!value) goto failed;
4038 542 : if (PyObject_SetAttr(result, state->cases, value) == -1)
4039 0 : goto failed;
4040 542 : Py_DECREF(value);
4041 542 : break;
4042 10985 : case Raise_kind:
4043 10985 : tp = (PyTypeObject *)state->Raise_type;
4044 10985 : result = PyType_GenericNew(tp, NULL, NULL);
4045 10985 : if (!result) goto failed;
4046 10985 : value = ast2obj_expr(state, o->v.Raise.exc);
4047 10985 : if (!value) goto failed;
4048 10985 : if (PyObject_SetAttr(result, state->exc, value) == -1)
4049 0 : goto failed;
4050 10985 : Py_DECREF(value);
4051 10985 : value = ast2obj_expr(state, o->v.Raise.cause);
4052 10985 : if (!value) goto failed;
4053 10985 : if (PyObject_SetAttr(result, state->cause, value) == -1)
4054 0 : goto failed;
4055 10985 : Py_DECREF(value);
4056 10985 : break;
4057 10838 : case Try_kind:
4058 10838 : tp = (PyTypeObject *)state->Try_type;
4059 10838 : result = PyType_GenericNew(tp, NULL, NULL);
4060 10838 : if (!result) goto failed;
4061 10838 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
4062 10838 : if (!value) goto failed;
4063 10838 : if (PyObject_SetAttr(result, state->body, value) == -1)
4064 0 : goto failed;
4065 10838 : Py_DECREF(value);
4066 10838 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
4067 : ast2obj_excepthandler);
4068 10838 : if (!value) goto failed;
4069 10838 : if (PyObject_SetAttr(result, state->handlers, value) == -1)
4070 0 : goto failed;
4071 10838 : Py_DECREF(value);
4072 10838 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
4073 10838 : if (!value) goto failed;
4074 10838 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
4075 0 : goto failed;
4076 10838 : Py_DECREF(value);
4077 10838 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
4078 : ast2obj_stmt);
4079 10838 : if (!value) goto failed;
4080 10838 : if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4081 0 : goto failed;
4082 10838 : Py_DECREF(value);
4083 10838 : break;
4084 145 : case TryStar_kind:
4085 145 : tp = (PyTypeObject *)state->TryStar_type;
4086 145 : result = PyType_GenericNew(tp, NULL, NULL);
4087 145 : if (!result) goto failed;
4088 145 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
4089 145 : if (!value) goto failed;
4090 145 : if (PyObject_SetAttr(result, state->body, value) == -1)
4091 0 : goto failed;
4092 145 : Py_DECREF(value);
4093 145 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
4094 : ast2obj_excepthandler);
4095 145 : if (!value) goto failed;
4096 145 : if (PyObject_SetAttr(result, state->handlers, value) == -1)
4097 0 : goto failed;
4098 145 : Py_DECREF(value);
4099 145 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
4100 : ast2obj_stmt);
4101 145 : if (!value) goto failed;
4102 145 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
4103 0 : goto failed;
4104 145 : Py_DECREF(value);
4105 145 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
4106 : ast2obj_stmt);
4107 145 : if (!value) goto failed;
4108 145 : if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4109 0 : goto failed;
4110 145 : Py_DECREF(value);
4111 145 : break;
4112 1556 : case Assert_kind:
4113 1556 : tp = (PyTypeObject *)state->Assert_type;
4114 1556 : result = PyType_GenericNew(tp, NULL, NULL);
4115 1556 : if (!result) goto failed;
4116 1556 : value = ast2obj_expr(state, o->v.Assert.test);
4117 1556 : if (!value) goto failed;
4118 1556 : if (PyObject_SetAttr(result, state->test, value) == -1)
4119 0 : goto failed;
4120 1556 : Py_DECREF(value);
4121 1556 : value = ast2obj_expr(state, o->v.Assert.msg);
4122 1556 : if (!value) goto failed;
4123 1556 : if (PyObject_SetAttr(result, state->msg, value) == -1)
4124 0 : goto failed;
4125 1556 : Py_DECREF(value);
4126 1556 : break;
4127 9687 : case Import_kind:
4128 9687 : tp = (PyTypeObject *)state->Import_type;
4129 9687 : result = PyType_GenericNew(tp, NULL, NULL);
4130 9687 : if (!result) goto failed;
4131 9687 : value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
4132 : ast2obj_alias);
4133 9687 : if (!value) goto failed;
4134 9687 : if (PyObject_SetAttr(result, state->names, value) == -1)
4135 0 : goto failed;
4136 9687 : Py_DECREF(value);
4137 9687 : break;
4138 4839 : case ImportFrom_kind:
4139 4839 : tp = (PyTypeObject *)state->ImportFrom_type;
4140 4839 : result = PyType_GenericNew(tp, NULL, NULL);
4141 4839 : if (!result) goto failed;
4142 4839 : value = ast2obj_identifier(state, o->v.ImportFrom.module);
4143 4839 : if (!value) goto failed;
4144 4839 : if (PyObject_SetAttr(result, state->module, value) == -1)
4145 0 : goto failed;
4146 4839 : Py_DECREF(value);
4147 4839 : value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
4148 : ast2obj_alias);
4149 4839 : if (!value) goto failed;
4150 4839 : if (PyObject_SetAttr(result, state->names, value) == -1)
4151 0 : goto failed;
4152 4839 : Py_DECREF(value);
4153 4839 : value = ast2obj_int(state, o->v.ImportFrom.level);
4154 4839 : if (!value) goto failed;
4155 4839 : if (PyObject_SetAttr(result, state->level, value) == -1)
4156 0 : goto failed;
4157 4839 : Py_DECREF(value);
4158 4839 : break;
4159 381 : case Global_kind:
4160 381 : tp = (PyTypeObject *)state->Global_type;
4161 381 : result = PyType_GenericNew(tp, NULL, NULL);
4162 381 : if (!result) goto failed;
4163 381 : value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
4164 : ast2obj_identifier);
4165 381 : if (!value) goto failed;
4166 381 : if (PyObject_SetAttr(result, state->names, value) == -1)
4167 0 : goto failed;
4168 381 : Py_DECREF(value);
4169 381 : break;
4170 364 : case Nonlocal_kind:
4171 364 : tp = (PyTypeObject *)state->Nonlocal_type;
4172 364 : result = PyType_GenericNew(tp, NULL, NULL);
4173 364 : if (!result) goto failed;
4174 364 : value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
4175 : ast2obj_identifier);
4176 364 : if (!value) goto failed;
4177 364 : if (PyObject_SetAttr(result, state->names, value) == -1)
4178 0 : goto failed;
4179 364 : Py_DECREF(value);
4180 364 : break;
4181 239643 : case Expr_kind:
4182 239643 : tp = (PyTypeObject *)state->Expr_type;
4183 239643 : result = PyType_GenericNew(tp, NULL, NULL);
4184 239643 : if (!result) goto failed;
4185 239643 : value = ast2obj_expr(state, o->v.Expr.value);
4186 239643 : if (!value) goto failed;
4187 239643 : if (PyObject_SetAttr(result, state->value, value) == -1)
4188 0 : goto failed;
4189 239643 : Py_DECREF(value);
4190 239643 : break;
4191 11089 : case Pass_kind:
4192 11089 : tp = (PyTypeObject *)state->Pass_type;
4193 11089 : result = PyType_GenericNew(tp, NULL, NULL);
4194 11089 : if (!result) goto failed;
4195 11089 : break;
4196 1721 : case Break_kind:
4197 1721 : tp = (PyTypeObject *)state->Break_type;
4198 1721 : result = PyType_GenericNew(tp, NULL, NULL);
4199 1721 : if (!result) goto failed;
4200 1721 : break;
4201 1456 : case Continue_kind:
4202 1456 : tp = (PyTypeObject *)state->Continue_type;
4203 1456 : result = PyType_GenericNew(tp, NULL, NULL);
4204 1456 : if (!result) goto failed;
4205 1456 : break;
4206 : }
4207 727431 : value = ast2obj_int(state, o->lineno);
4208 727431 : if (!value) goto failed;
4209 727431 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
4210 0 : goto failed;
4211 727431 : Py_DECREF(value);
4212 727431 : value = ast2obj_int(state, o->col_offset);
4213 727431 : if (!value) goto failed;
4214 727431 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4215 0 : goto failed;
4216 727431 : Py_DECREF(value);
4217 727431 : value = ast2obj_int(state, o->end_lineno);
4218 727431 : if (!value) goto failed;
4219 727431 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4220 0 : goto failed;
4221 727431 : Py_DECREF(value);
4222 727431 : value = ast2obj_int(state, o->end_col_offset);
4223 727431 : if (!value) goto failed;
4224 727431 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4225 0 : goto failed;
4226 727431 : Py_DECREF(value);
4227 727431 : return result;
4228 0 : failed:
4229 0 : Py_XDECREF(value);
4230 0 : Py_XDECREF(result);
4231 0 : return NULL;
4232 : }
4233 :
4234 : PyObject*
4235 4034320 : ast2obj_expr(struct ast_state *state, void* _o)
4236 : {
4237 4034320 : expr_ty o = (expr_ty)_o;
4238 4034320 : PyObject *result = NULL, *value = NULL;
4239 : PyTypeObject *tp;
4240 4034320 : if (!o) {
4241 269907 : Py_RETURN_NONE;
4242 : }
4243 3764420 : switch (o->kind) {
4244 9488 : case BoolOp_kind:
4245 9488 : tp = (PyTypeObject *)state->BoolOp_type;
4246 9488 : result = PyType_GenericNew(tp, NULL, NULL);
4247 9488 : if (!result) goto failed;
4248 9488 : value = ast2obj_boolop(state, o->v.BoolOp.op);
4249 9488 : if (!value) goto failed;
4250 9488 : if (PyObject_SetAttr(result, state->op, value) == -1)
4251 0 : goto failed;
4252 9488 : Py_DECREF(value);
4253 9488 : value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
4254 : ast2obj_expr);
4255 9488 : if (!value) goto failed;
4256 9488 : if (PyObject_SetAttr(result, state->values, value) == -1)
4257 0 : goto failed;
4258 9488 : Py_DECREF(value);
4259 9488 : break;
4260 196 : case NamedExpr_kind:
4261 196 : tp = (PyTypeObject *)state->NamedExpr_type;
4262 196 : result = PyType_GenericNew(tp, NULL, NULL);
4263 196 : if (!result) goto failed;
4264 196 : value = ast2obj_expr(state, o->v.NamedExpr.target);
4265 196 : if (!value) goto failed;
4266 196 : if (PyObject_SetAttr(result, state->target, value) == -1)
4267 0 : goto failed;
4268 196 : Py_DECREF(value);
4269 196 : value = ast2obj_expr(state, o->v.NamedExpr.value);
4270 196 : if (!value) goto failed;
4271 196 : if (PyObject_SetAttr(result, state->value, value) == -1)
4272 0 : goto failed;
4273 196 : Py_DECREF(value);
4274 196 : break;
4275 59622 : case BinOp_kind:
4276 59622 : tp = (PyTypeObject *)state->BinOp_type;
4277 59622 : result = PyType_GenericNew(tp, NULL, NULL);
4278 59622 : if (!result) goto failed;
4279 59622 : value = ast2obj_expr(state, o->v.BinOp.left);
4280 59622 : if (!value) goto failed;
4281 59622 : if (PyObject_SetAttr(result, state->left, value) == -1)
4282 0 : goto failed;
4283 59622 : Py_DECREF(value);
4284 59622 : value = ast2obj_operator(state, o->v.BinOp.op);
4285 59622 : if (!value) goto failed;
4286 59622 : if (PyObject_SetAttr(result, state->op, value) == -1)
4287 0 : goto failed;
4288 59622 : Py_DECREF(value);
4289 59622 : value = ast2obj_expr(state, o->v.BinOp.right);
4290 59622 : if (!value) goto failed;
4291 59622 : if (PyObject_SetAttr(result, state->right, value) == -1)
4292 0 : goto failed;
4293 59622 : Py_DECREF(value);
4294 59622 : break;
4295 23615 : case UnaryOp_kind:
4296 23615 : tp = (PyTypeObject *)state->UnaryOp_type;
4297 23615 : result = PyType_GenericNew(tp, NULL, NULL);
4298 23615 : if (!result) goto failed;
4299 23615 : value = ast2obj_unaryop(state, o->v.UnaryOp.op);
4300 23615 : if (!value) goto failed;
4301 23615 : if (PyObject_SetAttr(result, state->op, value) == -1)
4302 0 : goto failed;
4303 23615 : Py_DECREF(value);
4304 23615 : value = ast2obj_expr(state, o->v.UnaryOp.operand);
4305 23615 : if (!value) goto failed;
4306 23615 : if (PyObject_SetAttr(result, state->operand, value) == -1)
4307 0 : goto failed;
4308 23615 : Py_DECREF(value);
4309 23615 : break;
4310 2633 : case Lambda_kind:
4311 2633 : tp = (PyTypeObject *)state->Lambda_type;
4312 2633 : result = PyType_GenericNew(tp, NULL, NULL);
4313 2633 : if (!result) goto failed;
4314 2633 : value = ast2obj_arguments(state, o->v.Lambda.args);
4315 2633 : if (!value) goto failed;
4316 2633 : if (PyObject_SetAttr(result, state->args, value) == -1)
4317 0 : goto failed;
4318 2633 : Py_DECREF(value);
4319 2633 : value = ast2obj_expr(state, o->v.Lambda.body);
4320 2633 : if (!value) goto failed;
4321 2633 : if (PyObject_SetAttr(result, state->body, value) == -1)
4322 0 : goto failed;
4323 2633 : Py_DECREF(value);
4324 2633 : break;
4325 1423 : case IfExp_kind:
4326 1423 : tp = (PyTypeObject *)state->IfExp_type;
4327 1423 : result = PyType_GenericNew(tp, NULL, NULL);
4328 1423 : if (!result) goto failed;
4329 1423 : value = ast2obj_expr(state, o->v.IfExp.test);
4330 1423 : if (!value) goto failed;
4331 1423 : if (PyObject_SetAttr(result, state->test, value) == -1)
4332 0 : goto failed;
4333 1423 : Py_DECREF(value);
4334 1423 : value = ast2obj_expr(state, o->v.IfExp.body);
4335 1423 : if (!value) goto failed;
4336 1423 : if (PyObject_SetAttr(result, state->body, value) == -1)
4337 0 : goto failed;
4338 1423 : Py_DECREF(value);
4339 1423 : value = ast2obj_expr(state, o->v.IfExp.orelse);
4340 1423 : if (!value) goto failed;
4341 1423 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
4342 0 : goto failed;
4343 1423 : Py_DECREF(value);
4344 1423 : break;
4345 9802 : case Dict_kind:
4346 9802 : tp = (PyTypeObject *)state->Dict_type;
4347 9802 : result = PyType_GenericNew(tp, NULL, NULL);
4348 9802 : if (!result) goto failed;
4349 9802 : value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
4350 9802 : if (!value) goto failed;
4351 9802 : if (PyObject_SetAttr(result, state->keys, value) == -1)
4352 0 : goto failed;
4353 9802 : Py_DECREF(value);
4354 9802 : value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
4355 9802 : if (!value) goto failed;
4356 9802 : if (PyObject_SetAttr(result, state->values, value) == -1)
4357 0 : goto failed;
4358 9802 : Py_DECREF(value);
4359 9802 : break;
4360 1304 : case Set_kind:
4361 1304 : tp = (PyTypeObject *)state->Set_type;
4362 1304 : result = PyType_GenericNew(tp, NULL, NULL);
4363 1304 : if (!result) goto failed;
4364 1304 : value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
4365 1304 : if (!value) goto failed;
4366 1304 : if (PyObject_SetAttr(result, state->elts, value) == -1)
4367 0 : goto failed;
4368 1304 : Py_DECREF(value);
4369 1304 : break;
4370 2892 : case ListComp_kind:
4371 2892 : tp = (PyTypeObject *)state->ListComp_type;
4372 2892 : result = PyType_GenericNew(tp, NULL, NULL);
4373 2892 : if (!result) goto failed;
4374 2892 : value = ast2obj_expr(state, o->v.ListComp.elt);
4375 2892 : if (!value) goto failed;
4376 2892 : if (PyObject_SetAttr(result, state->elt, value) == -1)
4377 0 : goto failed;
4378 2892 : Py_DECREF(value);
4379 2892 : value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
4380 : ast2obj_comprehension);
4381 2892 : if (!value) goto failed;
4382 2892 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4383 0 : goto failed;
4384 2892 : Py_DECREF(value);
4385 2892 : break;
4386 127 : case SetComp_kind:
4387 127 : tp = (PyTypeObject *)state->SetComp_type;
4388 127 : result = PyType_GenericNew(tp, NULL, NULL);
4389 127 : if (!result) goto failed;
4390 127 : value = ast2obj_expr(state, o->v.SetComp.elt);
4391 127 : if (!value) goto failed;
4392 127 : if (PyObject_SetAttr(result, state->elt, value) == -1)
4393 0 : goto failed;
4394 127 : Py_DECREF(value);
4395 127 : value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
4396 : ast2obj_comprehension);
4397 127 : if (!value) goto failed;
4398 127 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4399 0 : goto failed;
4400 127 : Py_DECREF(value);
4401 127 : break;
4402 248 : case DictComp_kind:
4403 248 : tp = (PyTypeObject *)state->DictComp_type;
4404 248 : result = PyType_GenericNew(tp, NULL, NULL);
4405 248 : if (!result) goto failed;
4406 248 : value = ast2obj_expr(state, o->v.DictComp.key);
4407 248 : if (!value) goto failed;
4408 248 : if (PyObject_SetAttr(result, state->key, value) == -1)
4409 0 : goto failed;
4410 248 : Py_DECREF(value);
4411 248 : value = ast2obj_expr(state, o->v.DictComp.value);
4412 248 : if (!value) goto failed;
4413 248 : if (PyObject_SetAttr(result, state->value, value) == -1)
4414 0 : goto failed;
4415 248 : Py_DECREF(value);
4416 248 : value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
4417 : ast2obj_comprehension);
4418 248 : if (!value) goto failed;
4419 248 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4420 0 : goto failed;
4421 248 : Py_DECREF(value);
4422 248 : break;
4423 1499 : case GeneratorExp_kind:
4424 1499 : tp = (PyTypeObject *)state->GeneratorExp_type;
4425 1499 : result = PyType_GenericNew(tp, NULL, NULL);
4426 1499 : if (!result) goto failed;
4427 1499 : value = ast2obj_expr(state, o->v.GeneratorExp.elt);
4428 1499 : if (!value) goto failed;
4429 1499 : if (PyObject_SetAttr(result, state->elt, value) == -1)
4430 0 : goto failed;
4431 1499 : Py_DECREF(value);
4432 1499 : value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
4433 : ast2obj_comprehension);
4434 1499 : if (!value) goto failed;
4435 1499 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4436 0 : goto failed;
4437 1499 : Py_DECREF(value);
4438 1499 : break;
4439 653 : case Await_kind:
4440 653 : tp = (PyTypeObject *)state->Await_type;
4441 653 : result = PyType_GenericNew(tp, NULL, NULL);
4442 653 : if (!result) goto failed;
4443 653 : value = ast2obj_expr(state, o->v.Await.value);
4444 653 : if (!value) goto failed;
4445 653 : if (PyObject_SetAttr(result, state->value, value) == -1)
4446 0 : goto failed;
4447 653 : Py_DECREF(value);
4448 653 : break;
4449 2262 : case Yield_kind:
4450 2262 : tp = (PyTypeObject *)state->Yield_type;
4451 2262 : result = PyType_GenericNew(tp, NULL, NULL);
4452 2262 : if (!result) goto failed;
4453 2262 : value = ast2obj_expr(state, o->v.Yield.value);
4454 2262 : if (!value) goto failed;
4455 2262 : if (PyObject_SetAttr(result, state->value, value) == -1)
4456 0 : goto failed;
4457 2262 : Py_DECREF(value);
4458 2262 : break;
4459 318 : case YieldFrom_kind:
4460 318 : tp = (PyTypeObject *)state->YieldFrom_type;
4461 318 : result = PyType_GenericNew(tp, NULL, NULL);
4462 318 : if (!result) goto failed;
4463 318 : value = ast2obj_expr(state, o->v.YieldFrom.value);
4464 318 : if (!value) goto failed;
4465 318 : if (PyObject_SetAttr(result, state->value, value) == -1)
4466 0 : goto failed;
4467 318 : Py_DECREF(value);
4468 318 : break;
4469 42663 : case Compare_kind:
4470 42663 : tp = (PyTypeObject *)state->Compare_type;
4471 42663 : result = PyType_GenericNew(tp, NULL, NULL);
4472 42663 : if (!result) goto failed;
4473 42663 : value = ast2obj_expr(state, o->v.Compare.left);
4474 42663 : if (!value) goto failed;
4475 42663 : if (PyObject_SetAttr(result, state->left, value) == -1)
4476 0 : goto failed;
4477 42663 : Py_DECREF(value);
4478 : {
4479 42663 : Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
4480 42663 : value = PyList_New(n);
4481 42663 : if (!value) goto failed;
4482 86049 : for(i = 0; i < n; i++)
4483 43386 : PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
4484 : }
4485 42663 : if (!value) goto failed;
4486 42663 : if (PyObject_SetAttr(result, state->ops, value) == -1)
4487 0 : goto failed;
4488 42663 : Py_DECREF(value);
4489 42663 : value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
4490 : ast2obj_expr);
4491 42663 : if (!value) goto failed;
4492 42663 : if (PyObject_SetAttr(result, state->comparators, value) == -1)
4493 0 : goto failed;
4494 42663 : Py_DECREF(value);
4495 42663 : break;
4496 502348 : case Call_kind:
4497 502348 : tp = (PyTypeObject *)state->Call_type;
4498 502348 : result = PyType_GenericNew(tp, NULL, NULL);
4499 502348 : if (!result) goto failed;
4500 502348 : value = ast2obj_expr(state, o->v.Call.func);
4501 502348 : if (!value) goto failed;
4502 502348 : if (PyObject_SetAttr(result, state->func, value) == -1)
4503 0 : goto failed;
4504 502348 : Py_DECREF(value);
4505 502348 : value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
4506 502348 : if (!value) goto failed;
4507 502348 : if (PyObject_SetAttr(result, state->args, value) == -1)
4508 0 : goto failed;
4509 502348 : Py_DECREF(value);
4510 502348 : value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
4511 : ast2obj_keyword);
4512 502348 : if (!value) goto failed;
4513 502348 : if (PyObject_SetAttr(result, state->keywords, value) == -1)
4514 0 : goto failed;
4515 502348 : Py_DECREF(value);
4516 502348 : break;
4517 4900 : case FormattedValue_kind:
4518 4900 : tp = (PyTypeObject *)state->FormattedValue_type;
4519 4900 : result = PyType_GenericNew(tp, NULL, NULL);
4520 4900 : if (!result) goto failed;
4521 4900 : value = ast2obj_expr(state, o->v.FormattedValue.value);
4522 4900 : if (!value) goto failed;
4523 4900 : if (PyObject_SetAttr(result, state->value, value) == -1)
4524 0 : goto failed;
4525 4900 : Py_DECREF(value);
4526 4900 : value = ast2obj_int(state, o->v.FormattedValue.conversion);
4527 4900 : if (!value) goto failed;
4528 4900 : if (PyObject_SetAttr(result, state->conversion, value) == -1)
4529 0 : goto failed;
4530 4900 : Py_DECREF(value);
4531 4900 : value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
4532 4900 : if (!value) goto failed;
4533 4900 : if (PyObject_SetAttr(result, state->format_spec, value) == -1)
4534 0 : goto failed;
4535 4900 : Py_DECREF(value);
4536 4900 : break;
4537 4008 : case JoinedStr_kind:
4538 4008 : tp = (PyTypeObject *)state->JoinedStr_type;
4539 4008 : result = PyType_GenericNew(tp, NULL, NULL);
4540 4008 : if (!result) goto failed;
4541 4008 : value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
4542 : ast2obj_expr);
4543 4008 : if (!value) goto failed;
4544 4008 : if (PyObject_SetAttr(result, state->values, value) == -1)
4545 0 : goto failed;
4546 4008 : Py_DECREF(value);
4547 4008 : break;
4548 1052870 : case Constant_kind:
4549 1052870 : tp = (PyTypeObject *)state->Constant_type;
4550 1052870 : result = PyType_GenericNew(tp, NULL, NULL);
4551 1052870 : if (!result) goto failed;
4552 1052870 : value = ast2obj_constant(state, o->v.Constant.value);
4553 1052870 : if (!value) goto failed;
4554 1052870 : if (PyObject_SetAttr(result, state->value, value) == -1)
4555 0 : goto failed;
4556 1052870 : Py_DECREF(value);
4557 1052870 : value = ast2obj_string(state, o->v.Constant.kind);
4558 1052870 : if (!value) goto failed;
4559 1052870 : if (PyObject_SetAttr(result, state->kind, value) == -1)
4560 0 : goto failed;
4561 1052870 : Py_DECREF(value);
4562 1052870 : break;
4563 534560 : case Attribute_kind:
4564 534560 : tp = (PyTypeObject *)state->Attribute_type;
4565 534560 : result = PyType_GenericNew(tp, NULL, NULL);
4566 534560 : if (!result) goto failed;
4567 534560 : value = ast2obj_expr(state, o->v.Attribute.value);
4568 534560 : if (!value) goto failed;
4569 534560 : if (PyObject_SetAttr(result, state->value, value) == -1)
4570 0 : goto failed;
4571 534560 : Py_DECREF(value);
4572 534560 : value = ast2obj_identifier(state, o->v.Attribute.attr);
4573 534560 : if (!value) goto failed;
4574 534560 : if (PyObject_SetAttr(result, state->attr, value) == -1)
4575 0 : goto failed;
4576 534560 : Py_DECREF(value);
4577 534560 : value = ast2obj_expr_context(state, o->v.Attribute.ctx);
4578 534560 : if (!value) goto failed;
4579 534560 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4580 0 : goto failed;
4581 534560 : Py_DECREF(value);
4582 534560 : break;
4583 42923 : case Subscript_kind:
4584 42923 : tp = (PyTypeObject *)state->Subscript_type;
4585 42923 : result = PyType_GenericNew(tp, NULL, NULL);
4586 42923 : if (!result) goto failed;
4587 42923 : value = ast2obj_expr(state, o->v.Subscript.value);
4588 42923 : if (!value) goto failed;
4589 42923 : if (PyObject_SetAttr(result, state->value, value) == -1)
4590 0 : goto failed;
4591 42923 : Py_DECREF(value);
4592 42923 : value = ast2obj_expr(state, o->v.Subscript.slice);
4593 42923 : if (!value) goto failed;
4594 42923 : if (PyObject_SetAttr(result, state->slice, value) == -1)
4595 0 : goto failed;
4596 42923 : Py_DECREF(value);
4597 42923 : value = ast2obj_expr_context(state, o->v.Subscript.ctx);
4598 42923 : if (!value) goto failed;
4599 42923 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4600 0 : goto failed;
4601 42923 : Py_DECREF(value);
4602 42923 : break;
4603 3457 : case Starred_kind:
4604 3457 : tp = (PyTypeObject *)state->Starred_type;
4605 3457 : result = PyType_GenericNew(tp, NULL, NULL);
4606 3457 : if (!result) goto failed;
4607 3457 : value = ast2obj_expr(state, o->v.Starred.value);
4608 3457 : if (!value) goto failed;
4609 3457 : if (PyObject_SetAttr(result, state->value, value) == -1)
4610 0 : goto failed;
4611 3457 : Py_DECREF(value);
4612 3457 : value = ast2obj_expr_context(state, o->v.Starred.ctx);
4613 3457 : if (!value) goto failed;
4614 3457 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4615 0 : goto failed;
4616 3457 : Py_DECREF(value);
4617 3457 : break;
4618 1346940 : case Name_kind:
4619 1346940 : tp = (PyTypeObject *)state->Name_type;
4620 1346940 : result = PyType_GenericNew(tp, NULL, NULL);
4621 1346940 : if (!result) goto failed;
4622 1346940 : value = ast2obj_identifier(state, o->v.Name.id);
4623 1346940 : if (!value) goto failed;
4624 1346940 : if (PyObject_SetAttr(result, state->id, value) == -1)
4625 0 : goto failed;
4626 1346940 : Py_DECREF(value);
4627 1346940 : value = ast2obj_expr_context(state, o->v.Name.ctx);
4628 1346940 : if (!value) goto failed;
4629 1346940 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4630 0 : goto failed;
4631 1346940 : Py_DECREF(value);
4632 1346940 : break;
4633 34903 : case List_kind:
4634 34903 : tp = (PyTypeObject *)state->List_type;
4635 34903 : result = PyType_GenericNew(tp, NULL, NULL);
4636 34903 : if (!result) goto failed;
4637 34903 : value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
4638 34903 : if (!value) goto failed;
4639 34903 : if (PyObject_SetAttr(result, state->elts, value) == -1)
4640 0 : goto failed;
4641 34903 : Py_DECREF(value);
4642 34903 : value = ast2obj_expr_context(state, o->v.List.ctx);
4643 34903 : if (!value) goto failed;
4644 34903 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4645 0 : goto failed;
4646 34903 : Py_DECREF(value);
4647 34903 : break;
4648 70365 : case Tuple_kind:
4649 70365 : tp = (PyTypeObject *)state->Tuple_type;
4650 70365 : result = PyType_GenericNew(tp, NULL, NULL);
4651 70365 : if (!result) goto failed;
4652 70365 : value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
4653 70365 : if (!value) goto failed;
4654 70365 : if (PyObject_SetAttr(result, state->elts, value) == -1)
4655 0 : goto failed;
4656 70365 : Py_DECREF(value);
4657 70365 : value = ast2obj_expr_context(state, o->v.Tuple.ctx);
4658 70365 : if (!value) goto failed;
4659 70365 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4660 0 : goto failed;
4661 70365 : Py_DECREF(value);
4662 70365 : break;
4663 8397 : case Slice_kind:
4664 8397 : tp = (PyTypeObject *)state->Slice_type;
4665 8397 : result = PyType_GenericNew(tp, NULL, NULL);
4666 8397 : if (!result) goto failed;
4667 8397 : value = ast2obj_expr(state, o->v.Slice.lower);
4668 8397 : if (!value) goto failed;
4669 8397 : if (PyObject_SetAttr(result, state->lower, value) == -1)
4670 0 : goto failed;
4671 8397 : Py_DECREF(value);
4672 8397 : value = ast2obj_expr(state, o->v.Slice.upper);
4673 8397 : if (!value) goto failed;
4674 8397 : if (PyObject_SetAttr(result, state->upper, value) == -1)
4675 0 : goto failed;
4676 8397 : Py_DECREF(value);
4677 8397 : value = ast2obj_expr(state, o->v.Slice.step);
4678 8397 : if (!value) goto failed;
4679 8397 : if (PyObject_SetAttr(result, state->step, value) == -1)
4680 0 : goto failed;
4681 8397 : Py_DECREF(value);
4682 8397 : break;
4683 : }
4684 3764420 : value = ast2obj_int(state, o->lineno);
4685 3764420 : if (!value) goto failed;
4686 3764420 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
4687 0 : goto failed;
4688 3764420 : Py_DECREF(value);
4689 3764420 : value = ast2obj_int(state, o->col_offset);
4690 3764420 : if (!value) goto failed;
4691 3764420 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4692 0 : goto failed;
4693 3764420 : Py_DECREF(value);
4694 3764420 : value = ast2obj_int(state, o->end_lineno);
4695 3764420 : if (!value) goto failed;
4696 3764420 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4697 0 : goto failed;
4698 3764420 : Py_DECREF(value);
4699 3764420 : value = ast2obj_int(state, o->end_col_offset);
4700 3764420 : if (!value) goto failed;
4701 3764420 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4702 0 : goto failed;
4703 3764420 : Py_DECREF(value);
4704 3764420 : return result;
4705 0 : failed:
4706 0 : Py_XDECREF(value);
4707 0 : Py_XDECREF(result);
4708 0 : return NULL;
4709 : }
4710 :
4711 2033150 : PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
4712 : {
4713 2033150 : switch(o) {
4714 1768140 : case Load:
4715 1768140 : Py_INCREF(state->Load_singleton);
4716 1768140 : return state->Load_singleton;
4717 261822 : case Store:
4718 261822 : Py_INCREF(state->Store_singleton);
4719 261822 : return state->Store_singleton;
4720 3184 : case Del:
4721 3184 : Py_INCREF(state->Del_singleton);
4722 3184 : return state->Del_singleton;
4723 : }
4724 0 : Py_UNREACHABLE();
4725 : }
4726 9488 : PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
4727 : {
4728 9488 : switch(o) {
4729 5958 : case And:
4730 5958 : Py_INCREF(state->And_singleton);
4731 5958 : return state->And_singleton;
4732 3530 : case Or:
4733 3530 : Py_INCREF(state->Or_singleton);
4734 3530 : return state->Or_singleton;
4735 : }
4736 0 : Py_UNREACHABLE();
4737 : }
4738 64674 : PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
4739 : {
4740 64674 : switch(o) {
4741 25561 : case Add:
4742 25561 : Py_INCREF(state->Add_singleton);
4743 25561 : return state->Add_singleton;
4744 6529 : case Sub:
4745 6529 : Py_INCREF(state->Sub_singleton);
4746 6529 : return state->Sub_singleton;
4747 9192 : case Mult:
4748 9192 : Py_INCREF(state->Mult_singleton);
4749 9192 : return state->Mult_singleton;
4750 53 : case MatMult:
4751 53 : Py_INCREF(state->MatMult_singleton);
4752 53 : return state->MatMult_singleton;
4753 3489 : case Div:
4754 3489 : Py_INCREF(state->Div_singleton);
4755 3489 : return state->Div_singleton;
4756 9936 : case Mod:
4757 9936 : Py_INCREF(state->Mod_singleton);
4758 9936 : return state->Mod_singleton;
4759 2521 : case Pow:
4760 2521 : Py_INCREF(state->Pow_singleton);
4761 2521 : return state->Pow_singleton;
4762 1159 : case LShift:
4763 1159 : Py_INCREF(state->LShift_singleton);
4764 1159 : return state->LShift_singleton;
4765 391 : case RShift:
4766 391 : Py_INCREF(state->RShift_singleton);
4767 391 : return state->RShift_singleton;
4768 2696 : case BitOr:
4769 2696 : Py_INCREF(state->BitOr_singleton);
4770 2696 : return state->BitOr_singleton;
4771 454 : case BitXor:
4772 454 : Py_INCREF(state->BitXor_singleton);
4773 454 : return state->BitXor_singleton;
4774 1537 : case BitAnd:
4775 1537 : Py_INCREF(state->BitAnd_singleton);
4776 1537 : return state->BitAnd_singleton;
4777 1156 : case FloorDiv:
4778 1156 : Py_INCREF(state->FloorDiv_singleton);
4779 1156 : return state->FloorDiv_singleton;
4780 : }
4781 0 : Py_UNREACHABLE();
4782 : }
4783 23615 : PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
4784 : {
4785 23615 : switch(o) {
4786 281 : case Invert:
4787 281 : Py_INCREF(state->Invert_singleton);
4788 281 : return state->Invert_singleton;
4789 8226 : case Not:
4790 8226 : Py_INCREF(state->Not_singleton);
4791 8226 : return state->Not_singleton;
4792 138 : case UAdd:
4793 138 : Py_INCREF(state->UAdd_singleton);
4794 138 : return state->UAdd_singleton;
4795 14970 : case USub:
4796 14970 : Py_INCREF(state->USub_singleton);
4797 14970 : return state->USub_singleton;
4798 : }
4799 0 : Py_UNREACHABLE();
4800 : }
4801 43386 : PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
4802 : {
4803 43386 : switch(o) {
4804 13475 : case Eq:
4805 13475 : Py_INCREF(state->Eq_singleton);
4806 13475 : return state->Eq_singleton;
4807 3471 : case NotEq:
4808 3471 : Py_INCREF(state->NotEq_singleton);
4809 3471 : return state->NotEq_singleton;
4810 3178 : case Lt:
4811 3178 : Py_INCREF(state->Lt_singleton);
4812 3178 : return state->Lt_singleton;
4813 1744 : case LtE:
4814 1744 : Py_INCREF(state->LtE_singleton);
4815 1744 : return state->LtE_singleton;
4816 2599 : case Gt:
4817 2599 : Py_INCREF(state->Gt_singleton);
4818 2599 : return state->Gt_singleton;
4819 1645 : case GtE:
4820 1645 : Py_INCREF(state->GtE_singleton);
4821 1645 : return state->GtE_singleton;
4822 6557 : case Is:
4823 6557 : Py_INCREF(state->Is_singleton);
4824 6557 : return state->Is_singleton;
4825 4111 : case IsNot:
4826 4111 : Py_INCREF(state->IsNot_singleton);
4827 4111 : return state->IsNot_singleton;
4828 5123 : case In:
4829 5123 : Py_INCREF(state->In_singleton);
4830 5123 : return state->In_singleton;
4831 1483 : case NotIn:
4832 1483 : Py_INCREF(state->NotIn_singleton);
4833 1483 : return state->NotIn_singleton;
4834 : }
4835 0 : Py_UNREACHABLE();
4836 : }
4837 : PyObject*
4838 4953 : ast2obj_comprehension(struct ast_state *state, void* _o)
4839 : {
4840 4953 : comprehension_ty o = (comprehension_ty)_o;
4841 4953 : PyObject *result = NULL, *value = NULL;
4842 : PyTypeObject *tp;
4843 4953 : if (!o) {
4844 0 : Py_RETURN_NONE;
4845 : }
4846 4953 : tp = (PyTypeObject *)state->comprehension_type;
4847 4953 : result = PyType_GenericNew(tp, NULL, NULL);
4848 4953 : if (!result) return NULL;
4849 4953 : value = ast2obj_expr(state, o->target);
4850 4953 : if (!value) goto failed;
4851 4953 : if (PyObject_SetAttr(result, state->target, value) == -1)
4852 0 : goto failed;
4853 4953 : Py_DECREF(value);
4854 4953 : value = ast2obj_expr(state, o->iter);
4855 4953 : if (!value) goto failed;
4856 4953 : if (PyObject_SetAttr(result, state->iter, value) == -1)
4857 0 : goto failed;
4858 4953 : Py_DECREF(value);
4859 4953 : value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
4860 4953 : if (!value) goto failed;
4861 4953 : if (PyObject_SetAttr(result, state->ifs, value) == -1)
4862 0 : goto failed;
4863 4953 : Py_DECREF(value);
4864 4953 : value = ast2obj_int(state, o->is_async);
4865 4953 : if (!value) goto failed;
4866 4953 : if (PyObject_SetAttr(result, state->is_async, value) == -1)
4867 0 : goto failed;
4868 4953 : Py_DECREF(value);
4869 4953 : return result;
4870 0 : failed:
4871 0 : Py_XDECREF(value);
4872 0 : Py_XDECREF(result);
4873 0 : return NULL;
4874 : }
4875 :
4876 : PyObject*
4877 9244 : ast2obj_excepthandler(struct ast_state *state, void* _o)
4878 : {
4879 9244 : excepthandler_ty o = (excepthandler_ty)_o;
4880 9244 : PyObject *result = NULL, *value = NULL;
4881 : PyTypeObject *tp;
4882 9244 : if (!o) {
4883 0 : Py_RETURN_NONE;
4884 : }
4885 9244 : switch (o->kind) {
4886 9244 : case ExceptHandler_kind:
4887 9244 : tp = (PyTypeObject *)state->ExceptHandler_type;
4888 9244 : result = PyType_GenericNew(tp, NULL, NULL);
4889 9244 : if (!result) goto failed;
4890 9244 : value = ast2obj_expr(state, o->v.ExceptHandler.type);
4891 9244 : if (!value) goto failed;
4892 9244 : if (PyObject_SetAttr(result, state->type, value) == -1)
4893 0 : goto failed;
4894 9244 : Py_DECREF(value);
4895 9244 : value = ast2obj_identifier(state, o->v.ExceptHandler.name);
4896 9244 : if (!value) goto failed;
4897 9244 : if (PyObject_SetAttr(result, state->name, value) == -1)
4898 0 : goto failed;
4899 9244 : Py_DECREF(value);
4900 9244 : value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
4901 : ast2obj_stmt);
4902 9244 : if (!value) goto failed;
4903 9244 : if (PyObject_SetAttr(result, state->body, value) == -1)
4904 0 : goto failed;
4905 9244 : Py_DECREF(value);
4906 9244 : break;
4907 : }
4908 9244 : value = ast2obj_int(state, o->lineno);
4909 9244 : if (!value) goto failed;
4910 9244 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
4911 0 : goto failed;
4912 9244 : Py_DECREF(value);
4913 9244 : value = ast2obj_int(state, o->col_offset);
4914 9244 : if (!value) goto failed;
4915 9244 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4916 0 : goto failed;
4917 9244 : Py_DECREF(value);
4918 9244 : value = ast2obj_int(state, o->end_lineno);
4919 9244 : if (!value) goto failed;
4920 9244 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4921 0 : goto failed;
4922 9244 : Py_DECREF(value);
4923 9244 : value = ast2obj_int(state, o->end_col_offset);
4924 9244 : if (!value) goto failed;
4925 9244 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4926 0 : goto failed;
4927 9244 : Py_DECREF(value);
4928 9244 : return result;
4929 0 : failed:
4930 0 : Py_XDECREF(value);
4931 0 : Py_XDECREF(result);
4932 0 : return NULL;
4933 : }
4934 :
4935 : PyObject*
4936 91640 : ast2obj_arguments(struct ast_state *state, void* _o)
4937 : {
4938 91640 : arguments_ty o = (arguments_ty)_o;
4939 91640 : PyObject *result = NULL, *value = NULL;
4940 : PyTypeObject *tp;
4941 91640 : if (!o) {
4942 0 : Py_RETURN_NONE;
4943 : }
4944 91640 : tp = (PyTypeObject *)state->arguments_type;
4945 91640 : result = PyType_GenericNew(tp, NULL, NULL);
4946 91640 : if (!result) return NULL;
4947 91640 : value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
4948 91640 : if (!value) goto failed;
4949 91640 : if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
4950 0 : goto failed;
4951 91640 : Py_DECREF(value);
4952 91640 : value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
4953 91640 : if (!value) goto failed;
4954 91640 : if (PyObject_SetAttr(result, state->args, value) == -1)
4955 0 : goto failed;
4956 91640 : Py_DECREF(value);
4957 91640 : value = ast2obj_arg(state, o->vararg);
4958 91640 : if (!value) goto failed;
4959 91640 : if (PyObject_SetAttr(result, state->vararg, value) == -1)
4960 0 : goto failed;
4961 91640 : Py_DECREF(value);
4962 91640 : value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
4963 91640 : if (!value) goto failed;
4964 91640 : if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
4965 0 : goto failed;
4966 91640 : Py_DECREF(value);
4967 91640 : value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
4968 91640 : if (!value) goto failed;
4969 91640 : if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
4970 0 : goto failed;
4971 91640 : Py_DECREF(value);
4972 91640 : value = ast2obj_arg(state, o->kwarg);
4973 91640 : if (!value) goto failed;
4974 91640 : if (PyObject_SetAttr(result, state->kwarg, value) == -1)
4975 0 : goto failed;
4976 91640 : Py_DECREF(value);
4977 91640 : value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
4978 91640 : if (!value) goto failed;
4979 91640 : if (PyObject_SetAttr(result, state->defaults, value) == -1)
4980 0 : goto failed;
4981 91640 : Py_DECREF(value);
4982 91640 : return result;
4983 0 : failed:
4984 0 : Py_XDECREF(value);
4985 0 : Py_XDECREF(result);
4986 0 : return NULL;
4987 : }
4988 :
4989 : PyObject*
4990 311072 : ast2obj_arg(struct ast_state *state, void* _o)
4991 : {
4992 311072 : arg_ty o = (arg_ty)_o;
4993 311072 : PyObject *result = NULL, *value = NULL;
4994 : PyTypeObject *tp;
4995 311072 : if (!o) {
4996 177357 : Py_RETURN_NONE;
4997 : }
4998 133715 : tp = (PyTypeObject *)state->arg_type;
4999 133715 : result = PyType_GenericNew(tp, NULL, NULL);
5000 133715 : if (!result) return NULL;
5001 133715 : value = ast2obj_identifier(state, o->arg);
5002 133715 : if (!value) goto failed;
5003 133715 : if (PyObject_SetAttr(result, state->arg, value) == -1)
5004 0 : goto failed;
5005 133715 : Py_DECREF(value);
5006 133715 : value = ast2obj_expr(state, o->annotation);
5007 133715 : if (!value) goto failed;
5008 133715 : if (PyObject_SetAttr(result, state->annotation, value) == -1)
5009 0 : goto failed;
5010 133715 : Py_DECREF(value);
5011 133715 : value = ast2obj_string(state, o->type_comment);
5012 133715 : if (!value) goto failed;
5013 133715 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5014 0 : goto failed;
5015 133715 : Py_DECREF(value);
5016 133715 : value = ast2obj_int(state, o->lineno);
5017 133715 : if (!value) goto failed;
5018 133715 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5019 0 : goto failed;
5020 133715 : Py_DECREF(value);
5021 133715 : value = ast2obj_int(state, o->col_offset);
5022 133715 : if (!value) goto failed;
5023 133715 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5024 0 : goto failed;
5025 133715 : Py_DECREF(value);
5026 133715 : value = ast2obj_int(state, o->end_lineno);
5027 133715 : if (!value) goto failed;
5028 133715 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5029 0 : goto failed;
5030 133715 : Py_DECREF(value);
5031 133715 : value = ast2obj_int(state, o->end_col_offset);
5032 133715 : if (!value) goto failed;
5033 133715 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5034 0 : goto failed;
5035 133715 : Py_DECREF(value);
5036 133715 : return result;
5037 0 : failed:
5038 0 : Py_XDECREF(value);
5039 0 : Py_XDECREF(result);
5040 0 : return NULL;
5041 : }
5042 :
5043 : PyObject*
5044 52321 : ast2obj_keyword(struct ast_state *state, void* _o)
5045 : {
5046 52321 : keyword_ty o = (keyword_ty)_o;
5047 52321 : PyObject *result = NULL, *value = NULL;
5048 : PyTypeObject *tp;
5049 52321 : if (!o) {
5050 0 : Py_RETURN_NONE;
5051 : }
5052 52321 : tp = (PyTypeObject *)state->keyword_type;
5053 52321 : result = PyType_GenericNew(tp, NULL, NULL);
5054 52321 : if (!result) return NULL;
5055 52321 : value = ast2obj_identifier(state, o->arg);
5056 52321 : if (!value) goto failed;
5057 52321 : if (PyObject_SetAttr(result, state->arg, value) == -1)
5058 0 : goto failed;
5059 52321 : Py_DECREF(value);
5060 52321 : value = ast2obj_expr(state, o->value);
5061 52321 : if (!value) goto failed;
5062 52321 : if (PyObject_SetAttr(result, state->value, value) == -1)
5063 0 : goto failed;
5064 52321 : Py_DECREF(value);
5065 52321 : value = ast2obj_int(state, o->lineno);
5066 52321 : if (!value) goto failed;
5067 52321 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5068 0 : goto failed;
5069 52321 : Py_DECREF(value);
5070 52321 : value = ast2obj_int(state, o->col_offset);
5071 52321 : if (!value) goto failed;
5072 52321 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5073 0 : goto failed;
5074 52321 : Py_DECREF(value);
5075 52321 : value = ast2obj_int(state, o->end_lineno);
5076 52321 : if (!value) goto failed;
5077 52321 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5078 0 : goto failed;
5079 52321 : Py_DECREF(value);
5080 52321 : value = ast2obj_int(state, o->end_col_offset);
5081 52321 : if (!value) goto failed;
5082 52321 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5083 0 : goto failed;
5084 52321 : Py_DECREF(value);
5085 52321 : return result;
5086 0 : failed:
5087 0 : Py_XDECREF(value);
5088 0 : Py_XDECREF(result);
5089 0 : return NULL;
5090 : }
5091 :
5092 : PyObject*
5093 17377 : ast2obj_alias(struct ast_state *state, void* _o)
5094 : {
5095 17377 : alias_ty o = (alias_ty)_o;
5096 17377 : PyObject *result = NULL, *value = NULL;
5097 : PyTypeObject *tp;
5098 17377 : if (!o) {
5099 0 : Py_RETURN_NONE;
5100 : }
5101 17377 : tp = (PyTypeObject *)state->alias_type;
5102 17377 : result = PyType_GenericNew(tp, NULL, NULL);
5103 17377 : if (!result) return NULL;
5104 17377 : value = ast2obj_identifier(state, o->name);
5105 17377 : if (!value) goto failed;
5106 17377 : if (PyObject_SetAttr(result, state->name, value) == -1)
5107 0 : goto failed;
5108 17377 : Py_DECREF(value);
5109 17377 : value = ast2obj_identifier(state, o->asname);
5110 17377 : if (!value) goto failed;
5111 17377 : if (PyObject_SetAttr(result, state->asname, value) == -1)
5112 0 : goto failed;
5113 17377 : Py_DECREF(value);
5114 17377 : value = ast2obj_int(state, o->lineno);
5115 17377 : if (!value) goto failed;
5116 17377 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5117 0 : goto failed;
5118 17377 : Py_DECREF(value);
5119 17377 : value = ast2obj_int(state, o->col_offset);
5120 17377 : if (!value) goto failed;
5121 17377 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5122 0 : goto failed;
5123 17377 : Py_DECREF(value);
5124 17377 : value = ast2obj_int(state, o->end_lineno);
5125 17377 : if (!value) goto failed;
5126 17377 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5127 0 : goto failed;
5128 17377 : Py_DECREF(value);
5129 17377 : value = ast2obj_int(state, o->end_col_offset);
5130 17377 : if (!value) goto failed;
5131 17377 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5132 0 : goto failed;
5133 17377 : Py_DECREF(value);
5134 17377 : return result;
5135 0 : failed:
5136 0 : Py_XDECREF(value);
5137 0 : Py_XDECREF(result);
5138 0 : return NULL;
5139 : }
5140 :
5141 : PyObject*
5142 18924 : ast2obj_withitem(struct ast_state *state, void* _o)
5143 : {
5144 18924 : withitem_ty o = (withitem_ty)_o;
5145 18924 : PyObject *result = NULL, *value = NULL;
5146 : PyTypeObject *tp;
5147 18924 : if (!o) {
5148 0 : Py_RETURN_NONE;
5149 : }
5150 18924 : tp = (PyTypeObject *)state->withitem_type;
5151 18924 : result = PyType_GenericNew(tp, NULL, NULL);
5152 18924 : if (!result) return NULL;
5153 18924 : value = ast2obj_expr(state, o->context_expr);
5154 18924 : if (!value) goto failed;
5155 18924 : if (PyObject_SetAttr(result, state->context_expr, value) == -1)
5156 0 : goto failed;
5157 18924 : Py_DECREF(value);
5158 18924 : value = ast2obj_expr(state, o->optional_vars);
5159 18924 : if (!value) goto failed;
5160 18924 : if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
5161 0 : goto failed;
5162 18924 : Py_DECREF(value);
5163 18924 : return result;
5164 0 : failed:
5165 0 : Py_XDECREF(value);
5166 0 : Py_XDECREF(result);
5167 0 : return NULL;
5168 : }
5169 :
5170 : PyObject*
5171 796 : ast2obj_match_case(struct ast_state *state, void* _o)
5172 : {
5173 796 : match_case_ty o = (match_case_ty)_o;
5174 796 : PyObject *result = NULL, *value = NULL;
5175 : PyTypeObject *tp;
5176 796 : if (!o) {
5177 0 : Py_RETURN_NONE;
5178 : }
5179 796 : tp = (PyTypeObject *)state->match_case_type;
5180 796 : result = PyType_GenericNew(tp, NULL, NULL);
5181 796 : if (!result) return NULL;
5182 796 : value = ast2obj_pattern(state, o->pattern);
5183 796 : if (!value) goto failed;
5184 796 : if (PyObject_SetAttr(result, state->pattern, value) == -1)
5185 0 : goto failed;
5186 796 : Py_DECREF(value);
5187 796 : value = ast2obj_expr(state, o->guard);
5188 796 : if (!value) goto failed;
5189 796 : if (PyObject_SetAttr(result, state->guard, value) == -1)
5190 0 : goto failed;
5191 796 : Py_DECREF(value);
5192 796 : value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
5193 796 : if (!value) goto failed;
5194 796 : if (PyObject_SetAttr(result, state->body, value) == -1)
5195 0 : goto failed;
5196 796 : Py_DECREF(value);
5197 796 : return result;
5198 0 : failed:
5199 0 : Py_XDECREF(value);
5200 0 : Py_XDECREF(result);
5201 0 : return NULL;
5202 : }
5203 :
5204 : PyObject*
5205 2554 : ast2obj_pattern(struct ast_state *state, void* _o)
5206 : {
5207 2554 : pattern_ty o = (pattern_ty)_o;
5208 2554 : PyObject *result = NULL, *value = NULL;
5209 : PyTypeObject *tp;
5210 2554 : if (!o) {
5211 472 : Py_RETURN_NONE;
5212 : }
5213 2082 : switch (o->kind) {
5214 760 : case MatchValue_kind:
5215 760 : tp = (PyTypeObject *)state->MatchValue_type;
5216 760 : result = PyType_GenericNew(tp, NULL, NULL);
5217 760 : if (!result) goto failed;
5218 760 : value = ast2obj_expr(state, o->v.MatchValue.value);
5219 760 : if (!value) goto failed;
5220 760 : if (PyObject_SetAttr(result, state->value, value) == -1)
5221 0 : goto failed;
5222 760 : Py_DECREF(value);
5223 760 : break;
5224 24 : case MatchSingleton_kind:
5225 24 : tp = (PyTypeObject *)state->MatchSingleton_type;
5226 24 : result = PyType_GenericNew(tp, NULL, NULL);
5227 24 : if (!result) goto failed;
5228 24 : value = ast2obj_constant(state, o->v.MatchSingleton.value);
5229 24 : if (!value) goto failed;
5230 24 : if (PyObject_SetAttr(result, state->value, value) == -1)
5231 0 : goto failed;
5232 24 : Py_DECREF(value);
5233 24 : break;
5234 302 : case MatchSequence_kind:
5235 302 : tp = (PyTypeObject *)state->MatchSequence_type;
5236 302 : result = PyType_GenericNew(tp, NULL, NULL);
5237 302 : if (!result) goto failed;
5238 302 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
5239 : ast2obj_pattern);
5240 302 : if (!value) goto failed;
5241 302 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5242 0 : goto failed;
5243 302 : Py_DECREF(value);
5244 302 : break;
5245 156 : case MatchMapping_kind:
5246 156 : tp = (PyTypeObject *)state->MatchMapping_type;
5247 156 : result = PyType_GenericNew(tp, NULL, NULL);
5248 156 : if (!result) goto failed;
5249 156 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
5250 : ast2obj_expr);
5251 156 : if (!value) goto failed;
5252 156 : if (PyObject_SetAttr(result, state->keys, value) == -1)
5253 0 : goto failed;
5254 156 : Py_DECREF(value);
5255 156 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
5256 : ast2obj_pattern);
5257 156 : if (!value) goto failed;
5258 156 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5259 0 : goto failed;
5260 156 : Py_DECREF(value);
5261 156 : value = ast2obj_identifier(state, o->v.MatchMapping.rest);
5262 156 : if (!value) goto failed;
5263 156 : if (PyObject_SetAttr(result, state->rest, value) == -1)
5264 0 : goto failed;
5265 156 : Py_DECREF(value);
5266 156 : break;
5267 106 : case MatchClass_kind:
5268 106 : tp = (PyTypeObject *)state->MatchClass_type;
5269 106 : result = PyType_GenericNew(tp, NULL, NULL);
5270 106 : if (!result) goto failed;
5271 106 : value = ast2obj_expr(state, o->v.MatchClass.cls);
5272 106 : if (!value) goto failed;
5273 106 : if (PyObject_SetAttr(result, state->cls, value) == -1)
5274 0 : goto failed;
5275 106 : Py_DECREF(value);
5276 106 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
5277 : ast2obj_pattern);
5278 106 : if (!value) goto failed;
5279 106 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5280 0 : goto failed;
5281 106 : Py_DECREF(value);
5282 106 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
5283 : ast2obj_identifier);
5284 106 : if (!value) goto failed;
5285 106 : if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
5286 0 : goto failed;
5287 106 : Py_DECREF(value);
5288 106 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
5289 : ast2obj_pattern);
5290 106 : if (!value) goto failed;
5291 106 : if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
5292 0 : goto failed;
5293 106 : Py_DECREF(value);
5294 106 : break;
5295 72 : case MatchStar_kind:
5296 72 : tp = (PyTypeObject *)state->MatchStar_type;
5297 72 : result = PyType_GenericNew(tp, NULL, NULL);
5298 72 : if (!result) goto failed;
5299 72 : value = ast2obj_identifier(state, o->v.MatchStar.name);
5300 72 : if (!value) goto failed;
5301 72 : if (PyObject_SetAttr(result, state->name, value) == -1)
5302 0 : goto failed;
5303 72 : Py_DECREF(value);
5304 72 : break;
5305 562 : case MatchAs_kind:
5306 562 : tp = (PyTypeObject *)state->MatchAs_type;
5307 562 : result = PyType_GenericNew(tp, NULL, NULL);
5308 562 : if (!result) goto failed;
5309 562 : value = ast2obj_pattern(state, o->v.MatchAs.pattern);
5310 562 : if (!value) goto failed;
5311 562 : if (PyObject_SetAttr(result, state->pattern, value) == -1)
5312 0 : goto failed;
5313 562 : Py_DECREF(value);
5314 562 : value = ast2obj_identifier(state, o->v.MatchAs.name);
5315 562 : if (!value) goto failed;
5316 562 : if (PyObject_SetAttr(result, state->name, value) == -1)
5317 0 : goto failed;
5318 562 : Py_DECREF(value);
5319 562 : break;
5320 100 : case MatchOr_kind:
5321 100 : tp = (PyTypeObject *)state->MatchOr_type;
5322 100 : result = PyType_GenericNew(tp, NULL, NULL);
5323 100 : if (!result) goto failed;
5324 100 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
5325 : ast2obj_pattern);
5326 100 : if (!value) goto failed;
5327 100 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5328 0 : goto failed;
5329 100 : Py_DECREF(value);
5330 100 : break;
5331 : }
5332 2082 : value = ast2obj_int(state, o->lineno);
5333 2082 : if (!value) goto failed;
5334 2082 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5335 0 : goto failed;
5336 2082 : Py_DECREF(value);
5337 2082 : value = ast2obj_int(state, o->col_offset);
5338 2082 : if (!value) goto failed;
5339 2082 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5340 0 : goto failed;
5341 2082 : Py_DECREF(value);
5342 2082 : value = ast2obj_int(state, o->end_lineno);
5343 2082 : if (!value) goto failed;
5344 2082 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5345 0 : goto failed;
5346 2082 : Py_DECREF(value);
5347 2082 : value = ast2obj_int(state, o->end_col_offset);
5348 2082 : if (!value) goto failed;
5349 2082 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5350 0 : goto failed;
5351 2082 : Py_DECREF(value);
5352 2082 : return result;
5353 0 : failed:
5354 0 : Py_XDECREF(value);
5355 0 : Py_XDECREF(result);
5356 0 : return NULL;
5357 : }
5358 :
5359 : PyObject*
5360 74 : ast2obj_type_ignore(struct ast_state *state, void* _o)
5361 : {
5362 74 : type_ignore_ty o = (type_ignore_ty)_o;
5363 74 : PyObject *result = NULL, *value = NULL;
5364 : PyTypeObject *tp;
5365 74 : if (!o) {
5366 0 : Py_RETURN_NONE;
5367 : }
5368 74 : switch (o->kind) {
5369 74 : case TypeIgnore_kind:
5370 74 : tp = (PyTypeObject *)state->TypeIgnore_type;
5371 74 : result = PyType_GenericNew(tp, NULL, NULL);
5372 74 : if (!result) goto failed;
5373 74 : value = ast2obj_int(state, o->v.TypeIgnore.lineno);
5374 74 : if (!value) goto failed;
5375 74 : if (PyObject_SetAttr(result, state->lineno, value) == -1)
5376 0 : goto failed;
5377 74 : Py_DECREF(value);
5378 74 : value = ast2obj_string(state, o->v.TypeIgnore.tag);
5379 74 : if (!value) goto failed;
5380 74 : if (PyObject_SetAttr(result, state->tag, value) == -1)
5381 0 : goto failed;
5382 74 : Py_DECREF(value);
5383 74 : break;
5384 : }
5385 74 : return result;
5386 0 : failed:
5387 0 : Py_XDECREF(value);
5388 0 : Py_XDECREF(result);
5389 0 : return NULL;
5390 : }
5391 :
5392 :
5393 : int
5394 686 : obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
5395 : {
5396 : int isinstance;
5397 :
5398 686 : PyObject *tmp = NULL;
5399 : PyObject *tp;
5400 :
5401 686 : if (obj == Py_None) {
5402 0 : *out = NULL;
5403 0 : return 0;
5404 : }
5405 686 : tp = state->Module_type;
5406 686 : isinstance = PyObject_IsInstance(obj, tp);
5407 686 : if (isinstance == -1) {
5408 0 : return 1;
5409 : }
5410 686 : if (isinstance) {
5411 : asdl_stmt_seq* body;
5412 : asdl_type_ignore_seq* type_ignores;
5413 :
5414 573 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5415 0 : return 1;
5416 : }
5417 573 : if (tmp == NULL) {
5418 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
5419 0 : return 1;
5420 : }
5421 : else {
5422 : int res;
5423 : Py_ssize_t len;
5424 : Py_ssize_t i;
5425 573 : if (!PyList_Check(tmp)) {
5426 0 : PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5427 0 : goto failed;
5428 : }
5429 573 : len = PyList_GET_SIZE(tmp);
5430 573 : body = _Py_asdl_stmt_seq_new(len, arena);
5431 573 : if (body == NULL) goto failed;
5432 6675 : for (i = 0; i < len; i++) {
5433 : stmt_ty val;
5434 6107 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5435 6107 : Py_INCREF(tmp2);
5436 6107 : if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
5437 5 : goto failed;
5438 : }
5439 6107 : res = obj2ast_stmt(state, tmp2, &val, arena);
5440 6107 : _Py_LeaveRecursiveCall();
5441 6107 : Py_DECREF(tmp2);
5442 6107 : if (res != 0) goto failed;
5443 6102 : if (len != PyList_GET_SIZE(tmp)) {
5444 0 : PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
5445 0 : goto failed;
5446 : }
5447 6102 : asdl_seq_SET(body, i, val);
5448 : }
5449 568 : Py_CLEAR(tmp);
5450 : }
5451 568 : if (_PyObject_LookupAttr(obj, state->type_ignores, &tmp) < 0) {
5452 0 : return 1;
5453 : }
5454 568 : if (tmp == NULL) {
5455 0 : PyErr_SetString(PyExc_TypeError, "required field \"type_ignores\" missing from Module");
5456 0 : return 1;
5457 : }
5458 : else {
5459 : int res;
5460 : Py_ssize_t len;
5461 : Py_ssize_t i;
5462 568 : if (!PyList_Check(tmp)) {
5463 0 : PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5464 0 : goto failed;
5465 : }
5466 568 : len = PyList_GET_SIZE(tmp);
5467 568 : type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
5468 568 : if (type_ignores == NULL) goto failed;
5469 568 : for (i = 0; i < len; i++) {
5470 : type_ignore_ty val;
5471 0 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5472 0 : Py_INCREF(tmp2);
5473 0 : if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
5474 0 : goto failed;
5475 : }
5476 0 : res = obj2ast_type_ignore(state, tmp2, &val, arena);
5477 0 : _Py_LeaveRecursiveCall();
5478 0 : Py_DECREF(tmp2);
5479 0 : if (res != 0) goto failed;
5480 0 : if (len != PyList_GET_SIZE(tmp)) {
5481 0 : PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
5482 0 : goto failed;
5483 : }
5484 0 : asdl_seq_SET(type_ignores, i, val);
5485 : }
5486 568 : Py_CLEAR(tmp);
5487 : }
5488 568 : *out = _PyAST_Module(body, type_ignores, arena);
5489 568 : if (*out == NULL) goto failed;
5490 568 : return 0;
5491 : }
5492 113 : tp = state->Interactive_type;
5493 113 : isinstance = PyObject_IsInstance(obj, tp);
5494 113 : if (isinstance == -1) {
5495 0 : return 1;
5496 : }
5497 113 : if (isinstance) {
5498 : asdl_stmt_seq* body;
5499 :
5500 2 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5501 0 : return 1;
5502 : }
5503 2 : if (tmp == NULL) {
5504 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
5505 0 : return 1;
5506 : }
5507 : else {
5508 : int res;
5509 : Py_ssize_t len;
5510 : Py_ssize_t i;
5511 2 : if (!PyList_Check(tmp)) {
5512 0 : PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5513 0 : goto failed;
5514 : }
5515 2 : len = PyList_GET_SIZE(tmp);
5516 2 : body = _Py_asdl_stmt_seq_new(len, arena);
5517 2 : if (body == NULL) goto failed;
5518 4 : for (i = 0; i < len; i++) {
5519 : stmt_ty val;
5520 2 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5521 2 : Py_INCREF(tmp2);
5522 2 : if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
5523 0 : goto failed;
5524 : }
5525 2 : res = obj2ast_stmt(state, tmp2, &val, arena);
5526 2 : _Py_LeaveRecursiveCall();
5527 2 : Py_DECREF(tmp2);
5528 2 : if (res != 0) goto failed;
5529 2 : if (len != PyList_GET_SIZE(tmp)) {
5530 0 : PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
5531 0 : goto failed;
5532 : }
5533 2 : asdl_seq_SET(body, i, val);
5534 : }
5535 2 : Py_CLEAR(tmp);
5536 : }
5537 2 : *out = _PyAST_Interactive(body, arena);
5538 2 : if (*out == NULL) goto failed;
5539 2 : return 0;
5540 : }
5541 111 : tp = state->Expression_type;
5542 111 : isinstance = PyObject_IsInstance(obj, tp);
5543 111 : if (isinstance == -1) {
5544 0 : return 1;
5545 : }
5546 111 : if (isinstance) {
5547 : expr_ty body;
5548 :
5549 111 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5550 109 : return 1;
5551 : }
5552 111 : if (tmp == NULL) {
5553 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
5554 0 : return 1;
5555 : }
5556 : else {
5557 : int res;
5558 111 : if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
5559 2 : goto failed;
5560 : }
5561 111 : res = obj2ast_expr(state, tmp, &body, arena);
5562 111 : _Py_LeaveRecursiveCall();
5563 111 : if (res != 0) goto failed;
5564 109 : Py_CLEAR(tmp);
5565 : }
5566 109 : *out = _PyAST_Expression(body, arena);
5567 109 : if (*out == NULL) goto failed;
5568 109 : return 0;
5569 : }
5570 0 : tp = state->FunctionType_type;
5571 0 : isinstance = PyObject_IsInstance(obj, tp);
5572 0 : if (isinstance == -1) {
5573 0 : return 1;
5574 : }
5575 0 : if (isinstance) {
5576 : asdl_expr_seq* argtypes;
5577 : expr_ty returns;
5578 :
5579 0 : if (_PyObject_LookupAttr(obj, state->argtypes, &tmp) < 0) {
5580 0 : return 1;
5581 : }
5582 0 : if (tmp == NULL) {
5583 0 : PyErr_SetString(PyExc_TypeError, "required field \"argtypes\" missing from FunctionType");
5584 0 : return 1;
5585 : }
5586 : else {
5587 : int res;
5588 : Py_ssize_t len;
5589 : Py_ssize_t i;
5590 0 : if (!PyList_Check(tmp)) {
5591 0 : PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5592 0 : goto failed;
5593 : }
5594 0 : len = PyList_GET_SIZE(tmp);
5595 0 : argtypes = _Py_asdl_expr_seq_new(len, arena);
5596 0 : if (argtypes == NULL) goto failed;
5597 0 : for (i = 0; i < len; i++) {
5598 : expr_ty val;
5599 0 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5600 0 : Py_INCREF(tmp2);
5601 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
5602 0 : goto failed;
5603 : }
5604 0 : res = obj2ast_expr(state, tmp2, &val, arena);
5605 0 : _Py_LeaveRecursiveCall();
5606 0 : Py_DECREF(tmp2);
5607 0 : if (res != 0) goto failed;
5608 0 : if (len != PyList_GET_SIZE(tmp)) {
5609 0 : PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
5610 0 : goto failed;
5611 : }
5612 0 : asdl_seq_SET(argtypes, i, val);
5613 : }
5614 0 : Py_CLEAR(tmp);
5615 : }
5616 0 : if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5617 0 : return 1;
5618 : }
5619 0 : if (tmp == NULL) {
5620 0 : PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
5621 0 : return 1;
5622 : }
5623 : else {
5624 : int res;
5625 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
5626 0 : goto failed;
5627 : }
5628 0 : res = obj2ast_expr(state, tmp, &returns, arena);
5629 0 : _Py_LeaveRecursiveCall();
5630 0 : if (res != 0) goto failed;
5631 0 : Py_CLEAR(tmp);
5632 : }
5633 0 : *out = _PyAST_FunctionType(argtypes, returns, arena);
5634 0 : if (*out == NULL) goto failed;
5635 0 : return 0;
5636 : }
5637 :
5638 0 : PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
5639 7 : failed:
5640 7 : Py_XDECREF(tmp);
5641 7 : return 1;
5642 : }
5643 :
5644 : int
5645 70000 : obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
5646 : arena)
5647 : {
5648 : int isinstance;
5649 :
5650 70000 : PyObject *tmp = NULL;
5651 : PyObject *tp;
5652 : int lineno;
5653 : int col_offset;
5654 : int end_lineno;
5655 : int end_col_offset;
5656 :
5657 70000 : if (obj == Py_None) {
5658 1 : *out = NULL;
5659 1 : return 0;
5660 : }
5661 69999 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
5662 0 : return 1;
5663 : }
5664 69999 : if (tmp == NULL) {
5665 1 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
5666 1 : return 1;
5667 : }
5668 : else {
5669 : int res;
5670 69998 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5671 0 : goto failed;
5672 : }
5673 69998 : res = obj2ast_int(state, tmp, &lineno, arena);
5674 69998 : _Py_LeaveRecursiveCall();
5675 69998 : if (res != 0) goto failed;
5676 69997 : Py_CLEAR(tmp);
5677 : }
5678 69997 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
5679 0 : return 1;
5680 : }
5681 69997 : if (tmp == NULL) {
5682 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
5683 0 : return 1;
5684 : }
5685 : else {
5686 : int res;
5687 69997 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5688 0 : goto failed;
5689 : }
5690 69997 : res = obj2ast_int(state, tmp, &col_offset, arena);
5691 69997 : _Py_LeaveRecursiveCall();
5692 69997 : if (res != 0) goto failed;
5693 69997 : Py_CLEAR(tmp);
5694 : }
5695 69997 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
5696 0 : return 1;
5697 : }
5698 69997 : if (tmp == NULL || tmp == Py_None) {
5699 4 : Py_CLEAR(tmp);
5700 4 : end_lineno = lineno;
5701 : }
5702 : else {
5703 : int res;
5704 69993 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5705 0 : goto failed;
5706 : }
5707 69993 : res = obj2ast_int(state, tmp, &end_lineno, arena);
5708 69993 : _Py_LeaveRecursiveCall();
5709 69993 : if (res != 0) goto failed;
5710 69993 : Py_CLEAR(tmp);
5711 : }
5712 69997 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
5713 0 : return 1;
5714 : }
5715 69997 : if (tmp == NULL || tmp == Py_None) {
5716 4 : Py_CLEAR(tmp);
5717 4 : end_col_offset = col_offset;
5718 : }
5719 : else {
5720 : int res;
5721 69993 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5722 0 : goto failed;
5723 : }
5724 69993 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
5725 69993 : _Py_LeaveRecursiveCall();
5726 69993 : if (res != 0) goto failed;
5727 69993 : Py_CLEAR(tmp);
5728 : }
5729 69997 : tp = state->FunctionDef_type;
5730 69997 : isinstance = PyObject_IsInstance(obj, tp);
5731 69997 : if (isinstance == -1) {
5732 0 : return 1;
5733 : }
5734 69997 : if (isinstance) {
5735 : identifier name;
5736 : arguments_ty args;
5737 : asdl_stmt_seq* body;
5738 : asdl_expr_seq* decorator_list;
5739 : expr_ty returns;
5740 : string type_comment;
5741 :
5742 7396 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5743 7395 : return 1;
5744 : }
5745 7396 : if (tmp == NULL) {
5746 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
5747 0 : return 1;
5748 : }
5749 : else {
5750 : int res;
5751 7396 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5752 1 : goto failed;
5753 : }
5754 7396 : res = obj2ast_identifier(state, tmp, &name, arena);
5755 7396 : _Py_LeaveRecursiveCall();
5756 7396 : if (res != 0) goto failed;
5757 7396 : Py_CLEAR(tmp);
5758 : }
5759 7396 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5760 0 : return 1;
5761 : }
5762 7396 : if (tmp == NULL) {
5763 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
5764 0 : return 1;
5765 : }
5766 : else {
5767 : int res;
5768 7396 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5769 0 : goto failed;
5770 : }
5771 7396 : res = obj2ast_arguments(state, tmp, &args, arena);
5772 7396 : _Py_LeaveRecursiveCall();
5773 7396 : if (res != 0) goto failed;
5774 7396 : Py_CLEAR(tmp);
5775 : }
5776 7396 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5777 0 : return 1;
5778 : }
5779 7396 : if (tmp == NULL) {
5780 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
5781 0 : return 1;
5782 : }
5783 : else {
5784 : int res;
5785 : Py_ssize_t len;
5786 : Py_ssize_t i;
5787 7396 : if (!PyList_Check(tmp)) {
5788 0 : PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5789 0 : goto failed;
5790 : }
5791 7396 : len = PyList_GET_SIZE(tmp);
5792 7396 : body = _Py_asdl_stmt_seq_new(len, arena);
5793 7396 : if (body == NULL) goto failed;
5794 34424 : for (i = 0; i < len; i++) {
5795 : stmt_ty val;
5796 27029 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5797 27029 : Py_INCREF(tmp2);
5798 27029 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5799 1 : goto failed;
5800 : }
5801 27029 : res = obj2ast_stmt(state, tmp2, &val, arena);
5802 27029 : _Py_LeaveRecursiveCall();
5803 27029 : Py_DECREF(tmp2);
5804 27029 : if (res != 0) goto failed;
5805 27028 : if (len != PyList_GET_SIZE(tmp)) {
5806 0 : PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
5807 0 : goto failed;
5808 : }
5809 27028 : asdl_seq_SET(body, i, val);
5810 : }
5811 7395 : Py_CLEAR(tmp);
5812 : }
5813 7395 : if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
5814 0 : return 1;
5815 : }
5816 7395 : if (tmp == NULL) {
5817 0 : PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
5818 0 : return 1;
5819 : }
5820 : else {
5821 : int res;
5822 : Py_ssize_t len;
5823 : Py_ssize_t i;
5824 7395 : if (!PyList_Check(tmp)) {
5825 0 : PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5826 0 : goto failed;
5827 : }
5828 7395 : len = PyList_GET_SIZE(tmp);
5829 7395 : decorator_list = _Py_asdl_expr_seq_new(len, arena);
5830 7395 : if (decorator_list == NULL) goto failed;
5831 8015 : for (i = 0; i < len; i++) {
5832 : expr_ty val;
5833 620 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5834 620 : Py_INCREF(tmp2);
5835 620 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5836 0 : goto failed;
5837 : }
5838 620 : res = obj2ast_expr(state, tmp2, &val, arena);
5839 620 : _Py_LeaveRecursiveCall();
5840 620 : Py_DECREF(tmp2);
5841 620 : if (res != 0) goto failed;
5842 620 : if (len != PyList_GET_SIZE(tmp)) {
5843 0 : PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
5844 0 : goto failed;
5845 : }
5846 620 : asdl_seq_SET(decorator_list, i, val);
5847 : }
5848 7395 : Py_CLEAR(tmp);
5849 : }
5850 7395 : if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5851 0 : return 1;
5852 : }
5853 7395 : if (tmp == NULL || tmp == Py_None) {
5854 7339 : Py_CLEAR(tmp);
5855 7339 : returns = NULL;
5856 : }
5857 : else {
5858 : int res;
5859 56 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5860 0 : goto failed;
5861 : }
5862 56 : res = obj2ast_expr(state, tmp, &returns, arena);
5863 56 : _Py_LeaveRecursiveCall();
5864 56 : if (res != 0) goto failed;
5865 56 : Py_CLEAR(tmp);
5866 : }
5867 7395 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
5868 0 : return 1;
5869 : }
5870 7395 : if (tmp == NULL || tmp == Py_None) {
5871 7395 : Py_CLEAR(tmp);
5872 7395 : type_comment = NULL;
5873 : }
5874 : else {
5875 : int res;
5876 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5877 0 : goto failed;
5878 : }
5879 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
5880 0 : _Py_LeaveRecursiveCall();
5881 0 : if (res != 0) goto failed;
5882 0 : Py_CLEAR(tmp);
5883 : }
5884 7395 : *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
5885 : type_comment, lineno, col_offset, end_lineno,
5886 : end_col_offset, arena);
5887 7395 : if (*out == NULL) goto failed;
5888 7395 : return 0;
5889 : }
5890 62601 : tp = state->AsyncFunctionDef_type;
5891 62601 : isinstance = PyObject_IsInstance(obj, tp);
5892 62601 : if (isinstance == -1) {
5893 0 : return 1;
5894 : }
5895 62601 : if (isinstance) {
5896 : identifier name;
5897 : arguments_ty args;
5898 : asdl_stmt_seq* body;
5899 : asdl_expr_seq* decorator_list;
5900 : expr_ty returns;
5901 : string type_comment;
5902 :
5903 41 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5904 41 : return 1;
5905 : }
5906 41 : if (tmp == NULL) {
5907 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
5908 0 : return 1;
5909 : }
5910 : else {
5911 : int res;
5912 41 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5913 0 : goto failed;
5914 : }
5915 41 : res = obj2ast_identifier(state, tmp, &name, arena);
5916 41 : _Py_LeaveRecursiveCall();
5917 41 : if (res != 0) goto failed;
5918 41 : Py_CLEAR(tmp);
5919 : }
5920 41 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5921 0 : return 1;
5922 : }
5923 41 : if (tmp == NULL) {
5924 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
5925 0 : return 1;
5926 : }
5927 : else {
5928 : int res;
5929 41 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5930 0 : goto failed;
5931 : }
5932 41 : res = obj2ast_arguments(state, tmp, &args, arena);
5933 41 : _Py_LeaveRecursiveCall();
5934 41 : if (res != 0) goto failed;
5935 41 : Py_CLEAR(tmp);
5936 : }
5937 41 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5938 0 : return 1;
5939 : }
5940 41 : if (tmp == NULL) {
5941 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFunctionDef");
5942 0 : return 1;
5943 : }
5944 : else {
5945 : int res;
5946 : Py_ssize_t len;
5947 : Py_ssize_t i;
5948 41 : if (!PyList_Check(tmp)) {
5949 0 : PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5950 0 : goto failed;
5951 : }
5952 41 : len = PyList_GET_SIZE(tmp);
5953 41 : body = _Py_asdl_stmt_seq_new(len, arena);
5954 41 : if (body == NULL) goto failed;
5955 117 : for (i = 0; i < len; i++) {
5956 : stmt_ty val;
5957 76 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5958 76 : Py_INCREF(tmp2);
5959 76 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5960 0 : goto failed;
5961 : }
5962 76 : res = obj2ast_stmt(state, tmp2, &val, arena);
5963 76 : _Py_LeaveRecursiveCall();
5964 76 : Py_DECREF(tmp2);
5965 76 : if (res != 0) goto failed;
5966 76 : if (len != PyList_GET_SIZE(tmp)) {
5967 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
5968 0 : goto failed;
5969 : }
5970 76 : asdl_seq_SET(body, i, val);
5971 : }
5972 41 : Py_CLEAR(tmp);
5973 : }
5974 41 : if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
5975 0 : return 1;
5976 : }
5977 41 : if (tmp == NULL) {
5978 0 : PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from AsyncFunctionDef");
5979 0 : return 1;
5980 : }
5981 : else {
5982 : int res;
5983 : Py_ssize_t len;
5984 : Py_ssize_t i;
5985 41 : if (!PyList_Check(tmp)) {
5986 0 : PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5987 0 : goto failed;
5988 : }
5989 41 : len = PyList_GET_SIZE(tmp);
5990 41 : decorator_list = _Py_asdl_expr_seq_new(len, arena);
5991 41 : if (decorator_list == NULL) goto failed;
5992 53 : for (i = 0; i < len; i++) {
5993 : expr_ty val;
5994 12 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
5995 12 : Py_INCREF(tmp2);
5996 12 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5997 0 : goto failed;
5998 : }
5999 12 : res = obj2ast_expr(state, tmp2, &val, arena);
6000 12 : _Py_LeaveRecursiveCall();
6001 12 : Py_DECREF(tmp2);
6002 12 : if (res != 0) goto failed;
6003 12 : if (len != PyList_GET_SIZE(tmp)) {
6004 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
6005 0 : goto failed;
6006 : }
6007 12 : asdl_seq_SET(decorator_list, i, val);
6008 : }
6009 41 : Py_CLEAR(tmp);
6010 : }
6011 41 : if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
6012 0 : return 1;
6013 : }
6014 41 : if (tmp == NULL || tmp == Py_None) {
6015 41 : Py_CLEAR(tmp);
6016 41 : returns = NULL;
6017 : }
6018 : else {
6019 : int res;
6020 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6021 0 : goto failed;
6022 : }
6023 0 : res = obj2ast_expr(state, tmp, &returns, arena);
6024 0 : _Py_LeaveRecursiveCall();
6025 0 : if (res != 0) goto failed;
6026 0 : Py_CLEAR(tmp);
6027 : }
6028 41 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6029 0 : return 1;
6030 : }
6031 41 : if (tmp == NULL || tmp == Py_None) {
6032 41 : Py_CLEAR(tmp);
6033 41 : type_comment = NULL;
6034 : }
6035 : else {
6036 : int res;
6037 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6038 0 : goto failed;
6039 : }
6040 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6041 0 : _Py_LeaveRecursiveCall();
6042 0 : if (res != 0) goto failed;
6043 0 : Py_CLEAR(tmp);
6044 : }
6045 41 : *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
6046 : returns, type_comment, lineno,
6047 : col_offset, end_lineno, end_col_offset,
6048 : arena);
6049 41 : if (*out == NULL) goto failed;
6050 41 : return 0;
6051 : }
6052 62560 : tp = state->ClassDef_type;
6053 62560 : isinstance = PyObject_IsInstance(obj, tp);
6054 62560 : if (isinstance == -1) {
6055 0 : return 1;
6056 : }
6057 62560 : if (isinstance) {
6058 : identifier name;
6059 : asdl_expr_seq* bases;
6060 : asdl_keyword_seq* keywords;
6061 : asdl_stmt_seq* body;
6062 : asdl_expr_seq* decorator_list;
6063 :
6064 830 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
6065 830 : return 1;
6066 : }
6067 830 : if (tmp == NULL) {
6068 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
6069 0 : return 1;
6070 : }
6071 : else {
6072 : int res;
6073 830 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6074 0 : goto failed;
6075 : }
6076 830 : res = obj2ast_identifier(state, tmp, &name, arena);
6077 830 : _Py_LeaveRecursiveCall();
6078 830 : if (res != 0) goto failed;
6079 830 : Py_CLEAR(tmp);
6080 : }
6081 830 : if (_PyObject_LookupAttr(obj, state->bases, &tmp) < 0) {
6082 0 : return 1;
6083 : }
6084 830 : if (tmp == NULL) {
6085 0 : PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
6086 0 : return 1;
6087 : }
6088 : else {
6089 : int res;
6090 : Py_ssize_t len;
6091 : Py_ssize_t i;
6092 830 : if (!PyList_Check(tmp)) {
6093 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6094 0 : goto failed;
6095 : }
6096 830 : len = PyList_GET_SIZE(tmp);
6097 830 : bases = _Py_asdl_expr_seq_new(len, arena);
6098 830 : if (bases == NULL) goto failed;
6099 1445 : for (i = 0; i < len; i++) {
6100 : expr_ty val;
6101 615 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6102 615 : Py_INCREF(tmp2);
6103 615 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6104 0 : goto failed;
6105 : }
6106 615 : res = obj2ast_expr(state, tmp2, &val, arena);
6107 615 : _Py_LeaveRecursiveCall();
6108 615 : Py_DECREF(tmp2);
6109 615 : if (res != 0) goto failed;
6110 615 : if (len != PyList_GET_SIZE(tmp)) {
6111 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
6112 0 : goto failed;
6113 : }
6114 615 : asdl_seq_SET(bases, i, val);
6115 : }
6116 830 : Py_CLEAR(tmp);
6117 : }
6118 830 : if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
6119 0 : return 1;
6120 : }
6121 830 : if (tmp == NULL) {
6122 0 : PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
6123 0 : return 1;
6124 : }
6125 : else {
6126 : int res;
6127 : Py_ssize_t len;
6128 : Py_ssize_t i;
6129 830 : if (!PyList_Check(tmp)) {
6130 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6131 0 : goto failed;
6132 : }
6133 830 : len = PyList_GET_SIZE(tmp);
6134 830 : keywords = _Py_asdl_keyword_seq_new(len, arena);
6135 830 : if (keywords == NULL) goto failed;
6136 875 : for (i = 0; i < len; i++) {
6137 : keyword_ty val;
6138 45 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6139 45 : Py_INCREF(tmp2);
6140 45 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6141 0 : goto failed;
6142 : }
6143 45 : res = obj2ast_keyword(state, tmp2, &val, arena);
6144 45 : _Py_LeaveRecursiveCall();
6145 45 : Py_DECREF(tmp2);
6146 45 : if (res != 0) goto failed;
6147 45 : if (len != PyList_GET_SIZE(tmp)) {
6148 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
6149 0 : goto failed;
6150 : }
6151 45 : asdl_seq_SET(keywords, i, val);
6152 : }
6153 830 : Py_CLEAR(tmp);
6154 : }
6155 830 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6156 0 : return 1;
6157 : }
6158 830 : if (tmp == NULL) {
6159 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
6160 0 : return 1;
6161 : }
6162 : else {
6163 : int res;
6164 : Py_ssize_t len;
6165 : Py_ssize_t i;
6166 830 : if (!PyList_Check(tmp)) {
6167 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6168 0 : goto failed;
6169 : }
6170 830 : len = PyList_GET_SIZE(tmp);
6171 830 : body = _Py_asdl_stmt_seq_new(len, arena);
6172 830 : if (body == NULL) goto failed;
6173 7704 : for (i = 0; i < len; i++) {
6174 : stmt_ty val;
6175 6874 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6176 6874 : Py_INCREF(tmp2);
6177 6874 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6178 0 : goto failed;
6179 : }
6180 6874 : res = obj2ast_stmt(state, tmp2, &val, arena);
6181 6874 : _Py_LeaveRecursiveCall();
6182 6874 : Py_DECREF(tmp2);
6183 6874 : if (res != 0) goto failed;
6184 6874 : if (len != PyList_GET_SIZE(tmp)) {
6185 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
6186 0 : goto failed;
6187 : }
6188 6874 : asdl_seq_SET(body, i, val);
6189 : }
6190 830 : Py_CLEAR(tmp);
6191 : }
6192 830 : if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
6193 0 : return 1;
6194 : }
6195 830 : if (tmp == NULL) {
6196 0 : PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
6197 0 : return 1;
6198 : }
6199 : else {
6200 : int res;
6201 : Py_ssize_t len;
6202 : Py_ssize_t i;
6203 830 : if (!PyList_Check(tmp)) {
6204 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6205 0 : goto failed;
6206 : }
6207 830 : len = PyList_GET_SIZE(tmp);
6208 830 : decorator_list = _Py_asdl_expr_seq_new(len, arena);
6209 830 : if (decorator_list == NULL) goto failed;
6210 866 : for (i = 0; i < len; i++) {
6211 : expr_ty val;
6212 36 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6213 36 : Py_INCREF(tmp2);
6214 36 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6215 0 : goto failed;
6216 : }
6217 36 : res = obj2ast_expr(state, tmp2, &val, arena);
6218 36 : _Py_LeaveRecursiveCall();
6219 36 : Py_DECREF(tmp2);
6220 36 : if (res != 0) goto failed;
6221 36 : if (len != PyList_GET_SIZE(tmp)) {
6222 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
6223 0 : goto failed;
6224 : }
6225 36 : asdl_seq_SET(decorator_list, i, val);
6226 : }
6227 830 : Py_CLEAR(tmp);
6228 : }
6229 830 : *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
6230 : lineno, col_offset, end_lineno, end_col_offset,
6231 : arena);
6232 830 : if (*out == NULL) goto failed;
6233 830 : return 0;
6234 : }
6235 61730 : tp = state->Return_type;
6236 61730 : isinstance = PyObject_IsInstance(obj, tp);
6237 61730 : if (isinstance == -1) {
6238 0 : return 1;
6239 : }
6240 61730 : if (isinstance) {
6241 : expr_ty value;
6242 :
6243 7068 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6244 7068 : return 1;
6245 : }
6246 7068 : if (tmp == NULL || tmp == Py_None) {
6247 340 : Py_CLEAR(tmp);
6248 340 : value = NULL;
6249 : }
6250 : else {
6251 : int res;
6252 6728 : if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
6253 0 : goto failed;
6254 : }
6255 6728 : res = obj2ast_expr(state, tmp, &value, arena);
6256 6728 : _Py_LeaveRecursiveCall();
6257 6728 : if (res != 0) goto failed;
6258 6728 : Py_CLEAR(tmp);
6259 : }
6260 7068 : *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
6261 : end_col_offset, arena);
6262 7068 : if (*out == NULL) goto failed;
6263 7068 : return 0;
6264 : }
6265 54662 : tp = state->Delete_type;
6266 54662 : isinstance = PyObject_IsInstance(obj, tp);
6267 54662 : if (isinstance == -1) {
6268 0 : return 1;
6269 : }
6270 54662 : if (isinstance) {
6271 : asdl_expr_seq* targets;
6272 :
6273 223 : if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6274 0 : return 1;
6275 : }
6276 223 : if (tmp == NULL) {
6277 0 : PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
6278 0 : return 1;
6279 : }
6280 : else {
6281 : int res;
6282 : Py_ssize_t len;
6283 : Py_ssize_t i;
6284 223 : if (!PyList_Check(tmp)) {
6285 0 : PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6286 0 : goto failed;
6287 : }
6288 223 : len = PyList_GET_SIZE(tmp);
6289 223 : targets = _Py_asdl_expr_seq_new(len, arena);
6290 223 : if (targets == NULL) goto failed;
6291 489 : for (i = 0; i < len; i++) {
6292 : expr_ty val;
6293 266 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6294 266 : Py_INCREF(tmp2);
6295 266 : if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
6296 0 : goto failed;
6297 : }
6298 266 : res = obj2ast_expr(state, tmp2, &val, arena);
6299 266 : _Py_LeaveRecursiveCall();
6300 266 : Py_DECREF(tmp2);
6301 266 : if (res != 0) goto failed;
6302 266 : if (len != PyList_GET_SIZE(tmp)) {
6303 0 : PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
6304 0 : goto failed;
6305 : }
6306 266 : asdl_seq_SET(targets, i, val);
6307 : }
6308 223 : Py_CLEAR(tmp);
6309 : }
6310 223 : *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
6311 : end_col_offset, arena);
6312 223 : if (*out == NULL) goto failed;
6313 223 : return 0;
6314 : }
6315 54439 : tp = state->Assign_type;
6316 54439 : isinstance = PyObject_IsInstance(obj, tp);
6317 54439 : if (isinstance == -1) {
6318 0 : return 1;
6319 : }
6320 54439 : if (isinstance) {
6321 : asdl_expr_seq* targets;
6322 : expr_ty value;
6323 : string type_comment;
6324 :
6325 20850 : if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6326 20850 : return 1;
6327 : }
6328 20850 : if (tmp == NULL) {
6329 0 : PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
6330 0 : return 1;
6331 : }
6332 : else {
6333 : int res;
6334 : Py_ssize_t len;
6335 : Py_ssize_t i;
6336 20850 : if (!PyList_Check(tmp)) {
6337 0 : PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6338 0 : goto failed;
6339 : }
6340 20850 : len = PyList_GET_SIZE(tmp);
6341 20850 : targets = _Py_asdl_expr_seq_new(len, arena);
6342 20850 : if (targets == NULL) goto failed;
6343 41900 : for (i = 0; i < len; i++) {
6344 : expr_ty val;
6345 21050 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6346 21050 : Py_INCREF(tmp2);
6347 21050 : if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6348 0 : goto failed;
6349 : }
6350 21050 : res = obj2ast_expr(state, tmp2, &val, arena);
6351 21050 : _Py_LeaveRecursiveCall();
6352 21050 : Py_DECREF(tmp2);
6353 21050 : if (res != 0) goto failed;
6354 21050 : if (len != PyList_GET_SIZE(tmp)) {
6355 0 : PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
6356 0 : goto failed;
6357 : }
6358 21050 : asdl_seq_SET(targets, i, val);
6359 : }
6360 20850 : Py_CLEAR(tmp);
6361 : }
6362 20850 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6363 0 : return 1;
6364 : }
6365 20850 : if (tmp == NULL) {
6366 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
6367 0 : return 1;
6368 : }
6369 : else {
6370 : int res;
6371 20850 : if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6372 0 : goto failed;
6373 : }
6374 20850 : res = obj2ast_expr(state, tmp, &value, arena);
6375 20850 : _Py_LeaveRecursiveCall();
6376 20850 : if (res != 0) goto failed;
6377 20850 : Py_CLEAR(tmp);
6378 : }
6379 20850 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6380 0 : return 1;
6381 : }
6382 20850 : if (tmp == NULL || tmp == Py_None) {
6383 20850 : Py_CLEAR(tmp);
6384 20850 : type_comment = NULL;
6385 : }
6386 : else {
6387 : int res;
6388 0 : if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6389 0 : goto failed;
6390 : }
6391 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6392 0 : _Py_LeaveRecursiveCall();
6393 0 : if (res != 0) goto failed;
6394 0 : Py_CLEAR(tmp);
6395 : }
6396 20850 : *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
6397 : end_lineno, end_col_offset, arena);
6398 20850 : if (*out == NULL) goto failed;
6399 20850 : return 0;
6400 : }
6401 33589 : tp = state->AugAssign_type;
6402 33589 : isinstance = PyObject_IsInstance(obj, tp);
6403 33589 : if (isinstance == -1) {
6404 0 : return 1;
6405 : }
6406 33589 : if (isinstance) {
6407 : expr_ty target;
6408 : operator_ty op;
6409 : expr_ty value;
6410 :
6411 856 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6412 856 : return 1;
6413 : }
6414 856 : if (tmp == NULL) {
6415 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
6416 0 : return 1;
6417 : }
6418 : else {
6419 : int res;
6420 856 : if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6421 0 : goto failed;
6422 : }
6423 856 : res = obj2ast_expr(state, tmp, &target, arena);
6424 856 : _Py_LeaveRecursiveCall();
6425 856 : if (res != 0) goto failed;
6426 856 : Py_CLEAR(tmp);
6427 : }
6428 856 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
6429 0 : return 1;
6430 : }
6431 856 : if (tmp == NULL) {
6432 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
6433 0 : return 1;
6434 : }
6435 : else {
6436 : int res;
6437 856 : if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6438 0 : goto failed;
6439 : }
6440 856 : res = obj2ast_operator(state, tmp, &op, arena);
6441 856 : _Py_LeaveRecursiveCall();
6442 856 : if (res != 0) goto failed;
6443 856 : Py_CLEAR(tmp);
6444 : }
6445 856 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6446 0 : return 1;
6447 : }
6448 856 : if (tmp == NULL) {
6449 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
6450 0 : return 1;
6451 : }
6452 : else {
6453 : int res;
6454 856 : if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6455 0 : goto failed;
6456 : }
6457 856 : res = obj2ast_expr(state, tmp, &value, arena);
6458 856 : _Py_LeaveRecursiveCall();
6459 856 : if (res != 0) goto failed;
6460 856 : Py_CLEAR(tmp);
6461 : }
6462 856 : *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
6463 : end_lineno, end_col_offset, arena);
6464 856 : if (*out == NULL) goto failed;
6465 856 : return 0;
6466 : }
6467 32733 : tp = state->AnnAssign_type;
6468 32733 : isinstance = PyObject_IsInstance(obj, tp);
6469 32733 : if (isinstance == -1) {
6470 0 : return 1;
6471 : }
6472 32733 : if (isinstance) {
6473 : expr_ty target;
6474 : expr_ty annotation;
6475 : expr_ty value;
6476 : int simple;
6477 :
6478 37 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6479 37 : return 1;
6480 : }
6481 37 : if (tmp == NULL) {
6482 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
6483 0 : return 1;
6484 : }
6485 : else {
6486 : int res;
6487 37 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6488 0 : goto failed;
6489 : }
6490 37 : res = obj2ast_expr(state, tmp, &target, arena);
6491 37 : _Py_LeaveRecursiveCall();
6492 37 : if (res != 0) goto failed;
6493 37 : Py_CLEAR(tmp);
6494 : }
6495 37 : if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
6496 0 : return 1;
6497 : }
6498 37 : if (tmp == NULL) {
6499 0 : PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
6500 0 : return 1;
6501 : }
6502 : else {
6503 : int res;
6504 37 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6505 0 : goto failed;
6506 : }
6507 37 : res = obj2ast_expr(state, tmp, &annotation, arena);
6508 37 : _Py_LeaveRecursiveCall();
6509 37 : if (res != 0) goto failed;
6510 37 : Py_CLEAR(tmp);
6511 : }
6512 37 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6513 0 : return 1;
6514 : }
6515 37 : if (tmp == NULL || tmp == Py_None) {
6516 26 : Py_CLEAR(tmp);
6517 26 : value = NULL;
6518 : }
6519 : else {
6520 : int res;
6521 11 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6522 0 : goto failed;
6523 : }
6524 11 : res = obj2ast_expr(state, tmp, &value, arena);
6525 11 : _Py_LeaveRecursiveCall();
6526 11 : if (res != 0) goto failed;
6527 11 : Py_CLEAR(tmp);
6528 : }
6529 37 : if (_PyObject_LookupAttr(obj, state->simple, &tmp) < 0) {
6530 0 : return 1;
6531 : }
6532 37 : if (tmp == NULL) {
6533 0 : PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
6534 0 : return 1;
6535 : }
6536 : else {
6537 : int res;
6538 37 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6539 0 : goto failed;
6540 : }
6541 37 : res = obj2ast_int(state, tmp, &simple, arena);
6542 37 : _Py_LeaveRecursiveCall();
6543 37 : if (res != 0) goto failed;
6544 37 : Py_CLEAR(tmp);
6545 : }
6546 37 : *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
6547 : col_offset, end_lineno, end_col_offset, arena);
6548 37 : if (*out == NULL) goto failed;
6549 37 : return 0;
6550 : }
6551 32696 : tp = state->For_type;
6552 32696 : isinstance = PyObject_IsInstance(obj, tp);
6553 32696 : if (isinstance == -1) {
6554 0 : return 1;
6555 : }
6556 32696 : if (isinstance) {
6557 : expr_ty target;
6558 : expr_ty iter;
6559 : asdl_stmt_seq* body;
6560 : asdl_stmt_seq* orelse;
6561 : string type_comment;
6562 :
6563 1398 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6564 1398 : return 1;
6565 : }
6566 1398 : if (tmp == NULL) {
6567 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
6568 0 : return 1;
6569 : }
6570 : else {
6571 : int res;
6572 1398 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6573 0 : goto failed;
6574 : }
6575 1398 : res = obj2ast_expr(state, tmp, &target, arena);
6576 1398 : _Py_LeaveRecursiveCall();
6577 1398 : if (res != 0) goto failed;
6578 1398 : Py_CLEAR(tmp);
6579 : }
6580 1398 : if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6581 0 : return 1;
6582 : }
6583 1398 : if (tmp == NULL) {
6584 0 : PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
6585 0 : return 1;
6586 : }
6587 : else {
6588 : int res;
6589 1398 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6590 0 : goto failed;
6591 : }
6592 1398 : res = obj2ast_expr(state, tmp, &iter, arena);
6593 1398 : _Py_LeaveRecursiveCall();
6594 1398 : if (res != 0) goto failed;
6595 1398 : Py_CLEAR(tmp);
6596 : }
6597 1398 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6598 0 : return 1;
6599 : }
6600 1398 : if (tmp == NULL) {
6601 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
6602 0 : return 1;
6603 : }
6604 : else {
6605 : int res;
6606 : Py_ssize_t len;
6607 : Py_ssize_t i;
6608 1398 : if (!PyList_Check(tmp)) {
6609 0 : PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6610 0 : goto failed;
6611 : }
6612 1398 : len = PyList_GET_SIZE(tmp);
6613 1398 : body = _Py_asdl_stmt_seq_new(len, arena);
6614 1398 : if (body == NULL) goto failed;
6615 4173 : for (i = 0; i < len; i++) {
6616 : stmt_ty val;
6617 2775 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6618 2775 : Py_INCREF(tmp2);
6619 2775 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6620 0 : goto failed;
6621 : }
6622 2775 : res = obj2ast_stmt(state, tmp2, &val, arena);
6623 2775 : _Py_LeaveRecursiveCall();
6624 2775 : Py_DECREF(tmp2);
6625 2775 : if (res != 0) goto failed;
6626 2775 : if (len != PyList_GET_SIZE(tmp)) {
6627 0 : PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
6628 0 : goto failed;
6629 : }
6630 2775 : asdl_seq_SET(body, i, val);
6631 : }
6632 1398 : Py_CLEAR(tmp);
6633 : }
6634 1398 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6635 0 : return 1;
6636 : }
6637 1398 : if (tmp == NULL) {
6638 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
6639 0 : return 1;
6640 : }
6641 : else {
6642 : int res;
6643 : Py_ssize_t len;
6644 : Py_ssize_t i;
6645 1398 : if (!PyList_Check(tmp)) {
6646 0 : PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6647 0 : goto failed;
6648 : }
6649 1398 : len = PyList_GET_SIZE(tmp);
6650 1398 : orelse = _Py_asdl_stmt_seq_new(len, arena);
6651 1398 : if (orelse == NULL) goto failed;
6652 1450 : for (i = 0; i < len; i++) {
6653 : stmt_ty val;
6654 52 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6655 52 : Py_INCREF(tmp2);
6656 52 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6657 0 : goto failed;
6658 : }
6659 52 : res = obj2ast_stmt(state, tmp2, &val, arena);
6660 52 : _Py_LeaveRecursiveCall();
6661 52 : Py_DECREF(tmp2);
6662 52 : if (res != 0) goto failed;
6663 52 : if (len != PyList_GET_SIZE(tmp)) {
6664 0 : PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
6665 0 : goto failed;
6666 : }
6667 52 : asdl_seq_SET(orelse, i, val);
6668 : }
6669 1398 : Py_CLEAR(tmp);
6670 : }
6671 1398 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6672 0 : return 1;
6673 : }
6674 1398 : if (tmp == NULL || tmp == Py_None) {
6675 1398 : Py_CLEAR(tmp);
6676 1398 : type_comment = NULL;
6677 : }
6678 : else {
6679 : int res;
6680 0 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6681 0 : goto failed;
6682 : }
6683 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6684 0 : _Py_LeaveRecursiveCall();
6685 0 : if (res != 0) goto failed;
6686 0 : Py_CLEAR(tmp);
6687 : }
6688 1398 : *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
6689 : col_offset, end_lineno, end_col_offset, arena);
6690 1398 : if (*out == NULL) goto failed;
6691 1398 : return 0;
6692 : }
6693 31298 : tp = state->AsyncFor_type;
6694 31298 : isinstance = PyObject_IsInstance(obj, tp);
6695 31298 : if (isinstance == -1) {
6696 0 : return 1;
6697 : }
6698 31298 : if (isinstance) {
6699 : expr_ty target;
6700 : expr_ty iter;
6701 : asdl_stmt_seq* body;
6702 : asdl_stmt_seq* orelse;
6703 : string type_comment;
6704 :
6705 6 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6706 6 : return 1;
6707 : }
6708 6 : if (tmp == NULL) {
6709 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
6710 0 : return 1;
6711 : }
6712 : else {
6713 : int res;
6714 6 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6715 0 : goto failed;
6716 : }
6717 6 : res = obj2ast_expr(state, tmp, &target, arena);
6718 6 : _Py_LeaveRecursiveCall();
6719 6 : if (res != 0) goto failed;
6720 6 : Py_CLEAR(tmp);
6721 : }
6722 6 : if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6723 0 : return 1;
6724 : }
6725 6 : if (tmp == NULL) {
6726 0 : PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
6727 0 : return 1;
6728 : }
6729 : else {
6730 : int res;
6731 6 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6732 0 : goto failed;
6733 : }
6734 6 : res = obj2ast_expr(state, tmp, &iter, arena);
6735 6 : _Py_LeaveRecursiveCall();
6736 6 : if (res != 0) goto failed;
6737 6 : Py_CLEAR(tmp);
6738 : }
6739 6 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6740 0 : return 1;
6741 : }
6742 6 : if (tmp == NULL) {
6743 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFor");
6744 0 : return 1;
6745 : }
6746 : else {
6747 : int res;
6748 : Py_ssize_t len;
6749 : Py_ssize_t i;
6750 6 : if (!PyList_Check(tmp)) {
6751 0 : PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6752 0 : goto failed;
6753 : }
6754 6 : len = PyList_GET_SIZE(tmp);
6755 6 : body = _Py_asdl_stmt_seq_new(len, arena);
6756 6 : if (body == NULL) goto failed;
6757 12 : for (i = 0; i < len; i++) {
6758 : stmt_ty val;
6759 6 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6760 6 : Py_INCREF(tmp2);
6761 6 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6762 0 : goto failed;
6763 : }
6764 6 : res = obj2ast_stmt(state, tmp2, &val, arena);
6765 6 : _Py_LeaveRecursiveCall();
6766 6 : Py_DECREF(tmp2);
6767 6 : if (res != 0) goto failed;
6768 6 : if (len != PyList_GET_SIZE(tmp)) {
6769 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
6770 0 : goto failed;
6771 : }
6772 6 : asdl_seq_SET(body, i, val);
6773 : }
6774 6 : Py_CLEAR(tmp);
6775 : }
6776 6 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6777 0 : return 1;
6778 : }
6779 6 : if (tmp == NULL) {
6780 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from AsyncFor");
6781 0 : return 1;
6782 : }
6783 : else {
6784 : int res;
6785 : Py_ssize_t len;
6786 : Py_ssize_t i;
6787 6 : if (!PyList_Check(tmp)) {
6788 0 : PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6789 0 : goto failed;
6790 : }
6791 6 : len = PyList_GET_SIZE(tmp);
6792 6 : orelse = _Py_asdl_stmt_seq_new(len, arena);
6793 6 : if (orelse == NULL) goto failed;
6794 9 : for (i = 0; i < len; i++) {
6795 : stmt_ty val;
6796 3 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6797 3 : Py_INCREF(tmp2);
6798 3 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6799 0 : goto failed;
6800 : }
6801 3 : res = obj2ast_stmt(state, tmp2, &val, arena);
6802 3 : _Py_LeaveRecursiveCall();
6803 3 : Py_DECREF(tmp2);
6804 3 : if (res != 0) goto failed;
6805 3 : if (len != PyList_GET_SIZE(tmp)) {
6806 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
6807 0 : goto failed;
6808 : }
6809 3 : asdl_seq_SET(orelse, i, val);
6810 : }
6811 6 : Py_CLEAR(tmp);
6812 : }
6813 6 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6814 0 : return 1;
6815 : }
6816 6 : if (tmp == NULL || tmp == Py_None) {
6817 6 : Py_CLEAR(tmp);
6818 6 : type_comment = NULL;
6819 : }
6820 : else {
6821 : int res;
6822 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6823 0 : goto failed;
6824 : }
6825 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6826 0 : _Py_LeaveRecursiveCall();
6827 0 : if (res != 0) goto failed;
6828 0 : Py_CLEAR(tmp);
6829 : }
6830 6 : *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
6831 : lineno, col_offset, end_lineno, end_col_offset,
6832 : arena);
6833 6 : if (*out == NULL) goto failed;
6834 6 : return 0;
6835 : }
6836 31292 : tp = state->While_type;
6837 31292 : isinstance = PyObject_IsInstance(obj, tp);
6838 31292 : if (isinstance == -1) {
6839 0 : return 1;
6840 : }
6841 31292 : if (isinstance) {
6842 : expr_ty test;
6843 : asdl_stmt_seq* body;
6844 : asdl_stmt_seq* orelse;
6845 :
6846 443 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6847 443 : return 1;
6848 : }
6849 443 : if (tmp == NULL) {
6850 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
6851 0 : return 1;
6852 : }
6853 : else {
6854 : int res;
6855 443 : if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6856 0 : goto failed;
6857 : }
6858 443 : res = obj2ast_expr(state, tmp, &test, arena);
6859 443 : _Py_LeaveRecursiveCall();
6860 443 : if (res != 0) goto failed;
6861 443 : Py_CLEAR(tmp);
6862 : }
6863 443 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6864 0 : return 1;
6865 : }
6866 443 : if (tmp == NULL) {
6867 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
6868 0 : return 1;
6869 : }
6870 : else {
6871 : int res;
6872 : Py_ssize_t len;
6873 : Py_ssize_t i;
6874 443 : if (!PyList_Check(tmp)) {
6875 0 : PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6876 0 : goto failed;
6877 : }
6878 443 : len = PyList_GET_SIZE(tmp);
6879 443 : body = _Py_asdl_stmt_seq_new(len, arena);
6880 443 : if (body == NULL) goto failed;
6881 1846 : for (i = 0; i < len; i++) {
6882 : stmt_ty val;
6883 1403 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6884 1403 : Py_INCREF(tmp2);
6885 1403 : if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6886 0 : goto failed;
6887 : }
6888 1403 : res = obj2ast_stmt(state, tmp2, &val, arena);
6889 1403 : _Py_LeaveRecursiveCall();
6890 1403 : Py_DECREF(tmp2);
6891 1403 : if (res != 0) goto failed;
6892 1403 : if (len != PyList_GET_SIZE(tmp)) {
6893 0 : PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
6894 0 : goto failed;
6895 : }
6896 1403 : asdl_seq_SET(body, i, val);
6897 : }
6898 443 : Py_CLEAR(tmp);
6899 : }
6900 443 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6901 0 : return 1;
6902 : }
6903 443 : if (tmp == NULL) {
6904 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
6905 0 : return 1;
6906 : }
6907 : else {
6908 : int res;
6909 : Py_ssize_t len;
6910 : Py_ssize_t i;
6911 443 : if (!PyList_Check(tmp)) {
6912 0 : PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6913 0 : goto failed;
6914 : }
6915 443 : len = PyList_GET_SIZE(tmp);
6916 443 : orelse = _Py_asdl_stmt_seq_new(len, arena);
6917 443 : if (orelse == NULL) goto failed;
6918 454 : for (i = 0; i < len; i++) {
6919 : stmt_ty val;
6920 11 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6921 11 : Py_INCREF(tmp2);
6922 11 : if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6923 0 : goto failed;
6924 : }
6925 11 : res = obj2ast_stmt(state, tmp2, &val, arena);
6926 11 : _Py_LeaveRecursiveCall();
6927 11 : Py_DECREF(tmp2);
6928 11 : if (res != 0) goto failed;
6929 11 : if (len != PyList_GET_SIZE(tmp)) {
6930 0 : PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
6931 0 : goto failed;
6932 : }
6933 11 : asdl_seq_SET(orelse, i, val);
6934 : }
6935 443 : Py_CLEAR(tmp);
6936 : }
6937 443 : *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
6938 : end_col_offset, arena);
6939 443 : if (*out == NULL) goto failed;
6940 443 : return 0;
6941 : }
6942 30849 : tp = state->If_type;
6943 30849 : isinstance = PyObject_IsInstance(obj, tp);
6944 30849 : if (isinstance == -1) {
6945 0 : return 1;
6946 : }
6947 30849 : if (isinstance) {
6948 : expr_ty test;
6949 : asdl_stmt_seq* body;
6950 : asdl_stmt_seq* orelse;
6951 :
6952 11157 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6953 11157 : return 1;
6954 : }
6955 11157 : if (tmp == NULL) {
6956 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
6957 0 : return 1;
6958 : }
6959 : else {
6960 : int res;
6961 11157 : if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
6962 0 : goto failed;
6963 : }
6964 11157 : res = obj2ast_expr(state, tmp, &test, arena);
6965 11157 : _Py_LeaveRecursiveCall();
6966 11157 : if (res != 0) goto failed;
6967 11157 : Py_CLEAR(tmp);
6968 : }
6969 11157 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6970 0 : return 1;
6971 : }
6972 11157 : if (tmp == NULL) {
6973 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
6974 0 : return 1;
6975 : }
6976 : else {
6977 : int res;
6978 : Py_ssize_t len;
6979 : Py_ssize_t i;
6980 11157 : if (!PyList_Check(tmp)) {
6981 0 : PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6982 0 : goto failed;
6983 : }
6984 11157 : len = PyList_GET_SIZE(tmp);
6985 11157 : body = _Py_asdl_stmt_seq_new(len, arena);
6986 11157 : if (body == NULL) goto failed;
6987 27418 : for (i = 0; i < len; i++) {
6988 : stmt_ty val;
6989 16261 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
6990 16261 : Py_INCREF(tmp2);
6991 16261 : if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
6992 0 : goto failed;
6993 : }
6994 16261 : res = obj2ast_stmt(state, tmp2, &val, arena);
6995 16261 : _Py_LeaveRecursiveCall();
6996 16261 : Py_DECREF(tmp2);
6997 16261 : if (res != 0) goto failed;
6998 16261 : if (len != PyList_GET_SIZE(tmp)) {
6999 0 : PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
7000 0 : goto failed;
7001 : }
7002 16261 : asdl_seq_SET(body, i, val);
7003 : }
7004 11157 : Py_CLEAR(tmp);
7005 : }
7006 11157 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7007 0 : return 1;
7008 : }
7009 11157 : if (tmp == NULL) {
7010 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
7011 0 : return 1;
7012 : }
7013 : else {
7014 : int res;
7015 : Py_ssize_t len;
7016 : Py_ssize_t i;
7017 11157 : if (!PyList_Check(tmp)) {
7018 0 : PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7019 0 : goto failed;
7020 : }
7021 11157 : len = PyList_GET_SIZE(tmp);
7022 11157 : orelse = _Py_asdl_stmt_seq_new(len, arena);
7023 11157 : if (orelse == NULL) goto failed;
7024 15308 : for (i = 0; i < len; i++) {
7025 : stmt_ty val;
7026 4151 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7027 4151 : Py_INCREF(tmp2);
7028 4151 : if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
7029 0 : goto failed;
7030 : }
7031 4151 : res = obj2ast_stmt(state, tmp2, &val, arena);
7032 4151 : _Py_LeaveRecursiveCall();
7033 4151 : Py_DECREF(tmp2);
7034 4151 : if (res != 0) goto failed;
7035 4151 : if (len != PyList_GET_SIZE(tmp)) {
7036 0 : PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
7037 0 : goto failed;
7038 : }
7039 4151 : asdl_seq_SET(orelse, i, val);
7040 : }
7041 11157 : Py_CLEAR(tmp);
7042 : }
7043 11157 : *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
7044 : end_col_offset, arena);
7045 11157 : if (*out == NULL) goto failed;
7046 11157 : return 0;
7047 : }
7048 19692 : tp = state->With_type;
7049 19692 : isinstance = PyObject_IsInstance(obj, tp);
7050 19692 : if (isinstance == -1) {
7051 0 : return 1;
7052 : }
7053 19692 : if (isinstance) {
7054 : asdl_withitem_seq* items;
7055 : asdl_stmt_seq* body;
7056 : string type_comment;
7057 :
7058 385 : if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7059 385 : return 1;
7060 : }
7061 385 : if (tmp == NULL) {
7062 0 : PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
7063 0 : return 1;
7064 : }
7065 : else {
7066 : int res;
7067 : Py_ssize_t len;
7068 : Py_ssize_t i;
7069 385 : if (!PyList_Check(tmp)) {
7070 0 : PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7071 0 : goto failed;
7072 : }
7073 385 : len = PyList_GET_SIZE(tmp);
7074 385 : items = _Py_asdl_withitem_seq_new(len, arena);
7075 385 : if (items == NULL) goto failed;
7076 791 : for (i = 0; i < len; i++) {
7077 : withitem_ty val;
7078 406 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7079 406 : Py_INCREF(tmp2);
7080 406 : if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7081 0 : goto failed;
7082 : }
7083 406 : res = obj2ast_withitem(state, tmp2, &val, arena);
7084 406 : _Py_LeaveRecursiveCall();
7085 406 : Py_DECREF(tmp2);
7086 406 : if (res != 0) goto failed;
7087 406 : if (len != PyList_GET_SIZE(tmp)) {
7088 0 : PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
7089 0 : goto failed;
7090 : }
7091 406 : asdl_seq_SET(items, i, val);
7092 : }
7093 385 : Py_CLEAR(tmp);
7094 : }
7095 385 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7096 0 : return 1;
7097 : }
7098 385 : if (tmp == NULL) {
7099 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
7100 0 : return 1;
7101 : }
7102 : else {
7103 : int res;
7104 : Py_ssize_t len;
7105 : Py_ssize_t i;
7106 385 : if (!PyList_Check(tmp)) {
7107 0 : PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7108 0 : goto failed;
7109 : }
7110 385 : len = PyList_GET_SIZE(tmp);
7111 385 : body = _Py_asdl_stmt_seq_new(len, arena);
7112 385 : if (body == NULL) goto failed;
7113 1078 : for (i = 0; i < len; i++) {
7114 : stmt_ty val;
7115 693 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7116 693 : Py_INCREF(tmp2);
7117 693 : if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7118 0 : goto failed;
7119 : }
7120 693 : res = obj2ast_stmt(state, tmp2, &val, arena);
7121 693 : _Py_LeaveRecursiveCall();
7122 693 : Py_DECREF(tmp2);
7123 693 : if (res != 0) goto failed;
7124 693 : if (len != PyList_GET_SIZE(tmp)) {
7125 0 : PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
7126 0 : goto failed;
7127 : }
7128 693 : asdl_seq_SET(body, i, val);
7129 : }
7130 385 : Py_CLEAR(tmp);
7131 : }
7132 385 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7133 0 : return 1;
7134 : }
7135 385 : if (tmp == NULL || tmp == Py_None) {
7136 385 : Py_CLEAR(tmp);
7137 385 : type_comment = NULL;
7138 : }
7139 : else {
7140 : int res;
7141 0 : if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7142 0 : goto failed;
7143 : }
7144 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
7145 0 : _Py_LeaveRecursiveCall();
7146 0 : if (res != 0) goto failed;
7147 0 : Py_CLEAR(tmp);
7148 : }
7149 385 : *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
7150 : end_lineno, end_col_offset, arena);
7151 385 : if (*out == NULL) goto failed;
7152 385 : return 0;
7153 : }
7154 19307 : tp = state->AsyncWith_type;
7155 19307 : isinstance = PyObject_IsInstance(obj, tp);
7156 19307 : if (isinstance == -1) {
7157 0 : return 1;
7158 : }
7159 19307 : if (isinstance) {
7160 : asdl_withitem_seq* items;
7161 : asdl_stmt_seq* body;
7162 : string type_comment;
7163 :
7164 9 : if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7165 9 : return 1;
7166 : }
7167 9 : if (tmp == NULL) {
7168 0 : PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from AsyncWith");
7169 0 : return 1;
7170 : }
7171 : else {
7172 : int res;
7173 : Py_ssize_t len;
7174 : Py_ssize_t i;
7175 9 : if (!PyList_Check(tmp)) {
7176 0 : PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7177 0 : goto failed;
7178 : }
7179 9 : len = PyList_GET_SIZE(tmp);
7180 9 : items = _Py_asdl_withitem_seq_new(len, arena);
7181 9 : if (items == NULL) goto failed;
7182 21 : for (i = 0; i < len; i++) {
7183 : withitem_ty val;
7184 12 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7185 12 : Py_INCREF(tmp2);
7186 12 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7187 0 : goto failed;
7188 : }
7189 12 : res = obj2ast_withitem(state, tmp2, &val, arena);
7190 12 : _Py_LeaveRecursiveCall();
7191 12 : Py_DECREF(tmp2);
7192 12 : if (res != 0) goto failed;
7193 12 : if (len != PyList_GET_SIZE(tmp)) {
7194 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
7195 0 : goto failed;
7196 : }
7197 12 : asdl_seq_SET(items, i, val);
7198 : }
7199 9 : Py_CLEAR(tmp);
7200 : }
7201 9 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7202 0 : return 1;
7203 : }
7204 9 : if (tmp == NULL) {
7205 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncWith");
7206 0 : return 1;
7207 : }
7208 : else {
7209 : int res;
7210 : Py_ssize_t len;
7211 : Py_ssize_t i;
7212 9 : if (!PyList_Check(tmp)) {
7213 0 : PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7214 0 : goto failed;
7215 : }
7216 9 : len = PyList_GET_SIZE(tmp);
7217 9 : body = _Py_asdl_stmt_seq_new(len, arena);
7218 9 : if (body == NULL) goto failed;
7219 18 : for (i = 0; i < len; i++) {
7220 : stmt_ty val;
7221 9 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7222 9 : Py_INCREF(tmp2);
7223 9 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7224 0 : goto failed;
7225 : }
7226 9 : res = obj2ast_stmt(state, tmp2, &val, arena);
7227 9 : _Py_LeaveRecursiveCall();
7228 9 : Py_DECREF(tmp2);
7229 9 : if (res != 0) goto failed;
7230 9 : if (len != PyList_GET_SIZE(tmp)) {
7231 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
7232 0 : goto failed;
7233 : }
7234 9 : asdl_seq_SET(body, i, val);
7235 : }
7236 9 : Py_CLEAR(tmp);
7237 : }
7238 9 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7239 0 : return 1;
7240 : }
7241 9 : if (tmp == NULL || tmp == Py_None) {
7242 9 : Py_CLEAR(tmp);
7243 9 : type_comment = NULL;
7244 : }
7245 : else {
7246 : int res;
7247 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7248 0 : goto failed;
7249 : }
7250 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
7251 0 : _Py_LeaveRecursiveCall();
7252 0 : if (res != 0) goto failed;
7253 0 : Py_CLEAR(tmp);
7254 : }
7255 9 : *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
7256 : end_lineno, end_col_offset, arena);
7257 9 : if (*out == NULL) goto failed;
7258 9 : return 0;
7259 : }
7260 19298 : tp = state->Match_type;
7261 19298 : isinstance = PyObject_IsInstance(obj, tp);
7262 19298 : if (isinstance == -1) {
7263 0 : return 1;
7264 : }
7265 19298 : if (isinstance) {
7266 : expr_ty subject;
7267 : asdl_match_case_seq* cases;
7268 :
7269 29 : if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) {
7270 29 : return 1;
7271 : }
7272 29 : if (tmp == NULL) {
7273 0 : PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
7274 0 : return 1;
7275 : }
7276 : else {
7277 : int res;
7278 29 : if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
7279 0 : goto failed;
7280 : }
7281 29 : res = obj2ast_expr(state, tmp, &subject, arena);
7282 29 : _Py_LeaveRecursiveCall();
7283 29 : if (res != 0) goto failed;
7284 29 : Py_CLEAR(tmp);
7285 : }
7286 29 : if (_PyObject_LookupAttr(obj, state->cases, &tmp) < 0) {
7287 0 : return 1;
7288 : }
7289 29 : if (tmp == NULL) {
7290 0 : PyErr_SetString(PyExc_TypeError, "required field \"cases\" missing from Match");
7291 0 : return 1;
7292 : }
7293 : else {
7294 : int res;
7295 : Py_ssize_t len;
7296 : Py_ssize_t i;
7297 29 : if (!PyList_Check(tmp)) {
7298 0 : PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7299 0 : goto failed;
7300 : }
7301 29 : len = PyList_GET_SIZE(tmp);
7302 29 : cases = _Py_asdl_match_case_seq_new(len, arena);
7303 29 : if (cases == NULL) goto failed;
7304 62 : for (i = 0; i < len; i++) {
7305 : match_case_ty val;
7306 33 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7307 33 : Py_INCREF(tmp2);
7308 33 : if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
7309 0 : goto failed;
7310 : }
7311 33 : res = obj2ast_match_case(state, tmp2, &val, arena);
7312 33 : _Py_LeaveRecursiveCall();
7313 33 : Py_DECREF(tmp2);
7314 33 : if (res != 0) goto failed;
7315 33 : if (len != PyList_GET_SIZE(tmp)) {
7316 0 : PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
7317 0 : goto failed;
7318 : }
7319 33 : asdl_seq_SET(cases, i, val);
7320 : }
7321 29 : Py_CLEAR(tmp);
7322 : }
7323 29 : *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
7324 : end_col_offset, arena);
7325 29 : if (*out == NULL) goto failed;
7326 29 : return 0;
7327 : }
7328 19269 : tp = state->Raise_type;
7329 19269 : isinstance = PyObject_IsInstance(obj, tp);
7330 19269 : if (isinstance == -1) {
7331 0 : return 1;
7332 : }
7333 19269 : if (isinstance) {
7334 : expr_ty exc;
7335 : expr_ty cause;
7336 :
7337 2313 : if (_PyObject_LookupAttr(obj, state->exc, &tmp) < 0) {
7338 2313 : return 1;
7339 : }
7340 2313 : if (tmp == NULL || tmp == Py_None) {
7341 164 : Py_CLEAR(tmp);
7342 164 : exc = NULL;
7343 : }
7344 : else {
7345 : int res;
7346 2149 : if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
7347 0 : goto failed;
7348 : }
7349 2149 : res = obj2ast_expr(state, tmp, &exc, arena);
7350 2149 : _Py_LeaveRecursiveCall();
7351 2149 : if (res != 0) goto failed;
7352 2149 : Py_CLEAR(tmp);
7353 : }
7354 2313 : if (_PyObject_LookupAttr(obj, state->cause, &tmp) < 0) {
7355 0 : return 1;
7356 : }
7357 2313 : if (tmp == NULL || tmp == Py_None) {
7358 2180 : Py_CLEAR(tmp);
7359 2180 : cause = NULL;
7360 : }
7361 : else {
7362 : int res;
7363 133 : if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
7364 0 : goto failed;
7365 : }
7366 133 : res = obj2ast_expr(state, tmp, &cause, arena);
7367 133 : _Py_LeaveRecursiveCall();
7368 133 : if (res != 0) goto failed;
7369 133 : Py_CLEAR(tmp);
7370 : }
7371 2313 : *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
7372 : end_col_offset, arena);
7373 2313 : if (*out == NULL) goto failed;
7374 2313 : return 0;
7375 : }
7376 16956 : tp = state->Try_type;
7377 16956 : isinstance = PyObject_IsInstance(obj, tp);
7378 16956 : if (isinstance == -1) {
7379 0 : return 1;
7380 : }
7381 16956 : if (isinstance) {
7382 : asdl_stmt_seq* body;
7383 : asdl_excepthandler_seq* handlers;
7384 : asdl_stmt_seq* orelse;
7385 : asdl_stmt_seq* finalbody;
7386 :
7387 1473 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7388 0 : return 1;
7389 : }
7390 1473 : if (tmp == NULL) {
7391 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
7392 0 : return 1;
7393 : }
7394 : else {
7395 : int res;
7396 : Py_ssize_t len;
7397 : Py_ssize_t i;
7398 1473 : if (!PyList_Check(tmp)) {
7399 0 : PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7400 0 : goto failed;
7401 : }
7402 1473 : len = PyList_GET_SIZE(tmp);
7403 1473 : body = _Py_asdl_stmt_seq_new(len, arena);
7404 1473 : if (body == NULL) goto failed;
7405 3586 : for (i = 0; i < len; i++) {
7406 : stmt_ty val;
7407 2113 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7408 2113 : Py_INCREF(tmp2);
7409 2113 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7410 0 : goto failed;
7411 : }
7412 2113 : res = obj2ast_stmt(state, tmp2, &val, arena);
7413 2113 : _Py_LeaveRecursiveCall();
7414 2113 : Py_DECREF(tmp2);
7415 2113 : if (res != 0) goto failed;
7416 2113 : if (len != PyList_GET_SIZE(tmp)) {
7417 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
7418 0 : goto failed;
7419 : }
7420 2113 : asdl_seq_SET(body, i, val);
7421 : }
7422 1473 : Py_CLEAR(tmp);
7423 : }
7424 1473 : if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7425 0 : return 1;
7426 : }
7427 1473 : if (tmp == NULL) {
7428 0 : PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
7429 0 : return 1;
7430 : }
7431 : else {
7432 : int res;
7433 : Py_ssize_t len;
7434 : Py_ssize_t i;
7435 1473 : if (!PyList_Check(tmp)) {
7436 0 : PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7437 0 : goto failed;
7438 : }
7439 1473 : len = PyList_GET_SIZE(tmp);
7440 1473 : handlers = _Py_asdl_excepthandler_seq_new(len, arena);
7441 1473 : if (handlers == NULL) goto failed;
7442 2872 : for (i = 0; i < len; i++) {
7443 : excepthandler_ty val;
7444 1399 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7445 1399 : Py_INCREF(tmp2);
7446 1399 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7447 0 : goto failed;
7448 : }
7449 1399 : res = obj2ast_excepthandler(state, tmp2, &val, arena);
7450 1399 : _Py_LeaveRecursiveCall();
7451 1399 : Py_DECREF(tmp2);
7452 1399 : if (res != 0) goto failed;
7453 1399 : if (len != PyList_GET_SIZE(tmp)) {
7454 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
7455 0 : goto failed;
7456 : }
7457 1399 : asdl_seq_SET(handlers, i, val);
7458 : }
7459 1473 : Py_CLEAR(tmp);
7460 : }
7461 1473 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7462 0 : return 1;
7463 : }
7464 1473 : if (tmp == NULL) {
7465 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
7466 0 : return 1;
7467 : }
7468 : else {
7469 : int res;
7470 : Py_ssize_t len;
7471 : Py_ssize_t i;
7472 1473 : if (!PyList_Check(tmp)) {
7473 0 : PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7474 0 : goto failed;
7475 : }
7476 1473 : len = PyList_GET_SIZE(tmp);
7477 1473 : orelse = _Py_asdl_stmt_seq_new(len, arena);
7478 1473 : if (orelse == NULL) goto failed;
7479 1753 : for (i = 0; i < len; i++) {
7480 : stmt_ty val;
7481 280 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7482 280 : Py_INCREF(tmp2);
7483 280 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7484 0 : goto failed;
7485 : }
7486 280 : res = obj2ast_stmt(state, tmp2, &val, arena);
7487 280 : _Py_LeaveRecursiveCall();
7488 280 : Py_DECREF(tmp2);
7489 280 : if (res != 0) goto failed;
7490 280 : if (len != PyList_GET_SIZE(tmp)) {
7491 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
7492 0 : goto failed;
7493 : }
7494 280 : asdl_seq_SET(orelse, i, val);
7495 : }
7496 1473 : Py_CLEAR(tmp);
7497 : }
7498 1473 : if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7499 0 : return 1;
7500 : }
7501 1473 : if (tmp == NULL) {
7502 0 : PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
7503 0 : return 1;
7504 : }
7505 : else {
7506 : int res;
7507 : Py_ssize_t len;
7508 : Py_ssize_t i;
7509 1473 : if (!PyList_Check(tmp)) {
7510 0 : PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7511 0 : goto failed;
7512 : }
7513 1473 : len = PyList_GET_SIZE(tmp);
7514 1473 : finalbody = _Py_asdl_stmt_seq_new(len, arena);
7515 1473 : if (finalbody == NULL) goto failed;
7516 1694 : for (i = 0; i < len; i++) {
7517 : stmt_ty val;
7518 221 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7519 221 : Py_INCREF(tmp2);
7520 221 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7521 0 : goto failed;
7522 : }
7523 221 : res = obj2ast_stmt(state, tmp2, &val, arena);
7524 221 : _Py_LeaveRecursiveCall();
7525 221 : Py_DECREF(tmp2);
7526 221 : if (res != 0) goto failed;
7527 221 : if (len != PyList_GET_SIZE(tmp)) {
7528 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
7529 0 : goto failed;
7530 : }
7531 221 : asdl_seq_SET(finalbody, i, val);
7532 : }
7533 1473 : Py_CLEAR(tmp);
7534 : }
7535 1473 : *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
7536 : col_offset, end_lineno, end_col_offset, arena);
7537 1473 : if (*out == NULL) goto failed;
7538 1473 : return 0;
7539 : }
7540 15483 : tp = state->TryStar_type;
7541 15483 : isinstance = PyObject_IsInstance(obj, tp);
7542 15483 : if (isinstance == -1) {
7543 0 : return 1;
7544 : }
7545 15483 : if (isinstance) {
7546 : asdl_stmt_seq* body;
7547 : asdl_excepthandler_seq* handlers;
7548 : asdl_stmt_seq* orelse;
7549 : asdl_stmt_seq* finalbody;
7550 :
7551 14 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7552 0 : return 1;
7553 : }
7554 14 : if (tmp == NULL) {
7555 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryStar");
7556 0 : return 1;
7557 : }
7558 : else {
7559 : int res;
7560 : Py_ssize_t len;
7561 : Py_ssize_t i;
7562 14 : if (!PyList_Check(tmp)) {
7563 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7564 0 : goto failed;
7565 : }
7566 14 : len = PyList_GET_SIZE(tmp);
7567 14 : body = _Py_asdl_stmt_seq_new(len, arena);
7568 14 : if (body == NULL) goto failed;
7569 27 : for (i = 0; i < len; i++) {
7570 : stmt_ty val;
7571 13 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7572 13 : Py_INCREF(tmp2);
7573 13 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7574 0 : goto failed;
7575 : }
7576 13 : res = obj2ast_stmt(state, tmp2, &val, arena);
7577 13 : _Py_LeaveRecursiveCall();
7578 13 : Py_DECREF(tmp2);
7579 13 : if (res != 0) goto failed;
7580 13 : if (len != PyList_GET_SIZE(tmp)) {
7581 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
7582 0 : goto failed;
7583 : }
7584 13 : asdl_seq_SET(body, i, val);
7585 : }
7586 14 : Py_CLEAR(tmp);
7587 : }
7588 14 : if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7589 0 : return 1;
7590 : }
7591 14 : if (tmp == NULL) {
7592 0 : PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from TryStar");
7593 0 : return 1;
7594 : }
7595 : else {
7596 : int res;
7597 : Py_ssize_t len;
7598 : Py_ssize_t i;
7599 14 : if (!PyList_Check(tmp)) {
7600 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7601 0 : goto failed;
7602 : }
7603 14 : len = PyList_GET_SIZE(tmp);
7604 14 : handlers = _Py_asdl_excepthandler_seq_new(len, arena);
7605 14 : if (handlers == NULL) goto failed;
7606 25 : for (i = 0; i < len; i++) {
7607 : excepthandler_ty val;
7608 11 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7609 11 : Py_INCREF(tmp2);
7610 11 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7611 0 : goto failed;
7612 : }
7613 11 : res = obj2ast_excepthandler(state, tmp2, &val, arena);
7614 11 : _Py_LeaveRecursiveCall();
7615 11 : Py_DECREF(tmp2);
7616 11 : if (res != 0) goto failed;
7617 11 : if (len != PyList_GET_SIZE(tmp)) {
7618 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
7619 0 : goto failed;
7620 : }
7621 11 : asdl_seq_SET(handlers, i, val);
7622 : }
7623 14 : Py_CLEAR(tmp);
7624 : }
7625 14 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7626 0 : return 1;
7627 : }
7628 14 : if (tmp == NULL) {
7629 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from TryStar");
7630 0 : return 1;
7631 : }
7632 : else {
7633 : int res;
7634 : Py_ssize_t len;
7635 : Py_ssize_t i;
7636 14 : if (!PyList_Check(tmp)) {
7637 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7638 0 : goto failed;
7639 : }
7640 14 : len = PyList_GET_SIZE(tmp);
7641 14 : orelse = _Py_asdl_stmt_seq_new(len, arena);
7642 14 : if (orelse == NULL) goto failed;
7643 19 : for (i = 0; i < len; i++) {
7644 : stmt_ty val;
7645 5 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7646 5 : Py_INCREF(tmp2);
7647 5 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7648 0 : goto failed;
7649 : }
7650 5 : res = obj2ast_stmt(state, tmp2, &val, arena);
7651 5 : _Py_LeaveRecursiveCall();
7652 5 : Py_DECREF(tmp2);
7653 5 : if (res != 0) goto failed;
7654 5 : if (len != PyList_GET_SIZE(tmp)) {
7655 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
7656 0 : goto failed;
7657 : }
7658 5 : asdl_seq_SET(orelse, i, val);
7659 : }
7660 14 : Py_CLEAR(tmp);
7661 : }
7662 14 : if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7663 0 : return 1;
7664 : }
7665 14 : if (tmp == NULL) {
7666 0 : PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from TryStar");
7667 0 : return 1;
7668 : }
7669 : else {
7670 : int res;
7671 : Py_ssize_t len;
7672 : Py_ssize_t i;
7673 14 : if (!PyList_Check(tmp)) {
7674 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7675 0 : goto failed;
7676 : }
7677 14 : len = PyList_GET_SIZE(tmp);
7678 14 : finalbody = _Py_asdl_stmt_seq_new(len, arena);
7679 14 : if (finalbody == NULL) goto failed;
7680 19 : for (i = 0; i < len; i++) {
7681 : stmt_ty val;
7682 5 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7683 5 : Py_INCREF(tmp2);
7684 5 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7685 0 : goto failed;
7686 : }
7687 5 : res = obj2ast_stmt(state, tmp2, &val, arena);
7688 5 : _Py_LeaveRecursiveCall();
7689 5 : Py_DECREF(tmp2);
7690 5 : if (res != 0) goto failed;
7691 5 : if (len != PyList_GET_SIZE(tmp)) {
7692 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
7693 0 : goto failed;
7694 : }
7695 5 : asdl_seq_SET(finalbody, i, val);
7696 : }
7697 14 : Py_CLEAR(tmp);
7698 : }
7699 14 : *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
7700 : col_offset, end_lineno, end_col_offset, arena);
7701 14 : if (*out == NULL) goto failed;
7702 14 : return 0;
7703 : }
7704 15469 : tp = state->Assert_type;
7705 15469 : isinstance = PyObject_IsInstance(obj, tp);
7706 15469 : if (isinstance == -1) {
7707 0 : return 1;
7708 : }
7709 15469 : if (isinstance) {
7710 : expr_ty test;
7711 : expr_ty msg;
7712 :
7713 223 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
7714 223 : return 1;
7715 : }
7716 223 : if (tmp == NULL) {
7717 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
7718 0 : return 1;
7719 : }
7720 : else {
7721 : int res;
7722 223 : if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
7723 0 : goto failed;
7724 : }
7725 223 : res = obj2ast_expr(state, tmp, &test, arena);
7726 223 : _Py_LeaveRecursiveCall();
7727 223 : if (res != 0) goto failed;
7728 223 : Py_CLEAR(tmp);
7729 : }
7730 223 : if (_PyObject_LookupAttr(obj, state->msg, &tmp) < 0) {
7731 0 : return 1;
7732 : }
7733 223 : if (tmp == NULL || tmp == Py_None) {
7734 173 : Py_CLEAR(tmp);
7735 173 : msg = NULL;
7736 : }
7737 : else {
7738 : int res;
7739 50 : if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
7740 0 : goto failed;
7741 : }
7742 50 : res = obj2ast_expr(state, tmp, &msg, arena);
7743 50 : _Py_LeaveRecursiveCall();
7744 50 : if (res != 0) goto failed;
7745 50 : Py_CLEAR(tmp);
7746 : }
7747 223 : *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
7748 : end_col_offset, arena);
7749 223 : if (*out == NULL) goto failed;
7750 223 : return 0;
7751 : }
7752 15246 : tp = state->Import_type;
7753 15246 : isinstance = PyObject_IsInstance(obj, tp);
7754 15246 : if (isinstance == -1) {
7755 0 : return 1;
7756 : }
7757 15246 : if (isinstance) {
7758 : asdl_alias_seq* names;
7759 :
7760 963 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7761 0 : return 1;
7762 : }
7763 963 : if (tmp == NULL) {
7764 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
7765 0 : return 1;
7766 : }
7767 : else {
7768 : int res;
7769 : Py_ssize_t len;
7770 : Py_ssize_t i;
7771 963 : if (!PyList_Check(tmp)) {
7772 0 : PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7773 0 : goto failed;
7774 : }
7775 963 : len = PyList_GET_SIZE(tmp);
7776 963 : names = _Py_asdl_alias_seq_new(len, arena);
7777 963 : if (names == NULL) goto failed;
7778 1960 : for (i = 0; i < len; i++) {
7779 : alias_ty val;
7780 997 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7781 997 : Py_INCREF(tmp2);
7782 997 : if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
7783 0 : goto failed;
7784 : }
7785 997 : res = obj2ast_alias(state, tmp2, &val, arena);
7786 997 : _Py_LeaveRecursiveCall();
7787 997 : Py_DECREF(tmp2);
7788 997 : if (res != 0) goto failed;
7789 997 : if (len != PyList_GET_SIZE(tmp)) {
7790 0 : PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
7791 0 : goto failed;
7792 : }
7793 997 : asdl_seq_SET(names, i, val);
7794 : }
7795 963 : Py_CLEAR(tmp);
7796 : }
7797 963 : *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
7798 : end_col_offset, arena);
7799 963 : if (*out == NULL) goto failed;
7800 963 : return 0;
7801 : }
7802 14283 : tp = state->ImportFrom_type;
7803 14283 : isinstance = PyObject_IsInstance(obj, tp);
7804 14283 : if (isinstance == -1) {
7805 0 : return 1;
7806 : }
7807 14283 : if (isinstance) {
7808 : identifier module;
7809 : asdl_alias_seq* names;
7810 : int level;
7811 :
7812 370 : if (_PyObject_LookupAttr(obj, state->module, &tmp) < 0) {
7813 370 : return 1;
7814 : }
7815 370 : if (tmp == NULL || tmp == Py_None) {
7816 2 : Py_CLEAR(tmp);
7817 2 : module = NULL;
7818 : }
7819 : else {
7820 : int res;
7821 368 : if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7822 0 : goto failed;
7823 : }
7824 368 : res = obj2ast_identifier(state, tmp, &module, arena);
7825 368 : _Py_LeaveRecursiveCall();
7826 368 : if (res != 0) goto failed;
7827 368 : Py_CLEAR(tmp);
7828 : }
7829 370 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7830 0 : return 1;
7831 : }
7832 370 : if (tmp == NULL) {
7833 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
7834 0 : return 1;
7835 : }
7836 : else {
7837 : int res;
7838 : Py_ssize_t len;
7839 : Py_ssize_t i;
7840 370 : if (!PyList_Check(tmp)) {
7841 0 : PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7842 0 : goto failed;
7843 : }
7844 370 : len = PyList_GET_SIZE(tmp);
7845 370 : names = _Py_asdl_alias_seq_new(len, arena);
7846 370 : if (names == NULL) goto failed;
7847 993 : for (i = 0; i < len; i++) {
7848 : alias_ty val;
7849 623 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7850 623 : Py_INCREF(tmp2);
7851 623 : if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7852 0 : goto failed;
7853 : }
7854 623 : res = obj2ast_alias(state, tmp2, &val, arena);
7855 623 : _Py_LeaveRecursiveCall();
7856 623 : Py_DECREF(tmp2);
7857 623 : if (res != 0) goto failed;
7858 623 : if (len != PyList_GET_SIZE(tmp)) {
7859 0 : PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
7860 0 : goto failed;
7861 : }
7862 623 : asdl_seq_SET(names, i, val);
7863 : }
7864 370 : Py_CLEAR(tmp);
7865 : }
7866 370 : if (_PyObject_LookupAttr(obj, state->level, &tmp) < 0) {
7867 0 : return 1;
7868 : }
7869 370 : if (tmp == NULL || tmp == Py_None) {
7870 1 : Py_CLEAR(tmp);
7871 1 : level = 0;
7872 : }
7873 : else {
7874 : int res;
7875 369 : if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7876 0 : goto failed;
7877 : }
7878 369 : res = obj2ast_int(state, tmp, &level, arena);
7879 369 : _Py_LeaveRecursiveCall();
7880 369 : if (res != 0) goto failed;
7881 369 : Py_CLEAR(tmp);
7882 : }
7883 370 : *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
7884 : end_lineno, end_col_offset, arena);
7885 370 : if (*out == NULL) goto failed;
7886 370 : return 0;
7887 : }
7888 13913 : tp = state->Global_type;
7889 13913 : isinstance = PyObject_IsInstance(obj, tp);
7890 13913 : if (isinstance == -1) {
7891 0 : return 1;
7892 : }
7893 13913 : if (isinstance) {
7894 : asdl_identifier_seq* names;
7895 :
7896 66 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7897 0 : return 1;
7898 : }
7899 66 : if (tmp == NULL) {
7900 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
7901 0 : return 1;
7902 : }
7903 : else {
7904 : int res;
7905 : Py_ssize_t len;
7906 : Py_ssize_t i;
7907 66 : if (!PyList_Check(tmp)) {
7908 0 : PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7909 0 : goto failed;
7910 : }
7911 66 : len = PyList_GET_SIZE(tmp);
7912 66 : names = _Py_asdl_identifier_seq_new(len, arena);
7913 66 : if (names == NULL) goto failed;
7914 162 : for (i = 0; i < len; i++) {
7915 : identifier val;
7916 96 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7917 96 : Py_INCREF(tmp2);
7918 96 : if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
7919 0 : goto failed;
7920 : }
7921 96 : res = obj2ast_identifier(state, tmp2, &val, arena);
7922 96 : _Py_LeaveRecursiveCall();
7923 96 : Py_DECREF(tmp2);
7924 96 : if (res != 0) goto failed;
7925 96 : if (len != PyList_GET_SIZE(tmp)) {
7926 0 : PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
7927 0 : goto failed;
7928 : }
7929 96 : asdl_seq_SET(names, i, val);
7930 : }
7931 66 : Py_CLEAR(tmp);
7932 : }
7933 66 : *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
7934 : end_col_offset, arena);
7935 66 : if (*out == NULL) goto failed;
7936 66 : return 0;
7937 : }
7938 13847 : tp = state->Nonlocal_type;
7939 13847 : isinstance = PyObject_IsInstance(obj, tp);
7940 13847 : if (isinstance == -1) {
7941 0 : return 1;
7942 : }
7943 13847 : if (isinstance) {
7944 : asdl_identifier_seq* names;
7945 :
7946 21 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7947 0 : return 1;
7948 : }
7949 21 : if (tmp == NULL) {
7950 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
7951 0 : return 1;
7952 : }
7953 : else {
7954 : int res;
7955 : Py_ssize_t len;
7956 : Py_ssize_t i;
7957 21 : if (!PyList_Check(tmp)) {
7958 0 : PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7959 0 : goto failed;
7960 : }
7961 21 : len = PyList_GET_SIZE(tmp);
7962 21 : names = _Py_asdl_identifier_seq_new(len, arena);
7963 21 : if (names == NULL) goto failed;
7964 50 : for (i = 0; i < len; i++) {
7965 : identifier val;
7966 29 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
7967 29 : Py_INCREF(tmp2);
7968 29 : if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
7969 0 : goto failed;
7970 : }
7971 29 : res = obj2ast_identifier(state, tmp2, &val, arena);
7972 29 : _Py_LeaveRecursiveCall();
7973 29 : Py_DECREF(tmp2);
7974 29 : if (res != 0) goto failed;
7975 29 : if (len != PyList_GET_SIZE(tmp)) {
7976 0 : PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
7977 0 : goto failed;
7978 : }
7979 29 : asdl_seq_SET(names, i, val);
7980 : }
7981 21 : Py_CLEAR(tmp);
7982 : }
7983 21 : *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
7984 : end_col_offset, arena);
7985 21 : if (*out == NULL) goto failed;
7986 21 : return 0;
7987 : }
7988 13826 : tp = state->Expr_type;
7989 13826 : isinstance = PyObject_IsInstance(obj, tp);
7990 13826 : if (isinstance == -1) {
7991 0 : return 1;
7992 : }
7993 13826 : if (isinstance) {
7994 : expr_ty value;
7995 :
7996 12381 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
7997 12378 : return 1;
7998 : }
7999 12381 : if (tmp == NULL) {
8000 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
8001 0 : return 1;
8002 : }
8003 : else {
8004 : int res;
8005 12381 : if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
8006 3 : goto failed;
8007 : }
8008 12381 : res = obj2ast_expr(state, tmp, &value, arena);
8009 12381 : _Py_LeaveRecursiveCall();
8010 12381 : if (res != 0) goto failed;
8011 12378 : Py_CLEAR(tmp);
8012 : }
8013 12378 : *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
8014 : end_col_offset, arena);
8015 12378 : if (*out == NULL) goto failed;
8016 12378 : return 0;
8017 : }
8018 1445 : tp = state->Pass_type;
8019 1445 : isinstance = PyObject_IsInstance(obj, tp);
8020 1445 : if (isinstance == -1) {
8021 0 : return 1;
8022 : }
8023 1445 : if (isinstance) {
8024 :
8025 821 : *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
8026 : arena);
8027 821 : if (*out == NULL) goto failed;
8028 821 : return 0;
8029 : }
8030 624 : tp = state->Break_type;
8031 624 : isinstance = PyObject_IsInstance(obj, tp);
8032 624 : if (isinstance == -1) {
8033 0 : return 1;
8034 : }
8035 624 : if (isinstance) {
8036 :
8037 358 : *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
8038 : arena);
8039 358 : if (*out == NULL) goto failed;
8040 358 : return 0;
8041 : }
8042 266 : tp = state->Continue_type;
8043 266 : isinstance = PyObject_IsInstance(obj, tp);
8044 266 : if (isinstance == -1) {
8045 0 : return 1;
8046 : }
8047 266 : if (isinstance) {
8048 :
8049 266 : *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
8050 : arena);
8051 266 : if (*out == NULL) goto failed;
8052 266 : return 0;
8053 : }
8054 :
8055 0 : PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
8056 5 : failed:
8057 5 : Py_XDECREF(tmp);
8058 5 : return 1;
8059 : }
8060 :
8061 : int
8062 267591 : obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
8063 : arena)
8064 : {
8065 : int isinstance;
8066 :
8067 267591 : PyObject *tmp = NULL;
8068 : PyObject *tp;
8069 : int lineno;
8070 : int col_offset;
8071 : int end_lineno;
8072 : int end_col_offset;
8073 :
8074 267591 : if (obj == Py_None) {
8075 66 : *out = NULL;
8076 66 : return 0;
8077 : }
8078 267525 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
8079 0 : return 1;
8080 : }
8081 267525 : if (tmp == NULL) {
8082 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
8083 0 : return 1;
8084 : }
8085 : else {
8086 : int res;
8087 267525 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8088 2 : goto failed;
8089 : }
8090 267523 : res = obj2ast_int(state, tmp, &lineno, arena);
8091 267523 : _Py_LeaveRecursiveCall();
8092 267523 : if (res != 0) goto failed;
8093 267523 : Py_CLEAR(tmp);
8094 : }
8095 267523 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
8096 0 : return 1;
8097 : }
8098 267523 : if (tmp == NULL) {
8099 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
8100 0 : return 1;
8101 : }
8102 : else {
8103 : int res;
8104 267523 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8105 0 : goto failed;
8106 : }
8107 267523 : res = obj2ast_int(state, tmp, &col_offset, arena);
8108 267523 : _Py_LeaveRecursiveCall();
8109 267523 : if (res != 0) goto failed;
8110 267523 : Py_CLEAR(tmp);
8111 : }
8112 267523 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
8113 0 : return 1;
8114 : }
8115 267523 : if (tmp == NULL || tmp == Py_None) {
8116 85 : Py_CLEAR(tmp);
8117 85 : end_lineno = lineno;
8118 : }
8119 : else {
8120 : int res;
8121 267438 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8122 0 : goto failed;
8123 : }
8124 267438 : res = obj2ast_int(state, tmp, &end_lineno, arena);
8125 267438 : _Py_LeaveRecursiveCall();
8126 267438 : if (res != 0) goto failed;
8127 267438 : Py_CLEAR(tmp);
8128 : }
8129 267523 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
8130 0 : return 1;
8131 : }
8132 267523 : if (tmp == NULL || tmp == Py_None) {
8133 85 : Py_CLEAR(tmp);
8134 85 : end_col_offset = col_offset;
8135 : }
8136 : else {
8137 : int res;
8138 267438 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8139 0 : goto failed;
8140 : }
8141 267438 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
8142 267438 : _Py_LeaveRecursiveCall();
8143 267438 : if (res != 0) goto failed;
8144 267438 : Py_CLEAR(tmp);
8145 : }
8146 267523 : tp = state->BoolOp_type;
8147 267523 : isinstance = PyObject_IsInstance(obj, tp);
8148 267523 : if (isinstance == -1) {
8149 0 : return 1;
8150 : }
8151 267523 : if (isinstance) {
8152 : boolop_ty op;
8153 : asdl_expr_seq* values;
8154 :
8155 2065 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8156 2065 : return 1;
8157 : }
8158 2065 : if (tmp == NULL) {
8159 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
8160 0 : return 1;
8161 : }
8162 : else {
8163 : int res;
8164 2065 : if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
8165 0 : goto failed;
8166 : }
8167 2065 : res = obj2ast_boolop(state, tmp, &op, arena);
8168 2065 : _Py_LeaveRecursiveCall();
8169 2065 : if (res != 0) goto failed;
8170 2065 : Py_CLEAR(tmp);
8171 : }
8172 2065 : if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8173 0 : return 1;
8174 : }
8175 2065 : if (tmp == NULL) {
8176 0 : PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
8177 0 : return 1;
8178 : }
8179 : else {
8180 : int res;
8181 : Py_ssize_t len;
8182 : Py_ssize_t i;
8183 2065 : if (!PyList_Check(tmp)) {
8184 0 : PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8185 0 : goto failed;
8186 : }
8187 2065 : len = PyList_GET_SIZE(tmp);
8188 2065 : values = _Py_asdl_expr_seq_new(len, arena);
8189 2065 : if (values == NULL) goto failed;
8190 6460 : for (i = 0; i < len; i++) {
8191 : expr_ty val;
8192 4395 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8193 4395 : Py_INCREF(tmp2);
8194 4395 : if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
8195 0 : goto failed;
8196 : }
8197 4395 : res = obj2ast_expr(state, tmp2, &val, arena);
8198 4395 : _Py_LeaveRecursiveCall();
8199 4395 : Py_DECREF(tmp2);
8200 4395 : if (res != 0) goto failed;
8201 4395 : if (len != PyList_GET_SIZE(tmp)) {
8202 0 : PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
8203 0 : goto failed;
8204 : }
8205 4395 : asdl_seq_SET(values, i, val);
8206 : }
8207 2065 : Py_CLEAR(tmp);
8208 : }
8209 2065 : *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
8210 : end_col_offset, arena);
8211 2065 : if (*out == NULL) goto failed;
8212 2065 : return 0;
8213 : }
8214 265458 : tp = state->NamedExpr_type;
8215 265458 : isinstance = PyObject_IsInstance(obj, tp);
8216 265458 : if (isinstance == -1) {
8217 0 : return 1;
8218 : }
8219 265458 : if (isinstance) {
8220 : expr_ty target;
8221 : expr_ty value;
8222 :
8223 22 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
8224 22 : return 1;
8225 : }
8226 22 : if (tmp == NULL) {
8227 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
8228 0 : return 1;
8229 : }
8230 : else {
8231 : int res;
8232 22 : if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
8233 0 : goto failed;
8234 : }
8235 22 : res = obj2ast_expr(state, tmp, &target, arena);
8236 22 : _Py_LeaveRecursiveCall();
8237 22 : if (res != 0) goto failed;
8238 22 : Py_CLEAR(tmp);
8239 : }
8240 22 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8241 0 : return 1;
8242 : }
8243 22 : if (tmp == NULL) {
8244 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
8245 0 : return 1;
8246 : }
8247 : else {
8248 : int res;
8249 22 : if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
8250 0 : goto failed;
8251 : }
8252 22 : res = obj2ast_expr(state, tmp, &value, arena);
8253 22 : _Py_LeaveRecursiveCall();
8254 22 : if (res != 0) goto failed;
8255 22 : Py_CLEAR(tmp);
8256 : }
8257 22 : *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
8258 : end_col_offset, arena);
8259 22 : if (*out == NULL) goto failed;
8260 22 : return 0;
8261 : }
8262 265436 : tp = state->BinOp_type;
8263 265436 : isinstance = PyObject_IsInstance(obj, tp);
8264 265436 : if (isinstance == -1) {
8265 0 : return 1;
8266 : }
8267 265436 : if (isinstance) {
8268 : expr_ty left;
8269 : operator_ty op;
8270 : expr_ty right;
8271 :
8272 6632 : if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
8273 6632 : return 1;
8274 : }
8275 6632 : if (tmp == NULL) {
8276 0 : PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
8277 0 : return 1;
8278 : }
8279 : else {
8280 : int res;
8281 6632 : if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8282 0 : goto failed;
8283 : }
8284 6632 : res = obj2ast_expr(state, tmp, &left, arena);
8285 6632 : _Py_LeaveRecursiveCall();
8286 6632 : if (res != 0) goto failed;
8287 6632 : Py_CLEAR(tmp);
8288 : }
8289 6632 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8290 0 : return 1;
8291 : }
8292 6632 : if (tmp == NULL) {
8293 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
8294 0 : return 1;
8295 : }
8296 : else {
8297 : int res;
8298 6632 : if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8299 0 : goto failed;
8300 : }
8301 6632 : res = obj2ast_operator(state, tmp, &op, arena);
8302 6632 : _Py_LeaveRecursiveCall();
8303 6632 : if (res != 0) goto failed;
8304 6632 : Py_CLEAR(tmp);
8305 : }
8306 6632 : if (_PyObject_LookupAttr(obj, state->right, &tmp) < 0) {
8307 0 : return 1;
8308 : }
8309 6632 : if (tmp == NULL) {
8310 0 : PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
8311 0 : return 1;
8312 : }
8313 : else {
8314 : int res;
8315 6632 : if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8316 0 : goto failed;
8317 : }
8318 6632 : res = obj2ast_expr(state, tmp, &right, arena);
8319 6632 : _Py_LeaveRecursiveCall();
8320 6632 : if (res != 0) goto failed;
8321 6632 : Py_CLEAR(tmp);
8322 : }
8323 6632 : *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
8324 : end_col_offset, arena);
8325 6632 : if (*out == NULL) goto failed;
8326 6632 : return 0;
8327 : }
8328 258804 : tp = state->UnaryOp_type;
8329 258804 : isinstance = PyObject_IsInstance(obj, tp);
8330 258804 : if (isinstance == -1) {
8331 0 : return 1;
8332 : }
8333 258804 : if (isinstance) {
8334 : unaryop_ty op;
8335 : expr_ty operand;
8336 :
8337 3086 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8338 3002 : return 1;
8339 : }
8340 3086 : if (tmp == NULL) {
8341 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
8342 0 : return 1;
8343 : }
8344 : else {
8345 : int res;
8346 3086 : if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
8347 84 : goto failed;
8348 : }
8349 3086 : res = obj2ast_unaryop(state, tmp, &op, arena);
8350 3086 : _Py_LeaveRecursiveCall();
8351 3086 : if (res != 0) goto failed;
8352 3086 : Py_CLEAR(tmp);
8353 : }
8354 3086 : if (_PyObject_LookupAttr(obj, state->operand, &tmp) < 0) {
8355 0 : return 1;
8356 : }
8357 3086 : if (tmp == NULL) {
8358 0 : PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
8359 0 : return 1;
8360 : }
8361 : else {
8362 : int res;
8363 3086 : if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
8364 0 : goto failed;
8365 : }
8366 3086 : res = obj2ast_expr(state, tmp, &operand, arena);
8367 3086 : _Py_LeaveRecursiveCall();
8368 3086 : if (res != 0) goto failed;
8369 3002 : Py_CLEAR(tmp);
8370 : }
8371 3002 : *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
8372 : end_col_offset, arena);
8373 3002 : if (*out == NULL) goto failed;
8374 3002 : return 0;
8375 : }
8376 255718 : tp = state->Lambda_type;
8377 255718 : isinstance = PyObject_IsInstance(obj, tp);
8378 255718 : if (isinstance == -1) {
8379 0 : return 1;
8380 : }
8381 255718 : if (isinstance) {
8382 : arguments_ty args;
8383 : expr_ty body;
8384 :
8385 168 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
8386 168 : return 1;
8387 : }
8388 168 : if (tmp == NULL) {
8389 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
8390 0 : return 1;
8391 : }
8392 : else {
8393 : int res;
8394 168 : if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
8395 0 : goto failed;
8396 : }
8397 168 : res = obj2ast_arguments(state, tmp, &args, arena);
8398 168 : _Py_LeaveRecursiveCall();
8399 168 : if (res != 0) goto failed;
8400 168 : Py_CLEAR(tmp);
8401 : }
8402 168 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8403 0 : return 1;
8404 : }
8405 168 : if (tmp == NULL) {
8406 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
8407 0 : return 1;
8408 : }
8409 : else {
8410 : int res;
8411 168 : if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
8412 0 : goto failed;
8413 : }
8414 168 : res = obj2ast_expr(state, tmp, &body, arena);
8415 168 : _Py_LeaveRecursiveCall();
8416 168 : if (res != 0) goto failed;
8417 168 : Py_CLEAR(tmp);
8418 : }
8419 168 : *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
8420 : end_col_offset, arena);
8421 168 : if (*out == NULL) goto failed;
8422 168 : return 0;
8423 : }
8424 255550 : tp = state->IfExp_type;
8425 255550 : isinstance = PyObject_IsInstance(obj, tp);
8426 255550 : if (isinstance == -1) {
8427 0 : return 1;
8428 : }
8429 255550 : if (isinstance) {
8430 : expr_ty test;
8431 : expr_ty body;
8432 : expr_ty orelse;
8433 :
8434 238 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
8435 238 : return 1;
8436 : }
8437 238 : if (tmp == NULL) {
8438 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
8439 0 : return 1;
8440 : }
8441 : else {
8442 : int res;
8443 238 : if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8444 0 : goto failed;
8445 : }
8446 238 : res = obj2ast_expr(state, tmp, &test, arena);
8447 238 : _Py_LeaveRecursiveCall();
8448 238 : if (res != 0) goto failed;
8449 238 : Py_CLEAR(tmp);
8450 : }
8451 238 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8452 0 : return 1;
8453 : }
8454 238 : if (tmp == NULL) {
8455 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
8456 0 : return 1;
8457 : }
8458 : else {
8459 : int res;
8460 238 : if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8461 0 : goto failed;
8462 : }
8463 238 : res = obj2ast_expr(state, tmp, &body, arena);
8464 238 : _Py_LeaveRecursiveCall();
8465 238 : if (res != 0) goto failed;
8466 238 : Py_CLEAR(tmp);
8467 : }
8468 238 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
8469 0 : return 1;
8470 : }
8471 238 : if (tmp == NULL) {
8472 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
8473 0 : return 1;
8474 : }
8475 : else {
8476 : int res;
8477 238 : if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8478 0 : goto failed;
8479 : }
8480 238 : res = obj2ast_expr(state, tmp, &orelse, arena);
8481 238 : _Py_LeaveRecursiveCall();
8482 238 : if (res != 0) goto failed;
8483 238 : Py_CLEAR(tmp);
8484 : }
8485 238 : *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
8486 : end_col_offset, arena);
8487 238 : if (*out == NULL) goto failed;
8488 238 : return 0;
8489 : }
8490 255312 : tp = state->Dict_type;
8491 255312 : isinstance = PyObject_IsInstance(obj, tp);
8492 255312 : if (isinstance == -1) {
8493 0 : return 1;
8494 : }
8495 255312 : if (isinstance) {
8496 : asdl_expr_seq* keys;
8497 : asdl_expr_seq* values;
8498 :
8499 625 : if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
8500 0 : return 1;
8501 : }
8502 625 : if (tmp == NULL) {
8503 0 : PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
8504 0 : return 1;
8505 : }
8506 : else {
8507 : int res;
8508 : Py_ssize_t len;
8509 : Py_ssize_t i;
8510 625 : if (!PyList_Check(tmp)) {
8511 0 : PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8512 0 : goto failed;
8513 : }
8514 625 : len = PyList_GET_SIZE(tmp);
8515 625 : keys = _Py_asdl_expr_seq_new(len, arena);
8516 625 : if (keys == NULL) goto failed;
8517 3353 : for (i = 0; i < len; i++) {
8518 : expr_ty val;
8519 2728 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8520 2728 : Py_INCREF(tmp2);
8521 2728 : if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
8522 0 : goto failed;
8523 : }
8524 2728 : res = obj2ast_expr(state, tmp2, &val, arena);
8525 2728 : _Py_LeaveRecursiveCall();
8526 2728 : Py_DECREF(tmp2);
8527 2728 : if (res != 0) goto failed;
8528 2728 : if (len != PyList_GET_SIZE(tmp)) {
8529 0 : PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
8530 0 : goto failed;
8531 : }
8532 2728 : asdl_seq_SET(keys, i, val);
8533 : }
8534 625 : Py_CLEAR(tmp);
8535 : }
8536 625 : if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8537 0 : return 1;
8538 : }
8539 625 : if (tmp == NULL) {
8540 0 : PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
8541 0 : return 1;
8542 : }
8543 : else {
8544 : int res;
8545 : Py_ssize_t len;
8546 : Py_ssize_t i;
8547 625 : if (!PyList_Check(tmp)) {
8548 0 : PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8549 0 : goto failed;
8550 : }
8551 625 : len = PyList_GET_SIZE(tmp);
8552 625 : values = _Py_asdl_expr_seq_new(len, arena);
8553 625 : if (values == NULL) goto failed;
8554 3354 : for (i = 0; i < len; i++) {
8555 : expr_ty val;
8556 2729 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8557 2729 : Py_INCREF(tmp2);
8558 2729 : if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
8559 0 : goto failed;
8560 : }
8561 2729 : res = obj2ast_expr(state, tmp2, &val, arena);
8562 2729 : _Py_LeaveRecursiveCall();
8563 2729 : Py_DECREF(tmp2);
8564 2729 : if (res != 0) goto failed;
8565 2729 : if (len != PyList_GET_SIZE(tmp)) {
8566 0 : PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
8567 0 : goto failed;
8568 : }
8569 2729 : asdl_seq_SET(values, i, val);
8570 : }
8571 625 : Py_CLEAR(tmp);
8572 : }
8573 625 : *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
8574 : end_col_offset, arena);
8575 625 : if (*out == NULL) goto failed;
8576 625 : return 0;
8577 : }
8578 254687 : tp = state->Set_type;
8579 254687 : isinstance = PyObject_IsInstance(obj, tp);
8580 254687 : if (isinstance == -1) {
8581 0 : return 1;
8582 : }
8583 254687 : if (isinstance) {
8584 : asdl_expr_seq* elts;
8585 :
8586 114 : if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
8587 0 : return 1;
8588 : }
8589 114 : if (tmp == NULL) {
8590 0 : PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
8591 0 : return 1;
8592 : }
8593 : else {
8594 : int res;
8595 : Py_ssize_t len;
8596 : Py_ssize_t i;
8597 114 : if (!PyList_Check(tmp)) {
8598 0 : PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8599 0 : goto failed;
8600 : }
8601 114 : len = PyList_GET_SIZE(tmp);
8602 114 : elts = _Py_asdl_expr_seq_new(len, arena);
8603 114 : if (elts == NULL) goto failed;
8604 411 : for (i = 0; i < len; i++) {
8605 : expr_ty val;
8606 297 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8607 297 : Py_INCREF(tmp2);
8608 297 : if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
8609 0 : goto failed;
8610 : }
8611 297 : res = obj2ast_expr(state, tmp2, &val, arena);
8612 297 : _Py_LeaveRecursiveCall();
8613 297 : Py_DECREF(tmp2);
8614 297 : if (res != 0) goto failed;
8615 297 : if (len != PyList_GET_SIZE(tmp)) {
8616 0 : PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
8617 0 : goto failed;
8618 : }
8619 297 : asdl_seq_SET(elts, i, val);
8620 : }
8621 114 : Py_CLEAR(tmp);
8622 : }
8623 114 : *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
8624 : arena);
8625 114 : if (*out == NULL) goto failed;
8626 114 : return 0;
8627 : }
8628 254573 : tp = state->ListComp_type;
8629 254573 : isinstance = PyObject_IsInstance(obj, tp);
8630 254573 : if (isinstance == -1) {
8631 0 : return 1;
8632 : }
8633 254573 : if (isinstance) {
8634 : expr_ty elt;
8635 : asdl_comprehension_seq* generators;
8636 :
8637 320 : if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8638 320 : return 1;
8639 : }
8640 320 : if (tmp == NULL) {
8641 0 : PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
8642 0 : return 1;
8643 : }
8644 : else {
8645 : int res;
8646 320 : if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
8647 0 : goto failed;
8648 : }
8649 320 : res = obj2ast_expr(state, tmp, &elt, arena);
8650 320 : _Py_LeaveRecursiveCall();
8651 320 : if (res != 0) goto failed;
8652 320 : Py_CLEAR(tmp);
8653 : }
8654 320 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8655 0 : return 1;
8656 : }
8657 320 : if (tmp == NULL) {
8658 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
8659 0 : return 1;
8660 : }
8661 : else {
8662 : int res;
8663 : Py_ssize_t len;
8664 : Py_ssize_t i;
8665 320 : if (!PyList_Check(tmp)) {
8666 0 : PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8667 0 : goto failed;
8668 : }
8669 320 : len = PyList_GET_SIZE(tmp);
8670 320 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8671 320 : if (generators == NULL) goto failed;
8672 656 : for (i = 0; i < len; i++) {
8673 : comprehension_ty val;
8674 336 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8675 336 : Py_INCREF(tmp2);
8676 336 : if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
8677 0 : goto failed;
8678 : }
8679 336 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8680 336 : _Py_LeaveRecursiveCall();
8681 336 : Py_DECREF(tmp2);
8682 336 : if (res != 0) goto failed;
8683 336 : if (len != PyList_GET_SIZE(tmp)) {
8684 0 : PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
8685 0 : goto failed;
8686 : }
8687 336 : asdl_seq_SET(generators, i, val);
8688 : }
8689 320 : Py_CLEAR(tmp);
8690 : }
8691 320 : *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
8692 : end_col_offset, arena);
8693 320 : if (*out == NULL) goto failed;
8694 320 : return 0;
8695 : }
8696 254253 : tp = state->SetComp_type;
8697 254253 : isinstance = PyObject_IsInstance(obj, tp);
8698 254253 : if (isinstance == -1) {
8699 0 : return 1;
8700 : }
8701 254253 : if (isinstance) {
8702 : expr_ty elt;
8703 : asdl_comprehension_seq* generators;
8704 :
8705 23 : if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8706 23 : return 1;
8707 : }
8708 23 : if (tmp == NULL) {
8709 0 : PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
8710 0 : return 1;
8711 : }
8712 : else {
8713 : int res;
8714 23 : if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
8715 0 : goto failed;
8716 : }
8717 23 : res = obj2ast_expr(state, tmp, &elt, arena);
8718 23 : _Py_LeaveRecursiveCall();
8719 23 : if (res != 0) goto failed;
8720 23 : Py_CLEAR(tmp);
8721 : }
8722 23 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8723 0 : return 1;
8724 : }
8725 23 : if (tmp == NULL) {
8726 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
8727 0 : return 1;
8728 : }
8729 : else {
8730 : int res;
8731 : Py_ssize_t len;
8732 : Py_ssize_t i;
8733 23 : if (!PyList_Check(tmp)) {
8734 0 : PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8735 0 : goto failed;
8736 : }
8737 23 : len = PyList_GET_SIZE(tmp);
8738 23 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8739 23 : if (generators == NULL) goto failed;
8740 45 : for (i = 0; i < len; i++) {
8741 : comprehension_ty val;
8742 22 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8743 22 : Py_INCREF(tmp2);
8744 22 : if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
8745 0 : goto failed;
8746 : }
8747 22 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8748 22 : _Py_LeaveRecursiveCall();
8749 22 : Py_DECREF(tmp2);
8750 22 : if (res != 0) goto failed;
8751 22 : if (len != PyList_GET_SIZE(tmp)) {
8752 0 : PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
8753 0 : goto failed;
8754 : }
8755 22 : asdl_seq_SET(generators, i, val);
8756 : }
8757 23 : Py_CLEAR(tmp);
8758 : }
8759 23 : *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
8760 : end_col_offset, arena);
8761 23 : if (*out == NULL) goto failed;
8762 23 : return 0;
8763 : }
8764 254230 : tp = state->DictComp_type;
8765 254230 : isinstance = PyObject_IsInstance(obj, tp);
8766 254230 : if (isinstance == -1) {
8767 0 : return 1;
8768 : }
8769 254230 : if (isinstance) {
8770 : expr_ty key;
8771 : expr_ty value;
8772 : asdl_comprehension_seq* generators;
8773 :
8774 37 : if (_PyObject_LookupAttr(obj, state->key, &tmp) < 0) {
8775 37 : return 1;
8776 : }
8777 37 : if (tmp == NULL) {
8778 0 : PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
8779 0 : return 1;
8780 : }
8781 : else {
8782 : int res;
8783 37 : if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8784 0 : goto failed;
8785 : }
8786 37 : res = obj2ast_expr(state, tmp, &key, arena);
8787 37 : _Py_LeaveRecursiveCall();
8788 37 : if (res != 0) goto failed;
8789 37 : Py_CLEAR(tmp);
8790 : }
8791 37 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8792 0 : return 1;
8793 : }
8794 37 : if (tmp == NULL) {
8795 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
8796 0 : return 1;
8797 : }
8798 : else {
8799 : int res;
8800 37 : if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8801 0 : goto failed;
8802 : }
8803 37 : res = obj2ast_expr(state, tmp, &value, arena);
8804 37 : _Py_LeaveRecursiveCall();
8805 37 : if (res != 0) goto failed;
8806 37 : Py_CLEAR(tmp);
8807 : }
8808 37 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8809 0 : return 1;
8810 : }
8811 37 : if (tmp == NULL) {
8812 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
8813 0 : return 1;
8814 : }
8815 : else {
8816 : int res;
8817 : Py_ssize_t len;
8818 : Py_ssize_t i;
8819 37 : if (!PyList_Check(tmp)) {
8820 0 : PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8821 0 : goto failed;
8822 : }
8823 37 : len = PyList_GET_SIZE(tmp);
8824 37 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8825 37 : if (generators == NULL) goto failed;
8826 77 : for (i = 0; i < len; i++) {
8827 : comprehension_ty val;
8828 40 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8829 40 : Py_INCREF(tmp2);
8830 40 : if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8831 0 : goto failed;
8832 : }
8833 40 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8834 40 : _Py_LeaveRecursiveCall();
8835 40 : Py_DECREF(tmp2);
8836 40 : if (res != 0) goto failed;
8837 40 : if (len != PyList_GET_SIZE(tmp)) {
8838 0 : PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
8839 0 : goto failed;
8840 : }
8841 40 : asdl_seq_SET(generators, i, val);
8842 : }
8843 37 : Py_CLEAR(tmp);
8844 : }
8845 37 : *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
8846 : end_lineno, end_col_offset, arena);
8847 37 : if (*out == NULL) goto failed;
8848 37 : return 0;
8849 : }
8850 254193 : tp = state->GeneratorExp_type;
8851 254193 : isinstance = PyObject_IsInstance(obj, tp);
8852 254193 : if (isinstance == -1) {
8853 0 : return 1;
8854 : }
8855 254193 : if (isinstance) {
8856 : expr_ty elt;
8857 : asdl_comprehension_seq* generators;
8858 :
8859 232 : if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8860 232 : return 1;
8861 : }
8862 232 : if (tmp == NULL) {
8863 0 : PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
8864 0 : return 1;
8865 : }
8866 : else {
8867 : int res;
8868 232 : if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
8869 0 : goto failed;
8870 : }
8871 232 : res = obj2ast_expr(state, tmp, &elt, arena);
8872 232 : _Py_LeaveRecursiveCall();
8873 232 : if (res != 0) goto failed;
8874 232 : Py_CLEAR(tmp);
8875 : }
8876 232 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8877 0 : return 1;
8878 : }
8879 232 : if (tmp == NULL) {
8880 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
8881 0 : return 1;
8882 : }
8883 : else {
8884 : int res;
8885 : Py_ssize_t len;
8886 : Py_ssize_t i;
8887 232 : if (!PyList_Check(tmp)) {
8888 0 : PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8889 0 : goto failed;
8890 : }
8891 232 : len = PyList_GET_SIZE(tmp);
8892 232 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8893 232 : if (generators == NULL) goto failed;
8894 469 : for (i = 0; i < len; i++) {
8895 : comprehension_ty val;
8896 237 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
8897 237 : Py_INCREF(tmp2);
8898 237 : if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
8899 0 : goto failed;
8900 : }
8901 237 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8902 237 : _Py_LeaveRecursiveCall();
8903 237 : Py_DECREF(tmp2);
8904 237 : if (res != 0) goto failed;
8905 237 : if (len != PyList_GET_SIZE(tmp)) {
8906 0 : PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
8907 0 : goto failed;
8908 : }
8909 237 : asdl_seq_SET(generators, i, val);
8910 : }
8911 232 : Py_CLEAR(tmp);
8912 : }
8913 232 : *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
8914 : end_lineno, end_col_offset, arena);
8915 232 : if (*out == NULL) goto failed;
8916 232 : return 0;
8917 : }
8918 253961 : tp = state->Await_type;
8919 253961 : isinstance = PyObject_IsInstance(obj, tp);
8920 253961 : if (isinstance == -1) {
8921 0 : return 1;
8922 : }
8923 253961 : if (isinstance) {
8924 : expr_ty value;
8925 :
8926 14 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8927 14 : return 1;
8928 : }
8929 14 : if (tmp == NULL) {
8930 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
8931 0 : return 1;
8932 : }
8933 : else {
8934 : int res;
8935 14 : if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
8936 0 : goto failed;
8937 : }
8938 14 : res = obj2ast_expr(state, tmp, &value, arena);
8939 14 : _Py_LeaveRecursiveCall();
8940 14 : if (res != 0) goto failed;
8941 14 : Py_CLEAR(tmp);
8942 : }
8943 14 : *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
8944 : end_col_offset, arena);
8945 14 : if (*out == NULL) goto failed;
8946 14 : return 0;
8947 : }
8948 253947 : tp = state->Yield_type;
8949 253947 : isinstance = PyObject_IsInstance(obj, tp);
8950 253947 : if (isinstance == -1) {
8951 0 : return 1;
8952 : }
8953 253947 : if (isinstance) {
8954 : expr_ty value;
8955 :
8956 210 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8957 210 : return 1;
8958 : }
8959 210 : if (tmp == NULL || tmp == Py_None) {
8960 7 : Py_CLEAR(tmp);
8961 7 : value = NULL;
8962 : }
8963 : else {
8964 : int res;
8965 203 : if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
8966 0 : goto failed;
8967 : }
8968 203 : res = obj2ast_expr(state, tmp, &value, arena);
8969 203 : _Py_LeaveRecursiveCall();
8970 203 : if (res != 0) goto failed;
8971 203 : Py_CLEAR(tmp);
8972 : }
8973 210 : *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
8974 : end_col_offset, arena);
8975 210 : if (*out == NULL) goto failed;
8976 210 : return 0;
8977 : }
8978 253737 : tp = state->YieldFrom_type;
8979 253737 : isinstance = PyObject_IsInstance(obj, tp);
8980 253737 : if (isinstance == -1) {
8981 0 : return 1;
8982 : }
8983 253737 : if (isinstance) {
8984 : expr_ty value;
8985 :
8986 52 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8987 51 : return 1;
8988 : }
8989 52 : if (tmp == NULL) {
8990 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
8991 0 : return 1;
8992 : }
8993 : else {
8994 : int res;
8995 52 : if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
8996 1 : goto failed;
8997 : }
8998 52 : res = obj2ast_expr(state, tmp, &value, arena);
8999 52 : _Py_LeaveRecursiveCall();
9000 52 : if (res != 0) goto failed;
9001 52 : Py_CLEAR(tmp);
9002 : }
9003 52 : *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
9004 : end_col_offset, arena);
9005 52 : if (*out == NULL) goto failed;
9006 51 : return 0;
9007 : }
9008 253685 : tp = state->Compare_type;
9009 253685 : isinstance = PyObject_IsInstance(obj, tp);
9010 253685 : if (isinstance == -1) {
9011 0 : return 1;
9012 : }
9013 253685 : if (isinstance) {
9014 : expr_ty left;
9015 : asdl_int_seq* ops;
9016 : asdl_expr_seq* comparators;
9017 :
9018 8179 : if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
9019 8179 : return 1;
9020 : }
9021 8179 : if (tmp == NULL) {
9022 0 : PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
9023 0 : return 1;
9024 : }
9025 : else {
9026 : int res;
9027 8179 : if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9028 0 : goto failed;
9029 : }
9030 8179 : res = obj2ast_expr(state, tmp, &left, arena);
9031 8179 : _Py_LeaveRecursiveCall();
9032 8179 : if (res != 0) goto failed;
9033 8179 : Py_CLEAR(tmp);
9034 : }
9035 8179 : if (_PyObject_LookupAttr(obj, state->ops, &tmp) < 0) {
9036 0 : return 1;
9037 : }
9038 8179 : if (tmp == NULL) {
9039 0 : PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
9040 0 : return 1;
9041 : }
9042 : else {
9043 : int res;
9044 : Py_ssize_t len;
9045 : Py_ssize_t i;
9046 8179 : if (!PyList_Check(tmp)) {
9047 0 : PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9048 0 : goto failed;
9049 : }
9050 8179 : len = PyList_GET_SIZE(tmp);
9051 8179 : ops = _Py_asdl_int_seq_new(len, arena);
9052 8179 : if (ops == NULL) goto failed;
9053 16494 : for (i = 0; i < len; i++) {
9054 : cmpop_ty val;
9055 8315 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9056 8315 : Py_INCREF(tmp2);
9057 8315 : if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9058 0 : goto failed;
9059 : }
9060 8315 : res = obj2ast_cmpop(state, tmp2, &val, arena);
9061 8315 : _Py_LeaveRecursiveCall();
9062 8315 : Py_DECREF(tmp2);
9063 8315 : if (res != 0) goto failed;
9064 8315 : if (len != PyList_GET_SIZE(tmp)) {
9065 0 : PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
9066 0 : goto failed;
9067 : }
9068 8315 : asdl_seq_SET(ops, i, val);
9069 : }
9070 8179 : Py_CLEAR(tmp);
9071 : }
9072 8179 : if (_PyObject_LookupAttr(obj, state->comparators, &tmp) < 0) {
9073 0 : return 1;
9074 : }
9075 8179 : if (tmp == NULL) {
9076 0 : PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
9077 0 : return 1;
9078 : }
9079 : else {
9080 : int res;
9081 : Py_ssize_t len;
9082 : Py_ssize_t i;
9083 8179 : if (!PyList_Check(tmp)) {
9084 0 : PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9085 0 : goto failed;
9086 : }
9087 8179 : len = PyList_GET_SIZE(tmp);
9088 8179 : comparators = _Py_asdl_expr_seq_new(len, arena);
9089 8179 : if (comparators == NULL) goto failed;
9090 16494 : for (i = 0; i < len; i++) {
9091 : expr_ty val;
9092 8315 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9093 8315 : Py_INCREF(tmp2);
9094 8315 : if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9095 0 : goto failed;
9096 : }
9097 8315 : res = obj2ast_expr(state, tmp2, &val, arena);
9098 8315 : _Py_LeaveRecursiveCall();
9099 8315 : Py_DECREF(tmp2);
9100 8315 : if (res != 0) goto failed;
9101 8315 : if (len != PyList_GET_SIZE(tmp)) {
9102 0 : PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
9103 0 : goto failed;
9104 : }
9105 8315 : asdl_seq_SET(comparators, i, val);
9106 : }
9107 8179 : Py_CLEAR(tmp);
9108 : }
9109 8179 : *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
9110 : end_lineno, end_col_offset, arena);
9111 8179 : if (*out == NULL) goto failed;
9112 8179 : return 0;
9113 : }
9114 245506 : tp = state->Call_type;
9115 245506 : isinstance = PyObject_IsInstance(obj, tp);
9116 245506 : if (isinstance == -1) {
9117 0 : return 1;
9118 : }
9119 245506 : if (isinstance) {
9120 : expr_ty func;
9121 : asdl_expr_seq* args;
9122 : asdl_keyword_seq* keywords;
9123 :
9124 30116 : if (_PyObject_LookupAttr(obj, state->func, &tmp) < 0) {
9125 30116 : return 1;
9126 : }
9127 30116 : if (tmp == NULL) {
9128 0 : PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
9129 0 : return 1;
9130 : }
9131 : else {
9132 : int res;
9133 30116 : if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9134 0 : goto failed;
9135 : }
9136 30116 : res = obj2ast_expr(state, tmp, &func, arena);
9137 30116 : _Py_LeaveRecursiveCall();
9138 30116 : if (res != 0) goto failed;
9139 30116 : Py_CLEAR(tmp);
9140 : }
9141 30116 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
9142 0 : return 1;
9143 : }
9144 30116 : if (tmp == NULL) {
9145 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
9146 0 : return 1;
9147 : }
9148 : else {
9149 : int res;
9150 : Py_ssize_t len;
9151 : Py_ssize_t i;
9152 30116 : if (!PyList_Check(tmp)) {
9153 0 : PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9154 0 : goto failed;
9155 : }
9156 30116 : len = PyList_GET_SIZE(tmp);
9157 30116 : args = _Py_asdl_expr_seq_new(len, arena);
9158 30116 : if (args == NULL) goto failed;
9159 67078 : for (i = 0; i < len; i++) {
9160 : expr_ty val;
9161 36962 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9162 36962 : Py_INCREF(tmp2);
9163 36962 : if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9164 0 : goto failed;
9165 : }
9166 36962 : res = obj2ast_expr(state, tmp2, &val, arena);
9167 36962 : _Py_LeaveRecursiveCall();
9168 36962 : Py_DECREF(tmp2);
9169 36962 : if (res != 0) goto failed;
9170 36962 : if (len != PyList_GET_SIZE(tmp)) {
9171 0 : PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
9172 0 : goto failed;
9173 : }
9174 36962 : asdl_seq_SET(args, i, val);
9175 : }
9176 30116 : Py_CLEAR(tmp);
9177 : }
9178 30116 : if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
9179 0 : return 1;
9180 : }
9181 30116 : if (tmp == NULL) {
9182 0 : PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
9183 0 : return 1;
9184 : }
9185 : else {
9186 : int res;
9187 : Py_ssize_t len;
9188 : Py_ssize_t i;
9189 30116 : if (!PyList_Check(tmp)) {
9190 0 : PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9191 0 : goto failed;
9192 : }
9193 30116 : len = PyList_GET_SIZE(tmp);
9194 30116 : keywords = _Py_asdl_keyword_seq_new(len, arena);
9195 30116 : if (keywords == NULL) goto failed;
9196 33381 : for (i = 0; i < len; i++) {
9197 : keyword_ty val;
9198 3265 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9199 3265 : Py_INCREF(tmp2);
9200 3265 : if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9201 0 : goto failed;
9202 : }
9203 3265 : res = obj2ast_keyword(state, tmp2, &val, arena);
9204 3265 : _Py_LeaveRecursiveCall();
9205 3265 : Py_DECREF(tmp2);
9206 3265 : if (res != 0) goto failed;
9207 3265 : if (len != PyList_GET_SIZE(tmp)) {
9208 0 : PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
9209 0 : goto failed;
9210 : }
9211 3265 : asdl_seq_SET(keywords, i, val);
9212 : }
9213 30116 : Py_CLEAR(tmp);
9214 : }
9215 30116 : *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
9216 : end_lineno, end_col_offset, arena);
9217 30116 : if (*out == NULL) goto failed;
9218 30116 : return 0;
9219 : }
9220 215390 : tp = state->FormattedValue_type;
9221 215390 : isinstance = PyObject_IsInstance(obj, tp);
9222 215390 : if (isinstance == -1) {
9223 0 : return 1;
9224 : }
9225 215390 : if (isinstance) {
9226 : expr_ty value;
9227 : int conversion;
9228 : expr_ty format_spec;
9229 :
9230 555 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9231 555 : return 1;
9232 : }
9233 555 : if (tmp == NULL) {
9234 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
9235 0 : return 1;
9236 : }
9237 : else {
9238 : int res;
9239 555 : if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9240 0 : goto failed;
9241 : }
9242 555 : res = obj2ast_expr(state, tmp, &value, arena);
9243 555 : _Py_LeaveRecursiveCall();
9244 555 : if (res != 0) goto failed;
9245 555 : Py_CLEAR(tmp);
9246 : }
9247 555 : if (_PyObject_LookupAttr(obj, state->conversion, &tmp) < 0) {
9248 0 : return 1;
9249 : }
9250 555 : if (tmp == NULL) {
9251 0 : PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
9252 0 : return 1;
9253 : }
9254 : else {
9255 : int res;
9256 555 : if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9257 0 : goto failed;
9258 : }
9259 555 : res = obj2ast_int(state, tmp, &conversion, arena);
9260 555 : _Py_LeaveRecursiveCall();
9261 555 : if (res != 0) goto failed;
9262 555 : Py_CLEAR(tmp);
9263 : }
9264 555 : if (_PyObject_LookupAttr(obj, state->format_spec, &tmp) < 0) {
9265 0 : return 1;
9266 : }
9267 555 : if (tmp == NULL || tmp == Py_None) {
9268 536 : Py_CLEAR(tmp);
9269 536 : format_spec = NULL;
9270 : }
9271 : else {
9272 : int res;
9273 19 : if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9274 0 : goto failed;
9275 : }
9276 19 : res = obj2ast_expr(state, tmp, &format_spec, arena);
9277 19 : _Py_LeaveRecursiveCall();
9278 19 : if (res != 0) goto failed;
9279 19 : Py_CLEAR(tmp);
9280 : }
9281 555 : *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
9282 : col_offset, end_lineno, end_col_offset,
9283 : arena);
9284 555 : if (*out == NULL) goto failed;
9285 555 : return 0;
9286 : }
9287 214835 : tp = state->JoinedStr_type;
9288 214835 : isinstance = PyObject_IsInstance(obj, tp);
9289 214835 : if (isinstance == -1) {
9290 0 : return 1;
9291 : }
9292 214835 : if (isinstance) {
9293 : asdl_expr_seq* values;
9294 :
9295 391 : if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
9296 0 : return 1;
9297 : }
9298 391 : if (tmp == NULL) {
9299 0 : PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
9300 0 : return 1;
9301 : }
9302 : else {
9303 : int res;
9304 : Py_ssize_t len;
9305 : Py_ssize_t i;
9306 391 : if (!PyList_Check(tmp)) {
9307 0 : PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9308 0 : goto failed;
9309 : }
9310 391 : len = PyList_GET_SIZE(tmp);
9311 391 : values = _Py_asdl_expr_seq_new(len, arena);
9312 391 : if (values == NULL) goto failed;
9313 1582 : for (i = 0; i < len; i++) {
9314 : expr_ty val;
9315 1191 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9316 1191 : Py_INCREF(tmp2);
9317 1191 : if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
9318 0 : goto failed;
9319 : }
9320 1191 : res = obj2ast_expr(state, tmp2, &val, arena);
9321 1191 : _Py_LeaveRecursiveCall();
9322 1191 : Py_DECREF(tmp2);
9323 1191 : if (res != 0) goto failed;
9324 1191 : if (len != PyList_GET_SIZE(tmp)) {
9325 0 : PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
9326 0 : goto failed;
9327 : }
9328 1191 : asdl_seq_SET(values, i, val);
9329 : }
9330 391 : Py_CLEAR(tmp);
9331 : }
9332 391 : *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
9333 : end_col_offset, arena);
9334 391 : if (*out == NULL) goto failed;
9335 391 : return 0;
9336 : }
9337 214444 : tp = state->Constant_type;
9338 214444 : isinstance = PyObject_IsInstance(obj, tp);
9339 214444 : if (isinstance == -1) {
9340 0 : return 1;
9341 : }
9342 214444 : if (isinstance) {
9343 : constant value;
9344 : string kind;
9345 :
9346 46668 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9347 46668 : return 1;
9348 : }
9349 46668 : if (tmp == NULL) {
9350 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
9351 0 : return 1;
9352 : }
9353 : else {
9354 : int res;
9355 46668 : if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
9356 0 : goto failed;
9357 : }
9358 46668 : res = obj2ast_constant(state, tmp, &value, arena);
9359 46668 : _Py_LeaveRecursiveCall();
9360 46668 : if (res != 0) goto failed;
9361 46668 : Py_CLEAR(tmp);
9362 : }
9363 46668 : if (_PyObject_LookupAttr(obj, state->kind, &tmp) < 0) {
9364 0 : return 1;
9365 : }
9366 46668 : if (tmp == NULL || tmp == Py_None) {
9367 46668 : Py_CLEAR(tmp);
9368 46668 : kind = NULL;
9369 : }
9370 : else {
9371 : int res;
9372 0 : if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
9373 0 : goto failed;
9374 : }
9375 0 : res = obj2ast_string(state, tmp, &kind, arena);
9376 0 : _Py_LeaveRecursiveCall();
9377 0 : if (res != 0) goto failed;
9378 0 : Py_CLEAR(tmp);
9379 : }
9380 46668 : *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
9381 : end_col_offset, arena);
9382 46668 : if (*out == NULL) goto failed;
9383 46668 : return 0;
9384 : }
9385 167776 : tp = state->Attribute_type;
9386 167776 : isinstance = PyObject_IsInstance(obj, tp);
9387 167776 : if (isinstance == -1) {
9388 0 : return 1;
9389 : }
9390 167776 : if (isinstance) {
9391 : expr_ty value;
9392 : identifier attr;
9393 : expr_context_ty ctx;
9394 :
9395 35102 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9396 35102 : return 1;
9397 : }
9398 35102 : if (tmp == NULL) {
9399 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
9400 0 : return 1;
9401 : }
9402 : else {
9403 : int res;
9404 35102 : if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9405 0 : goto failed;
9406 : }
9407 35102 : res = obj2ast_expr(state, tmp, &value, arena);
9408 35102 : _Py_LeaveRecursiveCall();
9409 35102 : if (res != 0) goto failed;
9410 35102 : Py_CLEAR(tmp);
9411 : }
9412 35102 : if (_PyObject_LookupAttr(obj, state->attr, &tmp) < 0) {
9413 0 : return 1;
9414 : }
9415 35102 : if (tmp == NULL) {
9416 0 : PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
9417 0 : return 1;
9418 : }
9419 : else {
9420 : int res;
9421 35102 : if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9422 0 : goto failed;
9423 : }
9424 35102 : res = obj2ast_identifier(state, tmp, &attr, arena);
9425 35102 : _Py_LeaveRecursiveCall();
9426 35102 : if (res != 0) goto failed;
9427 35102 : Py_CLEAR(tmp);
9428 : }
9429 35102 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9430 0 : return 1;
9431 : }
9432 35102 : if (tmp == NULL) {
9433 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
9434 0 : return 1;
9435 : }
9436 : else {
9437 : int res;
9438 35102 : if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9439 0 : goto failed;
9440 : }
9441 35102 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9442 35102 : _Py_LeaveRecursiveCall();
9443 35102 : if (res != 0) goto failed;
9444 35102 : Py_CLEAR(tmp);
9445 : }
9446 35102 : *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
9447 : end_lineno, end_col_offset, arena);
9448 35102 : if (*out == NULL) goto failed;
9449 35102 : return 0;
9450 : }
9451 132674 : tp = state->Subscript_type;
9452 132674 : isinstance = PyObject_IsInstance(obj, tp);
9453 132674 : if (isinstance == -1) {
9454 0 : return 1;
9455 : }
9456 132674 : if (isinstance) {
9457 : expr_ty value;
9458 : expr_ty slice;
9459 : expr_context_ty ctx;
9460 :
9461 4948 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9462 4948 : return 1;
9463 : }
9464 4948 : if (tmp == NULL) {
9465 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
9466 0 : return 1;
9467 : }
9468 : else {
9469 : int res;
9470 4948 : if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9471 0 : goto failed;
9472 : }
9473 4948 : res = obj2ast_expr(state, tmp, &value, arena);
9474 4948 : _Py_LeaveRecursiveCall();
9475 4948 : if (res != 0) goto failed;
9476 4948 : Py_CLEAR(tmp);
9477 : }
9478 4948 : if (_PyObject_LookupAttr(obj, state->slice, &tmp) < 0) {
9479 0 : return 1;
9480 : }
9481 4948 : if (tmp == NULL) {
9482 0 : PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
9483 0 : return 1;
9484 : }
9485 : else {
9486 : int res;
9487 4948 : if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9488 0 : goto failed;
9489 : }
9490 4948 : res = obj2ast_expr(state, tmp, &slice, arena);
9491 4948 : _Py_LeaveRecursiveCall();
9492 4948 : if (res != 0) goto failed;
9493 4948 : Py_CLEAR(tmp);
9494 : }
9495 4948 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9496 0 : return 1;
9497 : }
9498 4948 : if (tmp == NULL) {
9499 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
9500 0 : return 1;
9501 : }
9502 : else {
9503 : int res;
9504 4948 : if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9505 0 : goto failed;
9506 : }
9507 4948 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9508 4948 : _Py_LeaveRecursiveCall();
9509 4948 : if (res != 0) goto failed;
9510 4948 : Py_CLEAR(tmp);
9511 : }
9512 4948 : *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
9513 : end_lineno, end_col_offset, arena);
9514 4948 : if (*out == NULL) goto failed;
9515 4948 : return 0;
9516 : }
9517 127726 : tp = state->Starred_type;
9518 127726 : isinstance = PyObject_IsInstance(obj, tp);
9519 127726 : if (isinstance == -1) {
9520 0 : return 1;
9521 : }
9522 127726 : if (isinstance) {
9523 : expr_ty value;
9524 : expr_context_ty ctx;
9525 :
9526 315 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9527 315 : return 1;
9528 : }
9529 315 : if (tmp == NULL) {
9530 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
9531 0 : return 1;
9532 : }
9533 : else {
9534 : int res;
9535 315 : if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
9536 0 : goto failed;
9537 : }
9538 315 : res = obj2ast_expr(state, tmp, &value, arena);
9539 315 : _Py_LeaveRecursiveCall();
9540 315 : if (res != 0) goto failed;
9541 315 : Py_CLEAR(tmp);
9542 : }
9543 315 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9544 0 : return 1;
9545 : }
9546 315 : if (tmp == NULL) {
9547 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
9548 0 : return 1;
9549 : }
9550 : else {
9551 : int res;
9552 315 : if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
9553 0 : goto failed;
9554 : }
9555 315 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9556 315 : _Py_LeaveRecursiveCall();
9557 315 : if (res != 0) goto failed;
9558 315 : Py_CLEAR(tmp);
9559 : }
9560 315 : *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
9561 : end_col_offset, arena);
9562 315 : if (*out == NULL) goto failed;
9563 315 : return 0;
9564 : }
9565 127411 : tp = state->Name_type;
9566 127411 : isinstance = PyObject_IsInstance(obj, tp);
9567 127411 : if (isinstance == -1) {
9568 0 : return 1;
9569 : }
9570 127411 : if (isinstance) {
9571 : identifier id;
9572 : expr_context_ty ctx;
9573 :
9574 119381 : if (_PyObject_LookupAttr(obj, state->id, &tmp) < 0) {
9575 119380 : return 1;
9576 : }
9577 119381 : if (tmp == NULL) {
9578 0 : PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
9579 0 : return 1;
9580 : }
9581 : else {
9582 : int res;
9583 119381 : if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
9584 1 : goto failed;
9585 : }
9586 119381 : res = obj2ast_identifier(state, tmp, &id, arena);
9587 119381 : _Py_LeaveRecursiveCall();
9588 119381 : if (res != 0) goto failed;
9589 119380 : Py_CLEAR(tmp);
9590 : }
9591 119380 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9592 0 : return 1;
9593 : }
9594 119380 : if (tmp == NULL) {
9595 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
9596 0 : return 1;
9597 : }
9598 : else {
9599 : int res;
9600 119380 : if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
9601 0 : goto failed;
9602 : }
9603 119380 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9604 119380 : _Py_LeaveRecursiveCall();
9605 119380 : if (res != 0) goto failed;
9606 119380 : Py_CLEAR(tmp);
9607 : }
9608 119380 : *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
9609 : end_col_offset, arena);
9610 119380 : if (*out == NULL) goto failed;
9611 119380 : return 0;
9612 : }
9613 8030 : tp = state->List_type;
9614 8030 : isinstance = PyObject_IsInstance(obj, tp);
9615 8030 : if (isinstance == -1) {
9616 0 : return 1;
9617 : }
9618 8030 : if (isinstance) {
9619 : asdl_expr_seq* elts;
9620 : expr_context_ty ctx;
9621 :
9622 1489 : if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9623 1489 : return 1;
9624 : }
9625 1489 : if (tmp == NULL) {
9626 0 : PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
9627 0 : return 1;
9628 : }
9629 : else {
9630 : int res;
9631 : Py_ssize_t len;
9632 : Py_ssize_t i;
9633 1489 : if (!PyList_Check(tmp)) {
9634 0 : PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9635 0 : goto failed;
9636 : }
9637 1489 : len = PyList_GET_SIZE(tmp);
9638 1489 : elts = _Py_asdl_expr_seq_new(len, arena);
9639 1489 : if (elts == NULL) goto failed;
9640 4944 : for (i = 0; i < len; i++) {
9641 : expr_ty val;
9642 3455 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9643 3455 : Py_INCREF(tmp2);
9644 3455 : if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
9645 0 : goto failed;
9646 : }
9647 3455 : res = obj2ast_expr(state, tmp2, &val, arena);
9648 3455 : _Py_LeaveRecursiveCall();
9649 3455 : Py_DECREF(tmp2);
9650 3455 : if (res != 0) goto failed;
9651 3455 : if (len != PyList_GET_SIZE(tmp)) {
9652 0 : PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
9653 0 : goto failed;
9654 : }
9655 3455 : asdl_seq_SET(elts, i, val);
9656 : }
9657 1489 : Py_CLEAR(tmp);
9658 : }
9659 1489 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9660 0 : return 1;
9661 : }
9662 1489 : if (tmp == NULL) {
9663 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
9664 0 : return 1;
9665 : }
9666 : else {
9667 : int res;
9668 1489 : if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
9669 0 : goto failed;
9670 : }
9671 1489 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9672 1489 : _Py_LeaveRecursiveCall();
9673 1489 : if (res != 0) goto failed;
9674 1489 : Py_CLEAR(tmp);
9675 : }
9676 1489 : *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
9677 : end_col_offset, arena);
9678 1489 : if (*out == NULL) goto failed;
9679 1489 : return 0;
9680 : }
9681 6541 : tp = state->Tuple_type;
9682 6541 : isinstance = PyObject_IsInstance(obj, tp);
9683 6541 : if (isinstance == -1) {
9684 0 : return 1;
9685 : }
9686 6541 : if (isinstance) {
9687 : asdl_expr_seq* elts;
9688 : expr_context_ty ctx;
9689 :
9690 5246 : if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9691 5246 : return 1;
9692 : }
9693 5246 : if (tmp == NULL) {
9694 0 : PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
9695 0 : return 1;
9696 : }
9697 : else {
9698 : int res;
9699 : Py_ssize_t len;
9700 : Py_ssize_t i;
9701 5246 : if (!PyList_Check(tmp)) {
9702 0 : PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9703 0 : goto failed;
9704 : }
9705 5246 : len = PyList_GET_SIZE(tmp);
9706 5246 : elts = _Py_asdl_expr_seq_new(len, arena);
9707 5246 : if (elts == NULL) goto failed;
9708 17596 : for (i = 0; i < len; i++) {
9709 : expr_ty val;
9710 12350 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
9711 12350 : Py_INCREF(tmp2);
9712 12350 : if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
9713 0 : goto failed;
9714 : }
9715 12350 : res = obj2ast_expr(state, tmp2, &val, arena);
9716 12350 : _Py_LeaveRecursiveCall();
9717 12350 : Py_DECREF(tmp2);
9718 12350 : if (res != 0) goto failed;
9719 12350 : if (len != PyList_GET_SIZE(tmp)) {
9720 0 : PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
9721 0 : goto failed;
9722 : }
9723 12350 : asdl_seq_SET(elts, i, val);
9724 : }
9725 5246 : Py_CLEAR(tmp);
9726 : }
9727 5246 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9728 0 : return 1;
9729 : }
9730 5246 : if (tmp == NULL) {
9731 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
9732 0 : return 1;
9733 : }
9734 : else {
9735 : int res;
9736 5246 : if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
9737 0 : goto failed;
9738 : }
9739 5246 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9740 5246 : _Py_LeaveRecursiveCall();
9741 5246 : if (res != 0) goto failed;
9742 5246 : Py_CLEAR(tmp);
9743 : }
9744 5246 : *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
9745 : end_col_offset, arena);
9746 5246 : if (*out == NULL) goto failed;
9747 5246 : return 0;
9748 : }
9749 1295 : tp = state->Slice_type;
9750 1295 : isinstance = PyObject_IsInstance(obj, tp);
9751 1295 : if (isinstance == -1) {
9752 0 : return 1;
9753 : }
9754 1295 : if (isinstance) {
9755 : expr_ty lower;
9756 : expr_ty upper;
9757 : expr_ty step;
9758 :
9759 1294 : if (_PyObject_LookupAttr(obj, state->lower, &tmp) < 0) {
9760 1294 : return 1;
9761 : }
9762 1294 : if (tmp == NULL || tmp == Py_None) {
9763 520 : Py_CLEAR(tmp);
9764 520 : lower = NULL;
9765 : }
9766 : else {
9767 : int res;
9768 774 : if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9769 0 : goto failed;
9770 : }
9771 774 : res = obj2ast_expr(state, tmp, &lower, arena);
9772 774 : _Py_LeaveRecursiveCall();
9773 774 : if (res != 0) goto failed;
9774 774 : Py_CLEAR(tmp);
9775 : }
9776 1294 : if (_PyObject_LookupAttr(obj, state->upper, &tmp) < 0) {
9777 0 : return 1;
9778 : }
9779 1294 : if (tmp == NULL || tmp == Py_None) {
9780 498 : Py_CLEAR(tmp);
9781 498 : upper = NULL;
9782 : }
9783 : else {
9784 : int res;
9785 796 : if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9786 0 : goto failed;
9787 : }
9788 796 : res = obj2ast_expr(state, tmp, &upper, arena);
9789 796 : _Py_LeaveRecursiveCall();
9790 796 : if (res != 0) goto failed;
9791 796 : Py_CLEAR(tmp);
9792 : }
9793 1294 : if (_PyObject_LookupAttr(obj, state->step, &tmp) < 0) {
9794 0 : return 1;
9795 : }
9796 1294 : if (tmp == NULL || tmp == Py_None) {
9797 1263 : Py_CLEAR(tmp);
9798 1263 : step = NULL;
9799 : }
9800 : else {
9801 : int res;
9802 31 : if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9803 0 : goto failed;
9804 : }
9805 31 : res = obj2ast_expr(state, tmp, &step, arena);
9806 31 : _Py_LeaveRecursiveCall();
9807 31 : if (res != 0) goto failed;
9808 31 : Py_CLEAR(tmp);
9809 : }
9810 1294 : *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
9811 : end_col_offset, arena);
9812 1294 : if (*out == NULL) goto failed;
9813 1294 : return 0;
9814 : }
9815 :
9816 1 : PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
9817 89 : failed:
9818 89 : Py_XDECREF(tmp);
9819 89 : return 1;
9820 : }
9821 :
9822 : int
9823 166480 : obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
9824 : out, PyArena* arena)
9825 : {
9826 : int isinstance;
9827 :
9828 166480 : isinstance = PyObject_IsInstance(obj, state->Load_type);
9829 166480 : if (isinstance == -1) {
9830 0 : return 1;
9831 : }
9832 166480 : if (isinstance) {
9833 138133 : *out = Load;
9834 138133 : return 0;
9835 : }
9836 28347 : isinstance = PyObject_IsInstance(obj, state->Store_type);
9837 28347 : if (isinstance == -1) {
9838 0 : return 1;
9839 : }
9840 28347 : if (isinstance) {
9841 28027 : *out = Store;
9842 28027 : return 0;
9843 : }
9844 320 : isinstance = PyObject_IsInstance(obj, state->Del_type);
9845 320 : if (isinstance == -1) {
9846 0 : return 1;
9847 : }
9848 320 : if (isinstance) {
9849 320 : *out = Del;
9850 320 : return 0;
9851 : }
9852 :
9853 0 : PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
9854 0 : return 1;
9855 : }
9856 :
9857 : int
9858 2065 : obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
9859 : arena)
9860 : {
9861 : int isinstance;
9862 :
9863 2065 : isinstance = PyObject_IsInstance(obj, state->And_type);
9864 2065 : if (isinstance == -1) {
9865 0 : return 1;
9866 : }
9867 2065 : if (isinstance) {
9868 1272 : *out = And;
9869 1272 : return 0;
9870 : }
9871 793 : isinstance = PyObject_IsInstance(obj, state->Or_type);
9872 793 : if (isinstance == -1) {
9873 0 : return 1;
9874 : }
9875 793 : if (isinstance) {
9876 793 : *out = Or;
9877 793 : return 0;
9878 : }
9879 :
9880 0 : PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
9881 0 : return 1;
9882 : }
9883 :
9884 : int
9885 7488 : obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
9886 : PyArena* arena)
9887 : {
9888 : int isinstance;
9889 :
9890 7488 : isinstance = PyObject_IsInstance(obj, state->Add_type);
9891 7488 : if (isinstance == -1) {
9892 0 : return 1;
9893 : }
9894 7488 : if (isinstance) {
9895 3092 : *out = Add;
9896 3092 : return 0;
9897 : }
9898 4396 : isinstance = PyObject_IsInstance(obj, state->Sub_type);
9899 4396 : if (isinstance == -1) {
9900 0 : return 1;
9901 : }
9902 4396 : if (isinstance) {
9903 966 : *out = Sub;
9904 966 : return 0;
9905 : }
9906 3430 : isinstance = PyObject_IsInstance(obj, state->Mult_type);
9907 3430 : if (isinstance == -1) {
9908 0 : return 1;
9909 : }
9910 3430 : if (isinstance) {
9911 797 : *out = Mult;
9912 797 : return 0;
9913 : }
9914 2633 : isinstance = PyObject_IsInstance(obj, state->MatMult_type);
9915 2633 : if (isinstance == -1) {
9916 0 : return 1;
9917 : }
9918 2633 : if (isinstance) {
9919 4 : *out = MatMult;
9920 4 : return 0;
9921 : }
9922 2629 : isinstance = PyObject_IsInstance(obj, state->Div_type);
9923 2629 : if (isinstance == -1) {
9924 0 : return 1;
9925 : }
9926 2629 : if (isinstance) {
9927 174 : *out = Div;
9928 174 : return 0;
9929 : }
9930 2455 : isinstance = PyObject_IsInstance(obj, state->Mod_type);
9931 2455 : if (isinstance == -1) {
9932 0 : return 1;
9933 : }
9934 2455 : if (isinstance) {
9935 1453 : *out = Mod;
9936 1453 : return 0;
9937 : }
9938 1002 : isinstance = PyObject_IsInstance(obj, state->Pow_type);
9939 1002 : if (isinstance == -1) {
9940 0 : return 1;
9941 : }
9942 1002 : if (isinstance) {
9943 133 : *out = Pow;
9944 133 : return 0;
9945 : }
9946 869 : isinstance = PyObject_IsInstance(obj, state->LShift_type);
9947 869 : if (isinstance == -1) {
9948 0 : return 1;
9949 : }
9950 869 : if (isinstance) {
9951 143 : *out = LShift;
9952 143 : return 0;
9953 : }
9954 726 : isinstance = PyObject_IsInstance(obj, state->RShift_type);
9955 726 : if (isinstance == -1) {
9956 0 : return 1;
9957 : }
9958 726 : if (isinstance) {
9959 66 : *out = RShift;
9960 66 : return 0;
9961 : }
9962 660 : isinstance = PyObject_IsInstance(obj, state->BitOr_type);
9963 660 : if (isinstance == -1) {
9964 0 : return 1;
9965 : }
9966 660 : if (isinstance) {
9967 201 : *out = BitOr;
9968 201 : return 0;
9969 : }
9970 459 : isinstance = PyObject_IsInstance(obj, state->BitXor_type);
9971 459 : if (isinstance == -1) {
9972 0 : return 1;
9973 : }
9974 459 : if (isinstance) {
9975 41 : *out = BitXor;
9976 41 : return 0;
9977 : }
9978 418 : isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
9979 418 : if (isinstance == -1) {
9980 0 : return 1;
9981 : }
9982 418 : if (isinstance) {
9983 253 : *out = BitAnd;
9984 253 : return 0;
9985 : }
9986 165 : isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
9987 165 : if (isinstance == -1) {
9988 0 : return 1;
9989 : }
9990 165 : if (isinstance) {
9991 165 : *out = FloorDiv;
9992 165 : return 0;
9993 : }
9994 :
9995 0 : PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
9996 0 : return 1;
9997 : }
9998 :
9999 : int
10000 3086 : obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
10001 : PyArena* arena)
10002 : {
10003 : int isinstance;
10004 :
10005 3086 : isinstance = PyObject_IsInstance(obj, state->Invert_type);
10006 3086 : if (isinstance == -1) {
10007 0 : return 1;
10008 : }
10009 3086 : if (isinstance) {
10010 32 : *out = Invert;
10011 32 : return 0;
10012 : }
10013 3054 : isinstance = PyObject_IsInstance(obj, state->Not_type);
10014 3054 : if (isinstance == -1) {
10015 0 : return 1;
10016 : }
10017 3054 : if (isinstance) {
10018 1913 : *out = Not;
10019 1913 : return 0;
10020 : }
10021 1141 : isinstance = PyObject_IsInstance(obj, state->UAdd_type);
10022 1141 : if (isinstance == -1) {
10023 0 : return 1;
10024 : }
10025 1141 : if (isinstance) {
10026 14 : *out = UAdd;
10027 14 : return 0;
10028 : }
10029 1127 : isinstance = PyObject_IsInstance(obj, state->USub_type);
10030 1127 : if (isinstance == -1) {
10031 0 : return 1;
10032 : }
10033 1127 : if (isinstance) {
10034 1127 : *out = USub;
10035 1127 : return 0;
10036 : }
10037 :
10038 0 : PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
10039 0 : return 1;
10040 : }
10041 :
10042 : int
10043 8315 : obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
10044 : arena)
10045 : {
10046 : int isinstance;
10047 :
10048 8315 : isinstance = PyObject_IsInstance(obj, state->Eq_type);
10049 8315 : if (isinstance == -1) {
10050 0 : return 1;
10051 : }
10052 8315 : if (isinstance) {
10053 2293 : *out = Eq;
10054 2293 : return 0;
10055 : }
10056 6022 : isinstance = PyObject_IsInstance(obj, state->NotEq_type);
10057 6022 : if (isinstance == -1) {
10058 0 : return 1;
10059 : }
10060 6022 : if (isinstance) {
10061 599 : *out = NotEq;
10062 599 : return 0;
10063 : }
10064 5423 : isinstance = PyObject_IsInstance(obj, state->Lt_type);
10065 5423 : if (isinstance == -1) {
10066 0 : return 1;
10067 : }
10068 5423 : if (isinstance) {
10069 583 : *out = Lt;
10070 583 : return 0;
10071 : }
10072 4840 : isinstance = PyObject_IsInstance(obj, state->LtE_type);
10073 4840 : if (isinstance == -1) {
10074 0 : return 1;
10075 : }
10076 4840 : if (isinstance) {
10077 321 : *out = LtE;
10078 321 : return 0;
10079 : }
10080 4519 : isinstance = PyObject_IsInstance(obj, state->Gt_type);
10081 4519 : if (isinstance == -1) {
10082 0 : return 1;
10083 : }
10084 4519 : if (isinstance) {
10085 485 : *out = Gt;
10086 485 : return 0;
10087 : }
10088 4034 : isinstance = PyObject_IsInstance(obj, state->GtE_type);
10089 4034 : if (isinstance == -1) {
10090 0 : return 1;
10091 : }
10092 4034 : if (isinstance) {
10093 278 : *out = GtE;
10094 278 : return 0;
10095 : }
10096 3756 : isinstance = PyObject_IsInstance(obj, state->Is_type);
10097 3756 : if (isinstance == -1) {
10098 0 : return 1;
10099 : }
10100 3756 : if (isinstance) {
10101 1412 : *out = Is;
10102 1412 : return 0;
10103 : }
10104 2344 : isinstance = PyObject_IsInstance(obj, state->IsNot_type);
10105 2344 : if (isinstance == -1) {
10106 0 : return 1;
10107 : }
10108 2344 : if (isinstance) {
10109 963 : *out = IsNot;
10110 963 : return 0;
10111 : }
10112 1381 : isinstance = PyObject_IsInstance(obj, state->In_type);
10113 1381 : if (isinstance == -1) {
10114 0 : return 1;
10115 : }
10116 1381 : if (isinstance) {
10117 1067 : *out = In;
10118 1067 : return 0;
10119 : }
10120 314 : isinstance = PyObject_IsInstance(obj, state->NotIn_type);
10121 314 : if (isinstance == -1) {
10122 0 : return 1;
10123 : }
10124 314 : if (isinstance) {
10125 314 : *out = NotIn;
10126 314 : return 0;
10127 : }
10128 :
10129 0 : PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
10130 0 : return 1;
10131 : }
10132 :
10133 : int
10134 635 : obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
10135 : out, PyArena* arena)
10136 : {
10137 635 : PyObject* tmp = NULL;
10138 : expr_ty target;
10139 : expr_ty iter;
10140 : asdl_expr_seq* ifs;
10141 : int is_async;
10142 :
10143 635 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
10144 0 : return 1;
10145 : }
10146 635 : if (tmp == NULL) {
10147 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
10148 0 : return 1;
10149 : }
10150 : else {
10151 : int res;
10152 635 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10153 0 : goto failed;
10154 : }
10155 635 : res = obj2ast_expr(state, tmp, &target, arena);
10156 635 : _Py_LeaveRecursiveCall();
10157 635 : if (res != 0) goto failed;
10158 635 : Py_CLEAR(tmp);
10159 : }
10160 635 : if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
10161 0 : return 1;
10162 : }
10163 635 : if (tmp == NULL) {
10164 0 : PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
10165 0 : return 1;
10166 : }
10167 : else {
10168 : int res;
10169 635 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10170 0 : goto failed;
10171 : }
10172 635 : res = obj2ast_expr(state, tmp, &iter, arena);
10173 635 : _Py_LeaveRecursiveCall();
10174 635 : if (res != 0) goto failed;
10175 635 : Py_CLEAR(tmp);
10176 : }
10177 635 : if (_PyObject_LookupAttr(obj, state->ifs, &tmp) < 0) {
10178 0 : return 1;
10179 : }
10180 635 : if (tmp == NULL) {
10181 0 : PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
10182 0 : return 1;
10183 : }
10184 : else {
10185 : int res;
10186 : Py_ssize_t len;
10187 : Py_ssize_t i;
10188 635 : if (!PyList_Check(tmp)) {
10189 0 : PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10190 0 : goto failed;
10191 : }
10192 635 : len = PyList_GET_SIZE(tmp);
10193 635 : ifs = _Py_asdl_expr_seq_new(len, arena);
10194 635 : if (ifs == NULL) goto failed;
10195 796 : for (i = 0; i < len; i++) {
10196 : expr_ty val;
10197 161 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10198 161 : Py_INCREF(tmp2);
10199 161 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10200 0 : goto failed;
10201 : }
10202 161 : res = obj2ast_expr(state, tmp2, &val, arena);
10203 161 : _Py_LeaveRecursiveCall();
10204 161 : Py_DECREF(tmp2);
10205 161 : if (res != 0) goto failed;
10206 161 : if (len != PyList_GET_SIZE(tmp)) {
10207 0 : PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
10208 0 : goto failed;
10209 : }
10210 161 : asdl_seq_SET(ifs, i, val);
10211 : }
10212 635 : Py_CLEAR(tmp);
10213 : }
10214 635 : if (_PyObject_LookupAttr(obj, state->is_async, &tmp) < 0) {
10215 0 : return 1;
10216 : }
10217 635 : if (tmp == NULL) {
10218 0 : PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
10219 0 : return 1;
10220 : }
10221 : else {
10222 : int res;
10223 635 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10224 0 : goto failed;
10225 : }
10226 635 : res = obj2ast_int(state, tmp, &is_async, arena);
10227 635 : _Py_LeaveRecursiveCall();
10228 635 : if (res != 0) goto failed;
10229 635 : Py_CLEAR(tmp);
10230 : }
10231 635 : *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
10232 635 : return 0;
10233 0 : failed:
10234 0 : Py_XDECREF(tmp);
10235 0 : return 1;
10236 : }
10237 :
10238 : int
10239 1410 : obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
10240 : out, PyArena* arena)
10241 : {
10242 : int isinstance;
10243 :
10244 1410 : PyObject *tmp = NULL;
10245 : PyObject *tp;
10246 : int lineno;
10247 : int col_offset;
10248 : int end_lineno;
10249 : int end_col_offset;
10250 :
10251 1410 : if (obj == Py_None) {
10252 0 : *out = NULL;
10253 0 : return 0;
10254 : }
10255 1410 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10256 0 : return 1;
10257 : }
10258 1410 : if (tmp == NULL) {
10259 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
10260 0 : return 1;
10261 : }
10262 : else {
10263 : int res;
10264 1410 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10265 0 : goto failed;
10266 : }
10267 1410 : res = obj2ast_int(state, tmp, &lineno, arena);
10268 1410 : _Py_LeaveRecursiveCall();
10269 1410 : if (res != 0) goto failed;
10270 1410 : Py_CLEAR(tmp);
10271 : }
10272 1410 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10273 0 : return 1;
10274 : }
10275 1410 : if (tmp == NULL) {
10276 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
10277 0 : return 1;
10278 : }
10279 : else {
10280 : int res;
10281 1410 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10282 0 : goto failed;
10283 : }
10284 1410 : res = obj2ast_int(state, tmp, &col_offset, arena);
10285 1410 : _Py_LeaveRecursiveCall();
10286 1410 : if (res != 0) goto failed;
10287 1410 : Py_CLEAR(tmp);
10288 : }
10289 1410 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10290 0 : return 1;
10291 : }
10292 1410 : if (tmp == NULL || tmp == Py_None) {
10293 0 : Py_CLEAR(tmp);
10294 0 : end_lineno = lineno;
10295 : }
10296 : else {
10297 : int res;
10298 1410 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10299 0 : goto failed;
10300 : }
10301 1410 : res = obj2ast_int(state, tmp, &end_lineno, arena);
10302 1410 : _Py_LeaveRecursiveCall();
10303 1410 : if (res != 0) goto failed;
10304 1410 : Py_CLEAR(tmp);
10305 : }
10306 1410 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10307 0 : return 1;
10308 : }
10309 1410 : if (tmp == NULL || tmp == Py_None) {
10310 0 : Py_CLEAR(tmp);
10311 0 : end_col_offset = col_offset;
10312 : }
10313 : else {
10314 : int res;
10315 1410 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10316 0 : goto failed;
10317 : }
10318 1410 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
10319 1410 : _Py_LeaveRecursiveCall();
10320 1410 : if (res != 0) goto failed;
10321 1410 : Py_CLEAR(tmp);
10322 : }
10323 1410 : tp = state->ExceptHandler_type;
10324 1410 : isinstance = PyObject_IsInstance(obj, tp);
10325 1410 : if (isinstance == -1) {
10326 0 : return 1;
10327 : }
10328 1410 : if (isinstance) {
10329 : expr_ty type;
10330 : identifier name;
10331 : asdl_stmt_seq* body;
10332 :
10333 1410 : if (_PyObject_LookupAttr(obj, state->type, &tmp) < 0) {
10334 1410 : return 1;
10335 : }
10336 1410 : if (tmp == NULL || tmp == Py_None) {
10337 96 : Py_CLEAR(tmp);
10338 96 : type = NULL;
10339 : }
10340 : else {
10341 : int res;
10342 1314 : if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10343 0 : goto failed;
10344 : }
10345 1314 : res = obj2ast_expr(state, tmp, &type, arena);
10346 1314 : _Py_LeaveRecursiveCall();
10347 1314 : if (res != 0) goto failed;
10348 1314 : Py_CLEAR(tmp);
10349 : }
10350 1410 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10351 0 : return 1;
10352 : }
10353 1410 : if (tmp == NULL || tmp == Py_None) {
10354 1176 : Py_CLEAR(tmp);
10355 1176 : name = NULL;
10356 : }
10357 : else {
10358 : int res;
10359 234 : if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10360 0 : goto failed;
10361 : }
10362 234 : res = obj2ast_identifier(state, tmp, &name, arena);
10363 234 : _Py_LeaveRecursiveCall();
10364 234 : if (res != 0) goto failed;
10365 234 : Py_CLEAR(tmp);
10366 : }
10367 1410 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
10368 0 : return 1;
10369 : }
10370 1410 : if (tmp == NULL) {
10371 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
10372 0 : return 1;
10373 : }
10374 : else {
10375 : int res;
10376 : Py_ssize_t len;
10377 : Py_ssize_t i;
10378 1410 : if (!PyList_Check(tmp)) {
10379 0 : PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10380 0 : goto failed;
10381 : }
10382 1410 : len = PyList_GET_SIZE(tmp);
10383 1410 : body = _Py_asdl_stmt_seq_new(len, arena);
10384 1410 : if (body == NULL) goto failed;
10385 3283 : for (i = 0; i < len; i++) {
10386 : stmt_ty val;
10387 1873 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10388 1873 : Py_INCREF(tmp2);
10389 1873 : if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10390 0 : goto failed;
10391 : }
10392 1873 : res = obj2ast_stmt(state, tmp2, &val, arena);
10393 1873 : _Py_LeaveRecursiveCall();
10394 1873 : Py_DECREF(tmp2);
10395 1873 : if (res != 0) goto failed;
10396 1873 : if (len != PyList_GET_SIZE(tmp)) {
10397 0 : PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
10398 0 : goto failed;
10399 : }
10400 1873 : asdl_seq_SET(body, i, val);
10401 : }
10402 1410 : Py_CLEAR(tmp);
10403 : }
10404 1410 : *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
10405 : end_lineno, end_col_offset, arena);
10406 1410 : if (*out == NULL) goto failed;
10407 1410 : return 0;
10408 : }
10409 :
10410 0 : PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
10411 0 : failed:
10412 0 : Py_XDECREF(tmp);
10413 0 : return 1;
10414 : }
10415 :
10416 : int
10417 7605 : obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
10418 : PyArena* arena)
10419 : {
10420 7605 : PyObject* tmp = NULL;
10421 : asdl_arg_seq* posonlyargs;
10422 : asdl_arg_seq* args;
10423 : arg_ty vararg;
10424 : asdl_arg_seq* kwonlyargs;
10425 : asdl_expr_seq* kw_defaults;
10426 : arg_ty kwarg;
10427 : asdl_expr_seq* defaults;
10428 :
10429 7605 : if (_PyObject_LookupAttr(obj, state->posonlyargs, &tmp) < 0) {
10430 0 : return 1;
10431 : }
10432 7605 : if (tmp == NULL) {
10433 0 : PyErr_SetString(PyExc_TypeError, "required field \"posonlyargs\" missing from arguments");
10434 0 : return 1;
10435 : }
10436 : else {
10437 : int res;
10438 : Py_ssize_t len;
10439 : Py_ssize_t i;
10440 7605 : if (!PyList_Check(tmp)) {
10441 0 : PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10442 0 : goto failed;
10443 : }
10444 7605 : len = PyList_GET_SIZE(tmp);
10445 7605 : posonlyargs = _Py_asdl_arg_seq_new(len, arena);
10446 7605 : if (posonlyargs == NULL) goto failed;
10447 7724 : for (i = 0; i < len; i++) {
10448 : arg_ty val;
10449 119 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10450 119 : Py_INCREF(tmp2);
10451 119 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10452 0 : goto failed;
10453 : }
10454 119 : res = obj2ast_arg(state, tmp2, &val, arena);
10455 119 : _Py_LeaveRecursiveCall();
10456 119 : Py_DECREF(tmp2);
10457 119 : if (res != 0) goto failed;
10458 119 : if (len != PyList_GET_SIZE(tmp)) {
10459 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
10460 0 : goto failed;
10461 : }
10462 119 : asdl_seq_SET(posonlyargs, i, val);
10463 : }
10464 7605 : Py_CLEAR(tmp);
10465 : }
10466 7605 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
10467 0 : return 1;
10468 : }
10469 7605 : if (tmp == NULL) {
10470 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
10471 0 : return 1;
10472 : }
10473 : else {
10474 : int res;
10475 : Py_ssize_t len;
10476 : Py_ssize_t i;
10477 7605 : if (!PyList_Check(tmp)) {
10478 0 : PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10479 0 : goto failed;
10480 : }
10481 7605 : len = PyList_GET_SIZE(tmp);
10482 7605 : args = _Py_asdl_arg_seq_new(len, arena);
10483 7605 : if (args == NULL) goto failed;
10484 21740 : for (i = 0; i < len; i++) {
10485 : arg_ty val;
10486 14135 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10487 14135 : Py_INCREF(tmp2);
10488 14135 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10489 0 : goto failed;
10490 : }
10491 14135 : res = obj2ast_arg(state, tmp2, &val, arena);
10492 14135 : _Py_LeaveRecursiveCall();
10493 14135 : Py_DECREF(tmp2);
10494 14135 : if (res != 0) goto failed;
10495 14135 : if (len != PyList_GET_SIZE(tmp)) {
10496 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
10497 0 : goto failed;
10498 : }
10499 14135 : asdl_seq_SET(args, i, val);
10500 : }
10501 7605 : Py_CLEAR(tmp);
10502 : }
10503 7605 : if (_PyObject_LookupAttr(obj, state->vararg, &tmp) < 0) {
10504 0 : return 1;
10505 : }
10506 7605 : if (tmp == NULL || tmp == Py_None) {
10507 7322 : Py_CLEAR(tmp);
10508 7322 : vararg = NULL;
10509 : }
10510 : else {
10511 : int res;
10512 283 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10513 0 : goto failed;
10514 : }
10515 283 : res = obj2ast_arg(state, tmp, &vararg, arena);
10516 283 : _Py_LeaveRecursiveCall();
10517 283 : if (res != 0) goto failed;
10518 283 : Py_CLEAR(tmp);
10519 : }
10520 7605 : if (_PyObject_LookupAttr(obj, state->kwonlyargs, &tmp) < 0) {
10521 0 : return 1;
10522 : }
10523 7605 : if (tmp == NULL) {
10524 0 : PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
10525 0 : return 1;
10526 : }
10527 : else {
10528 : int res;
10529 : Py_ssize_t len;
10530 : Py_ssize_t i;
10531 7605 : if (!PyList_Check(tmp)) {
10532 0 : PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10533 0 : goto failed;
10534 : }
10535 7605 : len = PyList_GET_SIZE(tmp);
10536 7605 : kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
10537 7605 : if (kwonlyargs == NULL) goto failed;
10538 8080 : for (i = 0; i < len; i++) {
10539 : arg_ty val;
10540 475 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10541 475 : Py_INCREF(tmp2);
10542 475 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10543 0 : goto failed;
10544 : }
10545 475 : res = obj2ast_arg(state, tmp2, &val, arena);
10546 475 : _Py_LeaveRecursiveCall();
10547 475 : Py_DECREF(tmp2);
10548 475 : if (res != 0) goto failed;
10549 475 : if (len != PyList_GET_SIZE(tmp)) {
10550 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
10551 0 : goto failed;
10552 : }
10553 475 : asdl_seq_SET(kwonlyargs, i, val);
10554 : }
10555 7605 : Py_CLEAR(tmp);
10556 : }
10557 7605 : if (_PyObject_LookupAttr(obj, state->kw_defaults, &tmp) < 0) {
10558 0 : return 1;
10559 : }
10560 7605 : if (tmp == NULL) {
10561 0 : PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
10562 0 : return 1;
10563 : }
10564 : else {
10565 : int res;
10566 : Py_ssize_t len;
10567 : Py_ssize_t i;
10568 7605 : if (!PyList_Check(tmp)) {
10569 0 : PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10570 0 : goto failed;
10571 : }
10572 7605 : len = PyList_GET_SIZE(tmp);
10573 7605 : kw_defaults = _Py_asdl_expr_seq_new(len, arena);
10574 7605 : if (kw_defaults == NULL) goto failed;
10575 8080 : for (i = 0; i < len; i++) {
10576 : expr_ty val;
10577 475 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10578 475 : Py_INCREF(tmp2);
10579 475 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10580 0 : goto failed;
10581 : }
10582 475 : res = obj2ast_expr(state, tmp2, &val, arena);
10583 475 : _Py_LeaveRecursiveCall();
10584 475 : Py_DECREF(tmp2);
10585 475 : if (res != 0) goto failed;
10586 475 : if (len != PyList_GET_SIZE(tmp)) {
10587 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
10588 0 : goto failed;
10589 : }
10590 475 : asdl_seq_SET(kw_defaults, i, val);
10591 : }
10592 7605 : Py_CLEAR(tmp);
10593 : }
10594 7605 : if (_PyObject_LookupAttr(obj, state->kwarg, &tmp) < 0) {
10595 0 : return 1;
10596 : }
10597 7605 : if (tmp == NULL || tmp == Py_None) {
10598 7432 : Py_CLEAR(tmp);
10599 7432 : kwarg = NULL;
10600 : }
10601 : else {
10602 : int res;
10603 173 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10604 0 : goto failed;
10605 : }
10606 173 : res = obj2ast_arg(state, tmp, &kwarg, arena);
10607 173 : _Py_LeaveRecursiveCall();
10608 173 : if (res != 0) goto failed;
10609 173 : Py_CLEAR(tmp);
10610 : }
10611 7605 : if (_PyObject_LookupAttr(obj, state->defaults, &tmp) < 0) {
10612 0 : return 1;
10613 : }
10614 7605 : if (tmp == NULL) {
10615 0 : PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
10616 0 : return 1;
10617 : }
10618 : else {
10619 : int res;
10620 : Py_ssize_t len;
10621 : Py_ssize_t i;
10622 7605 : if (!PyList_Check(tmp)) {
10623 0 : PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10624 0 : goto failed;
10625 : }
10626 7605 : len = PyList_GET_SIZE(tmp);
10627 7605 : defaults = _Py_asdl_expr_seq_new(len, arena);
10628 7605 : if (defaults == NULL) goto failed;
10629 10034 : for (i = 0; i < len; i++) {
10630 : expr_ty val;
10631 2429 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
10632 2429 : Py_INCREF(tmp2);
10633 2429 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10634 0 : goto failed;
10635 : }
10636 2429 : res = obj2ast_expr(state, tmp2, &val, arena);
10637 2429 : _Py_LeaveRecursiveCall();
10638 2429 : Py_DECREF(tmp2);
10639 2429 : if (res != 0) goto failed;
10640 2429 : if (len != PyList_GET_SIZE(tmp)) {
10641 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
10642 0 : goto failed;
10643 : }
10644 2429 : asdl_seq_SET(defaults, i, val);
10645 : }
10646 7605 : Py_CLEAR(tmp);
10647 : }
10648 7605 : *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
10649 : kwarg, defaults, arena);
10650 7605 : return 0;
10651 0 : failed:
10652 0 : Py_XDECREF(tmp);
10653 0 : return 1;
10654 : }
10655 :
10656 : int
10657 15185 : obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
10658 : {
10659 15185 : PyObject* tmp = NULL;
10660 : identifier arg;
10661 : expr_ty annotation;
10662 : string type_comment;
10663 : int lineno;
10664 : int col_offset;
10665 : int end_lineno;
10666 : int end_col_offset;
10667 :
10668 15185 : if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10669 0 : return 1;
10670 : }
10671 15185 : if (tmp == NULL) {
10672 0 : PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
10673 0 : return 1;
10674 : }
10675 : else {
10676 : int res;
10677 15185 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10678 0 : goto failed;
10679 : }
10680 15185 : res = obj2ast_identifier(state, tmp, &arg, arena);
10681 15185 : _Py_LeaveRecursiveCall();
10682 15185 : if (res != 0) goto failed;
10683 15185 : Py_CLEAR(tmp);
10684 : }
10685 15185 : if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
10686 0 : return 1;
10687 : }
10688 15185 : if (tmp == NULL || tmp == Py_None) {
10689 15109 : Py_CLEAR(tmp);
10690 15109 : annotation = NULL;
10691 : }
10692 : else {
10693 : int res;
10694 76 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10695 0 : goto failed;
10696 : }
10697 76 : res = obj2ast_expr(state, tmp, &annotation, arena);
10698 76 : _Py_LeaveRecursiveCall();
10699 76 : if (res != 0) goto failed;
10700 76 : Py_CLEAR(tmp);
10701 : }
10702 15185 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
10703 0 : return 1;
10704 : }
10705 15185 : if (tmp == NULL || tmp == Py_None) {
10706 15185 : Py_CLEAR(tmp);
10707 15185 : type_comment = NULL;
10708 : }
10709 : else {
10710 : int res;
10711 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10712 0 : goto failed;
10713 : }
10714 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
10715 0 : _Py_LeaveRecursiveCall();
10716 0 : if (res != 0) goto failed;
10717 0 : Py_CLEAR(tmp);
10718 : }
10719 15185 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10720 0 : return 1;
10721 : }
10722 15185 : if (tmp == NULL) {
10723 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
10724 0 : return 1;
10725 : }
10726 : else {
10727 : int res;
10728 15185 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10729 0 : goto failed;
10730 : }
10731 15185 : res = obj2ast_int(state, tmp, &lineno, arena);
10732 15185 : _Py_LeaveRecursiveCall();
10733 15185 : if (res != 0) goto failed;
10734 15185 : Py_CLEAR(tmp);
10735 : }
10736 15185 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10737 0 : return 1;
10738 : }
10739 15185 : if (tmp == NULL) {
10740 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
10741 0 : return 1;
10742 : }
10743 : else {
10744 : int res;
10745 15185 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10746 0 : goto failed;
10747 : }
10748 15185 : res = obj2ast_int(state, tmp, &col_offset, arena);
10749 15185 : _Py_LeaveRecursiveCall();
10750 15185 : if (res != 0) goto failed;
10751 15185 : Py_CLEAR(tmp);
10752 : }
10753 15185 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10754 0 : return 1;
10755 : }
10756 15185 : if (tmp == NULL || tmp == Py_None) {
10757 0 : Py_CLEAR(tmp);
10758 0 : end_lineno = lineno;
10759 : }
10760 : else {
10761 : int res;
10762 15185 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10763 0 : goto failed;
10764 : }
10765 15185 : res = obj2ast_int(state, tmp, &end_lineno, arena);
10766 15185 : _Py_LeaveRecursiveCall();
10767 15185 : if (res != 0) goto failed;
10768 15185 : Py_CLEAR(tmp);
10769 : }
10770 15185 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10771 0 : return 1;
10772 : }
10773 15185 : if (tmp == NULL || tmp == Py_None) {
10774 0 : Py_CLEAR(tmp);
10775 0 : end_col_offset = col_offset;
10776 : }
10777 : else {
10778 : int res;
10779 15185 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10780 0 : goto failed;
10781 : }
10782 15185 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
10783 15185 : _Py_LeaveRecursiveCall();
10784 15185 : if (res != 0) goto failed;
10785 15185 : Py_CLEAR(tmp);
10786 : }
10787 15185 : *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
10788 : end_lineno, end_col_offset, arena);
10789 15185 : return 0;
10790 0 : failed:
10791 0 : Py_XDECREF(tmp);
10792 0 : return 1;
10793 : }
10794 :
10795 : int
10796 3310 : obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
10797 : PyArena* arena)
10798 : {
10799 3310 : PyObject* tmp = NULL;
10800 : identifier arg;
10801 : expr_ty value;
10802 : int lineno;
10803 : int col_offset;
10804 : int end_lineno;
10805 : int end_col_offset;
10806 :
10807 3310 : if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10808 0 : return 1;
10809 : }
10810 3310 : if (tmp == NULL || tmp == Py_None) {
10811 154 : Py_CLEAR(tmp);
10812 154 : arg = NULL;
10813 : }
10814 : else {
10815 : int res;
10816 3156 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10817 0 : goto failed;
10818 : }
10819 3156 : res = obj2ast_identifier(state, tmp, &arg, arena);
10820 3156 : _Py_LeaveRecursiveCall();
10821 3156 : if (res != 0) goto failed;
10822 3156 : Py_CLEAR(tmp);
10823 : }
10824 3310 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
10825 0 : return 1;
10826 : }
10827 3310 : if (tmp == NULL) {
10828 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
10829 0 : return 1;
10830 : }
10831 : else {
10832 : int res;
10833 3310 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10834 0 : goto failed;
10835 : }
10836 3310 : res = obj2ast_expr(state, tmp, &value, arena);
10837 3310 : _Py_LeaveRecursiveCall();
10838 3310 : if (res != 0) goto failed;
10839 3310 : Py_CLEAR(tmp);
10840 : }
10841 3310 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10842 0 : return 1;
10843 : }
10844 3310 : if (tmp == NULL) {
10845 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
10846 0 : return 1;
10847 : }
10848 : else {
10849 : int res;
10850 3310 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10851 0 : goto failed;
10852 : }
10853 3310 : res = obj2ast_int(state, tmp, &lineno, arena);
10854 3310 : _Py_LeaveRecursiveCall();
10855 3310 : if (res != 0) goto failed;
10856 3310 : Py_CLEAR(tmp);
10857 : }
10858 3310 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10859 0 : return 1;
10860 : }
10861 3310 : if (tmp == NULL) {
10862 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
10863 0 : return 1;
10864 : }
10865 : else {
10866 : int res;
10867 3310 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10868 0 : goto failed;
10869 : }
10870 3310 : res = obj2ast_int(state, tmp, &col_offset, arena);
10871 3310 : _Py_LeaveRecursiveCall();
10872 3310 : if (res != 0) goto failed;
10873 3310 : Py_CLEAR(tmp);
10874 : }
10875 3310 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10876 0 : return 1;
10877 : }
10878 3310 : if (tmp == NULL || tmp == Py_None) {
10879 0 : Py_CLEAR(tmp);
10880 0 : end_lineno = lineno;
10881 : }
10882 : else {
10883 : int res;
10884 3310 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10885 0 : goto failed;
10886 : }
10887 3310 : res = obj2ast_int(state, tmp, &end_lineno, arena);
10888 3310 : _Py_LeaveRecursiveCall();
10889 3310 : if (res != 0) goto failed;
10890 3310 : Py_CLEAR(tmp);
10891 : }
10892 3310 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10893 0 : return 1;
10894 : }
10895 3310 : if (tmp == NULL || tmp == Py_None) {
10896 0 : Py_CLEAR(tmp);
10897 0 : end_col_offset = col_offset;
10898 : }
10899 : else {
10900 : int res;
10901 3310 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10902 0 : goto failed;
10903 : }
10904 3310 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
10905 3310 : _Py_LeaveRecursiveCall();
10906 3310 : if (res != 0) goto failed;
10907 3310 : Py_CLEAR(tmp);
10908 : }
10909 3310 : *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
10910 : end_col_offset, arena);
10911 3310 : return 0;
10912 0 : failed:
10913 0 : Py_XDECREF(tmp);
10914 0 : return 1;
10915 : }
10916 :
10917 : int
10918 1620 : obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
10919 : arena)
10920 : {
10921 1620 : PyObject* tmp = NULL;
10922 : identifier name;
10923 : identifier asname;
10924 : int lineno;
10925 : int col_offset;
10926 : int end_lineno;
10927 : int end_col_offset;
10928 :
10929 1620 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10930 0 : return 1;
10931 : }
10932 1620 : if (tmp == NULL) {
10933 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
10934 0 : return 1;
10935 : }
10936 : else {
10937 : int res;
10938 1620 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10939 0 : goto failed;
10940 : }
10941 1620 : res = obj2ast_identifier(state, tmp, &name, arena);
10942 1620 : _Py_LeaveRecursiveCall();
10943 1620 : if (res != 0) goto failed;
10944 1620 : Py_CLEAR(tmp);
10945 : }
10946 1620 : if (_PyObject_LookupAttr(obj, state->asname, &tmp) < 0) {
10947 0 : return 1;
10948 : }
10949 1620 : if (tmp == NULL || tmp == Py_None) {
10950 1483 : Py_CLEAR(tmp);
10951 1483 : asname = NULL;
10952 : }
10953 : else {
10954 : int res;
10955 137 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10956 0 : goto failed;
10957 : }
10958 137 : res = obj2ast_identifier(state, tmp, &asname, arena);
10959 137 : _Py_LeaveRecursiveCall();
10960 137 : if (res != 0) goto failed;
10961 137 : Py_CLEAR(tmp);
10962 : }
10963 1620 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10964 0 : return 1;
10965 : }
10966 1620 : if (tmp == NULL) {
10967 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
10968 0 : return 1;
10969 : }
10970 : else {
10971 : int res;
10972 1620 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10973 0 : goto failed;
10974 : }
10975 1620 : res = obj2ast_int(state, tmp, &lineno, arena);
10976 1620 : _Py_LeaveRecursiveCall();
10977 1620 : if (res != 0) goto failed;
10978 1620 : Py_CLEAR(tmp);
10979 : }
10980 1620 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10981 0 : return 1;
10982 : }
10983 1620 : if (tmp == NULL) {
10984 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
10985 0 : return 1;
10986 : }
10987 : else {
10988 : int res;
10989 1620 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10990 0 : goto failed;
10991 : }
10992 1620 : res = obj2ast_int(state, tmp, &col_offset, arena);
10993 1620 : _Py_LeaveRecursiveCall();
10994 1620 : if (res != 0) goto failed;
10995 1620 : Py_CLEAR(tmp);
10996 : }
10997 1620 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10998 0 : return 1;
10999 : }
11000 1620 : if (tmp == NULL || tmp == Py_None) {
11001 3 : Py_CLEAR(tmp);
11002 3 : end_lineno = lineno;
11003 : }
11004 : else {
11005 : int res;
11006 1617 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
11007 0 : goto failed;
11008 : }
11009 1617 : res = obj2ast_int(state, tmp, &end_lineno, arena);
11010 1617 : _Py_LeaveRecursiveCall();
11011 1617 : if (res != 0) goto failed;
11012 1617 : Py_CLEAR(tmp);
11013 : }
11014 1620 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11015 0 : return 1;
11016 : }
11017 1620 : if (tmp == NULL || tmp == Py_None) {
11018 3 : Py_CLEAR(tmp);
11019 3 : end_col_offset = col_offset;
11020 : }
11021 : else {
11022 : int res;
11023 1617 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
11024 0 : goto failed;
11025 : }
11026 1617 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
11027 1617 : _Py_LeaveRecursiveCall();
11028 1617 : if (res != 0) goto failed;
11029 1617 : Py_CLEAR(tmp);
11030 : }
11031 1620 : *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
11032 : end_col_offset, arena);
11033 1620 : return 0;
11034 0 : failed:
11035 0 : Py_XDECREF(tmp);
11036 0 : return 1;
11037 : }
11038 :
11039 : int
11040 418 : obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
11041 : PyArena* arena)
11042 : {
11043 418 : PyObject* tmp = NULL;
11044 : expr_ty context_expr;
11045 : expr_ty optional_vars;
11046 :
11047 418 : if (_PyObject_LookupAttr(obj, state->context_expr, &tmp) < 0) {
11048 0 : return 1;
11049 : }
11050 418 : if (tmp == NULL) {
11051 0 : PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
11052 0 : return 1;
11053 : }
11054 : else {
11055 : int res;
11056 418 : if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
11057 0 : goto failed;
11058 : }
11059 418 : res = obj2ast_expr(state, tmp, &context_expr, arena);
11060 418 : _Py_LeaveRecursiveCall();
11061 418 : if (res != 0) goto failed;
11062 418 : Py_CLEAR(tmp);
11063 : }
11064 418 : if (_PyObject_LookupAttr(obj, state->optional_vars, &tmp) < 0) {
11065 0 : return 1;
11066 : }
11067 418 : if (tmp == NULL || tmp == Py_None) {
11068 225 : Py_CLEAR(tmp);
11069 225 : optional_vars = NULL;
11070 : }
11071 : else {
11072 : int res;
11073 193 : if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
11074 0 : goto failed;
11075 : }
11076 193 : res = obj2ast_expr(state, tmp, &optional_vars, arena);
11077 193 : _Py_LeaveRecursiveCall();
11078 193 : if (res != 0) goto failed;
11079 193 : Py_CLEAR(tmp);
11080 : }
11081 418 : *out = _PyAST_withitem(context_expr, optional_vars, arena);
11082 418 : return 0;
11083 0 : failed:
11084 0 : Py_XDECREF(tmp);
11085 0 : return 1;
11086 : }
11087 :
11088 : int
11089 33 : obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
11090 : PyArena* arena)
11091 : {
11092 33 : PyObject* tmp = NULL;
11093 : pattern_ty pattern;
11094 : expr_ty guard;
11095 : asdl_stmt_seq* body;
11096 :
11097 33 : if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11098 0 : return 1;
11099 : }
11100 33 : if (tmp == NULL) {
11101 0 : PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
11102 0 : return 1;
11103 : }
11104 : else {
11105 : int res;
11106 33 : if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11107 0 : goto failed;
11108 : }
11109 33 : res = obj2ast_pattern(state, tmp, &pattern, arena);
11110 33 : _Py_LeaveRecursiveCall();
11111 33 : if (res != 0) goto failed;
11112 33 : Py_CLEAR(tmp);
11113 : }
11114 33 : if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) {
11115 0 : return 1;
11116 : }
11117 33 : if (tmp == NULL || tmp == Py_None) {
11118 32 : Py_CLEAR(tmp);
11119 32 : guard = NULL;
11120 : }
11121 : else {
11122 : int res;
11123 1 : if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11124 0 : goto failed;
11125 : }
11126 1 : res = obj2ast_expr(state, tmp, &guard, arena);
11127 1 : _Py_LeaveRecursiveCall();
11128 1 : if (res != 0) goto failed;
11129 1 : Py_CLEAR(tmp);
11130 : }
11131 33 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
11132 0 : return 1;
11133 : }
11134 33 : if (tmp == NULL) {
11135 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from match_case");
11136 0 : return 1;
11137 : }
11138 : else {
11139 : int res;
11140 : Py_ssize_t len;
11141 : Py_ssize_t i;
11142 33 : if (!PyList_Check(tmp)) {
11143 0 : PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11144 0 : goto failed;
11145 : }
11146 33 : len = PyList_GET_SIZE(tmp);
11147 33 : body = _Py_asdl_stmt_seq_new(len, arena);
11148 33 : if (body == NULL) goto failed;
11149 71 : for (i = 0; i < len; i++) {
11150 : stmt_ty val;
11151 38 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11152 38 : Py_INCREF(tmp2);
11153 38 : if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11154 0 : goto failed;
11155 : }
11156 38 : res = obj2ast_stmt(state, tmp2, &val, arena);
11157 38 : _Py_LeaveRecursiveCall();
11158 38 : Py_DECREF(tmp2);
11159 38 : if (res != 0) goto failed;
11160 38 : if (len != PyList_GET_SIZE(tmp)) {
11161 0 : PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
11162 0 : goto failed;
11163 : }
11164 38 : asdl_seq_SET(body, i, val);
11165 : }
11166 33 : Py_CLEAR(tmp);
11167 : }
11168 33 : *out = _PyAST_match_case(pattern, guard, body, arena);
11169 33 : return 0;
11170 0 : failed:
11171 0 : Py_XDECREF(tmp);
11172 0 : return 1;
11173 : }
11174 :
11175 : int
11176 54 : obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
11177 : PyArena* arena)
11178 : {
11179 : int isinstance;
11180 :
11181 54 : PyObject *tmp = NULL;
11182 : PyObject *tp;
11183 : int lineno;
11184 : int col_offset;
11185 : int end_lineno;
11186 : int end_col_offset;
11187 :
11188 54 : if (obj == Py_None) {
11189 0 : *out = NULL;
11190 0 : return 0;
11191 : }
11192 54 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11193 0 : return 1;
11194 : }
11195 54 : if (tmp == NULL) {
11196 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
11197 0 : return 1;
11198 : }
11199 : else {
11200 : int res;
11201 54 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11202 0 : goto failed;
11203 : }
11204 54 : res = obj2ast_int(state, tmp, &lineno, arena);
11205 54 : _Py_LeaveRecursiveCall();
11206 54 : if (res != 0) goto failed;
11207 54 : Py_CLEAR(tmp);
11208 : }
11209 54 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
11210 0 : return 1;
11211 : }
11212 54 : if (tmp == NULL) {
11213 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
11214 0 : return 1;
11215 : }
11216 : else {
11217 : int res;
11218 54 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11219 0 : goto failed;
11220 : }
11221 54 : res = obj2ast_int(state, tmp, &col_offset, arena);
11222 54 : _Py_LeaveRecursiveCall();
11223 54 : if (res != 0) goto failed;
11224 54 : Py_CLEAR(tmp);
11225 : }
11226 54 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
11227 0 : return 1;
11228 : }
11229 54 : if (tmp == NULL) {
11230 0 : PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
11231 0 : return 1;
11232 : }
11233 : else {
11234 : int res;
11235 54 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11236 0 : goto failed;
11237 : }
11238 54 : res = obj2ast_int(state, tmp, &end_lineno, arena);
11239 54 : _Py_LeaveRecursiveCall();
11240 54 : if (res != 0) goto failed;
11241 54 : Py_CLEAR(tmp);
11242 : }
11243 54 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11244 0 : return 1;
11245 : }
11246 54 : if (tmp == NULL) {
11247 0 : PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
11248 0 : return 1;
11249 : }
11250 : else {
11251 : int res;
11252 54 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11253 0 : goto failed;
11254 : }
11255 54 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
11256 54 : _Py_LeaveRecursiveCall();
11257 54 : if (res != 0) goto failed;
11258 54 : Py_CLEAR(tmp);
11259 : }
11260 54 : tp = state->MatchValue_type;
11261 54 : isinstance = PyObject_IsInstance(obj, tp);
11262 54 : if (isinstance == -1) {
11263 0 : return 1;
11264 : }
11265 54 : if (isinstance) {
11266 : expr_ty value;
11267 :
11268 15 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11269 15 : return 1;
11270 : }
11271 15 : if (tmp == NULL) {
11272 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
11273 0 : return 1;
11274 : }
11275 : else {
11276 : int res;
11277 15 : if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
11278 0 : goto failed;
11279 : }
11280 15 : res = obj2ast_expr(state, tmp, &value, arena);
11281 15 : _Py_LeaveRecursiveCall();
11282 15 : if (res != 0) goto failed;
11283 15 : Py_CLEAR(tmp);
11284 : }
11285 15 : *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
11286 : end_col_offset, arena);
11287 15 : if (*out == NULL) goto failed;
11288 15 : return 0;
11289 : }
11290 39 : tp = state->MatchSingleton_type;
11291 39 : isinstance = PyObject_IsInstance(obj, tp);
11292 39 : if (isinstance == -1) {
11293 0 : return 1;
11294 : }
11295 39 : if (isinstance) {
11296 : constant value;
11297 :
11298 6 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11299 6 : return 1;
11300 : }
11301 6 : if (tmp == NULL) {
11302 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
11303 0 : return 1;
11304 : }
11305 : else {
11306 : int res;
11307 6 : if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
11308 0 : goto failed;
11309 : }
11310 6 : res = obj2ast_constant(state, tmp, &value, arena);
11311 6 : _Py_LeaveRecursiveCall();
11312 6 : if (res != 0) goto failed;
11313 6 : Py_CLEAR(tmp);
11314 : }
11315 6 : *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
11316 : end_col_offset, arena);
11317 6 : if (*out == NULL) goto failed;
11318 6 : return 0;
11319 : }
11320 33 : tp = state->MatchSequence_type;
11321 33 : isinstance = PyObject_IsInstance(obj, tp);
11322 33 : if (isinstance == -1) {
11323 0 : return 1;
11324 : }
11325 33 : if (isinstance) {
11326 : asdl_pattern_seq* patterns;
11327 :
11328 5 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11329 0 : return 1;
11330 : }
11331 5 : if (tmp == NULL) {
11332 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchSequence");
11333 0 : return 1;
11334 : }
11335 : else {
11336 : int res;
11337 : Py_ssize_t len;
11338 : Py_ssize_t i;
11339 5 : if (!PyList_Check(tmp)) {
11340 0 : PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11341 0 : goto failed;
11342 : }
11343 5 : len = PyList_GET_SIZE(tmp);
11344 5 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11345 5 : if (patterns == NULL) goto failed;
11346 10 : for (i = 0; i < len; i++) {
11347 : pattern_ty val;
11348 5 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11349 5 : Py_INCREF(tmp2);
11350 5 : if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
11351 0 : goto failed;
11352 : }
11353 5 : res = obj2ast_pattern(state, tmp2, &val, arena);
11354 5 : _Py_LeaveRecursiveCall();
11355 5 : Py_DECREF(tmp2);
11356 5 : if (res != 0) goto failed;
11357 5 : if (len != PyList_GET_SIZE(tmp)) {
11358 0 : PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
11359 0 : goto failed;
11360 : }
11361 5 : asdl_seq_SET(patterns, i, val);
11362 : }
11363 5 : Py_CLEAR(tmp);
11364 : }
11365 5 : *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
11366 : end_col_offset, arena);
11367 5 : if (*out == NULL) goto failed;
11368 5 : return 0;
11369 : }
11370 28 : tp = state->MatchMapping_type;
11371 28 : isinstance = PyObject_IsInstance(obj, tp);
11372 28 : if (isinstance == -1) {
11373 0 : return 1;
11374 : }
11375 28 : if (isinstance) {
11376 : asdl_expr_seq* keys;
11377 : asdl_pattern_seq* patterns;
11378 : identifier rest;
11379 :
11380 4 : if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
11381 4 : return 1;
11382 : }
11383 4 : if (tmp == NULL) {
11384 0 : PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from MatchMapping");
11385 0 : return 1;
11386 : }
11387 : else {
11388 : int res;
11389 : Py_ssize_t len;
11390 : Py_ssize_t i;
11391 4 : if (!PyList_Check(tmp)) {
11392 0 : PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11393 0 : goto failed;
11394 : }
11395 4 : len = PyList_GET_SIZE(tmp);
11396 4 : keys = _Py_asdl_expr_seq_new(len, arena);
11397 4 : if (keys == NULL) goto failed;
11398 10 : for (i = 0; i < len; i++) {
11399 : expr_ty val;
11400 6 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11401 6 : Py_INCREF(tmp2);
11402 6 : if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11403 0 : goto failed;
11404 : }
11405 6 : res = obj2ast_expr(state, tmp2, &val, arena);
11406 6 : _Py_LeaveRecursiveCall();
11407 6 : Py_DECREF(tmp2);
11408 6 : if (res != 0) goto failed;
11409 6 : if (len != PyList_GET_SIZE(tmp)) {
11410 0 : PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
11411 0 : goto failed;
11412 : }
11413 6 : asdl_seq_SET(keys, i, val);
11414 : }
11415 4 : Py_CLEAR(tmp);
11416 : }
11417 4 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11418 0 : return 1;
11419 : }
11420 4 : if (tmp == NULL) {
11421 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchMapping");
11422 0 : return 1;
11423 : }
11424 : else {
11425 : int res;
11426 : Py_ssize_t len;
11427 : Py_ssize_t i;
11428 4 : if (!PyList_Check(tmp)) {
11429 0 : PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11430 0 : goto failed;
11431 : }
11432 4 : len = PyList_GET_SIZE(tmp);
11433 4 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11434 4 : if (patterns == NULL) goto failed;
11435 9 : for (i = 0; i < len; i++) {
11436 : pattern_ty val;
11437 5 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11438 5 : Py_INCREF(tmp2);
11439 5 : if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11440 0 : goto failed;
11441 : }
11442 5 : res = obj2ast_pattern(state, tmp2, &val, arena);
11443 5 : _Py_LeaveRecursiveCall();
11444 5 : Py_DECREF(tmp2);
11445 5 : if (res != 0) goto failed;
11446 5 : if (len != PyList_GET_SIZE(tmp)) {
11447 0 : PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
11448 0 : goto failed;
11449 : }
11450 5 : asdl_seq_SET(patterns, i, val);
11451 : }
11452 4 : Py_CLEAR(tmp);
11453 : }
11454 4 : if (_PyObject_LookupAttr(obj, state->rest, &tmp) < 0) {
11455 0 : return 1;
11456 : }
11457 4 : if (tmp == NULL || tmp == Py_None) {
11458 1 : Py_CLEAR(tmp);
11459 1 : rest = NULL;
11460 : }
11461 : else {
11462 : int res;
11463 3 : if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11464 0 : goto failed;
11465 : }
11466 3 : res = obj2ast_identifier(state, tmp, &rest, arena);
11467 3 : _Py_LeaveRecursiveCall();
11468 3 : if (res != 0) goto failed;
11469 3 : Py_CLEAR(tmp);
11470 : }
11471 4 : *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
11472 : end_lineno, end_col_offset, arena);
11473 4 : if (*out == NULL) goto failed;
11474 4 : return 0;
11475 : }
11476 24 : tp = state->MatchClass_type;
11477 24 : isinstance = PyObject_IsInstance(obj, tp);
11478 24 : if (isinstance == -1) {
11479 0 : return 1;
11480 : }
11481 24 : if (isinstance) {
11482 : expr_ty cls;
11483 : asdl_pattern_seq* patterns;
11484 : asdl_identifier_seq* kwd_attrs;
11485 : asdl_pattern_seq* kwd_patterns;
11486 :
11487 10 : if (_PyObject_LookupAttr(obj, state->cls, &tmp) < 0) {
11488 10 : return 1;
11489 : }
11490 10 : if (tmp == NULL) {
11491 0 : PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
11492 0 : return 1;
11493 : }
11494 : else {
11495 : int res;
11496 10 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11497 0 : goto failed;
11498 : }
11499 10 : res = obj2ast_expr(state, tmp, &cls, arena);
11500 10 : _Py_LeaveRecursiveCall();
11501 10 : if (res != 0) goto failed;
11502 10 : Py_CLEAR(tmp);
11503 : }
11504 10 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11505 0 : return 1;
11506 : }
11507 10 : if (tmp == NULL) {
11508 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchClass");
11509 0 : return 1;
11510 : }
11511 : else {
11512 : int res;
11513 : Py_ssize_t len;
11514 : Py_ssize_t i;
11515 10 : if (!PyList_Check(tmp)) {
11516 0 : PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11517 0 : goto failed;
11518 : }
11519 10 : len = PyList_GET_SIZE(tmp);
11520 10 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11521 10 : if (patterns == NULL) goto failed;
11522 14 : for (i = 0; i < len; i++) {
11523 : pattern_ty val;
11524 4 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11525 4 : Py_INCREF(tmp2);
11526 4 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11527 0 : goto failed;
11528 : }
11529 4 : res = obj2ast_pattern(state, tmp2, &val, arena);
11530 4 : _Py_LeaveRecursiveCall();
11531 4 : Py_DECREF(tmp2);
11532 4 : if (res != 0) goto failed;
11533 4 : if (len != PyList_GET_SIZE(tmp)) {
11534 0 : PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
11535 0 : goto failed;
11536 : }
11537 4 : asdl_seq_SET(patterns, i, val);
11538 : }
11539 10 : Py_CLEAR(tmp);
11540 : }
11541 10 : if (_PyObject_LookupAttr(obj, state->kwd_attrs, &tmp) < 0) {
11542 0 : return 1;
11543 : }
11544 10 : if (tmp == NULL) {
11545 0 : PyErr_SetString(PyExc_TypeError, "required field \"kwd_attrs\" missing from MatchClass");
11546 0 : return 1;
11547 : }
11548 : else {
11549 : int res;
11550 : Py_ssize_t len;
11551 : Py_ssize_t i;
11552 10 : if (!PyList_Check(tmp)) {
11553 0 : PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11554 0 : goto failed;
11555 : }
11556 10 : len = PyList_GET_SIZE(tmp);
11557 10 : kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
11558 10 : if (kwd_attrs == NULL) goto failed;
11559 11 : for (i = 0; i < len; i++) {
11560 : identifier val;
11561 1 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11562 1 : Py_INCREF(tmp2);
11563 1 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11564 0 : goto failed;
11565 : }
11566 1 : res = obj2ast_identifier(state, tmp2, &val, arena);
11567 1 : _Py_LeaveRecursiveCall();
11568 1 : Py_DECREF(tmp2);
11569 1 : if (res != 0) goto failed;
11570 1 : if (len != PyList_GET_SIZE(tmp)) {
11571 0 : PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
11572 0 : goto failed;
11573 : }
11574 1 : asdl_seq_SET(kwd_attrs, i, val);
11575 : }
11576 10 : Py_CLEAR(tmp);
11577 : }
11578 10 : if (_PyObject_LookupAttr(obj, state->kwd_patterns, &tmp) < 0) {
11579 0 : return 1;
11580 : }
11581 10 : if (tmp == NULL) {
11582 0 : PyErr_SetString(PyExc_TypeError, "required field \"kwd_patterns\" missing from MatchClass");
11583 0 : return 1;
11584 : }
11585 : else {
11586 : int res;
11587 : Py_ssize_t len;
11588 : Py_ssize_t i;
11589 10 : if (!PyList_Check(tmp)) {
11590 0 : PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11591 0 : goto failed;
11592 : }
11593 10 : len = PyList_GET_SIZE(tmp);
11594 10 : kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
11595 10 : if (kwd_patterns == NULL) goto failed;
11596 13 : for (i = 0; i < len; i++) {
11597 : pattern_ty val;
11598 3 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11599 3 : Py_INCREF(tmp2);
11600 3 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11601 0 : goto failed;
11602 : }
11603 3 : res = obj2ast_pattern(state, tmp2, &val, arena);
11604 3 : _Py_LeaveRecursiveCall();
11605 3 : Py_DECREF(tmp2);
11606 3 : if (res != 0) goto failed;
11607 3 : if (len != PyList_GET_SIZE(tmp)) {
11608 0 : PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
11609 0 : goto failed;
11610 : }
11611 3 : asdl_seq_SET(kwd_patterns, i, val);
11612 : }
11613 10 : Py_CLEAR(tmp);
11614 : }
11615 10 : *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
11616 : lineno, col_offset, end_lineno,
11617 : end_col_offset, arena);
11618 10 : if (*out == NULL) goto failed;
11619 10 : return 0;
11620 : }
11621 14 : tp = state->MatchStar_type;
11622 14 : isinstance = PyObject_IsInstance(obj, tp);
11623 14 : if (isinstance == -1) {
11624 0 : return 1;
11625 : }
11626 14 : if (isinstance) {
11627 : identifier name;
11628 :
11629 5 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11630 5 : return 1;
11631 : }
11632 5 : if (tmp == NULL || tmp == Py_None) {
11633 2 : Py_CLEAR(tmp);
11634 2 : name = NULL;
11635 : }
11636 : else {
11637 : int res;
11638 3 : if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
11639 0 : goto failed;
11640 : }
11641 3 : res = obj2ast_identifier(state, tmp, &name, arena);
11642 3 : _Py_LeaveRecursiveCall();
11643 3 : if (res != 0) goto failed;
11644 3 : Py_CLEAR(tmp);
11645 : }
11646 5 : *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
11647 : end_col_offset, arena);
11648 5 : if (*out == NULL) goto failed;
11649 5 : return 0;
11650 : }
11651 9 : tp = state->MatchAs_type;
11652 9 : isinstance = PyObject_IsInstance(obj, tp);
11653 9 : if (isinstance == -1) {
11654 0 : return 1;
11655 : }
11656 9 : if (isinstance) {
11657 : pattern_ty pattern;
11658 : identifier name;
11659 :
11660 6 : if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11661 6 : return 1;
11662 : }
11663 6 : if (tmp == NULL || tmp == Py_None) {
11664 6 : Py_CLEAR(tmp);
11665 6 : pattern = NULL;
11666 : }
11667 : else {
11668 : int res;
11669 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
11670 0 : goto failed;
11671 : }
11672 0 : res = obj2ast_pattern(state, tmp, &pattern, arena);
11673 0 : _Py_LeaveRecursiveCall();
11674 0 : if (res != 0) goto failed;
11675 0 : Py_CLEAR(tmp);
11676 : }
11677 6 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11678 0 : return 1;
11679 : }
11680 6 : if (tmp == NULL || tmp == Py_None) {
11681 1 : Py_CLEAR(tmp);
11682 1 : name = NULL;
11683 : }
11684 : else {
11685 : int res;
11686 5 : if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
11687 0 : goto failed;
11688 : }
11689 5 : res = obj2ast_identifier(state, tmp, &name, arena);
11690 5 : _Py_LeaveRecursiveCall();
11691 5 : if (res != 0) goto failed;
11692 5 : Py_CLEAR(tmp);
11693 : }
11694 6 : *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
11695 : end_col_offset, arena);
11696 6 : if (*out == NULL) goto failed;
11697 6 : return 0;
11698 : }
11699 3 : tp = state->MatchOr_type;
11700 3 : isinstance = PyObject_IsInstance(obj, tp);
11701 3 : if (isinstance == -1) {
11702 0 : return 1;
11703 : }
11704 3 : if (isinstance) {
11705 : asdl_pattern_seq* patterns;
11706 :
11707 3 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11708 0 : return 1;
11709 : }
11710 3 : if (tmp == NULL) {
11711 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchOr");
11712 0 : return 1;
11713 : }
11714 : else {
11715 : int res;
11716 : Py_ssize_t len;
11717 : Py_ssize_t i;
11718 3 : if (!PyList_Check(tmp)) {
11719 0 : PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11720 0 : goto failed;
11721 : }
11722 3 : len = PyList_GET_SIZE(tmp);
11723 3 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11724 3 : if (patterns == NULL) goto failed;
11725 7 : for (i = 0; i < len; i++) {
11726 : pattern_ty val;
11727 4 : PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
11728 4 : Py_INCREF(tmp2);
11729 4 : if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
11730 0 : goto failed;
11731 : }
11732 4 : res = obj2ast_pattern(state, tmp2, &val, arena);
11733 4 : _Py_LeaveRecursiveCall();
11734 4 : Py_DECREF(tmp2);
11735 4 : if (res != 0) goto failed;
11736 4 : if (len != PyList_GET_SIZE(tmp)) {
11737 0 : PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
11738 0 : goto failed;
11739 : }
11740 4 : asdl_seq_SET(patterns, i, val);
11741 : }
11742 3 : Py_CLEAR(tmp);
11743 : }
11744 3 : *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
11745 : end_col_offset, arena);
11746 3 : if (*out == NULL) goto failed;
11747 3 : return 0;
11748 : }
11749 :
11750 0 : PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
11751 0 : failed:
11752 0 : Py_XDECREF(tmp);
11753 0 : return 1;
11754 : }
11755 :
11756 : int
11757 0 : obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
11758 : out, PyArena* arena)
11759 : {
11760 : int isinstance;
11761 :
11762 0 : PyObject *tmp = NULL;
11763 : PyObject *tp;
11764 :
11765 0 : if (obj == Py_None) {
11766 0 : *out = NULL;
11767 0 : return 0;
11768 : }
11769 0 : tp = state->TypeIgnore_type;
11770 0 : isinstance = PyObject_IsInstance(obj, tp);
11771 0 : if (isinstance == -1) {
11772 0 : return 1;
11773 : }
11774 0 : if (isinstance) {
11775 : int lineno;
11776 : string tag;
11777 :
11778 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11779 0 : return 1;
11780 : }
11781 0 : if (tmp == NULL) {
11782 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
11783 0 : return 1;
11784 : }
11785 : else {
11786 : int res;
11787 0 : if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
11788 0 : goto failed;
11789 : }
11790 0 : res = obj2ast_int(state, tmp, &lineno, arena);
11791 0 : _Py_LeaveRecursiveCall();
11792 0 : if (res != 0) goto failed;
11793 0 : Py_CLEAR(tmp);
11794 : }
11795 0 : if (_PyObject_LookupAttr(obj, state->tag, &tmp) < 0) {
11796 0 : return 1;
11797 : }
11798 0 : if (tmp == NULL) {
11799 0 : PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
11800 0 : return 1;
11801 : }
11802 : else {
11803 : int res;
11804 0 : if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
11805 0 : goto failed;
11806 : }
11807 0 : res = obj2ast_string(state, tmp, &tag, arena);
11808 0 : _Py_LeaveRecursiveCall();
11809 0 : if (res != 0) goto failed;
11810 0 : Py_CLEAR(tmp);
11811 : }
11812 0 : *out = _PyAST_TypeIgnore(lineno, tag, arena);
11813 0 : if (*out == NULL) goto failed;
11814 0 : return 0;
11815 : }
11816 :
11817 0 : PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
11818 0 : failed:
11819 0 : Py_XDECREF(tmp);
11820 0 : return 1;
11821 : }
11822 :
11823 :
11824 : static int
11825 1326 : astmodule_exec(PyObject *m)
11826 : {
11827 1326 : struct ast_state *state = get_ast_state();
11828 1326 : if (state == NULL) {
11829 0 : return -1;
11830 : }
11831 1326 : if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
11832 0 : return -1;
11833 : }
11834 1326 : if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
11835 0 : return -1;
11836 : }
11837 1326 : if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
11838 0 : return -1;
11839 : }
11840 1326 : if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
11841 0 : return -1;
11842 : }
11843 1326 : if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
11844 0 : return -1;
11845 : }
11846 1326 : if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
11847 0 : return -1;
11848 : }
11849 1326 : if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
11850 0 : return -1;
11851 : }
11852 1326 : if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
11853 0 : return -1;
11854 : }
11855 1326 : if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
11856 : {
11857 0 : return -1;
11858 : }
11859 1326 : if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
11860 0 : return -1;
11861 : }
11862 1326 : if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
11863 0 : return -1;
11864 : }
11865 1326 : if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
11866 : state->AsyncFunctionDef_type) < 0) {
11867 0 : return -1;
11868 : }
11869 1326 : if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
11870 0 : return -1;
11871 : }
11872 1326 : if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
11873 0 : return -1;
11874 : }
11875 1326 : if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
11876 0 : return -1;
11877 : }
11878 1326 : if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
11879 0 : return -1;
11880 : }
11881 1326 : if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
11882 0 : return -1;
11883 : }
11884 1326 : if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
11885 0 : return -1;
11886 : }
11887 1326 : if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
11888 0 : return -1;
11889 : }
11890 1326 : if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
11891 0 : return -1;
11892 : }
11893 1326 : if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
11894 0 : return -1;
11895 : }
11896 1326 : if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
11897 0 : return -1;
11898 : }
11899 1326 : if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
11900 0 : return -1;
11901 : }
11902 1326 : if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
11903 0 : return -1;
11904 : }
11905 1326 : if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
11906 0 : return -1;
11907 : }
11908 1326 : if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
11909 0 : return -1;
11910 : }
11911 1326 : if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
11912 0 : return -1;
11913 : }
11914 1326 : if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
11915 0 : return -1;
11916 : }
11917 1326 : if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
11918 0 : return -1;
11919 : }
11920 1326 : if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
11921 0 : return -1;
11922 : }
11923 1326 : if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
11924 0 : return -1;
11925 : }
11926 1326 : if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
11927 0 : return -1;
11928 : }
11929 1326 : if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
11930 0 : return -1;
11931 : }
11932 1326 : if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
11933 0 : return -1;
11934 : }
11935 1326 : if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
11936 0 : return -1;
11937 : }
11938 1326 : if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
11939 0 : return -1;
11940 : }
11941 1326 : if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
11942 0 : return -1;
11943 : }
11944 1326 : if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
11945 0 : return -1;
11946 : }
11947 1326 : if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
11948 0 : return -1;
11949 : }
11950 1326 : if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
11951 0 : return -1;
11952 : }
11953 1326 : if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
11954 0 : return -1;
11955 : }
11956 1326 : if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
11957 0 : return -1;
11958 : }
11959 1326 : if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
11960 0 : return -1;
11961 : }
11962 1326 : if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
11963 0 : return -1;
11964 : }
11965 1326 : if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
11966 0 : return -1;
11967 : }
11968 1326 : if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
11969 0 : return -1;
11970 : }
11971 1326 : if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
11972 0 : return -1;
11973 : }
11974 1326 : if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
11975 0 : return -1;
11976 : }
11977 1326 : if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
11978 0 : return -1;
11979 : }
11980 1326 : if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
11981 : {
11982 0 : return -1;
11983 : }
11984 1326 : if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
11985 0 : return -1;
11986 : }
11987 1326 : if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
11988 0 : return -1;
11989 : }
11990 1326 : if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
11991 0 : return -1;
11992 : }
11993 1326 : if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
11994 0 : return -1;
11995 : }
11996 1326 : if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
11997 0 : return -1;
11998 : }
11999 1326 : if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
12000 : < 0) {
12001 0 : return -1;
12002 : }
12003 1326 : if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
12004 0 : return -1;
12005 : }
12006 1326 : if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
12007 0 : return -1;
12008 : }
12009 1326 : if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
12010 0 : return -1;
12011 : }
12012 1326 : if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
12013 0 : return -1;
12014 : }
12015 1326 : if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
12016 0 : return -1;
12017 : }
12018 1326 : if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
12019 0 : return -1;
12020 : }
12021 1326 : if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
12022 0 : return -1;
12023 : }
12024 1326 : if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
12025 0 : return -1;
12026 : }
12027 1326 : if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
12028 0 : return -1;
12029 : }
12030 1326 : if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
12031 : {
12032 0 : return -1;
12033 : }
12034 1326 : if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
12035 0 : return -1;
12036 : }
12037 1326 : if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
12038 0 : return -1;
12039 : }
12040 1326 : if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
12041 0 : return -1;
12042 : }
12043 1326 : if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
12044 0 : return -1;
12045 : }
12046 1326 : if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
12047 0 : return -1;
12048 : }
12049 1326 : if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
12050 0 : return -1;
12051 : }
12052 1326 : if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
12053 0 : return -1;
12054 : }
12055 1326 : if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
12056 0 : return -1;
12057 : }
12058 1326 : if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
12059 0 : return -1;
12060 : }
12061 1326 : if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
12062 0 : return -1;
12063 : }
12064 1326 : if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
12065 0 : return -1;
12066 : }
12067 1326 : if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
12068 0 : return -1;
12069 : }
12070 1326 : if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
12071 0 : return -1;
12072 : }
12073 1326 : if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
12074 0 : return -1;
12075 : }
12076 1326 : if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
12077 0 : return -1;
12078 : }
12079 1326 : if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
12080 0 : return -1;
12081 : }
12082 1326 : if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
12083 0 : return -1;
12084 : }
12085 1326 : if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
12086 0 : return -1;
12087 : }
12088 1326 : if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
12089 0 : return -1;
12090 : }
12091 1326 : if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
12092 0 : return -1;
12093 : }
12094 1326 : if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
12095 0 : return -1;
12096 : }
12097 1326 : if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
12098 0 : return -1;
12099 : }
12100 1326 : if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
12101 0 : return -1;
12102 : }
12103 1326 : if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
12104 0 : return -1;
12105 : }
12106 1326 : if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
12107 0 : return -1;
12108 : }
12109 1326 : if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
12110 0 : return -1;
12111 : }
12112 1326 : if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
12113 0 : return -1;
12114 : }
12115 1326 : if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
12116 0 : return -1;
12117 : }
12118 1326 : if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
12119 0 : return -1;
12120 : }
12121 1326 : if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
12122 0 : return -1;
12123 : }
12124 1326 : if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
12125 0 : return -1;
12126 : }
12127 1326 : if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
12128 0 : return -1;
12129 : }
12130 1326 : if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
12131 0 : return -1;
12132 : }
12133 1326 : if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
12134 0 : return -1;
12135 : }
12136 1326 : if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
12137 0 : return -1;
12138 : }
12139 1326 : if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
12140 0 : return -1;
12141 : }
12142 1326 : if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
12143 : 0) {
12144 0 : return -1;
12145 : }
12146 1326 : if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
12147 : 0) {
12148 0 : return -1;
12149 : }
12150 1326 : if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
12151 : 0) {
12152 0 : return -1;
12153 : }
12154 1326 : if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
12155 0 : return -1;
12156 : }
12157 1326 : if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
12158 0 : return -1;
12159 : }
12160 1326 : if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
12161 0 : return -1;
12162 : }
12163 1326 : if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
12164 0 : return -1;
12165 : }
12166 1326 : if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
12167 0 : return -1;
12168 : }
12169 1326 : if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
12170 0 : return -1;
12171 : }
12172 1326 : if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
12173 0 : return -1;
12174 : }
12175 1326 : if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
12176 0 : return -1;
12177 : }
12178 1326 : if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
12179 : < 0) {
12180 0 : return -1;
12181 : }
12182 1326 : if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
12183 : 0) {
12184 0 : return -1;
12185 : }
12186 1326 : if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
12187 : {
12188 0 : return -1;
12189 : }
12190 1326 : if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
12191 0 : return -1;
12192 : }
12193 1326 : if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
12194 0 : return -1;
12195 : }
12196 1326 : if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
12197 0 : return -1;
12198 : }
12199 1326 : if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
12200 0 : return -1;
12201 : }
12202 1326 : if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
12203 0 : return -1;
12204 : }
12205 1326 : if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
12206 0 : return -1;
12207 : }
12208 1326 : return 0;
12209 : }
12210 :
12211 : static PyModuleDef_Slot astmodule_slots[] = {
12212 : {Py_mod_exec, astmodule_exec},
12213 : {0, NULL}
12214 : };
12215 :
12216 : static struct PyModuleDef _astmodule = {
12217 : PyModuleDef_HEAD_INIT,
12218 : .m_name = "_ast",
12219 : // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
12220 : .m_size = 0,
12221 : .m_slots = astmodule_slots,
12222 : };
12223 :
12224 : PyMODINIT_FUNC
12225 1326 : PyInit__ast(void)
12226 : {
12227 1326 : return PyModuleDef_Init(&_astmodule);
12228 : }
12229 :
12230 :
12231 10978 : PyObject* PyAST_mod2obj(mod_ty t)
12232 : {
12233 10978 : struct ast_state *state = get_ast_state();
12234 10978 : if (state == NULL) {
12235 0 : return NULL;
12236 : }
12237 10978 : return ast2obj_mod(state, t);
12238 : }
12239 :
12240 : /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
12241 688 : mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
12242 : {
12243 688 : const char * const req_name[] = {"Module", "Expression", "Interactive"};
12244 : int isinstance;
12245 :
12246 688 : if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
12247 0 : return NULL;
12248 : }
12249 :
12250 688 : struct ast_state *state = get_ast_state();
12251 688 : if (state == NULL) {
12252 0 : return NULL;
12253 : }
12254 :
12255 : PyObject *req_type[3];
12256 688 : req_type[0] = state->Module_type;
12257 688 : req_type[1] = state->Expression_type;
12258 688 : req_type[2] = state->Interactive_type;
12259 :
12260 688 : assert(0 <= mode && mode <= 2);
12261 :
12262 688 : isinstance = PyObject_IsInstance(ast, req_type[mode]);
12263 688 : if (isinstance == -1)
12264 0 : return NULL;
12265 688 : if (!isinstance) {
12266 2 : PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
12267 : req_name[mode], _PyType_Name(Py_TYPE(ast)));
12268 2 : return NULL;
12269 : }
12270 :
12271 686 : mod_ty res = NULL;
12272 686 : if (obj2ast_mod(state, ast, &res, arena) != 0)
12273 7 : return NULL;
12274 : else
12275 679 : return res;
12276 : }
12277 :
12278 31033 : int PyAST_Check(PyObject* obj)
12279 : {
12280 31033 : struct ast_state *state = get_ast_state();
12281 31033 : if (state == NULL) {
12282 0 : return -1;
12283 : }
12284 31033 : return PyObject_IsInstance(obj, state->AST_type);
12285 : }
12286 :
12287 :
|