Branch data 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 : 303 : get_ast_state(void)
17 : : {
18 : 303 : PyInterpreterState *interp = _PyInterpreterState_GET();
19 : 303 : struct ast_state *state = &interp->ast;
20 [ - + ]: 303 : if (!init_types(state)) {
21 : 0 : return NULL;
22 : : }
23 : 303 : return state;
24 : : }
25 : :
26 : 25 : void _PyAST_Fini(PyInterpreterState *interp)
27 : : {
28 : 25 : struct ast_state *state = &interp->ast;
29 : :
30 [ + + ]: 25 : Py_CLEAR(state->AST_type);
31 [ + + ]: 25 : Py_CLEAR(state->Add_singleton);
32 [ + + ]: 25 : Py_CLEAR(state->Add_type);
33 [ + + ]: 25 : Py_CLEAR(state->And_singleton);
34 [ + + ]: 25 : Py_CLEAR(state->And_type);
35 [ + + ]: 25 : Py_CLEAR(state->AnnAssign_type);
36 [ + + ]: 25 : Py_CLEAR(state->Assert_type);
37 [ + + ]: 25 : Py_CLEAR(state->Assign_type);
38 [ + + ]: 25 : Py_CLEAR(state->AsyncFor_type);
39 [ + + ]: 25 : Py_CLEAR(state->AsyncFunctionDef_type);
40 [ + + ]: 25 : Py_CLEAR(state->AsyncWith_type);
41 [ + + ]: 25 : Py_CLEAR(state->Attribute_type);
42 [ + + ]: 25 : Py_CLEAR(state->AugAssign_type);
43 [ + + ]: 25 : Py_CLEAR(state->Await_type);
44 [ + + ]: 25 : Py_CLEAR(state->BinOp_type);
45 [ + + ]: 25 : Py_CLEAR(state->BitAnd_singleton);
46 [ + + ]: 25 : Py_CLEAR(state->BitAnd_type);
47 [ + + ]: 25 : Py_CLEAR(state->BitOr_singleton);
48 [ + + ]: 25 : Py_CLEAR(state->BitOr_type);
49 [ + + ]: 25 : Py_CLEAR(state->BitXor_singleton);
50 [ + + ]: 25 : Py_CLEAR(state->BitXor_type);
51 [ + + ]: 25 : Py_CLEAR(state->BoolOp_type);
52 [ + + ]: 25 : Py_CLEAR(state->Break_type);
53 [ + + ]: 25 : Py_CLEAR(state->Call_type);
54 [ + + ]: 25 : Py_CLEAR(state->ClassDef_type);
55 [ + + ]: 25 : Py_CLEAR(state->Compare_type);
56 [ + + ]: 25 : Py_CLEAR(state->Constant_type);
57 [ + + ]: 25 : Py_CLEAR(state->Continue_type);
58 [ + + ]: 25 : Py_CLEAR(state->Del_singleton);
59 [ + + ]: 25 : Py_CLEAR(state->Del_type);
60 [ + + ]: 25 : Py_CLEAR(state->Delete_type);
61 [ + + ]: 25 : Py_CLEAR(state->DictComp_type);
62 [ + + ]: 25 : Py_CLEAR(state->Dict_type);
63 [ + + ]: 25 : Py_CLEAR(state->Div_singleton);
64 [ + + ]: 25 : Py_CLEAR(state->Div_type);
65 [ + + ]: 25 : Py_CLEAR(state->Eq_singleton);
66 [ + + ]: 25 : Py_CLEAR(state->Eq_type);
67 [ + + ]: 25 : Py_CLEAR(state->ExceptHandler_type);
68 [ + + ]: 25 : Py_CLEAR(state->Expr_type);
69 [ + + ]: 25 : Py_CLEAR(state->Expression_type);
70 [ + + ]: 25 : Py_CLEAR(state->FloorDiv_singleton);
71 [ + + ]: 25 : Py_CLEAR(state->FloorDiv_type);
72 [ + + ]: 25 : Py_CLEAR(state->For_type);
73 [ + + ]: 25 : Py_CLEAR(state->FormattedValue_type);
74 [ + + ]: 25 : Py_CLEAR(state->FunctionDef_type);
75 [ + + ]: 25 : Py_CLEAR(state->FunctionType_type);
76 [ + + ]: 25 : Py_CLEAR(state->GeneratorExp_type);
77 [ + + ]: 25 : Py_CLEAR(state->Global_type);
78 [ + + ]: 25 : Py_CLEAR(state->GtE_singleton);
79 [ + + ]: 25 : Py_CLEAR(state->GtE_type);
80 [ + + ]: 25 : Py_CLEAR(state->Gt_singleton);
81 [ + + ]: 25 : Py_CLEAR(state->Gt_type);
82 [ + + ]: 25 : Py_CLEAR(state->IfExp_type);
83 [ + + ]: 25 : Py_CLEAR(state->If_type);
84 [ + + ]: 25 : Py_CLEAR(state->ImportFrom_type);
85 [ + + ]: 25 : Py_CLEAR(state->Import_type);
86 [ + + ]: 25 : Py_CLEAR(state->In_singleton);
87 [ + + ]: 25 : Py_CLEAR(state->In_type);
88 [ + + ]: 25 : Py_CLEAR(state->Interactive_type);
89 [ + + ]: 25 : Py_CLEAR(state->Invert_singleton);
90 [ + + ]: 25 : Py_CLEAR(state->Invert_type);
91 [ + + ]: 25 : Py_CLEAR(state->IsNot_singleton);
92 [ + + ]: 25 : Py_CLEAR(state->IsNot_type);
93 [ + + ]: 25 : Py_CLEAR(state->Is_singleton);
94 [ + + ]: 25 : Py_CLEAR(state->Is_type);
95 [ + + ]: 25 : Py_CLEAR(state->JoinedStr_type);
96 [ + + ]: 25 : Py_CLEAR(state->LShift_singleton);
97 [ + + ]: 25 : Py_CLEAR(state->LShift_type);
98 [ + + ]: 25 : Py_CLEAR(state->Lambda_type);
99 [ + + ]: 25 : Py_CLEAR(state->ListComp_type);
100 [ + + ]: 25 : Py_CLEAR(state->List_type);
101 [ + + ]: 25 : Py_CLEAR(state->Load_singleton);
102 [ + + ]: 25 : Py_CLEAR(state->Load_type);
103 [ + + ]: 25 : Py_CLEAR(state->LtE_singleton);
104 [ + + ]: 25 : Py_CLEAR(state->LtE_type);
105 [ + + ]: 25 : Py_CLEAR(state->Lt_singleton);
106 [ + + ]: 25 : Py_CLEAR(state->Lt_type);
107 [ + + ]: 25 : Py_CLEAR(state->MatMult_singleton);
108 [ + + ]: 25 : Py_CLEAR(state->MatMult_type);
109 [ + + ]: 25 : Py_CLEAR(state->MatchAs_type);
110 [ + + ]: 25 : Py_CLEAR(state->MatchClass_type);
111 [ + + ]: 25 : Py_CLEAR(state->MatchMapping_type);
112 [ + + ]: 25 : Py_CLEAR(state->MatchOr_type);
113 [ + + ]: 25 : Py_CLEAR(state->MatchSequence_type);
114 [ + + ]: 25 : Py_CLEAR(state->MatchSingleton_type);
115 [ + + ]: 25 : Py_CLEAR(state->MatchStar_type);
116 [ + + ]: 25 : Py_CLEAR(state->MatchValue_type);
117 [ + + ]: 25 : Py_CLEAR(state->Match_type);
118 [ + + ]: 25 : Py_CLEAR(state->Mod_singleton);
119 [ + + ]: 25 : Py_CLEAR(state->Mod_type);
120 [ + + ]: 25 : Py_CLEAR(state->Module_type);
121 [ + + ]: 25 : Py_CLEAR(state->Mult_singleton);
122 [ + + ]: 25 : Py_CLEAR(state->Mult_type);
123 [ + + ]: 25 : Py_CLEAR(state->Name_type);
124 [ + + ]: 25 : Py_CLEAR(state->NamedExpr_type);
125 [ + + ]: 25 : Py_CLEAR(state->Nonlocal_type);
126 [ + + ]: 25 : Py_CLEAR(state->NotEq_singleton);
127 [ + + ]: 25 : Py_CLEAR(state->NotEq_type);
128 [ + + ]: 25 : Py_CLEAR(state->NotIn_singleton);
129 [ + + ]: 25 : Py_CLEAR(state->NotIn_type);
130 [ + + ]: 25 : Py_CLEAR(state->Not_singleton);
131 [ + + ]: 25 : Py_CLEAR(state->Not_type);
132 [ + + ]: 25 : Py_CLEAR(state->Or_singleton);
133 [ + + ]: 25 : Py_CLEAR(state->Or_type);
134 [ + + ]: 25 : Py_CLEAR(state->Pass_type);
135 [ + + ]: 25 : Py_CLEAR(state->Pow_singleton);
136 [ + + ]: 25 : Py_CLEAR(state->Pow_type);
137 [ + + ]: 25 : Py_CLEAR(state->RShift_singleton);
138 [ + + ]: 25 : Py_CLEAR(state->RShift_type);
139 [ + + ]: 25 : Py_CLEAR(state->Raise_type);
140 [ + + ]: 25 : Py_CLEAR(state->Return_type);
141 [ + + ]: 25 : Py_CLEAR(state->SetComp_type);
142 [ + + ]: 25 : Py_CLEAR(state->Set_type);
143 [ + + ]: 25 : Py_CLEAR(state->Slice_type);
144 [ + + ]: 25 : Py_CLEAR(state->Starred_type);
145 [ + + ]: 25 : Py_CLEAR(state->Store_singleton);
146 [ + + ]: 25 : Py_CLEAR(state->Store_type);
147 [ + + ]: 25 : Py_CLEAR(state->Sub_singleton);
148 [ + + ]: 25 : Py_CLEAR(state->Sub_type);
149 [ + + ]: 25 : Py_CLEAR(state->Subscript_type);
150 [ + + ]: 25 : Py_CLEAR(state->TryStar_type);
151 [ + + ]: 25 : Py_CLEAR(state->Try_type);
152 [ + + ]: 25 : Py_CLEAR(state->Tuple_type);
153 [ + + ]: 25 : Py_CLEAR(state->TypeIgnore_type);
154 [ + + ]: 25 : Py_CLEAR(state->UAdd_singleton);
155 [ + + ]: 25 : Py_CLEAR(state->UAdd_type);
156 [ + + ]: 25 : Py_CLEAR(state->USub_singleton);
157 [ + + ]: 25 : Py_CLEAR(state->USub_type);
158 [ + + ]: 25 : Py_CLEAR(state->UnaryOp_type);
159 [ + + ]: 25 : Py_CLEAR(state->While_type);
160 [ + + ]: 25 : Py_CLEAR(state->With_type);
161 [ + + ]: 25 : Py_CLEAR(state->YieldFrom_type);
162 [ + + ]: 25 : Py_CLEAR(state->Yield_type);
163 [ + + ]: 25 : Py_CLEAR(state->__dict__);
164 [ + + ]: 25 : Py_CLEAR(state->__doc__);
165 [ + + ]: 25 : Py_CLEAR(state->__match_args__);
166 [ + + ]: 25 : Py_CLEAR(state->__module__);
167 [ + + ]: 25 : Py_CLEAR(state->_attributes);
168 [ + + ]: 25 : Py_CLEAR(state->_fields);
169 [ + + ]: 25 : Py_CLEAR(state->alias_type);
170 [ + + ]: 25 : Py_CLEAR(state->annotation);
171 [ + + ]: 25 : Py_CLEAR(state->arg);
172 [ + + ]: 25 : Py_CLEAR(state->arg_type);
173 [ + + ]: 25 : Py_CLEAR(state->args);
174 [ + + ]: 25 : Py_CLEAR(state->argtypes);
175 [ + + ]: 25 : Py_CLEAR(state->arguments_type);
176 [ + + ]: 25 : Py_CLEAR(state->asname);
177 [ + + ]: 25 : Py_CLEAR(state->ast);
178 [ + + ]: 25 : Py_CLEAR(state->attr);
179 [ + + ]: 25 : Py_CLEAR(state->bases);
180 [ + + ]: 25 : Py_CLEAR(state->body);
181 [ + + ]: 25 : Py_CLEAR(state->boolop_type);
182 [ + + ]: 25 : Py_CLEAR(state->cases);
183 [ + + ]: 25 : Py_CLEAR(state->cause);
184 [ + + ]: 25 : Py_CLEAR(state->cls);
185 [ + + ]: 25 : Py_CLEAR(state->cmpop_type);
186 [ + + ]: 25 : Py_CLEAR(state->col_offset);
187 [ + + ]: 25 : Py_CLEAR(state->comparators);
188 [ + + ]: 25 : Py_CLEAR(state->comprehension_type);
189 [ + + ]: 25 : Py_CLEAR(state->context_expr);
190 [ + + ]: 25 : Py_CLEAR(state->conversion);
191 [ + + ]: 25 : Py_CLEAR(state->ctx);
192 [ + + ]: 25 : Py_CLEAR(state->decorator_list);
193 [ + + ]: 25 : Py_CLEAR(state->defaults);
194 [ + + ]: 25 : Py_CLEAR(state->elt);
195 [ + + ]: 25 : Py_CLEAR(state->elts);
196 [ + + ]: 25 : Py_CLEAR(state->end_col_offset);
197 [ + + ]: 25 : Py_CLEAR(state->end_lineno);
198 [ + + ]: 25 : Py_CLEAR(state->exc);
199 [ + + ]: 25 : Py_CLEAR(state->excepthandler_type);
200 [ + + ]: 25 : Py_CLEAR(state->expr_context_type);
201 [ + + ]: 25 : Py_CLEAR(state->expr_type);
202 [ + + ]: 25 : Py_CLEAR(state->finalbody);
203 [ + + ]: 25 : Py_CLEAR(state->format_spec);
204 [ + + ]: 25 : Py_CLEAR(state->func);
205 [ + + ]: 25 : Py_CLEAR(state->generators);
206 [ + + ]: 25 : Py_CLEAR(state->guard);
207 [ + + ]: 25 : Py_CLEAR(state->handlers);
208 [ + + ]: 25 : Py_CLEAR(state->id);
209 [ + + ]: 25 : Py_CLEAR(state->ifs);
210 [ + + ]: 25 : Py_CLEAR(state->is_async);
211 [ + + ]: 25 : Py_CLEAR(state->items);
212 [ + + ]: 25 : Py_CLEAR(state->iter);
213 [ + + ]: 25 : Py_CLEAR(state->key);
214 [ + + ]: 25 : Py_CLEAR(state->keys);
215 [ + + ]: 25 : Py_CLEAR(state->keyword_type);
216 [ + + ]: 25 : Py_CLEAR(state->keywords);
217 [ + + ]: 25 : Py_CLEAR(state->kind);
218 [ + + ]: 25 : Py_CLEAR(state->kw_defaults);
219 [ + + ]: 25 : Py_CLEAR(state->kwarg);
220 [ + + ]: 25 : Py_CLEAR(state->kwd_attrs);
221 [ + + ]: 25 : Py_CLEAR(state->kwd_patterns);
222 [ + + ]: 25 : Py_CLEAR(state->kwonlyargs);
223 [ + + ]: 25 : Py_CLEAR(state->left);
224 [ + + ]: 25 : Py_CLEAR(state->level);
225 [ + + ]: 25 : Py_CLEAR(state->lineno);
226 [ + + ]: 25 : Py_CLEAR(state->lower);
227 [ + + ]: 25 : Py_CLEAR(state->match_case_type);
228 [ + + ]: 25 : Py_CLEAR(state->mod_type);
229 [ + + ]: 25 : Py_CLEAR(state->module);
230 [ + + ]: 25 : Py_CLEAR(state->msg);
231 [ + + ]: 25 : Py_CLEAR(state->name);
232 [ + + ]: 25 : Py_CLEAR(state->names);
233 [ + + ]: 25 : Py_CLEAR(state->op);
234 [ + + ]: 25 : Py_CLEAR(state->operand);
235 [ + + ]: 25 : Py_CLEAR(state->operator_type);
236 [ + + ]: 25 : Py_CLEAR(state->ops);
237 [ + + ]: 25 : Py_CLEAR(state->optional_vars);
238 [ + + ]: 25 : Py_CLEAR(state->orelse);
239 [ + + ]: 25 : Py_CLEAR(state->pattern);
240 [ + + ]: 25 : Py_CLEAR(state->pattern_type);
241 [ + + ]: 25 : Py_CLEAR(state->patterns);
242 [ + + ]: 25 : Py_CLEAR(state->posonlyargs);
243 [ + + ]: 25 : Py_CLEAR(state->rest);
244 [ + + ]: 25 : Py_CLEAR(state->returns);
245 [ + + ]: 25 : Py_CLEAR(state->right);
246 [ + + ]: 25 : Py_CLEAR(state->simple);
247 [ + + ]: 25 : Py_CLEAR(state->slice);
248 [ + + ]: 25 : Py_CLEAR(state->step);
249 [ + + ]: 25 : Py_CLEAR(state->stmt_type);
250 [ + + ]: 25 : Py_CLEAR(state->subject);
251 [ + + ]: 25 : Py_CLEAR(state->tag);
252 [ + + ]: 25 : Py_CLEAR(state->target);
253 [ + + ]: 25 : Py_CLEAR(state->targets);
254 [ + + ]: 25 : Py_CLEAR(state->test);
255 [ + + ]: 25 : Py_CLEAR(state->type);
256 [ + + ]: 25 : Py_CLEAR(state->type_comment);
257 [ + + ]: 25 : Py_CLEAR(state->type_ignore_type);
258 [ + + ]: 25 : Py_CLEAR(state->type_ignores);
259 [ + + ]: 25 : Py_CLEAR(state->unaryop_type);
260 [ + + ]: 25 : Py_CLEAR(state->upper);
261 [ + + ]: 25 : Py_CLEAR(state->value);
262 [ + + ]: 25 : Py_CLEAR(state->values);
263 [ + + ]: 25 : Py_CLEAR(state->vararg);
264 [ + + ]: 25 : Py_CLEAR(state->withitem_type);
265 : :
266 [ - + ]: 25 : Py_CLEAR(_Py_INTERP_CACHED_OBJECT(interp, str_replace_inf));
267 : :
268 : : #if !defined(NDEBUG)
269 : : state->initialized = -1;
270 : : #else
271 : 25 : state->initialized = 0;
272 : : #endif
273 : 25 : }
274 : :
275 : 24 : static int init_identifiers(struct ast_state *state)
276 : : {
277 [ - + ]: 24 : if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return 0;
278 [ - + ]: 24 : if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return 0;
279 [ - + ]: 24 : if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return 0;
280 [ - + ]: 24 : if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return 0;
281 [ - + ]: 24 : if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return 0;
282 [ - + ]: 24 : if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return 0;
283 [ - + ]: 24 : if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return 0;
284 [ - + ]: 24 : if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return 0;
285 [ - + ]: 24 : if ((state->args = PyUnicode_InternFromString("args")) == NULL) return 0;
286 [ - + ]: 24 : if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return 0;
287 [ - + ]: 24 : if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return 0;
288 [ - + ]: 24 : if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return 0;
289 [ - + ]: 24 : if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0;
290 [ - + ]: 24 : if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0;
291 [ - + ]: 24 : if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0;
292 [ - + ]: 24 : if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0;
293 [ - + ]: 24 : if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0;
294 [ - + ]: 24 : if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return 0;
295 [ - + ]: 24 : if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return 0;
296 [ - + ]: 24 : if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return 0;
297 [ - + ]: 24 : if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return 0;
298 [ - + ]: 24 : if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return 0;
299 [ - + ]: 24 : if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return 0;
300 [ - + ]: 24 : if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return 0;
301 [ - + ]: 24 : if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return 0;
302 [ - + ]: 24 : if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return 0;
303 [ - + ]: 24 : if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return 0;
304 [ - + ]: 24 : if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return 0;
305 [ - + ]: 24 : if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return 0;
306 [ - + ]: 24 : if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return 0;
307 [ - + ]: 24 : if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return 0;
308 [ - + ]: 24 : if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return 0;
309 [ - + ]: 24 : if ((state->func = PyUnicode_InternFromString("func")) == NULL) return 0;
310 [ - + ]: 24 : if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return 0;
311 [ - + ]: 24 : if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return 0;
312 [ - + ]: 24 : if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return 0;
313 [ - + ]: 24 : if ((state->id = PyUnicode_InternFromString("id")) == NULL) return 0;
314 [ - + ]: 24 : if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return 0;
315 [ - + ]: 24 : if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return 0;
316 [ - + ]: 24 : if ((state->items = PyUnicode_InternFromString("items")) == NULL) return 0;
317 [ - + ]: 24 : if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return 0;
318 [ - + ]: 24 : if ((state->key = PyUnicode_InternFromString("key")) == NULL) return 0;
319 [ - + ]: 24 : if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return 0;
320 [ - + ]: 24 : if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return 0;
321 [ - + ]: 24 : if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return 0;
322 [ - + ]: 24 : if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return 0;
323 [ - + ]: 24 : if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return 0;
324 [ - + ]: 24 : if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return 0;
325 [ - + ]: 24 : if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return 0;
326 [ - + ]: 24 : if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return 0;
327 [ - + ]: 24 : if ((state->left = PyUnicode_InternFromString("left")) == NULL) return 0;
328 [ - + ]: 24 : if ((state->level = PyUnicode_InternFromString("level")) == NULL) return 0;
329 [ - + ]: 24 : if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return 0;
330 [ - + ]: 24 : if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return 0;
331 [ - + ]: 24 : if ((state->module = PyUnicode_InternFromString("module")) == NULL) return 0;
332 [ - + ]: 24 : if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return 0;
333 [ - + ]: 24 : if ((state->name = PyUnicode_InternFromString("name")) == NULL) return 0;
334 [ - + ]: 24 : if ((state->names = PyUnicode_InternFromString("names")) == NULL) return 0;
335 [ - + ]: 24 : if ((state->op = PyUnicode_InternFromString("op")) == NULL) return 0;
336 [ - + ]: 24 : if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return 0;
337 [ - + ]: 24 : if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return 0;
338 [ - + ]: 24 : if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0;
339 [ - + ]: 24 : if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0;
340 [ - + ]: 24 : if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0;
341 [ - + ]: 24 : if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return 0;
342 [ - + ]: 24 : if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0;
343 [ - + ]: 24 : if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return 0;
344 [ - + ]: 24 : if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0;
345 [ - + ]: 24 : if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0;
346 [ - + ]: 24 : if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return 0;
347 [ - + ]: 24 : if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return 0;
348 [ - + ]: 24 : if ((state->step = PyUnicode_InternFromString("step")) == NULL) return 0;
349 [ - + ]: 24 : if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return 0;
350 [ - + ]: 24 : if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return 0;
351 [ - + ]: 24 : if ((state->target = PyUnicode_InternFromString("target")) == NULL) return 0;
352 [ - + ]: 24 : if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return 0;
353 [ - + ]: 24 : if ((state->test = PyUnicode_InternFromString("test")) == NULL) return 0;
354 [ - + ]: 24 : if ((state->type = PyUnicode_InternFromString("type")) == NULL) return 0;
355 [ - + ]: 24 : if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return 0;
356 [ - + ]: 24 : if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return 0;
357 [ - + ]: 24 : if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return 0;
358 [ - + ]: 24 : if ((state->value = PyUnicode_InternFromString("value")) == NULL) return 0;
359 [ - + ]: 24 : if ((state->values = PyUnicode_InternFromString("values")) == NULL) return 0;
360 [ - + ]: 24 : if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return 0;
361 : 24 : return 1;
362 : : };
363 : :
364 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
# # # # #
# # # ]
365 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
# # # # #
# # # ]
366 [ + - + + : 23739 : GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
- + + + -
+ - + ]
367 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
# # # # #
# # # ]
368 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
# # # # #
# # # ]
369 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
# # # # #
# # # ]
370 [ + - + + : 19561 : GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
- + + + -
+ - + ]
371 [ + - + - : 1381 : GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
- + + - -
+ - + ]
372 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
# # # # #
# # # ]
373 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
# # # # #
# # # ]
374 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
# # # # #
# # # ]
375 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
# # # # #
# # # ]
376 [ # # # # : 0 : GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
# # # # #
# # # ]
377 : :
378 : : static PyObject* ast2obj_mod(struct ast_state *state, void*);
379 : : static const char * const Module_fields[]={
380 : : "body",
381 : : "type_ignores",
382 : : };
383 : : static const char * const Interactive_fields[]={
384 : : "body",
385 : : };
386 : : static const char * const Expression_fields[]={
387 : : "body",
388 : : };
389 : : static const char * const FunctionType_fields[]={
390 : : "argtypes",
391 : : "returns",
392 : : };
393 : : static const char * const stmt_attributes[] = {
394 : : "lineno",
395 : : "col_offset",
396 : : "end_lineno",
397 : : "end_col_offset",
398 : : };
399 : : static PyObject* ast2obj_stmt(struct ast_state *state, void*);
400 : : static const char * const FunctionDef_fields[]={
401 : : "name",
402 : : "args",
403 : : "body",
404 : : "decorator_list",
405 : : "returns",
406 : : "type_comment",
407 : : };
408 : : static const char * const AsyncFunctionDef_fields[]={
409 : : "name",
410 : : "args",
411 : : "body",
412 : : "decorator_list",
413 : : "returns",
414 : : "type_comment",
415 : : };
416 : : static const char * const ClassDef_fields[]={
417 : : "name",
418 : : "bases",
419 : : "keywords",
420 : : "body",
421 : : "decorator_list",
422 : : };
423 : : static const char * const Return_fields[]={
424 : : "value",
425 : : };
426 : : static const char * const Delete_fields[]={
427 : : "targets",
428 : : };
429 : : static const char * const Assign_fields[]={
430 : : "targets",
431 : : "value",
432 : : "type_comment",
433 : : };
434 : : static const char * const AugAssign_fields[]={
435 : : "target",
436 : : "op",
437 : : "value",
438 : : };
439 : : static const char * const AnnAssign_fields[]={
440 : : "target",
441 : : "annotation",
442 : : "value",
443 : : "simple",
444 : : };
445 : : static const char * const For_fields[]={
446 : : "target",
447 : : "iter",
448 : : "body",
449 : : "orelse",
450 : : "type_comment",
451 : : };
452 : : static const char * const AsyncFor_fields[]={
453 : : "target",
454 : : "iter",
455 : : "body",
456 : : "orelse",
457 : : "type_comment",
458 : : };
459 : : static const char * const While_fields[]={
460 : : "test",
461 : : "body",
462 : : "orelse",
463 : : };
464 : : static const char * const If_fields[]={
465 : : "test",
466 : : "body",
467 : : "orelse",
468 : : };
469 : : static const char * const With_fields[]={
470 : : "items",
471 : : "body",
472 : : "type_comment",
473 : : };
474 : : static const char * const AsyncWith_fields[]={
475 : : "items",
476 : : "body",
477 : : "type_comment",
478 : : };
479 : : static const char * const Match_fields[]={
480 : : "subject",
481 : : "cases",
482 : : };
483 : : static const char * const Raise_fields[]={
484 : : "exc",
485 : : "cause",
486 : : };
487 : : static const char * const Try_fields[]={
488 : : "body",
489 : : "handlers",
490 : : "orelse",
491 : : "finalbody",
492 : : };
493 : : static const char * const TryStar_fields[]={
494 : : "body",
495 : : "handlers",
496 : : "orelse",
497 : : "finalbody",
498 : : };
499 : : static const char * const Assert_fields[]={
500 : : "test",
501 : : "msg",
502 : : };
503 : : static const char * const Import_fields[]={
504 : : "names",
505 : : };
506 : : static const char * const ImportFrom_fields[]={
507 : : "module",
508 : : "names",
509 : : "level",
510 : : };
511 : : static const char * const Global_fields[]={
512 : : "names",
513 : : };
514 : : static const char * const Nonlocal_fields[]={
515 : : "names",
516 : : };
517 : : static const char * const Expr_fields[]={
518 : : "value",
519 : : };
520 : : static const char * const expr_attributes[] = {
521 : : "lineno",
522 : : "col_offset",
523 : : "end_lineno",
524 : : "end_col_offset",
525 : : };
526 : : static PyObject* ast2obj_expr(struct ast_state *state, void*);
527 : : static const char * const BoolOp_fields[]={
528 : : "op",
529 : : "values",
530 : : };
531 : : static const char * const NamedExpr_fields[]={
532 : : "target",
533 : : "value",
534 : : };
535 : : static const char * const BinOp_fields[]={
536 : : "left",
537 : : "op",
538 : : "right",
539 : : };
540 : : static const char * const UnaryOp_fields[]={
541 : : "op",
542 : : "operand",
543 : : };
544 : : static const char * const Lambda_fields[]={
545 : : "args",
546 : : "body",
547 : : };
548 : : static const char * const IfExp_fields[]={
549 : : "test",
550 : : "body",
551 : : "orelse",
552 : : };
553 : : static const char * const Dict_fields[]={
554 : : "keys",
555 : : "values",
556 : : };
557 : : static const char * const Set_fields[]={
558 : : "elts",
559 : : };
560 : : static const char * const ListComp_fields[]={
561 : : "elt",
562 : : "generators",
563 : : };
564 : : static const char * const SetComp_fields[]={
565 : : "elt",
566 : : "generators",
567 : : };
568 : : static const char * const DictComp_fields[]={
569 : : "key",
570 : : "value",
571 : : "generators",
572 : : };
573 : : static const char * const GeneratorExp_fields[]={
574 : : "elt",
575 : : "generators",
576 : : };
577 : : static const char * const Await_fields[]={
578 : : "value",
579 : : };
580 : : static const char * const Yield_fields[]={
581 : : "value",
582 : : };
583 : : static const char * const YieldFrom_fields[]={
584 : : "value",
585 : : };
586 : : static const char * const Compare_fields[]={
587 : : "left",
588 : : "ops",
589 : : "comparators",
590 : : };
591 : : static const char * const Call_fields[]={
592 : : "func",
593 : : "args",
594 : : "keywords",
595 : : };
596 : : static const char * const FormattedValue_fields[]={
597 : : "value",
598 : : "conversion",
599 : : "format_spec",
600 : : };
601 : : static const char * const JoinedStr_fields[]={
602 : : "values",
603 : : };
604 : : static const char * const Constant_fields[]={
605 : : "value",
606 : : "kind",
607 : : };
608 : : static const char * const Attribute_fields[]={
609 : : "value",
610 : : "attr",
611 : : "ctx",
612 : : };
613 : : static const char * const Subscript_fields[]={
614 : : "value",
615 : : "slice",
616 : : "ctx",
617 : : };
618 : : static const char * const Starred_fields[]={
619 : : "value",
620 : : "ctx",
621 : : };
622 : : static const char * const Name_fields[]={
623 : : "id",
624 : : "ctx",
625 : : };
626 : : static const char * const List_fields[]={
627 : : "elts",
628 : : "ctx",
629 : : };
630 : : static const char * const Tuple_fields[]={
631 : : "elts",
632 : : "ctx",
633 : : };
634 : : static const char * const Slice_fields[]={
635 : : "lower",
636 : : "upper",
637 : : "step",
638 : : };
639 : : static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
640 : : static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
641 : : static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
642 : : static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
643 : : static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
644 : : static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
645 : : static const char * const comprehension_fields[]={
646 : : "target",
647 : : "iter",
648 : : "ifs",
649 : : "is_async",
650 : : };
651 : : static const char * const excepthandler_attributes[] = {
652 : : "lineno",
653 : : "col_offset",
654 : : "end_lineno",
655 : : "end_col_offset",
656 : : };
657 : : static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
658 : : static const char * const ExceptHandler_fields[]={
659 : : "type",
660 : : "name",
661 : : "body",
662 : : };
663 : : static PyObject* ast2obj_arguments(struct ast_state *state, void*);
664 : : static const char * const arguments_fields[]={
665 : : "posonlyargs",
666 : : "args",
667 : : "vararg",
668 : : "kwonlyargs",
669 : : "kw_defaults",
670 : : "kwarg",
671 : : "defaults",
672 : : };
673 : : static PyObject* ast2obj_arg(struct ast_state *state, void*);
674 : : static const char * const arg_attributes[] = {
675 : : "lineno",
676 : : "col_offset",
677 : : "end_lineno",
678 : : "end_col_offset",
679 : : };
680 : : static const char * const arg_fields[]={
681 : : "arg",
682 : : "annotation",
683 : : "type_comment",
684 : : };
685 : : static PyObject* ast2obj_keyword(struct ast_state *state, void*);
686 : : static const char * const keyword_attributes[] = {
687 : : "lineno",
688 : : "col_offset",
689 : : "end_lineno",
690 : : "end_col_offset",
691 : : };
692 : : static const char * const keyword_fields[]={
693 : : "arg",
694 : : "value",
695 : : };
696 : : static PyObject* ast2obj_alias(struct ast_state *state, void*);
697 : : static const char * const alias_attributes[] = {
698 : : "lineno",
699 : : "col_offset",
700 : : "end_lineno",
701 : : "end_col_offset",
702 : : };
703 : : static const char * const alias_fields[]={
704 : : "name",
705 : : "asname",
706 : : };
707 : : static PyObject* ast2obj_withitem(struct ast_state *state, void*);
708 : : static const char * const withitem_fields[]={
709 : : "context_expr",
710 : : "optional_vars",
711 : : };
712 : : static PyObject* ast2obj_match_case(struct ast_state *state, void*);
713 : : static const char * const match_case_fields[]={
714 : : "pattern",
715 : : "guard",
716 : : "body",
717 : : };
718 : : static const char * const pattern_attributes[] = {
719 : : "lineno",
720 : : "col_offset",
721 : : "end_lineno",
722 : : "end_col_offset",
723 : : };
724 : : static PyObject* ast2obj_pattern(struct ast_state *state, void*);
725 : : static const char * const MatchValue_fields[]={
726 : : "value",
727 : : };
728 : : static const char * const MatchSingleton_fields[]={
729 : : "value",
730 : : };
731 : : static const char * const MatchSequence_fields[]={
732 : : "patterns",
733 : : };
734 : : static const char * const MatchMapping_fields[]={
735 : : "keys",
736 : : "patterns",
737 : : "rest",
738 : : };
739 : : static const char * const MatchClass_fields[]={
740 : : "cls",
741 : : "patterns",
742 : : "kwd_attrs",
743 : : "kwd_patterns",
744 : : };
745 : : static const char * const MatchStar_fields[]={
746 : : "name",
747 : : };
748 : : static const char * const MatchAs_fields[]={
749 : : "pattern",
750 : : "name",
751 : : };
752 : : static const char * const MatchOr_fields[]={
753 : : "patterns",
754 : : };
755 : : static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
756 : : static const char * const TypeIgnore_fields[]={
757 : : "lineno",
758 : : "tag",
759 : : };
760 : :
761 : :
762 : :
763 : : typedef struct {
764 : : PyObject_HEAD
765 : : PyObject *dict;
766 : : } AST_object;
767 : :
768 : : static void
769 : 407079 : ast_dealloc(AST_object *self)
770 : : {
771 : : /* bpo-31095: UnTrack is needed before calling any callbacks */
772 : 407079 : PyTypeObject *tp = Py_TYPE(self);
773 : 407079 : PyObject_GC_UnTrack(self);
774 [ + + ]: 407079 : Py_CLEAR(self->dict);
775 : 407079 : freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
776 : : assert(free_func != NULL);
777 : 407079 : free_func(self);
778 : 407079 : Py_DECREF(tp);
779 : 407079 : }
780 : :
781 : : static int
782 : 818250 : ast_traverse(AST_object *self, visitproc visit, void *arg)
783 : : {
784 [ + - - + ]: 818250 : Py_VISIT(Py_TYPE(self));
785 [ + + - + ]: 818250 : Py_VISIT(self->dict);
786 : 818250 : return 0;
787 : : }
788 : :
789 : : static int
790 : 0 : ast_clear(AST_object *self)
791 : : {
792 [ # # ]: 0 : Py_CLEAR(self->dict);
793 : 0 : return 0;
794 : : }
795 : :
796 : : static int
797 : 0 : ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
798 : : {
799 : 0 : struct ast_state *state = get_ast_state();
800 [ # # ]: 0 : if (state == NULL) {
801 : 0 : return -1;
802 : : }
803 : :
804 : 0 : Py_ssize_t i, numfields = 0;
805 : 0 : int res = -1;
806 : : PyObject *key, *value, *fields;
807 [ # # ]: 0 : if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
808 : 0 : goto cleanup;
809 : : }
810 [ # # ]: 0 : if (fields) {
811 : 0 : numfields = PySequence_Size(fields);
812 [ # # ]: 0 : if (numfields == -1) {
813 : 0 : goto cleanup;
814 : : }
815 : : }
816 : :
817 : 0 : res = 0; /* if no error occurs, this stays 0 to the end */
818 [ # # ]: 0 : if (numfields < PyTuple_GET_SIZE(args)) {
819 [ # # ]: 0 : PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
820 : : "%zd positional argument%s",
821 : : _PyType_Name(Py_TYPE(self)),
822 : : numfields, numfields == 1 ? "" : "s");
823 : 0 : res = -1;
824 : 0 : goto cleanup;
825 : : }
826 [ # # ]: 0 : for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
827 : : /* cannot be reached when fields is NULL */
828 : 0 : PyObject *name = PySequence_GetItem(fields, i);
829 [ # # ]: 0 : if (!name) {
830 : 0 : res = -1;
831 : 0 : goto cleanup;
832 : : }
833 : 0 : res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
834 : 0 : Py_DECREF(name);
835 [ # # ]: 0 : if (res < 0) {
836 : 0 : goto cleanup;
837 : : }
838 : : }
839 [ # # ]: 0 : if (kw) {
840 : 0 : i = 0; /* needed by PyDict_Next */
841 [ # # ]: 0 : while (PyDict_Next(kw, &i, &key, &value)) {
842 : 0 : int contains = PySequence_Contains(fields, key);
843 [ # # ]: 0 : if (contains == -1) {
844 : 0 : res = -1;
845 : 0 : goto cleanup;
846 [ # # ]: 0 : } else if (contains == 1) {
847 : 0 : Py_ssize_t p = PySequence_Index(fields, key);
848 [ # # ]: 0 : if (p == -1) {
849 : 0 : res = -1;
850 : 0 : goto cleanup;
851 : : }
852 [ # # ]: 0 : if (p < PyTuple_GET_SIZE(args)) {
853 : 0 : PyErr_Format(PyExc_TypeError,
854 : : "%.400s got multiple values for argument '%U'",
855 : 0 : Py_TYPE(self)->tp_name, key);
856 : 0 : res = -1;
857 : 0 : goto cleanup;
858 : : }
859 : : }
860 : 0 : res = PyObject_SetAttr(self, key, value);
861 [ # # ]: 0 : if (res < 0) {
862 : 0 : goto cleanup;
863 : : }
864 : : }
865 : : }
866 : 0 : cleanup:
867 : 0 : Py_XDECREF(fields);
868 : 0 : return res;
869 : : }
870 : :
871 : : /* Pickling support */
872 : : static PyObject *
873 : 0 : ast_type_reduce(PyObject *self, PyObject *unused)
874 : : {
875 : 0 : struct ast_state *state = get_ast_state();
876 [ # # ]: 0 : if (state == NULL) {
877 : 0 : return NULL;
878 : : }
879 : :
880 : : PyObject *dict;
881 [ # # ]: 0 : if (_PyObject_LookupAttr(self, state->__dict__, &dict) < 0) {
882 : 0 : return NULL;
883 : : }
884 [ # # ]: 0 : if (dict) {
885 : 0 : return Py_BuildValue("O()N", Py_TYPE(self), dict);
886 : : }
887 : 0 : return Py_BuildValue("O()", Py_TYPE(self));
888 : : }
889 : :
890 : : static PyMemberDef ast_type_members[] = {
891 : : {"__dictoffset__", T_PYSSIZET, offsetof(AST_object, dict), READONLY},
892 : : {NULL} /* Sentinel */
893 : : };
894 : :
895 : : static PyMethodDef ast_type_methods[] = {
896 : : {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
897 : : {NULL}
898 : : };
899 : :
900 : : static PyGetSetDef ast_type_getsets[] = {
901 : : {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
902 : : {NULL}
903 : : };
904 : :
905 : : static PyType_Slot AST_type_slots[] = {
906 : : {Py_tp_dealloc, ast_dealloc},
907 : : {Py_tp_getattro, PyObject_GenericGetAttr},
908 : : {Py_tp_setattro, PyObject_GenericSetAttr},
909 : : {Py_tp_traverse, ast_traverse},
910 : : {Py_tp_clear, ast_clear},
911 : : {Py_tp_members, ast_type_members},
912 : : {Py_tp_methods, ast_type_methods},
913 : : {Py_tp_getset, ast_type_getsets},
914 : : {Py_tp_init, ast_type_init},
915 : : {Py_tp_alloc, PyType_GenericAlloc},
916 : : {Py_tp_new, PyType_GenericNew},
917 : : {Py_tp_free, PyObject_GC_Del},
918 : : {0, 0},
919 : : };
920 : :
921 : : static PyType_Spec AST_type_spec = {
922 : : "ast.AST",
923 : : sizeof(AST_object),
924 : : 0,
925 : : Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
926 : : AST_type_slots
927 : : };
928 : :
929 : : static PyObject *
930 : 2832 : make_type(struct ast_state *state, const char *type, PyObject* base,
931 : : const char* const* fields, int num_fields, const char *doc)
932 : : {
933 : : PyObject *fnames, *result;
934 : : int i;
935 : 2832 : fnames = PyTuple_New(num_fields);
936 [ - + ]: 2832 : if (!fnames) return NULL;
937 [ + + ]: 7104 : for (i = 0; i < num_fields; i++) {
938 : 4272 : PyObject *field = PyUnicode_InternFromString(fields[i]);
939 [ - + ]: 4272 : if (!field) {
940 : 0 : Py_DECREF(fnames);
941 : 0 : return NULL;
942 : : }
943 : 4272 : PyTuple_SET_ITEM(fnames, i, field);
944 : : }
945 : 2832 : result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
946 : : type, base,
947 : : state->_fields, fnames,
948 : : state->__match_args__, fnames,
949 : : state->__module__,
950 : : state->ast,
951 : : state->__doc__, doc);
952 : 2832 : Py_DECREF(fnames);
953 : 2832 : return result;
954 : : }
955 : :
956 : : static int
957 : 432 : add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
958 : : {
959 : : int i, result;
960 : 432 : PyObject *s, *l = PyTuple_New(num_fields);
961 [ - + ]: 432 : if (!l)
962 : 0 : return 0;
963 [ + + ]: 1104 : for (i = 0; i < num_fields; i++) {
964 : 672 : s = PyUnicode_InternFromString(attrs[i]);
965 [ - + ]: 672 : if (!s) {
966 : 0 : Py_DECREF(l);
967 : 0 : return 0;
968 : : }
969 : 672 : PyTuple_SET_ITEM(l, i, s);
970 : : }
971 : 432 : result = PyObject_SetAttr(type, state->_attributes, l) >= 0;
972 : 432 : Py_DECREF(l);
973 : 432 : return result;
974 : : }
975 : :
976 : : /* Conversion AST -> Python */
977 : :
978 : 57 : static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq, PyObject* (*func)(struct ast_state *state, void*))
979 : : {
980 [ + + ]: 57 : Py_ssize_t i, n = asdl_seq_LEN(seq);
981 : 57 : PyObject *result = PyList_New(n);
982 : : PyObject *value;
983 [ - + ]: 57 : if (!result)
984 : 0 : return NULL;
985 [ + + ]: 406293 : for (i = 0; i < n; i++) {
986 : 406236 : value = func(state, asdl_seq_GET_UNTYPED(seq, i));
987 [ - + ]: 406236 : if (!value) {
988 : 0 : Py_DECREF(result);
989 : 0 : return NULL;
990 : : }
991 : 406236 : PyList_SET_ITEM(result, i, value);
992 : : }
993 : 57 : return result;
994 : : }
995 : :
996 : 812458 : static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
997 : : {
998 : 812458 : PyObject *op = (PyObject*)o;
999 [ + + ]: 812458 : if (!op) {
1000 : 406221 : op = Py_None;
1001 : : }
1002 : 812458 : return Py_NewRef(op);
1003 : : }
1004 : : #define ast2obj_constant ast2obj_object
1005 : : #define ast2obj_identifier ast2obj_object
1006 : : #define ast2obj_string ast2obj_object
1007 : :
1008 : 1625116 : static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
1009 : : {
1010 : 1625116 : return PyLong_FromLong(b);
1011 : : }
1012 : :
1013 : : /* Conversion Python -> AST */
1014 : :
1015 : 0 : static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1016 : : {
1017 [ # # ]: 0 : if (obj == Py_None)
1018 : 0 : obj = NULL;
1019 [ # # ]: 0 : if (obj) {
1020 [ # # ]: 0 : if (_PyArena_AddPyObject(arena, obj) < 0) {
1021 : 0 : *out = NULL;
1022 : 0 : return -1;
1023 : : }
1024 : 0 : *out = Py_NewRef(obj);
1025 : : }
1026 : : else {
1027 : 0 : *out = NULL;
1028 : : }
1029 : 0 : return 0;
1030 : : }
1031 : :
1032 : 0 : static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1033 : : {
1034 [ # # ]: 0 : if (_PyArena_AddPyObject(arena, obj) < 0) {
1035 : 0 : *out = NULL;
1036 : 0 : return -1;
1037 : : }
1038 : 0 : *out = Py_NewRef(obj);
1039 : 0 : return 0;
1040 : : }
1041 : :
1042 : 0 : static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1043 : : {
1044 [ # # # # ]: 0 : if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
1045 : 0 : PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
1046 : 0 : return 1;
1047 : : }
1048 : 0 : return obj2ast_object(state, obj, out, arena);
1049 : : }
1050 : :
1051 : 0 : static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1052 : : {
1053 [ # # # # ]: 0 : if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
1054 : 0 : PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
1055 : 0 : return 1;
1056 : : }
1057 : 0 : return obj2ast_object(state, obj, out, arena);
1058 : : }
1059 : :
1060 : 0 : static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
1061 : : {
1062 : : int i;
1063 [ # # ]: 0 : if (!PyLong_Check(obj)) {
1064 : 0 : PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
1065 : 0 : return 1;
1066 : : }
1067 : :
1068 : 0 : i = _PyLong_AsInt(obj);
1069 [ # # # # ]: 0 : if (i == -1 && PyErr_Occurred())
1070 : 0 : return 1;
1071 : 0 : *out = i;
1072 : 0 : return 0;
1073 : : }
1074 : :
1075 : 24 : static int add_ast_fields(struct ast_state *state)
1076 : : {
1077 : : PyObject *empty_tuple;
1078 : 24 : empty_tuple = PyTuple_New(0);
1079 [ + - + - ]: 48 : if (!empty_tuple ||
1080 [ + - ]: 48 : PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
1081 [ - + ]: 48 : PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
1082 : 24 : PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
1083 : 0 : Py_XDECREF(empty_tuple);
1084 : 0 : return -1;
1085 : : }
1086 : 24 : Py_DECREF(empty_tuple);
1087 : 24 : return 0;
1088 : : }
1089 : :
1090 : :
1091 : :
1092 : : static int
1093 : 303 : init_types(struct ast_state *state)
1094 : : {
1095 : : // init_types() must not be called after _PyAST_Fini()
1096 : : // has been called
1097 : : assert(state->initialized >= 0);
1098 : :
1099 [ + + ]: 303 : if (state->initialized) {
1100 : 279 : return 1;
1101 : : }
1102 [ - + ]: 24 : if (init_identifiers(state) < 0) {
1103 : 0 : return 0;
1104 : : }
1105 : 24 : state->AST_type = PyType_FromSpec(&AST_type_spec);
1106 [ - + ]: 24 : if (!state->AST_type) {
1107 : 0 : return 0;
1108 : : }
1109 [ - + ]: 24 : if (add_ast_fields(state) < 0) {
1110 : 0 : return 0;
1111 : : }
1112 : 24 : state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
1113 : : "mod = Module(stmt* body, type_ignore* type_ignores)\n"
1114 : : " | Interactive(stmt* body)\n"
1115 : : " | Expression(expr body)\n"
1116 : : " | FunctionType(expr* argtypes, expr returns)");
1117 [ - + ]: 24 : if (!state->mod_type) return 0;
1118 [ - + ]: 24 : if (!add_attributes(state, state->mod_type, NULL, 0)) return 0;
1119 : 24 : state->Module_type = make_type(state, "Module", state->mod_type,
1120 : : Module_fields, 2,
1121 : : "Module(stmt* body, type_ignore* type_ignores)");
1122 [ - + ]: 24 : if (!state->Module_type) return 0;
1123 : 24 : state->Interactive_type = make_type(state, "Interactive", state->mod_type,
1124 : : Interactive_fields, 1,
1125 : : "Interactive(stmt* body)");
1126 [ - + ]: 24 : if (!state->Interactive_type) return 0;
1127 : 24 : state->Expression_type = make_type(state, "Expression", state->mod_type,
1128 : : Expression_fields, 1,
1129 : : "Expression(expr body)");
1130 [ - + ]: 24 : if (!state->Expression_type) return 0;
1131 : 24 : state->FunctionType_type = make_type(state, "FunctionType",
1132 : : state->mod_type, FunctionType_fields,
1133 : : 2,
1134 : : "FunctionType(expr* argtypes, expr returns)");
1135 [ - + ]: 24 : if (!state->FunctionType_type) return 0;
1136 : 24 : state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
1137 : : "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n"
1138 : : " | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n"
1139 : : " | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)\n"
1140 : : " | Return(expr? value)\n"
1141 : : " | Delete(expr* targets)\n"
1142 : : " | Assign(expr* targets, expr value, string? type_comment)\n"
1143 : : " | AugAssign(expr target, operator op, expr value)\n"
1144 : : " | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
1145 : : " | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
1146 : : " | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
1147 : : " | While(expr test, stmt* body, stmt* orelse)\n"
1148 : : " | If(expr test, stmt* body, stmt* orelse)\n"
1149 : : " | With(withitem* items, stmt* body, string? type_comment)\n"
1150 : : " | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
1151 : : " | Match(expr subject, match_case* cases)\n"
1152 : : " | Raise(expr? exc, expr? cause)\n"
1153 : : " | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
1154 : : " | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
1155 : : " | Assert(expr test, expr? msg)\n"
1156 : : " | Import(alias* names)\n"
1157 : : " | ImportFrom(identifier? module, alias* names, int? level)\n"
1158 : : " | Global(identifier* names)\n"
1159 : : " | Nonlocal(identifier* names)\n"
1160 : : " | Expr(expr value)\n"
1161 : : " | Pass\n"
1162 : : " | Break\n"
1163 : : " | Continue");
1164 [ - + ]: 24 : if (!state->stmt_type) return 0;
1165 [ - + ]: 24 : if (!add_attributes(state, state->stmt_type, stmt_attributes, 4)) return 0;
1166 [ - + ]: 24 : if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
1167 : 0 : return 0;
1168 [ - + ]: 24 : if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
1169 : : -1)
1170 : 0 : return 0;
1171 : 24 : state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
1172 : : FunctionDef_fields, 6,
1173 : : "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)");
1174 [ - + ]: 24 : if (!state->FunctionDef_type) return 0;
1175 [ - + ]: 24 : if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
1176 : : -1)
1177 : 0 : return 0;
1178 [ - + ]: 24 : if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
1179 : : == -1)
1180 : 0 : return 0;
1181 : 24 : state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
1182 : : state->stmt_type,
1183 : : AsyncFunctionDef_fields, 6,
1184 : : "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)");
1185 [ - + ]: 24 : if (!state->AsyncFunctionDef_type) return 0;
1186 [ - + ]: 24 : if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
1187 : : == -1)
1188 : 0 : return 0;
1189 [ - + ]: 24 : if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
1190 : : Py_None) == -1)
1191 : 0 : return 0;
1192 : 24 : state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
1193 : : ClassDef_fields, 5,
1194 : : "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)");
1195 [ - + ]: 24 : if (!state->ClassDef_type) return 0;
1196 : 24 : state->Return_type = make_type(state, "Return", state->stmt_type,
1197 : : Return_fields, 1,
1198 : : "Return(expr? value)");
1199 [ - + ]: 24 : if (!state->Return_type) return 0;
1200 [ - + ]: 24 : if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
1201 : 0 : return 0;
1202 : 24 : state->Delete_type = make_type(state, "Delete", state->stmt_type,
1203 : : Delete_fields, 1,
1204 : : "Delete(expr* targets)");
1205 [ - + ]: 24 : if (!state->Delete_type) return 0;
1206 : 24 : state->Assign_type = make_type(state, "Assign", state->stmt_type,
1207 : : Assign_fields, 3,
1208 : : "Assign(expr* targets, expr value, string? type_comment)");
1209 [ - + ]: 24 : if (!state->Assign_type) return 0;
1210 [ - + ]: 24 : if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
1211 : : -1)
1212 : 0 : return 0;
1213 : 24 : state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
1214 : : AugAssign_fields, 3,
1215 : : "AugAssign(expr target, operator op, expr value)");
1216 [ - + ]: 24 : if (!state->AugAssign_type) return 0;
1217 : 24 : state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
1218 : : AnnAssign_fields, 4,
1219 : : "AnnAssign(expr target, expr annotation, expr? value, int simple)");
1220 [ - + ]: 24 : if (!state->AnnAssign_type) return 0;
1221 [ - + ]: 24 : if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
1222 : 0 : return 0;
1223 : 24 : state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
1224 : : "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
1225 [ - + ]: 24 : if (!state->For_type) return 0;
1226 [ - + ]: 24 : if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
1227 : 0 : return 0;
1228 : 24 : state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
1229 : : AsyncFor_fields, 5,
1230 : : "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
1231 [ - + ]: 24 : if (!state->AsyncFor_type) return 0;
1232 [ - + ]: 24 : if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
1233 : : -1)
1234 : 0 : return 0;
1235 : 24 : state->While_type = make_type(state, "While", state->stmt_type,
1236 : : While_fields, 3,
1237 : : "While(expr test, stmt* body, stmt* orelse)");
1238 [ - + ]: 24 : if (!state->While_type) return 0;
1239 : 24 : state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
1240 : : "If(expr test, stmt* body, stmt* orelse)");
1241 [ - + ]: 24 : if (!state->If_type) return 0;
1242 : 24 : state->With_type = make_type(state, "With", state->stmt_type, With_fields,
1243 : : 3,
1244 : : "With(withitem* items, stmt* body, string? type_comment)");
1245 [ - + ]: 24 : if (!state->With_type) return 0;
1246 [ - + ]: 24 : if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
1247 : 0 : return 0;
1248 : 24 : state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
1249 : : AsyncWith_fields, 3,
1250 : : "AsyncWith(withitem* items, stmt* body, string? type_comment)");
1251 [ - + ]: 24 : if (!state->AsyncWith_type) return 0;
1252 [ - + ]: 24 : if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
1253 : : == -1)
1254 : 0 : return 0;
1255 : 24 : state->Match_type = make_type(state, "Match", state->stmt_type,
1256 : : Match_fields, 2,
1257 : : "Match(expr subject, match_case* cases)");
1258 [ - + ]: 24 : if (!state->Match_type) return 0;
1259 : 24 : state->Raise_type = make_type(state, "Raise", state->stmt_type,
1260 : : Raise_fields, 2,
1261 : : "Raise(expr? exc, expr? cause)");
1262 [ - + ]: 24 : if (!state->Raise_type) return 0;
1263 [ - + ]: 24 : if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
1264 : 0 : return 0;
1265 [ - + ]: 24 : if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
1266 : 0 : return 0;
1267 : 24 : state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
1268 : : "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
1269 [ - + ]: 24 : if (!state->Try_type) return 0;
1270 : 24 : state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
1271 : : TryStar_fields, 4,
1272 : : "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
1273 [ - + ]: 24 : if (!state->TryStar_type) return 0;
1274 : 24 : state->Assert_type = make_type(state, "Assert", state->stmt_type,
1275 : : Assert_fields, 2,
1276 : : "Assert(expr test, expr? msg)");
1277 [ - + ]: 24 : if (!state->Assert_type) return 0;
1278 [ - + ]: 24 : if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
1279 : 0 : return 0;
1280 : 24 : state->Import_type = make_type(state, "Import", state->stmt_type,
1281 : : Import_fields, 1,
1282 : : "Import(alias* names)");
1283 [ - + ]: 24 : if (!state->Import_type) return 0;
1284 : 24 : state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
1285 : : ImportFrom_fields, 3,
1286 : : "ImportFrom(identifier? module, alias* names, int? level)");
1287 [ - + ]: 24 : if (!state->ImportFrom_type) return 0;
1288 [ - + ]: 24 : if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
1289 : 0 : return 0;
1290 [ - + ]: 24 : if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
1291 : 0 : return 0;
1292 : 24 : state->Global_type = make_type(state, "Global", state->stmt_type,
1293 : : Global_fields, 1,
1294 : : "Global(identifier* names)");
1295 [ - + ]: 24 : if (!state->Global_type) return 0;
1296 : 24 : state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
1297 : : Nonlocal_fields, 1,
1298 : : "Nonlocal(identifier* names)");
1299 [ - + ]: 24 : if (!state->Nonlocal_type) return 0;
1300 : 24 : state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
1301 : : 1,
1302 : : "Expr(expr value)");
1303 [ - + ]: 24 : if (!state->Expr_type) return 0;
1304 : 24 : state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
1305 : : "Pass");
1306 [ - + ]: 24 : if (!state->Pass_type) return 0;
1307 : 24 : state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
1308 : : "Break");
1309 [ - + ]: 24 : if (!state->Break_type) return 0;
1310 : 24 : state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
1311 : : 0,
1312 : : "Continue");
1313 [ - + ]: 24 : if (!state->Continue_type) return 0;
1314 : 24 : state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
1315 : : "expr = BoolOp(boolop op, expr* values)\n"
1316 : : " | NamedExpr(expr target, expr value)\n"
1317 : : " | BinOp(expr left, operator op, expr right)\n"
1318 : : " | UnaryOp(unaryop op, expr operand)\n"
1319 : : " | Lambda(arguments args, expr body)\n"
1320 : : " | IfExp(expr test, expr body, expr orelse)\n"
1321 : : " | Dict(expr* keys, expr* values)\n"
1322 : : " | Set(expr* elts)\n"
1323 : : " | ListComp(expr elt, comprehension* generators)\n"
1324 : : " | SetComp(expr elt, comprehension* generators)\n"
1325 : : " | DictComp(expr key, expr value, comprehension* generators)\n"
1326 : : " | GeneratorExp(expr elt, comprehension* generators)\n"
1327 : : " | Await(expr value)\n"
1328 : : " | Yield(expr? value)\n"
1329 : : " | YieldFrom(expr value)\n"
1330 : : " | Compare(expr left, cmpop* ops, expr* comparators)\n"
1331 : : " | Call(expr func, expr* args, keyword* keywords)\n"
1332 : : " | FormattedValue(expr value, int conversion, expr? format_spec)\n"
1333 : : " | JoinedStr(expr* values)\n"
1334 : : " | Constant(constant value, string? kind)\n"
1335 : : " | Attribute(expr value, identifier attr, expr_context ctx)\n"
1336 : : " | Subscript(expr value, expr slice, expr_context ctx)\n"
1337 : : " | Starred(expr value, expr_context ctx)\n"
1338 : : " | Name(identifier id, expr_context ctx)\n"
1339 : : " | List(expr* elts, expr_context ctx)\n"
1340 : : " | Tuple(expr* elts, expr_context ctx)\n"
1341 : : " | Slice(expr? lower, expr? upper, expr? step)");
1342 [ - + ]: 24 : if (!state->expr_type) return 0;
1343 [ - + ]: 24 : if (!add_attributes(state, state->expr_type, expr_attributes, 4)) return 0;
1344 [ - + ]: 24 : if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
1345 : 0 : return 0;
1346 [ - + ]: 24 : if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
1347 : : -1)
1348 : 0 : return 0;
1349 : 24 : state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
1350 : : BoolOp_fields, 2,
1351 : : "BoolOp(boolop op, expr* values)");
1352 [ - + ]: 24 : if (!state->BoolOp_type) return 0;
1353 : 24 : state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
1354 : : NamedExpr_fields, 2,
1355 : : "NamedExpr(expr target, expr value)");
1356 [ - + ]: 24 : if (!state->NamedExpr_type) return 0;
1357 : 24 : state->BinOp_type = make_type(state, "BinOp", state->expr_type,
1358 : : BinOp_fields, 3,
1359 : : "BinOp(expr left, operator op, expr right)");
1360 [ - + ]: 24 : if (!state->BinOp_type) return 0;
1361 : 24 : state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
1362 : : UnaryOp_fields, 2,
1363 : : "UnaryOp(unaryop op, expr operand)");
1364 [ - + ]: 24 : if (!state->UnaryOp_type) return 0;
1365 : 24 : state->Lambda_type = make_type(state, "Lambda", state->expr_type,
1366 : : Lambda_fields, 2,
1367 : : "Lambda(arguments args, expr body)");
1368 [ - + ]: 24 : if (!state->Lambda_type) return 0;
1369 : 24 : state->IfExp_type = make_type(state, "IfExp", state->expr_type,
1370 : : IfExp_fields, 3,
1371 : : "IfExp(expr test, expr body, expr orelse)");
1372 [ - + ]: 24 : if (!state->IfExp_type) return 0;
1373 : 24 : state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
1374 : : 2,
1375 : : "Dict(expr* keys, expr* values)");
1376 [ - + ]: 24 : if (!state->Dict_type) return 0;
1377 : 24 : state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
1378 : : "Set(expr* elts)");
1379 [ - + ]: 24 : if (!state->Set_type) return 0;
1380 : 24 : state->ListComp_type = make_type(state, "ListComp", state->expr_type,
1381 : : ListComp_fields, 2,
1382 : : "ListComp(expr elt, comprehension* generators)");
1383 [ - + ]: 24 : if (!state->ListComp_type) return 0;
1384 : 24 : state->SetComp_type = make_type(state, "SetComp", state->expr_type,
1385 : : SetComp_fields, 2,
1386 : : "SetComp(expr elt, comprehension* generators)");
1387 [ - + ]: 24 : if (!state->SetComp_type) return 0;
1388 : 24 : state->DictComp_type = make_type(state, "DictComp", state->expr_type,
1389 : : DictComp_fields, 3,
1390 : : "DictComp(expr key, expr value, comprehension* generators)");
1391 [ - + ]: 24 : if (!state->DictComp_type) return 0;
1392 : 24 : state->GeneratorExp_type = make_type(state, "GeneratorExp",
1393 : : state->expr_type, GeneratorExp_fields,
1394 : : 2,
1395 : : "GeneratorExp(expr elt, comprehension* generators)");
1396 [ - + ]: 24 : if (!state->GeneratorExp_type) return 0;
1397 : 24 : state->Await_type = make_type(state, "Await", state->expr_type,
1398 : : Await_fields, 1,
1399 : : "Await(expr value)");
1400 [ - + ]: 24 : if (!state->Await_type) return 0;
1401 : 24 : state->Yield_type = make_type(state, "Yield", state->expr_type,
1402 : : Yield_fields, 1,
1403 : : "Yield(expr? value)");
1404 [ - + ]: 24 : if (!state->Yield_type) return 0;
1405 [ - + ]: 24 : if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
1406 : 0 : return 0;
1407 : 24 : state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
1408 : : YieldFrom_fields, 1,
1409 : : "YieldFrom(expr value)");
1410 [ - + ]: 24 : if (!state->YieldFrom_type) return 0;
1411 : 24 : state->Compare_type = make_type(state, "Compare", state->expr_type,
1412 : : Compare_fields, 3,
1413 : : "Compare(expr left, cmpop* ops, expr* comparators)");
1414 [ - + ]: 24 : if (!state->Compare_type) return 0;
1415 : 24 : state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
1416 : : 3,
1417 : : "Call(expr func, expr* args, keyword* keywords)");
1418 [ - + ]: 24 : if (!state->Call_type) return 0;
1419 : 24 : state->FormattedValue_type = make_type(state, "FormattedValue",
1420 : : state->expr_type,
1421 : : FormattedValue_fields, 3,
1422 : : "FormattedValue(expr value, int conversion, expr? format_spec)");
1423 [ - + ]: 24 : if (!state->FormattedValue_type) return 0;
1424 [ - + ]: 24 : if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
1425 : : Py_None) == -1)
1426 : 0 : return 0;
1427 : 24 : state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
1428 : : JoinedStr_fields, 1,
1429 : : "JoinedStr(expr* values)");
1430 [ - + ]: 24 : if (!state->JoinedStr_type) return 0;
1431 : 24 : state->Constant_type = make_type(state, "Constant", state->expr_type,
1432 : : Constant_fields, 2,
1433 : : "Constant(constant value, string? kind)");
1434 [ - + ]: 24 : if (!state->Constant_type) return 0;
1435 [ - + ]: 24 : if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
1436 : 0 : return 0;
1437 : 24 : state->Attribute_type = make_type(state, "Attribute", state->expr_type,
1438 : : Attribute_fields, 3,
1439 : : "Attribute(expr value, identifier attr, expr_context ctx)");
1440 [ - + ]: 24 : if (!state->Attribute_type) return 0;
1441 : 24 : state->Subscript_type = make_type(state, "Subscript", state->expr_type,
1442 : : Subscript_fields, 3,
1443 : : "Subscript(expr value, expr slice, expr_context ctx)");
1444 [ - + ]: 24 : if (!state->Subscript_type) return 0;
1445 : 24 : state->Starred_type = make_type(state, "Starred", state->expr_type,
1446 : : Starred_fields, 2,
1447 : : "Starred(expr value, expr_context ctx)");
1448 [ - + ]: 24 : if (!state->Starred_type) return 0;
1449 : 24 : state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
1450 : : 2,
1451 : : "Name(identifier id, expr_context ctx)");
1452 [ - + ]: 24 : if (!state->Name_type) return 0;
1453 : 24 : state->List_type = make_type(state, "List", state->expr_type, List_fields,
1454 : : 2,
1455 : : "List(expr* elts, expr_context ctx)");
1456 [ - + ]: 24 : if (!state->List_type) return 0;
1457 : 24 : state->Tuple_type = make_type(state, "Tuple", state->expr_type,
1458 : : Tuple_fields, 2,
1459 : : "Tuple(expr* elts, expr_context ctx)");
1460 [ - + ]: 24 : if (!state->Tuple_type) return 0;
1461 : 24 : state->Slice_type = make_type(state, "Slice", state->expr_type,
1462 : : Slice_fields, 3,
1463 : : "Slice(expr? lower, expr? upper, expr? step)");
1464 [ - + ]: 24 : if (!state->Slice_type) return 0;
1465 [ - + ]: 24 : if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
1466 : 0 : return 0;
1467 [ - + ]: 24 : if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
1468 : 0 : return 0;
1469 [ - + ]: 24 : if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
1470 : 0 : return 0;
1471 : 24 : state->expr_context_type = make_type(state, "expr_context",
1472 : : state->AST_type, NULL, 0,
1473 : : "expr_context = Load | Store | Del");
1474 [ - + ]: 24 : if (!state->expr_context_type) return 0;
1475 [ - + ]: 24 : if (!add_attributes(state, state->expr_context_type, NULL, 0)) return 0;
1476 : 24 : state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
1477 : : 0,
1478 : : "Load");
1479 [ - + ]: 24 : if (!state->Load_type) return 0;
1480 : 24 : state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
1481 : : NULL, NULL);
1482 [ - + ]: 24 : if (!state->Load_singleton) return 0;
1483 : 24 : state->Store_type = make_type(state, "Store", state->expr_context_type,
1484 : : NULL, 0,
1485 : : "Store");
1486 [ - + ]: 24 : if (!state->Store_type) return 0;
1487 : 48 : state->Store_singleton = PyType_GenericNew((PyTypeObject
1488 : 24 : *)state->Store_type, NULL, NULL);
1489 [ - + ]: 24 : if (!state->Store_singleton) return 0;
1490 : 24 : state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
1491 : : "Del");
1492 [ - + ]: 24 : if (!state->Del_type) return 0;
1493 : 24 : state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
1494 : : NULL, NULL);
1495 [ - + ]: 24 : if (!state->Del_singleton) return 0;
1496 : 24 : state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
1497 : : "boolop = And | Or");
1498 [ - + ]: 24 : if (!state->boolop_type) return 0;
1499 [ - + ]: 24 : if (!add_attributes(state, state->boolop_type, NULL, 0)) return 0;
1500 : 24 : state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
1501 : : "And");
1502 [ - + ]: 24 : if (!state->And_type) return 0;
1503 : 24 : state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
1504 : : NULL, NULL);
1505 [ - + ]: 24 : if (!state->And_singleton) return 0;
1506 : 24 : state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
1507 : : "Or");
1508 [ - + ]: 24 : if (!state->Or_type) return 0;
1509 : 24 : state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
1510 : : NULL, NULL);
1511 [ - + ]: 24 : if (!state->Or_singleton) return 0;
1512 : 24 : state->operator_type = make_type(state, "operator", state->AST_type, NULL,
1513 : : 0,
1514 : : "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
1515 [ - + ]: 24 : if (!state->operator_type) return 0;
1516 [ - + ]: 24 : if (!add_attributes(state, state->operator_type, NULL, 0)) return 0;
1517 : 24 : state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
1518 : : "Add");
1519 [ - + ]: 24 : if (!state->Add_type) return 0;
1520 : 24 : state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
1521 : : NULL, NULL);
1522 [ - + ]: 24 : if (!state->Add_singleton) return 0;
1523 : 24 : state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
1524 : : "Sub");
1525 [ - + ]: 24 : if (!state->Sub_type) return 0;
1526 : 24 : state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
1527 : : NULL, NULL);
1528 [ - + ]: 24 : if (!state->Sub_singleton) return 0;
1529 : 24 : state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
1530 : : "Mult");
1531 [ - + ]: 24 : if (!state->Mult_type) return 0;
1532 : 24 : state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
1533 : : NULL, NULL);
1534 [ - + ]: 24 : if (!state->Mult_singleton) return 0;
1535 : 24 : state->MatMult_type = make_type(state, "MatMult", state->operator_type,
1536 : : NULL, 0,
1537 : : "MatMult");
1538 [ - + ]: 24 : if (!state->MatMult_type) return 0;
1539 : 48 : state->MatMult_singleton = PyType_GenericNew((PyTypeObject
1540 : 24 : *)state->MatMult_type, NULL,
1541 : : NULL);
1542 [ - + ]: 24 : if (!state->MatMult_singleton) return 0;
1543 : 24 : state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
1544 : : "Div");
1545 [ - + ]: 24 : if (!state->Div_type) return 0;
1546 : 24 : state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
1547 : : NULL, NULL);
1548 [ - + ]: 24 : if (!state->Div_singleton) return 0;
1549 : 24 : state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
1550 : : "Mod");
1551 [ - + ]: 24 : if (!state->Mod_type) return 0;
1552 : 24 : state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
1553 : : NULL, NULL);
1554 [ - + ]: 24 : if (!state->Mod_singleton) return 0;
1555 : 24 : state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
1556 : : "Pow");
1557 [ - + ]: 24 : if (!state->Pow_type) return 0;
1558 : 24 : state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
1559 : : NULL, NULL);
1560 [ - + ]: 24 : if (!state->Pow_singleton) return 0;
1561 : 24 : state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
1562 : : 0,
1563 : : "LShift");
1564 [ - + ]: 24 : if (!state->LShift_type) return 0;
1565 : 48 : state->LShift_singleton = PyType_GenericNew((PyTypeObject
1566 : 24 : *)state->LShift_type, NULL,
1567 : : NULL);
1568 [ - + ]: 24 : if (!state->LShift_singleton) return 0;
1569 : 24 : state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
1570 : : 0,
1571 : : "RShift");
1572 [ - + ]: 24 : if (!state->RShift_type) return 0;
1573 : 48 : state->RShift_singleton = PyType_GenericNew((PyTypeObject
1574 : 24 : *)state->RShift_type, NULL,
1575 : : NULL);
1576 [ - + ]: 24 : if (!state->RShift_singleton) return 0;
1577 : 24 : state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
1578 : : "BitOr");
1579 [ - + ]: 24 : if (!state->BitOr_type) return 0;
1580 : 48 : state->BitOr_singleton = PyType_GenericNew((PyTypeObject
1581 : 24 : *)state->BitOr_type, NULL, NULL);
1582 [ - + ]: 24 : if (!state->BitOr_singleton) return 0;
1583 : 24 : state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
1584 : : 0,
1585 : : "BitXor");
1586 [ - + ]: 24 : if (!state->BitXor_type) return 0;
1587 : 48 : state->BitXor_singleton = PyType_GenericNew((PyTypeObject
1588 : 24 : *)state->BitXor_type, NULL,
1589 : : NULL);
1590 [ - + ]: 24 : if (!state->BitXor_singleton) return 0;
1591 : 24 : state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
1592 : : 0,
1593 : : "BitAnd");
1594 [ - + ]: 24 : if (!state->BitAnd_type) return 0;
1595 : 48 : state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
1596 : 24 : *)state->BitAnd_type, NULL,
1597 : : NULL);
1598 [ - + ]: 24 : if (!state->BitAnd_singleton) return 0;
1599 : 24 : state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
1600 : : NULL, 0,
1601 : : "FloorDiv");
1602 [ - + ]: 24 : if (!state->FloorDiv_type) return 0;
1603 : 48 : state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
1604 : 24 : *)state->FloorDiv_type, NULL,
1605 : : NULL);
1606 [ - + ]: 24 : if (!state->FloorDiv_singleton) return 0;
1607 : 24 : state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
1608 : : "unaryop = Invert | Not | UAdd | USub");
1609 [ - + ]: 24 : if (!state->unaryop_type) return 0;
1610 [ - + ]: 24 : if (!add_attributes(state, state->unaryop_type, NULL, 0)) return 0;
1611 : 24 : state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
1612 : : 0,
1613 : : "Invert");
1614 [ - + ]: 24 : if (!state->Invert_type) return 0;
1615 : 48 : state->Invert_singleton = PyType_GenericNew((PyTypeObject
1616 : 24 : *)state->Invert_type, NULL,
1617 : : NULL);
1618 [ - + ]: 24 : if (!state->Invert_singleton) return 0;
1619 : 24 : state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
1620 : : "Not");
1621 [ - + ]: 24 : if (!state->Not_type) return 0;
1622 : 24 : state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
1623 : : NULL, NULL);
1624 [ - + ]: 24 : if (!state->Not_singleton) return 0;
1625 : 24 : state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
1626 : : "UAdd");
1627 [ - + ]: 24 : if (!state->UAdd_type) return 0;
1628 : 24 : state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
1629 : : NULL, NULL);
1630 [ - + ]: 24 : if (!state->UAdd_singleton) return 0;
1631 : 24 : state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
1632 : : "USub");
1633 [ - + ]: 24 : if (!state->USub_type) return 0;
1634 : 24 : state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
1635 : : NULL, NULL);
1636 [ - + ]: 24 : if (!state->USub_singleton) return 0;
1637 : 24 : state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
1638 : : "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
1639 [ - + ]: 24 : if (!state->cmpop_type) return 0;
1640 [ - + ]: 24 : if (!add_attributes(state, state->cmpop_type, NULL, 0)) return 0;
1641 : 24 : state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
1642 : : "Eq");
1643 [ - + ]: 24 : if (!state->Eq_type) return 0;
1644 : 24 : state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
1645 : : NULL, NULL);
1646 [ - + ]: 24 : if (!state->Eq_singleton) return 0;
1647 : 24 : state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
1648 : : "NotEq");
1649 [ - + ]: 24 : if (!state->NotEq_type) return 0;
1650 : 48 : state->NotEq_singleton = PyType_GenericNew((PyTypeObject
1651 : 24 : *)state->NotEq_type, NULL, NULL);
1652 [ - + ]: 24 : if (!state->NotEq_singleton) return 0;
1653 : 24 : state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
1654 : : "Lt");
1655 [ - + ]: 24 : if (!state->Lt_type) return 0;
1656 : 24 : state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
1657 : : NULL, NULL);
1658 [ - + ]: 24 : if (!state->Lt_singleton) return 0;
1659 : 24 : state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
1660 : : "LtE");
1661 [ - + ]: 24 : if (!state->LtE_type) return 0;
1662 : 24 : state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
1663 : : NULL, NULL);
1664 [ - + ]: 24 : if (!state->LtE_singleton) return 0;
1665 : 24 : state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
1666 : : "Gt");
1667 [ - + ]: 24 : if (!state->Gt_type) return 0;
1668 : 24 : state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
1669 : : NULL, NULL);
1670 [ - + ]: 24 : if (!state->Gt_singleton) return 0;
1671 : 24 : state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
1672 : : "GtE");
1673 [ - + ]: 24 : if (!state->GtE_type) return 0;
1674 : 24 : state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
1675 : : NULL, NULL);
1676 [ - + ]: 24 : if (!state->GtE_singleton) return 0;
1677 : 24 : state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
1678 : : "Is");
1679 [ - + ]: 24 : if (!state->Is_type) return 0;
1680 : 24 : state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
1681 : : NULL, NULL);
1682 [ - + ]: 24 : if (!state->Is_singleton) return 0;
1683 : 24 : state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
1684 : : "IsNot");
1685 [ - + ]: 24 : if (!state->IsNot_type) return 0;
1686 : 48 : state->IsNot_singleton = PyType_GenericNew((PyTypeObject
1687 : 24 : *)state->IsNot_type, NULL, NULL);
1688 [ - + ]: 24 : if (!state->IsNot_singleton) return 0;
1689 : 24 : state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
1690 : : "In");
1691 [ - + ]: 24 : if (!state->In_type) return 0;
1692 : 24 : state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
1693 : : NULL, NULL);
1694 [ - + ]: 24 : if (!state->In_singleton) return 0;
1695 : 24 : state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
1696 : : "NotIn");
1697 [ - + ]: 24 : if (!state->NotIn_type) return 0;
1698 : 48 : state->NotIn_singleton = PyType_GenericNew((PyTypeObject
1699 : 24 : *)state->NotIn_type, NULL, NULL);
1700 [ - + ]: 24 : if (!state->NotIn_singleton) return 0;
1701 : 24 : state->comprehension_type = make_type(state, "comprehension",
1702 : : state->AST_type,
1703 : : comprehension_fields, 4,
1704 : : "comprehension(expr target, expr iter, expr* ifs, int is_async)");
1705 [ - + ]: 24 : if (!state->comprehension_type) return 0;
1706 [ - + ]: 24 : if (!add_attributes(state, state->comprehension_type, NULL, 0)) return 0;
1707 : 24 : state->excepthandler_type = make_type(state, "excepthandler",
1708 : : state->AST_type, NULL, 0,
1709 : : "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
1710 [ - + ]: 24 : if (!state->excepthandler_type) return 0;
1711 [ - + ]: 24 : if (!add_attributes(state, state->excepthandler_type,
1712 : 0 : excepthandler_attributes, 4)) return 0;
1713 [ - + ]: 24 : if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
1714 : : == -1)
1715 : 0 : return 0;
1716 [ - + ]: 24 : if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
1717 : : Py_None) == -1)
1718 : 0 : return 0;
1719 : 24 : state->ExceptHandler_type = make_type(state, "ExceptHandler",
1720 : : state->excepthandler_type,
1721 : : ExceptHandler_fields, 3,
1722 : : "ExceptHandler(expr? type, identifier? name, stmt* body)");
1723 [ - + ]: 24 : if (!state->ExceptHandler_type) return 0;
1724 [ - + ]: 24 : if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
1725 : 0 : return 0;
1726 [ - + ]: 24 : if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
1727 : 0 : return 0;
1728 : 24 : state->arguments_type = make_type(state, "arguments", state->AST_type,
1729 : : arguments_fields, 7,
1730 : : "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults, arg? kwarg, expr* defaults)");
1731 [ - + ]: 24 : if (!state->arguments_type) return 0;
1732 [ - + ]: 24 : if (!add_attributes(state, state->arguments_type, NULL, 0)) return 0;
1733 [ - + ]: 24 : if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
1734 : 0 : return 0;
1735 [ - + ]: 24 : if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
1736 : 0 : return 0;
1737 : 24 : state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
1738 : : "arg(identifier arg, expr? annotation, string? type_comment)");
1739 [ - + ]: 24 : if (!state->arg_type) return 0;
1740 [ - + ]: 24 : if (!add_attributes(state, state->arg_type, arg_attributes, 4)) return 0;
1741 [ - + ]: 24 : if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
1742 : 0 : return 0;
1743 [ - + ]: 24 : if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
1744 : 0 : return 0;
1745 [ - + ]: 24 : if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
1746 : 0 : return 0;
1747 [ - + ]: 24 : if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
1748 : 0 : return 0;
1749 : 24 : state->keyword_type = make_type(state, "keyword", state->AST_type,
1750 : : keyword_fields, 2,
1751 : : "keyword(identifier? arg, expr value)");
1752 [ - + ]: 24 : if (!state->keyword_type) return 0;
1753 [ - + ]: 24 : if (!add_attributes(state, state->keyword_type, keyword_attributes, 4))
1754 : 0 : return 0;
1755 [ - + ]: 24 : if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
1756 : 0 : return 0;
1757 [ - + ]: 24 : if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
1758 : 0 : return 0;
1759 [ - + ]: 24 : if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
1760 : : == -1)
1761 : 0 : return 0;
1762 : 24 : state->alias_type = make_type(state, "alias", state->AST_type,
1763 : : alias_fields, 2,
1764 : : "alias(identifier name, identifier? asname)");
1765 [ - + ]: 24 : if (!state->alias_type) return 0;
1766 [ - + ]: 24 : if (!add_attributes(state, state->alias_type, alias_attributes, 4)) return
1767 : 0 : 0;
1768 [ - + ]: 24 : if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
1769 : 0 : return 0;
1770 [ - + ]: 24 : if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
1771 : 0 : return 0;
1772 [ - + ]: 24 : if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
1773 : : -1)
1774 : 0 : return 0;
1775 : 24 : state->withitem_type = make_type(state, "withitem", state->AST_type,
1776 : : withitem_fields, 2,
1777 : : "withitem(expr context_expr, expr? optional_vars)");
1778 [ - + ]: 24 : if (!state->withitem_type) return 0;
1779 [ - + ]: 24 : if (!add_attributes(state, state->withitem_type, NULL, 0)) return 0;
1780 [ - + ]: 24 : if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
1781 : : == -1)
1782 : 0 : return 0;
1783 : 24 : state->match_case_type = make_type(state, "match_case", state->AST_type,
1784 : : match_case_fields, 3,
1785 : : "match_case(pattern pattern, expr? guard, stmt* body)");
1786 [ - + ]: 24 : if (!state->match_case_type) return 0;
1787 [ - + ]: 24 : if (!add_attributes(state, state->match_case_type, NULL, 0)) return 0;
1788 [ - + ]: 24 : if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
1789 : 0 : return 0;
1790 : 24 : state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
1791 : : "pattern = MatchValue(expr value)\n"
1792 : : " | MatchSingleton(constant value)\n"
1793 : : " | MatchSequence(pattern* patterns)\n"
1794 : : " | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
1795 : : " | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
1796 : : " | MatchStar(identifier? name)\n"
1797 : : " | MatchAs(pattern? pattern, identifier? name)\n"
1798 : : " | MatchOr(pattern* patterns)");
1799 [ - + ]: 24 : if (!state->pattern_type) return 0;
1800 [ - + ]: 24 : if (!add_attributes(state, state->pattern_type, pattern_attributes, 4))
1801 : 0 : return 0;
1802 : 24 : state->MatchValue_type = make_type(state, "MatchValue",
1803 : : state->pattern_type, MatchValue_fields,
1804 : : 1,
1805 : : "MatchValue(expr value)");
1806 [ - + ]: 24 : if (!state->MatchValue_type) return 0;
1807 : 24 : state->MatchSingleton_type = make_type(state, "MatchSingleton",
1808 : : state->pattern_type,
1809 : : MatchSingleton_fields, 1,
1810 : : "MatchSingleton(constant value)");
1811 [ - + ]: 24 : if (!state->MatchSingleton_type) return 0;
1812 : 24 : state->MatchSequence_type = make_type(state, "MatchSequence",
1813 : : state->pattern_type,
1814 : : MatchSequence_fields, 1,
1815 : : "MatchSequence(pattern* patterns)");
1816 [ - + ]: 24 : if (!state->MatchSequence_type) return 0;
1817 : 24 : state->MatchMapping_type = make_type(state, "MatchMapping",
1818 : : state->pattern_type,
1819 : : MatchMapping_fields, 3,
1820 : : "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
1821 [ - + ]: 24 : if (!state->MatchMapping_type) return 0;
1822 [ - + ]: 24 : if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
1823 : 0 : return 0;
1824 : 24 : state->MatchClass_type = make_type(state, "MatchClass",
1825 : : state->pattern_type, MatchClass_fields,
1826 : : 4,
1827 : : "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
1828 [ - + ]: 24 : if (!state->MatchClass_type) return 0;
1829 : 24 : state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
1830 : : MatchStar_fields, 1,
1831 : : "MatchStar(identifier? name)");
1832 [ - + ]: 24 : if (!state->MatchStar_type) return 0;
1833 [ - + ]: 24 : if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
1834 : 0 : return 0;
1835 : 24 : state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
1836 : : MatchAs_fields, 2,
1837 : : "MatchAs(pattern? pattern, identifier? name)");
1838 [ - + ]: 24 : if (!state->MatchAs_type) return 0;
1839 [ - + ]: 24 : if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
1840 : 0 : return 0;
1841 [ - + ]: 24 : if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
1842 : 0 : return 0;
1843 : 24 : state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
1844 : : MatchOr_fields, 1,
1845 : : "MatchOr(pattern* patterns)");
1846 [ - + ]: 24 : if (!state->MatchOr_type) return 0;
1847 : 24 : state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
1848 : : NULL, 0,
1849 : : "type_ignore = TypeIgnore(int lineno, string tag)");
1850 [ - + ]: 24 : if (!state->type_ignore_type) return 0;
1851 [ - + ]: 24 : if (!add_attributes(state, state->type_ignore_type, NULL, 0)) return 0;
1852 : 24 : state->TypeIgnore_type = make_type(state, "TypeIgnore",
1853 : : state->type_ignore_type,
1854 : : TypeIgnore_fields, 2,
1855 : : "TypeIgnore(int lineno, string tag)");
1856 [ - + ]: 24 : if (!state->TypeIgnore_type) return 0;
1857 : :
1858 : 24 : state->recursion_depth = 0;
1859 : 24 : state->recursion_limit = 0;
1860 : 24 : state->initialized = 1;
1861 : 24 : return 1;
1862 : : }
1863 : :
1864 : : static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
1865 : : PyArena* arena);
1866 : : static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
1867 : : PyArena* arena);
1868 : : static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
1869 : : PyArena* arena);
1870 : : static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
1871 : : expr_context_ty* out, PyArena* arena);
1872 : : static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
1873 : : out, PyArena* arena);
1874 : : static int obj2ast_operator(struct ast_state *state, PyObject* obj,
1875 : : operator_ty* out, PyArena* arena);
1876 : : static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
1877 : : out, PyArena* arena);
1878 : : static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
1879 : : PyArena* arena);
1880 : : static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
1881 : : comprehension_ty* out, PyArena* arena);
1882 : : static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
1883 : : excepthandler_ty* out, PyArena* arena);
1884 : : static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
1885 : : arguments_ty* out, PyArena* arena);
1886 : : static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
1887 : : PyArena* arena);
1888 : : static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
1889 : : out, PyArena* arena);
1890 : : static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
1891 : : PyArena* arena);
1892 : : static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
1893 : : withitem_ty* out, PyArena* arena);
1894 : : static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
1895 : : match_case_ty* out, PyArena* arena);
1896 : : static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
1897 : : out, PyArena* arena);
1898 : : static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
1899 : : type_ignore_ty* out, PyArena* arena);
1900 : :
1901 : : mod_ty
1902 : 215 : _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
1903 : : PyArena *arena)
1904 : : {
1905 : : mod_ty p;
1906 : 215 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1907 [ - + ]: 215 : if (!p)
1908 : 0 : return NULL;
1909 : 215 : p->kind = Module_kind;
1910 : 215 : p->v.Module.body = body;
1911 : 215 : p->v.Module.type_ignores = type_ignores;
1912 : 215 : return p;
1913 : : }
1914 : :
1915 : : mod_ty
1916 : 56 : _PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
1917 : : {
1918 : : mod_ty p;
1919 : 56 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1920 [ - + ]: 56 : if (!p)
1921 : 0 : return NULL;
1922 : 56 : p->kind = Interactive_kind;
1923 : 56 : p->v.Interactive.body = body;
1924 : 56 : return p;
1925 : : }
1926 : :
1927 : : mod_ty
1928 : 80 : _PyAST_Expression(expr_ty body, PyArena *arena)
1929 : : {
1930 : : mod_ty p;
1931 [ - + ]: 80 : if (!body) {
1932 : 0 : PyErr_SetString(PyExc_ValueError,
1933 : : "field 'body' is required for Expression");
1934 : 0 : return NULL;
1935 : : }
1936 : 80 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1937 [ - + ]: 80 : if (!p)
1938 : 0 : return NULL;
1939 : 80 : p->kind = Expression_kind;
1940 : 80 : p->v.Expression.body = body;
1941 : 80 : return p;
1942 : : }
1943 : :
1944 : : mod_ty
1945 : 0 : _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
1946 : : {
1947 : : mod_ty p;
1948 [ # # ]: 0 : if (!returns) {
1949 : 0 : PyErr_SetString(PyExc_ValueError,
1950 : : "field 'returns' is required for FunctionType");
1951 : 0 : return NULL;
1952 : : }
1953 : 0 : p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
1954 [ # # ]: 0 : if (!p)
1955 : 0 : return NULL;
1956 : 0 : p->kind = FunctionType_kind;
1957 : 0 : p->v.FunctionType.argtypes = argtypes;
1958 : 0 : p->v.FunctionType.returns = returns;
1959 : 0 : return p;
1960 : : }
1961 : :
1962 : : stmt_ty
1963 : 6808 : _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
1964 : : asdl_expr_seq * decorator_list, expr_ty returns, string
1965 : : type_comment, int lineno, int col_offset, int end_lineno,
1966 : : int end_col_offset, PyArena *arena)
1967 : : {
1968 : : stmt_ty p;
1969 [ - + ]: 6808 : if (!name) {
1970 : 0 : PyErr_SetString(PyExc_ValueError,
1971 : : "field 'name' is required for FunctionDef");
1972 : 0 : return NULL;
1973 : : }
1974 [ - + ]: 6808 : if (!args) {
1975 : 0 : PyErr_SetString(PyExc_ValueError,
1976 : : "field 'args' is required for FunctionDef");
1977 : 0 : return NULL;
1978 : : }
1979 : 6808 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
1980 [ - + ]: 6808 : if (!p)
1981 : 0 : return NULL;
1982 : 6808 : p->kind = FunctionDef_kind;
1983 : 6808 : p->v.FunctionDef.name = name;
1984 : 6808 : p->v.FunctionDef.args = args;
1985 : 6808 : p->v.FunctionDef.body = body;
1986 : 6808 : p->v.FunctionDef.decorator_list = decorator_list;
1987 : 6808 : p->v.FunctionDef.returns = returns;
1988 : 6808 : p->v.FunctionDef.type_comment = type_comment;
1989 : 6808 : p->lineno = lineno;
1990 : 6808 : p->col_offset = col_offset;
1991 : 6808 : p->end_lineno = end_lineno;
1992 : 6808 : p->end_col_offset = end_col_offset;
1993 : 6808 : return p;
1994 : : }
1995 : :
1996 : : stmt_ty
1997 : 166 : _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
1998 : : body, asdl_expr_seq * decorator_list, expr_ty returns,
1999 : : string type_comment, int lineno, int col_offset, int
2000 : : end_lineno, int end_col_offset, PyArena *arena)
2001 : : {
2002 : : stmt_ty p;
2003 [ - + ]: 166 : if (!name) {
2004 : 0 : PyErr_SetString(PyExc_ValueError,
2005 : : "field 'name' is required for AsyncFunctionDef");
2006 : 0 : return NULL;
2007 : : }
2008 [ - + ]: 166 : if (!args) {
2009 : 0 : PyErr_SetString(PyExc_ValueError,
2010 : : "field 'args' is required for AsyncFunctionDef");
2011 : 0 : return NULL;
2012 : : }
2013 : 166 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2014 [ - + ]: 166 : if (!p)
2015 : 0 : return NULL;
2016 : 166 : p->kind = AsyncFunctionDef_kind;
2017 : 166 : p->v.AsyncFunctionDef.name = name;
2018 : 166 : p->v.AsyncFunctionDef.args = args;
2019 : 166 : p->v.AsyncFunctionDef.body = body;
2020 : 166 : p->v.AsyncFunctionDef.decorator_list = decorator_list;
2021 : 166 : p->v.AsyncFunctionDef.returns = returns;
2022 : 166 : p->v.AsyncFunctionDef.type_comment = type_comment;
2023 : 166 : p->lineno = lineno;
2024 : 166 : p->col_offset = col_offset;
2025 : 166 : p->end_lineno = end_lineno;
2026 : 166 : p->end_col_offset = end_col_offset;
2027 : 166 : return p;
2028 : : }
2029 : :
2030 : : stmt_ty
2031 : 750 : _PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
2032 : : keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
2033 : : int lineno, int col_offset, int end_lineno, int end_col_offset,
2034 : : PyArena *arena)
2035 : : {
2036 : : stmt_ty p;
2037 [ - + ]: 750 : if (!name) {
2038 : 0 : PyErr_SetString(PyExc_ValueError,
2039 : : "field 'name' is required for ClassDef");
2040 : 0 : return NULL;
2041 : : }
2042 : 750 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2043 [ - + ]: 750 : if (!p)
2044 : 0 : return NULL;
2045 : 750 : p->kind = ClassDef_kind;
2046 : 750 : p->v.ClassDef.name = name;
2047 : 750 : p->v.ClassDef.bases = bases;
2048 : 750 : p->v.ClassDef.keywords = keywords;
2049 : 750 : p->v.ClassDef.body = body;
2050 : 750 : p->v.ClassDef.decorator_list = decorator_list;
2051 : 750 : p->lineno = lineno;
2052 : 750 : p->col_offset = col_offset;
2053 : 750 : p->end_lineno = end_lineno;
2054 : 750 : p->end_col_offset = end_col_offset;
2055 : 750 : return p;
2056 : : }
2057 : :
2058 : : stmt_ty
2059 : 5841 : _PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
2060 : : end_col_offset, PyArena *arena)
2061 : : {
2062 : : stmt_ty p;
2063 : 5841 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2064 [ - + ]: 5841 : if (!p)
2065 : 0 : return NULL;
2066 : 5841 : p->kind = Return_kind;
2067 : 5841 : p->v.Return.value = value;
2068 : 5841 : p->lineno = lineno;
2069 : 5841 : p->col_offset = col_offset;
2070 : 5841 : p->end_lineno = end_lineno;
2071 : 5841 : p->end_col_offset = end_col_offset;
2072 : 5841 : return p;
2073 : : }
2074 : :
2075 : : stmt_ty
2076 : 192 : _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
2077 : : end_lineno, int end_col_offset, PyArena *arena)
2078 : : {
2079 : : stmt_ty p;
2080 : 192 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2081 [ - + ]: 192 : if (!p)
2082 : 0 : return NULL;
2083 : 192 : p->kind = Delete_kind;
2084 : 192 : p->v.Delete.targets = targets;
2085 : 192 : p->lineno = lineno;
2086 : 192 : p->col_offset = col_offset;
2087 : 192 : p->end_lineno = end_lineno;
2088 : 192 : p->end_col_offset = end_col_offset;
2089 : 192 : return p;
2090 : : }
2091 : :
2092 : : stmt_ty
2093 : 16574 : _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
2094 : : lineno, int col_offset, int end_lineno, int end_col_offset,
2095 : : PyArena *arena)
2096 : : {
2097 : : stmt_ty p;
2098 [ - + ]: 16574 : if (!value) {
2099 : 0 : PyErr_SetString(PyExc_ValueError,
2100 : : "field 'value' is required for Assign");
2101 : 0 : return NULL;
2102 : : }
2103 : 16574 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2104 [ - + ]: 16574 : if (!p)
2105 : 0 : return NULL;
2106 : 16574 : p->kind = Assign_kind;
2107 : 16574 : p->v.Assign.targets = targets;
2108 : 16574 : p->v.Assign.value = value;
2109 : 16574 : p->v.Assign.type_comment = type_comment;
2110 : 16574 : p->lineno = lineno;
2111 : 16574 : p->col_offset = col_offset;
2112 : 16574 : p->end_lineno = end_lineno;
2113 : 16574 : p->end_col_offset = end_col_offset;
2114 : 16574 : return p;
2115 : : }
2116 : :
2117 : : stmt_ty
2118 : 715 : _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
2119 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2120 : : {
2121 : : stmt_ty p;
2122 [ - + ]: 715 : if (!target) {
2123 : 0 : PyErr_SetString(PyExc_ValueError,
2124 : : "field 'target' is required for AugAssign");
2125 : 0 : return NULL;
2126 : : }
2127 [ - + ]: 715 : if (!op) {
2128 : 0 : PyErr_SetString(PyExc_ValueError,
2129 : : "field 'op' is required for AugAssign");
2130 : 0 : return NULL;
2131 : : }
2132 [ - + ]: 715 : if (!value) {
2133 : 0 : PyErr_SetString(PyExc_ValueError,
2134 : : "field 'value' is required for AugAssign");
2135 : 0 : return NULL;
2136 : : }
2137 : 715 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2138 [ - + ]: 715 : if (!p)
2139 : 0 : return NULL;
2140 : 715 : p->kind = AugAssign_kind;
2141 : 715 : p->v.AugAssign.target = target;
2142 : 715 : p->v.AugAssign.op = op;
2143 : 715 : p->v.AugAssign.value = value;
2144 : 715 : p->lineno = lineno;
2145 : 715 : p->col_offset = col_offset;
2146 : 715 : p->end_lineno = end_lineno;
2147 : 715 : p->end_col_offset = end_col_offset;
2148 : 715 : return p;
2149 : : }
2150 : :
2151 : : stmt_ty
2152 : 17 : _PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
2153 : : int lineno, int col_offset, int end_lineno, int
2154 : : end_col_offset, PyArena *arena)
2155 : : {
2156 : : stmt_ty p;
2157 [ - + ]: 17 : if (!target) {
2158 : 0 : PyErr_SetString(PyExc_ValueError,
2159 : : "field 'target' is required for AnnAssign");
2160 : 0 : return NULL;
2161 : : }
2162 [ - + ]: 17 : if (!annotation) {
2163 : 0 : PyErr_SetString(PyExc_ValueError,
2164 : : "field 'annotation' is required for AnnAssign");
2165 : 0 : return NULL;
2166 : : }
2167 : 17 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2168 [ - + ]: 17 : if (!p)
2169 : 0 : return NULL;
2170 : 17 : p->kind = AnnAssign_kind;
2171 : 17 : p->v.AnnAssign.target = target;
2172 : 17 : p->v.AnnAssign.annotation = annotation;
2173 : 17 : p->v.AnnAssign.value = value;
2174 : 17 : p->v.AnnAssign.simple = simple;
2175 : 17 : p->lineno = lineno;
2176 : 17 : p->col_offset = col_offset;
2177 : 17 : p->end_lineno = end_lineno;
2178 : 17 : p->end_col_offset = end_col_offset;
2179 : 17 : return p;
2180 : : }
2181 : :
2182 : : stmt_ty
2183 : 1222 : _PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
2184 : : orelse, string type_comment, int lineno, int col_offset, int
2185 : : end_lineno, int end_col_offset, PyArena *arena)
2186 : : {
2187 : : stmt_ty p;
2188 [ - + ]: 1222 : if (!target) {
2189 : 0 : PyErr_SetString(PyExc_ValueError,
2190 : : "field 'target' is required for For");
2191 : 0 : return NULL;
2192 : : }
2193 [ - + ]: 1222 : if (!iter) {
2194 : 0 : PyErr_SetString(PyExc_ValueError,
2195 : : "field 'iter' is required for For");
2196 : 0 : return NULL;
2197 : : }
2198 : 1222 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2199 [ - + ]: 1222 : if (!p)
2200 : 0 : return NULL;
2201 : 1222 : p->kind = For_kind;
2202 : 1222 : p->v.For.target = target;
2203 : 1222 : p->v.For.iter = iter;
2204 : 1222 : p->v.For.body = body;
2205 : 1222 : p->v.For.orelse = orelse;
2206 : 1222 : p->v.For.type_comment = type_comment;
2207 : 1222 : p->lineno = lineno;
2208 : 1222 : p->col_offset = col_offset;
2209 : 1222 : p->end_lineno = end_lineno;
2210 : 1222 : p->end_col_offset = end_col_offset;
2211 : 1222 : return p;
2212 : : }
2213 : :
2214 : : stmt_ty
2215 : 0 : _PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
2216 : : asdl_stmt_seq * orelse, string type_comment, int lineno, int
2217 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2218 : : {
2219 : : stmt_ty p;
2220 [ # # ]: 0 : if (!target) {
2221 : 0 : PyErr_SetString(PyExc_ValueError,
2222 : : "field 'target' is required for AsyncFor");
2223 : 0 : return NULL;
2224 : : }
2225 [ # # ]: 0 : if (!iter) {
2226 : 0 : PyErr_SetString(PyExc_ValueError,
2227 : : "field 'iter' is required for AsyncFor");
2228 : 0 : return NULL;
2229 : : }
2230 : 0 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2231 [ # # ]: 0 : if (!p)
2232 : 0 : return NULL;
2233 : 0 : p->kind = AsyncFor_kind;
2234 : 0 : p->v.AsyncFor.target = target;
2235 : 0 : p->v.AsyncFor.iter = iter;
2236 : 0 : p->v.AsyncFor.body = body;
2237 : 0 : p->v.AsyncFor.orelse = orelse;
2238 : 0 : p->v.AsyncFor.type_comment = type_comment;
2239 : 0 : p->lineno = lineno;
2240 : 0 : p->col_offset = col_offset;
2241 : 0 : p->end_lineno = end_lineno;
2242 : 0 : p->end_col_offset = end_col_offset;
2243 : 0 : return p;
2244 : : }
2245 : :
2246 : : stmt_ty
2247 : 302 : _PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
2248 : : lineno, int col_offset, int end_lineno, int end_col_offset,
2249 : : PyArena *arena)
2250 : : {
2251 : : stmt_ty p;
2252 [ - + ]: 302 : if (!test) {
2253 : 0 : PyErr_SetString(PyExc_ValueError,
2254 : : "field 'test' is required for While");
2255 : 0 : return NULL;
2256 : : }
2257 : 302 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2258 [ - + ]: 302 : if (!p)
2259 : 0 : return NULL;
2260 : 302 : p->kind = While_kind;
2261 : 302 : p->v.While.test = test;
2262 : 302 : p->v.While.body = body;
2263 : 302 : p->v.While.orelse = orelse;
2264 : 302 : p->lineno = lineno;
2265 : 302 : p->col_offset = col_offset;
2266 : 302 : p->end_lineno = end_lineno;
2267 : 302 : p->end_col_offset = end_col_offset;
2268 : 302 : return p;
2269 : : }
2270 : :
2271 : : stmt_ty
2272 : 8830 : _PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
2273 : : lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
2274 : : *arena)
2275 : : {
2276 : : stmt_ty p;
2277 [ - + ]: 8830 : if (!test) {
2278 : 0 : PyErr_SetString(PyExc_ValueError,
2279 : : "field 'test' is required for If");
2280 : 0 : return NULL;
2281 : : }
2282 : 8830 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2283 [ - + ]: 8830 : if (!p)
2284 : 0 : return NULL;
2285 : 8830 : p->kind = If_kind;
2286 : 8830 : p->v.If.test = test;
2287 : 8830 : p->v.If.body = body;
2288 : 8830 : p->v.If.orelse = orelse;
2289 : 8830 : p->lineno = lineno;
2290 : 8830 : p->col_offset = col_offset;
2291 : 8830 : p->end_lineno = end_lineno;
2292 : 8830 : p->end_col_offset = end_col_offset;
2293 : 8830 : return p;
2294 : : }
2295 : :
2296 : : stmt_ty
2297 : 378 : _PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
2298 : : type_comment, int lineno, int col_offset, int end_lineno, int
2299 : : end_col_offset, PyArena *arena)
2300 : : {
2301 : : stmt_ty p;
2302 : 378 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2303 [ - + ]: 378 : if (!p)
2304 : 0 : return NULL;
2305 : 378 : p->kind = With_kind;
2306 : 378 : p->v.With.items = items;
2307 : 378 : p->v.With.body = body;
2308 : 378 : p->v.With.type_comment = type_comment;
2309 : 378 : p->lineno = lineno;
2310 : 378 : p->col_offset = col_offset;
2311 : 378 : p->end_lineno = end_lineno;
2312 : 378 : p->end_col_offset = end_col_offset;
2313 : 378 : return p;
2314 : : }
2315 : :
2316 : : stmt_ty
2317 : 5 : _PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
2318 : : type_comment, int lineno, int col_offset, int end_lineno, int
2319 : : end_col_offset, PyArena *arena)
2320 : : {
2321 : : stmt_ty p;
2322 : 5 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2323 [ - + ]: 5 : if (!p)
2324 : 0 : return NULL;
2325 : 5 : p->kind = AsyncWith_kind;
2326 : 5 : p->v.AsyncWith.items = items;
2327 : 5 : p->v.AsyncWith.body = body;
2328 : 5 : p->v.AsyncWith.type_comment = type_comment;
2329 : 5 : p->lineno = lineno;
2330 : 5 : p->col_offset = col_offset;
2331 : 5 : p->end_lineno = end_lineno;
2332 : 5 : p->end_col_offset = end_col_offset;
2333 : 5 : return p;
2334 : : }
2335 : :
2336 : : stmt_ty
2337 : 4 : _PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
2338 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2339 : : {
2340 : : stmt_ty p;
2341 [ - + ]: 4 : if (!subject) {
2342 : 0 : PyErr_SetString(PyExc_ValueError,
2343 : : "field 'subject' is required for Match");
2344 : 0 : return NULL;
2345 : : }
2346 : 4 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2347 [ - + ]: 4 : if (!p)
2348 : 0 : return NULL;
2349 : 4 : p->kind = Match_kind;
2350 : 4 : p->v.Match.subject = subject;
2351 : 4 : p->v.Match.cases = cases;
2352 : 4 : p->lineno = lineno;
2353 : 4 : p->col_offset = col_offset;
2354 : 4 : p->end_lineno = end_lineno;
2355 : 4 : p->end_col_offset = end_col_offset;
2356 : 4 : return p;
2357 : : }
2358 : :
2359 : : stmt_ty
2360 : 1931 : _PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
2361 : : end_lineno, int end_col_offset, PyArena *arena)
2362 : : {
2363 : : stmt_ty p;
2364 : 1931 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2365 [ - + ]: 1931 : if (!p)
2366 : 0 : return NULL;
2367 : 1931 : p->kind = Raise_kind;
2368 : 1931 : p->v.Raise.exc = exc;
2369 : 1931 : p->v.Raise.cause = cause;
2370 : 1931 : p->lineno = lineno;
2371 : 1931 : p->col_offset = col_offset;
2372 : 1931 : p->end_lineno = end_lineno;
2373 : 1931 : p->end_col_offset = end_col_offset;
2374 : 1931 : return p;
2375 : : }
2376 : :
2377 : : stmt_ty
2378 : 1455 : _PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
2379 : : asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
2380 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2381 : : {
2382 : : stmt_ty p;
2383 : 1455 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2384 [ - + ]: 1455 : if (!p)
2385 : 0 : return NULL;
2386 : 1455 : p->kind = Try_kind;
2387 : 1455 : p->v.Try.body = body;
2388 : 1455 : p->v.Try.handlers = handlers;
2389 : 1455 : p->v.Try.orelse = orelse;
2390 : 1455 : p->v.Try.finalbody = finalbody;
2391 : 1455 : p->lineno = lineno;
2392 : 1455 : p->col_offset = col_offset;
2393 : 1455 : p->end_lineno = end_lineno;
2394 : 1455 : p->end_col_offset = end_col_offset;
2395 : 1455 : return p;
2396 : : }
2397 : :
2398 : : stmt_ty
2399 : 0 : _PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
2400 : : asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
2401 : : int col_offset, int end_lineno, int end_col_offset, PyArena
2402 : : *arena)
2403 : : {
2404 : : stmt_ty p;
2405 : 0 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2406 [ # # ]: 0 : if (!p)
2407 : 0 : return NULL;
2408 : 0 : p->kind = TryStar_kind;
2409 : 0 : p->v.TryStar.body = body;
2410 : 0 : p->v.TryStar.handlers = handlers;
2411 : 0 : p->v.TryStar.orelse = orelse;
2412 : 0 : p->v.TryStar.finalbody = finalbody;
2413 : 0 : p->lineno = lineno;
2414 : 0 : p->col_offset = col_offset;
2415 : 0 : p->end_lineno = end_lineno;
2416 : 0 : p->end_col_offset = end_col_offset;
2417 : 0 : return p;
2418 : : }
2419 : :
2420 : : stmt_ty
2421 : 239 : _PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
2422 : : end_lineno, int end_col_offset, PyArena *arena)
2423 : : {
2424 : : stmt_ty p;
2425 [ - + ]: 239 : if (!test) {
2426 : 0 : PyErr_SetString(PyExc_ValueError,
2427 : : "field 'test' is required for Assert");
2428 : 0 : return NULL;
2429 : : }
2430 : 239 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2431 [ - + ]: 239 : if (!p)
2432 : 0 : return NULL;
2433 : 239 : p->kind = Assert_kind;
2434 : 239 : p->v.Assert.test = test;
2435 : 239 : p->v.Assert.msg = msg;
2436 : 239 : p->lineno = lineno;
2437 : 239 : p->col_offset = col_offset;
2438 : 239 : p->end_lineno = end_lineno;
2439 : 239 : p->end_col_offset = end_col_offset;
2440 : 239 : return p;
2441 : : }
2442 : :
2443 : : stmt_ty
2444 : 896 : _PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
2445 : : end_lineno, int end_col_offset, PyArena *arena)
2446 : : {
2447 : : stmt_ty p;
2448 : 896 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2449 [ - + ]: 896 : if (!p)
2450 : 0 : return NULL;
2451 : 896 : p->kind = Import_kind;
2452 : 896 : p->v.Import.names = names;
2453 : 896 : p->lineno = lineno;
2454 : 896 : p->col_offset = col_offset;
2455 : 896 : p->end_lineno = end_lineno;
2456 : 896 : p->end_col_offset = end_col_offset;
2457 : 896 : return p;
2458 : : }
2459 : :
2460 : : stmt_ty
2461 : 524 : _PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
2462 : : lineno, int col_offset, int end_lineno, int end_col_offset,
2463 : : PyArena *arena)
2464 : : {
2465 : : stmt_ty p;
2466 : 524 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2467 [ - + ]: 524 : if (!p)
2468 : 0 : return NULL;
2469 : 524 : p->kind = ImportFrom_kind;
2470 : 524 : p->v.ImportFrom.module = module;
2471 : 524 : p->v.ImportFrom.names = names;
2472 : 524 : p->v.ImportFrom.level = level;
2473 : 524 : p->lineno = lineno;
2474 : 524 : p->col_offset = col_offset;
2475 : 524 : p->end_lineno = end_lineno;
2476 : 524 : p->end_col_offset = end_col_offset;
2477 : 524 : return p;
2478 : : }
2479 : :
2480 : : stmt_ty
2481 : 70 : _PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
2482 : : end_lineno, int end_col_offset, PyArena *arena)
2483 : : {
2484 : : stmt_ty p;
2485 : 70 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2486 [ - + ]: 70 : if (!p)
2487 : 0 : return NULL;
2488 : 70 : p->kind = Global_kind;
2489 : 70 : p->v.Global.names = names;
2490 : 70 : p->lineno = lineno;
2491 : 70 : p->col_offset = col_offset;
2492 : 70 : p->end_lineno = end_lineno;
2493 : 70 : p->end_col_offset = end_col_offset;
2494 : 70 : return p;
2495 : : }
2496 : :
2497 : : stmt_ty
2498 : 17 : _PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
2499 : : end_lineno, int end_col_offset, PyArena *arena)
2500 : : {
2501 : : stmt_ty p;
2502 : 17 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2503 [ - + ]: 17 : if (!p)
2504 : 0 : return NULL;
2505 : 17 : p->kind = Nonlocal_kind;
2506 : 17 : p->v.Nonlocal.names = names;
2507 : 17 : p->lineno = lineno;
2508 : 17 : p->col_offset = col_offset;
2509 : 17 : p->end_lineno = end_lineno;
2510 : 17 : p->end_col_offset = end_col_offset;
2511 : 17 : return p;
2512 : : }
2513 : :
2514 : : stmt_ty
2515 : 10981 : _PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
2516 : : end_col_offset, PyArena *arena)
2517 : : {
2518 : : stmt_ty p;
2519 [ - + ]: 10981 : if (!value) {
2520 : 0 : PyErr_SetString(PyExc_ValueError,
2521 : : "field 'value' is required for Expr");
2522 : 0 : return NULL;
2523 : : }
2524 : 10981 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2525 [ - + ]: 10981 : if (!p)
2526 : 0 : return NULL;
2527 : 10981 : p->kind = Expr_kind;
2528 : 10981 : p->v.Expr.value = value;
2529 : 10981 : p->lineno = lineno;
2530 : 10981 : p->col_offset = col_offset;
2531 : 10981 : p->end_lineno = end_lineno;
2532 : 10981 : p->end_col_offset = end_col_offset;
2533 : 10981 : return p;
2534 : : }
2535 : :
2536 : : stmt_ty
2537 : 496 : _PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
2538 : : PyArena *arena)
2539 : : {
2540 : : stmt_ty p;
2541 : 496 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2542 [ - + ]: 496 : if (!p)
2543 : 0 : return NULL;
2544 : 496 : p->kind = Pass_kind;
2545 : 496 : p->lineno = lineno;
2546 : 496 : p->col_offset = col_offset;
2547 : 496 : p->end_lineno = end_lineno;
2548 : 496 : p->end_col_offset = end_col_offset;
2549 : 496 : return p;
2550 : : }
2551 : :
2552 : : stmt_ty
2553 : 271 : _PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
2554 : : PyArena *arena)
2555 : : {
2556 : : stmt_ty p;
2557 : 271 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2558 [ - + ]: 271 : if (!p)
2559 : 0 : return NULL;
2560 : 271 : p->kind = Break_kind;
2561 : 271 : p->lineno = lineno;
2562 : 271 : p->col_offset = col_offset;
2563 : 271 : p->end_lineno = end_lineno;
2564 : 271 : p->end_col_offset = end_col_offset;
2565 : 271 : return p;
2566 : : }
2567 : :
2568 : : stmt_ty
2569 : 231 : _PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
2570 : : PyArena *arena)
2571 : : {
2572 : : stmt_ty p;
2573 : 231 : p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
2574 [ - + ]: 231 : if (!p)
2575 : 0 : return NULL;
2576 : 231 : p->kind = Continue_kind;
2577 : 231 : p->lineno = lineno;
2578 : 231 : p->col_offset = col_offset;
2579 : 231 : p->end_lineno = end_lineno;
2580 : 231 : p->end_col_offset = end_col_offset;
2581 : 231 : return p;
2582 : : }
2583 : :
2584 : : expr_ty
2585 : 1755 : _PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
2586 : : int end_lineno, int end_col_offset, PyArena *arena)
2587 : : {
2588 : : expr_ty p;
2589 [ - + ]: 1755 : if (!op) {
2590 : 0 : PyErr_SetString(PyExc_ValueError,
2591 : : "field 'op' is required for BoolOp");
2592 : 0 : return NULL;
2593 : : }
2594 : 1755 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2595 [ - + ]: 1755 : if (!p)
2596 : 0 : return NULL;
2597 : 1755 : p->kind = BoolOp_kind;
2598 : 1755 : p->v.BoolOp.op = op;
2599 : 1755 : p->v.BoolOp.values = values;
2600 : 1755 : p->lineno = lineno;
2601 : 1755 : p->col_offset = col_offset;
2602 : 1755 : p->end_lineno = end_lineno;
2603 : 1755 : p->end_col_offset = end_col_offset;
2604 : 1755 : return p;
2605 : : }
2606 : :
2607 : : expr_ty
2608 : 58 : _PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
2609 : : end_lineno, int end_col_offset, PyArena *arena)
2610 : : {
2611 : : expr_ty p;
2612 [ - + ]: 58 : if (!target) {
2613 : 0 : PyErr_SetString(PyExc_ValueError,
2614 : : "field 'target' is required for NamedExpr");
2615 : 0 : return NULL;
2616 : : }
2617 [ - + ]: 58 : if (!value) {
2618 : 0 : PyErr_SetString(PyExc_ValueError,
2619 : : "field 'value' is required for NamedExpr");
2620 : 0 : return NULL;
2621 : : }
2622 : 58 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2623 [ - + ]: 58 : if (!p)
2624 : 0 : return NULL;
2625 : 58 : p->kind = NamedExpr_kind;
2626 : 58 : p->v.NamedExpr.target = target;
2627 : 58 : p->v.NamedExpr.value = value;
2628 : 58 : p->lineno = lineno;
2629 : 58 : p->col_offset = col_offset;
2630 : 58 : p->end_lineno = end_lineno;
2631 : 58 : p->end_col_offset = end_col_offset;
2632 : 58 : return p;
2633 : : }
2634 : :
2635 : : expr_ty
2636 : 3956 : _PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
2637 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2638 : : {
2639 : : expr_ty p;
2640 [ - + ]: 3956 : if (!left) {
2641 : 0 : PyErr_SetString(PyExc_ValueError,
2642 : : "field 'left' is required for BinOp");
2643 : 0 : return NULL;
2644 : : }
2645 [ - + ]: 3956 : if (!op) {
2646 : 0 : PyErr_SetString(PyExc_ValueError,
2647 : : "field 'op' is required for BinOp");
2648 : 0 : return NULL;
2649 : : }
2650 [ - + ]: 3956 : if (!right) {
2651 : 0 : PyErr_SetString(PyExc_ValueError,
2652 : : "field 'right' is required for BinOp");
2653 : 0 : return NULL;
2654 : : }
2655 : 3956 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2656 [ - + ]: 3956 : if (!p)
2657 : 0 : return NULL;
2658 : 3956 : p->kind = BinOp_kind;
2659 : 3956 : p->v.BinOp.left = left;
2660 : 3956 : p->v.BinOp.op = op;
2661 : 3956 : p->v.BinOp.right = right;
2662 : 3956 : p->lineno = lineno;
2663 : 3956 : p->col_offset = col_offset;
2664 : 3956 : p->end_lineno = end_lineno;
2665 : 3956 : p->end_col_offset = end_col_offset;
2666 : 3956 : return p;
2667 : : }
2668 : :
2669 : : expr_ty
2670 : 2671 : _PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
2671 : : end_lineno, int end_col_offset, PyArena *arena)
2672 : : {
2673 : : expr_ty p;
2674 [ - + ]: 2671 : if (!op) {
2675 : 0 : PyErr_SetString(PyExc_ValueError,
2676 : : "field 'op' is required for UnaryOp");
2677 : 0 : return NULL;
2678 : : }
2679 [ - + ]: 2671 : if (!operand) {
2680 : 0 : PyErr_SetString(PyExc_ValueError,
2681 : : "field 'operand' is required for UnaryOp");
2682 : 0 : return NULL;
2683 : : }
2684 : 2671 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2685 [ - + ]: 2671 : if (!p)
2686 : 0 : return NULL;
2687 : 2671 : p->kind = UnaryOp_kind;
2688 : 2671 : p->v.UnaryOp.op = op;
2689 : 2671 : p->v.UnaryOp.operand = operand;
2690 : 2671 : p->lineno = lineno;
2691 : 2671 : p->col_offset = col_offset;
2692 : 2671 : p->end_lineno = end_lineno;
2693 : 2671 : p->end_col_offset = end_col_offset;
2694 : 2671 : return p;
2695 : : }
2696 : :
2697 : : expr_ty
2698 : 135 : _PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
2699 : : end_lineno, int end_col_offset, PyArena *arena)
2700 : : {
2701 : : expr_ty p;
2702 [ - + ]: 135 : if (!args) {
2703 : 0 : PyErr_SetString(PyExc_ValueError,
2704 : : "field 'args' is required for Lambda");
2705 : 0 : return NULL;
2706 : : }
2707 [ - + ]: 135 : if (!body) {
2708 : 0 : PyErr_SetString(PyExc_ValueError,
2709 : : "field 'body' is required for Lambda");
2710 : 0 : return NULL;
2711 : : }
2712 : 135 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2713 [ - + ]: 135 : if (!p)
2714 : 0 : return NULL;
2715 : 135 : p->kind = Lambda_kind;
2716 : 135 : p->v.Lambda.args = args;
2717 : 135 : p->v.Lambda.body = body;
2718 : 135 : p->lineno = lineno;
2719 : 135 : p->col_offset = col_offset;
2720 : 135 : p->end_lineno = end_lineno;
2721 : 135 : p->end_col_offset = end_col_offset;
2722 : 135 : return p;
2723 : : }
2724 : :
2725 : : expr_ty
2726 : 233 : _PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
2727 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2728 : : {
2729 : : expr_ty p;
2730 [ - + ]: 233 : if (!test) {
2731 : 0 : PyErr_SetString(PyExc_ValueError,
2732 : : "field 'test' is required for IfExp");
2733 : 0 : return NULL;
2734 : : }
2735 [ - + ]: 233 : if (!body) {
2736 : 0 : PyErr_SetString(PyExc_ValueError,
2737 : : "field 'body' is required for IfExp");
2738 : 0 : return NULL;
2739 : : }
2740 [ - + ]: 233 : if (!orelse) {
2741 : 0 : PyErr_SetString(PyExc_ValueError,
2742 : : "field 'orelse' is required for IfExp");
2743 : 0 : return NULL;
2744 : : }
2745 : 233 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2746 [ - + ]: 233 : if (!p)
2747 : 0 : return NULL;
2748 : 233 : p->kind = IfExp_kind;
2749 : 233 : p->v.IfExp.test = test;
2750 : 233 : p->v.IfExp.body = body;
2751 : 233 : p->v.IfExp.orelse = orelse;
2752 : 233 : p->lineno = lineno;
2753 : 233 : p->col_offset = col_offset;
2754 : 233 : p->end_lineno = end_lineno;
2755 : 233 : p->end_col_offset = end_col_offset;
2756 : 233 : return p;
2757 : : }
2758 : :
2759 : : expr_ty
2760 : 1063 : _PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
2761 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
2762 : : {
2763 : : expr_ty p;
2764 : 1063 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2765 [ - + ]: 1063 : if (!p)
2766 : 0 : return NULL;
2767 : 1063 : p->kind = Dict_kind;
2768 : 1063 : p->v.Dict.keys = keys;
2769 : 1063 : p->v.Dict.values = values;
2770 : 1063 : p->lineno = lineno;
2771 : 1063 : p->col_offset = col_offset;
2772 : 1063 : p->end_lineno = end_lineno;
2773 : 1063 : p->end_col_offset = end_col_offset;
2774 : 1063 : return p;
2775 : : }
2776 : :
2777 : : expr_ty
2778 : 159 : _PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
2779 : : int end_col_offset, PyArena *arena)
2780 : : {
2781 : : expr_ty p;
2782 : 159 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2783 [ - + ]: 159 : if (!p)
2784 : 0 : return NULL;
2785 : 159 : p->kind = Set_kind;
2786 : 159 : p->v.Set.elts = elts;
2787 : 159 : p->lineno = lineno;
2788 : 159 : p->col_offset = col_offset;
2789 : 159 : p->end_lineno = end_lineno;
2790 : 159 : p->end_col_offset = end_col_offset;
2791 : 159 : return p;
2792 : : }
2793 : :
2794 : : expr_ty
2795 : 566 : _PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
2796 : : int col_offset, int end_lineno, int end_col_offset, PyArena
2797 : : *arena)
2798 : : {
2799 : : expr_ty p;
2800 [ - + ]: 566 : if (!elt) {
2801 : 0 : PyErr_SetString(PyExc_ValueError,
2802 : : "field 'elt' is required for ListComp");
2803 : 0 : return NULL;
2804 : : }
2805 : 566 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2806 [ - + ]: 566 : if (!p)
2807 : 0 : return NULL;
2808 : 566 : p->kind = ListComp_kind;
2809 : 566 : p->v.ListComp.elt = elt;
2810 : 566 : p->v.ListComp.generators = generators;
2811 : 566 : p->lineno = lineno;
2812 : 566 : p->col_offset = col_offset;
2813 : 566 : p->end_lineno = end_lineno;
2814 : 566 : p->end_col_offset = end_col_offset;
2815 : 566 : return p;
2816 : : }
2817 : :
2818 : : expr_ty
2819 : 34 : _PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
2820 : : int col_offset, int end_lineno, int end_col_offset, PyArena
2821 : : *arena)
2822 : : {
2823 : : expr_ty p;
2824 [ - + ]: 34 : if (!elt) {
2825 : 0 : PyErr_SetString(PyExc_ValueError,
2826 : : "field 'elt' is required for SetComp");
2827 : 0 : return NULL;
2828 : : }
2829 : 34 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2830 [ - + ]: 34 : if (!p)
2831 : 0 : return NULL;
2832 : 34 : p->kind = SetComp_kind;
2833 : 34 : p->v.SetComp.elt = elt;
2834 : 34 : p->v.SetComp.generators = generators;
2835 : 34 : p->lineno = lineno;
2836 : 34 : p->col_offset = col_offset;
2837 : 34 : p->end_lineno = end_lineno;
2838 : 34 : p->end_col_offset = end_col_offset;
2839 : 34 : return p;
2840 : : }
2841 : :
2842 : : expr_ty
2843 : 64 : _PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
2844 : : generators, int lineno, int col_offset, int end_lineno, int
2845 : : end_col_offset, PyArena *arena)
2846 : : {
2847 : : expr_ty p;
2848 [ - + ]: 64 : if (!key) {
2849 : 0 : PyErr_SetString(PyExc_ValueError,
2850 : : "field 'key' is required for DictComp");
2851 : 0 : return NULL;
2852 : : }
2853 [ - + ]: 64 : if (!value) {
2854 : 0 : PyErr_SetString(PyExc_ValueError,
2855 : : "field 'value' is required for DictComp");
2856 : 0 : return NULL;
2857 : : }
2858 : 64 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2859 [ - + ]: 64 : if (!p)
2860 : 0 : return NULL;
2861 : 64 : p->kind = DictComp_kind;
2862 : 64 : p->v.DictComp.key = key;
2863 : 64 : p->v.DictComp.value = value;
2864 : 64 : p->v.DictComp.generators = generators;
2865 : 64 : p->lineno = lineno;
2866 : 64 : p->col_offset = col_offset;
2867 : 64 : p->end_lineno = end_lineno;
2868 : 64 : p->end_col_offset = end_col_offset;
2869 : 64 : return p;
2870 : : }
2871 : :
2872 : : expr_ty
2873 : 290 : _PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
2874 : : lineno, int col_offset, int end_lineno, int end_col_offset,
2875 : : PyArena *arena)
2876 : : {
2877 : : expr_ty p;
2878 [ - + ]: 290 : if (!elt) {
2879 : 0 : PyErr_SetString(PyExc_ValueError,
2880 : : "field 'elt' is required for GeneratorExp");
2881 : 0 : return NULL;
2882 : : }
2883 : 290 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2884 [ - + ]: 290 : if (!p)
2885 : 0 : return NULL;
2886 : 290 : p->kind = GeneratorExp_kind;
2887 : 290 : p->v.GeneratorExp.elt = elt;
2888 : 290 : p->v.GeneratorExp.generators = generators;
2889 : 290 : p->lineno = lineno;
2890 : 290 : p->col_offset = col_offset;
2891 : 290 : p->end_lineno = end_lineno;
2892 : 290 : p->end_col_offset = end_col_offset;
2893 : 290 : return p;
2894 : : }
2895 : :
2896 : : expr_ty
2897 : 128 : _PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
2898 : : end_col_offset, PyArena *arena)
2899 : : {
2900 : : expr_ty p;
2901 [ - + ]: 128 : if (!value) {
2902 : 0 : PyErr_SetString(PyExc_ValueError,
2903 : : "field 'value' is required for Await");
2904 : 0 : return NULL;
2905 : : }
2906 : 128 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2907 [ - + ]: 128 : if (!p)
2908 : 0 : return NULL;
2909 : 128 : p->kind = Await_kind;
2910 : 128 : p->v.Await.value = value;
2911 : 128 : p->lineno = lineno;
2912 : 128 : p->col_offset = col_offset;
2913 : 128 : p->end_lineno = end_lineno;
2914 : 128 : p->end_col_offset = end_col_offset;
2915 : 128 : return p;
2916 : : }
2917 : :
2918 : : expr_ty
2919 : 254 : _PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
2920 : : end_col_offset, PyArena *arena)
2921 : : {
2922 : : expr_ty p;
2923 : 254 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2924 [ - + ]: 254 : if (!p)
2925 : 0 : return NULL;
2926 : 254 : p->kind = Yield_kind;
2927 : 254 : p->v.Yield.value = value;
2928 : 254 : p->lineno = lineno;
2929 : 254 : p->col_offset = col_offset;
2930 : 254 : p->end_lineno = end_lineno;
2931 : 254 : p->end_col_offset = end_col_offset;
2932 : 254 : return p;
2933 : : }
2934 : :
2935 : : expr_ty
2936 : 44 : _PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
2937 : : end_col_offset, PyArena *arena)
2938 : : {
2939 : : expr_ty p;
2940 [ - + ]: 44 : if (!value) {
2941 : 0 : PyErr_SetString(PyExc_ValueError,
2942 : : "field 'value' is required for YieldFrom");
2943 : 0 : return NULL;
2944 : : }
2945 : 44 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2946 [ - + ]: 44 : if (!p)
2947 : 0 : return NULL;
2948 : 44 : p->kind = YieldFrom_kind;
2949 : 44 : p->v.YieldFrom.value = value;
2950 : 44 : p->lineno = lineno;
2951 : 44 : p->col_offset = col_offset;
2952 : 44 : p->end_lineno = end_lineno;
2953 : 44 : p->end_col_offset = end_col_offset;
2954 : 44 : return p;
2955 : : }
2956 : :
2957 : : expr_ty
2958 : 6203 : _PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
2959 : : int lineno, int col_offset, int end_lineno, int end_col_offset,
2960 : : PyArena *arena)
2961 : : {
2962 : : expr_ty p;
2963 [ - + ]: 6203 : if (!left) {
2964 : 0 : PyErr_SetString(PyExc_ValueError,
2965 : : "field 'left' is required for Compare");
2966 : 0 : return NULL;
2967 : : }
2968 : 6203 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2969 [ - + ]: 6203 : if (!p)
2970 : 0 : return NULL;
2971 : 6203 : p->kind = Compare_kind;
2972 : 6203 : p->v.Compare.left = left;
2973 : 6203 : p->v.Compare.ops = ops;
2974 : 6203 : p->v.Compare.comparators = comparators;
2975 : 6203 : p->lineno = lineno;
2976 : 6203 : p->col_offset = col_offset;
2977 : 6203 : p->end_lineno = end_lineno;
2978 : 6203 : p->end_col_offset = end_col_offset;
2979 : 6203 : return p;
2980 : : }
2981 : :
2982 : : expr_ty
2983 : 49306 : _PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
2984 : : int lineno, int col_offset, int end_lineno, int end_col_offset,
2985 : : PyArena *arena)
2986 : : {
2987 : : expr_ty p;
2988 [ - + ]: 49306 : if (!func) {
2989 : 0 : PyErr_SetString(PyExc_ValueError,
2990 : : "field 'func' is required for Call");
2991 : 0 : return NULL;
2992 : : }
2993 : 49306 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
2994 [ - + ]: 49306 : if (!p)
2995 : 0 : return NULL;
2996 : 49306 : p->kind = Call_kind;
2997 : 49306 : p->v.Call.func = func;
2998 : 49306 : p->v.Call.args = args;
2999 : 49306 : p->v.Call.keywords = keywords;
3000 : 49306 : p->lineno = lineno;
3001 : 49306 : p->col_offset = col_offset;
3002 : 49306 : p->end_lineno = end_lineno;
3003 : 49306 : p->end_col_offset = end_col_offset;
3004 : 49306 : return p;
3005 : : }
3006 : :
3007 : : expr_ty
3008 : 1885 : _PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
3009 : : lineno, int col_offset, int end_lineno, int
3010 : : end_col_offset, PyArena *arena)
3011 : : {
3012 : : expr_ty p;
3013 [ - + ]: 1885 : if (!value) {
3014 : 0 : PyErr_SetString(PyExc_ValueError,
3015 : : "field 'value' is required for FormattedValue");
3016 : 0 : return NULL;
3017 : : }
3018 : 1885 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3019 [ - + ]: 1885 : if (!p)
3020 : 0 : return NULL;
3021 : 1885 : p->kind = FormattedValue_kind;
3022 : 1885 : p->v.FormattedValue.value = value;
3023 : 1885 : p->v.FormattedValue.conversion = conversion;
3024 : 1885 : p->v.FormattedValue.format_spec = format_spec;
3025 : 1885 : p->lineno = lineno;
3026 : 1885 : p->col_offset = col_offset;
3027 : 1885 : p->end_lineno = end_lineno;
3028 : 1885 : p->end_col_offset = end_col_offset;
3029 : 1885 : return p;
3030 : : }
3031 : :
3032 : : expr_ty
3033 : 1186 : _PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
3034 : : end_lineno, int end_col_offset, PyArena *arena)
3035 : : {
3036 : : expr_ty p;
3037 : 1186 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3038 [ - + ]: 1186 : if (!p)
3039 : 0 : return NULL;
3040 : 1186 : p->kind = JoinedStr_kind;
3041 : 1186 : p->v.JoinedStr.values = values;
3042 : 1186 : p->lineno = lineno;
3043 : 1186 : p->col_offset = col_offset;
3044 : 1186 : p->end_lineno = end_lineno;
3045 : 1186 : p->end_col_offset = end_col_offset;
3046 : 1186 : return p;
3047 : : }
3048 : :
3049 : : expr_ty
3050 : 869603 : _PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
3051 : : end_lineno, int end_col_offset, PyArena *arena)
3052 : : {
3053 : : expr_ty p;
3054 [ - + ]: 869603 : if (!value) {
3055 : 0 : PyErr_SetString(PyExc_ValueError,
3056 : : "field 'value' is required for Constant");
3057 : 0 : return NULL;
3058 : : }
3059 : 869603 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3060 [ - + ]: 869603 : if (!p)
3061 : 0 : return NULL;
3062 : 869603 : p->kind = Constant_kind;
3063 : 869603 : p->v.Constant.value = value;
3064 : 869603 : p->v.Constant.kind = kind;
3065 : 869603 : p->lineno = lineno;
3066 : 869603 : p->col_offset = col_offset;
3067 : 869603 : p->end_lineno = end_lineno;
3068 : 869603 : p->end_col_offset = end_col_offset;
3069 : 869603 : return p;
3070 : : }
3071 : :
3072 : : expr_ty
3073 : 45018 : _PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
3074 : : lineno, int col_offset, int end_lineno, int end_col_offset,
3075 : : PyArena *arena)
3076 : : {
3077 : : expr_ty p;
3078 [ - + ]: 45018 : if (!value) {
3079 : 0 : PyErr_SetString(PyExc_ValueError,
3080 : : "field 'value' is required for Attribute");
3081 : 0 : return NULL;
3082 : : }
3083 [ - + ]: 45018 : if (!attr) {
3084 : 0 : PyErr_SetString(PyExc_ValueError,
3085 : : "field 'attr' is required for Attribute");
3086 : 0 : return NULL;
3087 : : }
3088 [ - + ]: 45018 : if (!ctx) {
3089 : 0 : PyErr_SetString(PyExc_ValueError,
3090 : : "field 'ctx' is required for Attribute");
3091 : 0 : return NULL;
3092 : : }
3093 : 45018 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3094 [ - + ]: 45018 : if (!p)
3095 : 0 : return NULL;
3096 : 45018 : p->kind = Attribute_kind;
3097 : 45018 : p->v.Attribute.value = value;
3098 : 45018 : p->v.Attribute.attr = attr;
3099 : 45018 : p->v.Attribute.ctx = ctx;
3100 : 45018 : p->lineno = lineno;
3101 : 45018 : p->col_offset = col_offset;
3102 : 45018 : p->end_lineno = end_lineno;
3103 : 45018 : p->end_col_offset = end_col_offset;
3104 : 45018 : return p;
3105 : : }
3106 : :
3107 : : expr_ty
3108 : 5307 : _PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
3109 : : int col_offset, int end_lineno, int end_col_offset, PyArena
3110 : : *arena)
3111 : : {
3112 : : expr_ty p;
3113 [ - + ]: 5307 : if (!value) {
3114 : 0 : PyErr_SetString(PyExc_ValueError,
3115 : : "field 'value' is required for Subscript");
3116 : 0 : return NULL;
3117 : : }
3118 [ - + ]: 5307 : if (!slice) {
3119 : 0 : PyErr_SetString(PyExc_ValueError,
3120 : : "field 'slice' is required for Subscript");
3121 : 0 : return NULL;
3122 : : }
3123 [ - + ]: 5307 : if (!ctx) {
3124 : 0 : PyErr_SetString(PyExc_ValueError,
3125 : : "field 'ctx' is required for Subscript");
3126 : 0 : return NULL;
3127 : : }
3128 : 5307 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3129 [ - + ]: 5307 : if (!p)
3130 : 0 : return NULL;
3131 : 5307 : p->kind = Subscript_kind;
3132 : 5307 : p->v.Subscript.value = value;
3133 : 5307 : p->v.Subscript.slice = slice;
3134 : 5307 : p->v.Subscript.ctx = ctx;
3135 : 5307 : p->lineno = lineno;
3136 : 5307 : p->col_offset = col_offset;
3137 : 5307 : p->end_lineno = end_lineno;
3138 : 5307 : p->end_col_offset = end_col_offset;
3139 : 5307 : return p;
3140 : : }
3141 : :
3142 : : expr_ty
3143 : 358 : _PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
3144 : : int end_lineno, int end_col_offset, PyArena *arena)
3145 : : {
3146 : : expr_ty p;
3147 [ - + ]: 358 : if (!value) {
3148 : 0 : PyErr_SetString(PyExc_ValueError,
3149 : : "field 'value' is required for Starred");
3150 : 0 : return NULL;
3151 : : }
3152 [ - + ]: 358 : if (!ctx) {
3153 : 0 : PyErr_SetString(PyExc_ValueError,
3154 : : "field 'ctx' is required for Starred");
3155 : 0 : return NULL;
3156 : : }
3157 : 358 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3158 [ - + ]: 358 : if (!p)
3159 : 0 : return NULL;
3160 : 358 : p->kind = Starred_kind;
3161 : 358 : p->v.Starred.value = value;
3162 : 358 : p->v.Starred.ctx = ctx;
3163 : 358 : p->lineno = lineno;
3164 : 358 : p->col_offset = col_offset;
3165 : 358 : p->end_lineno = end_lineno;
3166 : 358 : p->end_col_offset = end_col_offset;
3167 : 358 : return p;
3168 : : }
3169 : :
3170 : : expr_ty
3171 : 576542 : _PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
3172 : : end_lineno, int end_col_offset, PyArena *arena)
3173 : : {
3174 : : expr_ty p;
3175 [ - + ]: 576542 : if (!id) {
3176 : 0 : PyErr_SetString(PyExc_ValueError,
3177 : : "field 'id' is required for Name");
3178 : 0 : return NULL;
3179 : : }
3180 [ - + ]: 576542 : if (!ctx) {
3181 : 0 : PyErr_SetString(PyExc_ValueError,
3182 : : "field 'ctx' is required for Name");
3183 : 0 : return NULL;
3184 : : }
3185 : 576542 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3186 [ - + ]: 576542 : if (!p)
3187 : 0 : return NULL;
3188 : 576542 : p->kind = Name_kind;
3189 : 576542 : p->v.Name.id = id;
3190 : 576542 : p->v.Name.ctx = ctx;
3191 : 576542 : p->lineno = lineno;
3192 : 576542 : p->col_offset = col_offset;
3193 : 576542 : p->end_lineno = end_lineno;
3194 : 576542 : p->end_col_offset = end_col_offset;
3195 : 576542 : return p;
3196 : : }
3197 : :
3198 : : expr_ty
3199 : 3260 : _PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
3200 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3201 : : {
3202 : : expr_ty p;
3203 [ - + ]: 3260 : if (!ctx) {
3204 : 0 : PyErr_SetString(PyExc_ValueError,
3205 : : "field 'ctx' is required for List");
3206 : 0 : return NULL;
3207 : : }
3208 : 3260 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3209 [ - + ]: 3260 : if (!p)
3210 : 0 : return NULL;
3211 : 3260 : p->kind = List_kind;
3212 : 3260 : p->v.List.elts = elts;
3213 : 3260 : p->v.List.ctx = ctx;
3214 : 3260 : p->lineno = lineno;
3215 : 3260 : p->col_offset = col_offset;
3216 : 3260 : p->end_lineno = end_lineno;
3217 : 3260 : p->end_col_offset = end_col_offset;
3218 : 3260 : return p;
3219 : : }
3220 : :
3221 : : expr_ty
3222 : 7424 : _PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
3223 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3224 : : {
3225 : : expr_ty p;
3226 [ - + ]: 7424 : if (!ctx) {
3227 : 0 : PyErr_SetString(PyExc_ValueError,
3228 : : "field 'ctx' is required for Tuple");
3229 : 0 : return NULL;
3230 : : }
3231 : 7424 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3232 [ - + ]: 7424 : if (!p)
3233 : 0 : return NULL;
3234 : 7424 : p->kind = Tuple_kind;
3235 : 7424 : p->v.Tuple.elts = elts;
3236 : 7424 : p->v.Tuple.ctx = ctx;
3237 : 7424 : p->lineno = lineno;
3238 : 7424 : p->col_offset = col_offset;
3239 : 7424 : p->end_lineno = end_lineno;
3240 : 7424 : p->end_col_offset = end_col_offset;
3241 : 7424 : return p;
3242 : : }
3243 : :
3244 : : expr_ty
3245 : 1430 : _PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
3246 : : col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3247 : : {
3248 : : expr_ty p;
3249 : 1430 : p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3250 [ - + ]: 1430 : if (!p)
3251 : 0 : return NULL;
3252 : 1430 : p->kind = Slice_kind;
3253 : 1430 : p->v.Slice.lower = lower;
3254 : 1430 : p->v.Slice.upper = upper;
3255 : 1430 : p->v.Slice.step = step;
3256 : 1430 : p->lineno = lineno;
3257 : 1430 : p->col_offset = col_offset;
3258 : 1430 : p->end_lineno = end_lineno;
3259 : 1430 : p->end_col_offset = end_col_offset;
3260 : 1430 : return p;
3261 : : }
3262 : :
3263 : : comprehension_ty
3264 : 998 : _PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
3265 : : is_async, PyArena *arena)
3266 : : {
3267 : : comprehension_ty p;
3268 [ - + ]: 998 : if (!target) {
3269 : 0 : PyErr_SetString(PyExc_ValueError,
3270 : : "field 'target' is required for comprehension");
3271 : 0 : return NULL;
3272 : : }
3273 [ - + ]: 998 : if (!iter) {
3274 : 0 : PyErr_SetString(PyExc_ValueError,
3275 : : "field 'iter' is required for comprehension");
3276 : 0 : return NULL;
3277 : : }
3278 : 998 : p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
3279 [ - + ]: 998 : if (!p)
3280 : 0 : return NULL;
3281 : 998 : p->target = target;
3282 : 998 : p->iter = iter;
3283 : 998 : p->ifs = ifs;
3284 : 998 : p->is_async = is_async;
3285 : 998 : return p;
3286 : : }
3287 : :
3288 : : excepthandler_ty
3289 : 1431 : _PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
3290 : : lineno, int col_offset, int end_lineno, int
3291 : : end_col_offset, PyArena *arena)
3292 : : {
3293 : : excepthandler_ty p;
3294 : 1431 : p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
3295 [ - + ]: 1431 : if (!p)
3296 : 0 : return NULL;
3297 : 1431 : p->kind = ExceptHandler_kind;
3298 : 1431 : p->v.ExceptHandler.type = type;
3299 : 1431 : p->v.ExceptHandler.name = name;
3300 : 1431 : p->v.ExceptHandler.body = body;
3301 : 1431 : p->lineno = lineno;
3302 : 1431 : p->col_offset = col_offset;
3303 : 1431 : p->end_lineno = end_lineno;
3304 : 1431 : p->end_col_offset = end_col_offset;
3305 : 1431 : return p;
3306 : : }
3307 : :
3308 : : arguments_ty
3309 : 6536 : _PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
3310 : : vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
3311 : : kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
3312 : : *arena)
3313 : : {
3314 : : arguments_ty p;
3315 : 6536 : p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
3316 [ - + ]: 6536 : if (!p)
3317 : 0 : return NULL;
3318 : 6536 : p->posonlyargs = posonlyargs;
3319 : 6536 : p->args = args;
3320 : 6536 : p->vararg = vararg;
3321 : 6536 : p->kwonlyargs = kwonlyargs;
3322 : 6536 : p->kw_defaults = kw_defaults;
3323 : 6536 : p->kwarg = kwarg;
3324 : 6536 : p->defaults = defaults;
3325 : 6536 : return p;
3326 : : }
3327 : :
3328 : : arg_ty
3329 : 96190 : _PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
3330 : : int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3331 : : {
3332 : : arg_ty p;
3333 [ - + ]: 96190 : if (!arg) {
3334 : 0 : PyErr_SetString(PyExc_ValueError,
3335 : : "field 'arg' is required for arg");
3336 : 0 : return NULL;
3337 : : }
3338 : 96190 : p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
3339 [ - + ]: 96190 : if (!p)
3340 : 0 : return NULL;
3341 : 96190 : p->arg = arg;
3342 : 96190 : p->annotation = annotation;
3343 : 96190 : p->type_comment = type_comment;
3344 : 96190 : p->lineno = lineno;
3345 : 96190 : p->col_offset = col_offset;
3346 : 96190 : p->end_lineno = end_lineno;
3347 : 96190 : p->end_col_offset = end_col_offset;
3348 : 96190 : return p;
3349 : : }
3350 : :
3351 : : keyword_ty
3352 : 4155 : _PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
3353 : : end_lineno, int end_col_offset, PyArena *arena)
3354 : : {
3355 : : keyword_ty p;
3356 [ - + ]: 4155 : if (!value) {
3357 : 0 : PyErr_SetString(PyExc_ValueError,
3358 : : "field 'value' is required for keyword");
3359 : 0 : return NULL;
3360 : : }
3361 : 4155 : p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
3362 [ - + ]: 4155 : if (!p)
3363 : 0 : return NULL;
3364 : 4155 : p->arg = arg;
3365 : 4155 : p->value = value;
3366 : 4155 : p->lineno = lineno;
3367 : 4155 : p->col_offset = col_offset;
3368 : 4155 : p->end_lineno = end_lineno;
3369 : 4155 : p->end_col_offset = end_col_offset;
3370 : 4155 : return p;
3371 : : }
3372 : :
3373 : : alias_ty
3374 : 1740 : _PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
3375 : : int end_lineno, int end_col_offset, PyArena *arena)
3376 : : {
3377 : : alias_ty p;
3378 [ - + ]: 1740 : if (!name) {
3379 : 0 : PyErr_SetString(PyExc_ValueError,
3380 : : "field 'name' is required for alias");
3381 : 0 : return NULL;
3382 : : }
3383 : 1740 : p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
3384 [ - + ]: 1740 : if (!p)
3385 : 0 : return NULL;
3386 : 1740 : p->name = name;
3387 : 1740 : p->asname = asname;
3388 : 1740 : p->lineno = lineno;
3389 : 1740 : p->col_offset = col_offset;
3390 : 1740 : p->end_lineno = end_lineno;
3391 : 1740 : p->end_col_offset = end_col_offset;
3392 : 1740 : return p;
3393 : : }
3394 : :
3395 : : withitem_ty
3396 : 388 : _PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
3397 : : {
3398 : : withitem_ty p;
3399 [ - + ]: 388 : if (!context_expr) {
3400 : 0 : PyErr_SetString(PyExc_ValueError,
3401 : : "field 'context_expr' is required for withitem");
3402 : 0 : return NULL;
3403 : : }
3404 : 388 : p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
3405 [ - + ]: 388 : if (!p)
3406 : 0 : return NULL;
3407 : 388 : p->context_expr = context_expr;
3408 : 388 : p->optional_vars = optional_vars;
3409 : 388 : return p;
3410 : : }
3411 : :
3412 : : match_case_ty
3413 : 12 : _PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
3414 : : PyArena *arena)
3415 : : {
3416 : : match_case_ty p;
3417 [ - + ]: 12 : if (!pattern) {
3418 : 0 : PyErr_SetString(PyExc_ValueError,
3419 : : "field 'pattern' is required for match_case");
3420 : 0 : return NULL;
3421 : : }
3422 : 12 : p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
3423 [ - + ]: 12 : if (!p)
3424 : 0 : return NULL;
3425 : 12 : p->pattern = pattern;
3426 : 12 : p->guard = guard;
3427 : 12 : p->body = body;
3428 : 12 : return p;
3429 : : }
3430 : :
3431 : : pattern_ty
3432 : 4 : _PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
3433 : : int end_col_offset, PyArena *arena)
3434 : : {
3435 : : pattern_ty p;
3436 [ - + ]: 4 : if (!value) {
3437 : 0 : PyErr_SetString(PyExc_ValueError,
3438 : : "field 'value' is required for MatchValue");
3439 : 0 : return NULL;
3440 : : }
3441 : 4 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3442 [ - + ]: 4 : if (!p)
3443 : 0 : return NULL;
3444 : 4 : p->kind = MatchValue_kind;
3445 : 4 : p->v.MatchValue.value = value;
3446 : 4 : p->lineno = lineno;
3447 : 4 : p->col_offset = col_offset;
3448 : 4 : p->end_lineno = end_lineno;
3449 : 4 : p->end_col_offset = end_col_offset;
3450 : 4 : return p;
3451 : : }
3452 : :
3453 : : pattern_ty
3454 : 1 : _PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
3455 : : end_lineno, int end_col_offset, PyArena *arena)
3456 : : {
3457 : : pattern_ty p;
3458 [ - + ]: 1 : if (!value) {
3459 : 0 : PyErr_SetString(PyExc_ValueError,
3460 : : "field 'value' is required for MatchSingleton");
3461 : 0 : return NULL;
3462 : : }
3463 : 1 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3464 [ - + ]: 1 : if (!p)
3465 : 0 : return NULL;
3466 : 1 : p->kind = MatchSingleton_kind;
3467 : 1 : p->v.MatchSingleton.value = value;
3468 : 1 : p->lineno = lineno;
3469 : 1 : p->col_offset = col_offset;
3470 : 1 : p->end_lineno = end_lineno;
3471 : 1 : p->end_col_offset = end_col_offset;
3472 : 1 : return p;
3473 : : }
3474 : :
3475 : : pattern_ty
3476 : 5 : _PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
3477 : : int end_lineno, int end_col_offset, PyArena *arena)
3478 : : {
3479 : : pattern_ty p;
3480 : 5 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3481 [ - + ]: 5 : if (!p)
3482 : 0 : return NULL;
3483 : 5 : p->kind = MatchSequence_kind;
3484 : 5 : p->v.MatchSequence.patterns = patterns;
3485 : 5 : p->lineno = lineno;
3486 : 5 : p->col_offset = col_offset;
3487 : 5 : p->end_lineno = end_lineno;
3488 : 5 : p->end_col_offset = end_col_offset;
3489 : 5 : return p;
3490 : : }
3491 : :
3492 : : pattern_ty
3493 : 0 : _PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
3494 : : identifier rest, int lineno, int col_offset, int
3495 : : end_lineno, int end_col_offset, PyArena *arena)
3496 : : {
3497 : : pattern_ty p;
3498 : 0 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3499 [ # # ]: 0 : if (!p)
3500 : 0 : return NULL;
3501 : 0 : p->kind = MatchMapping_kind;
3502 : 0 : p->v.MatchMapping.keys = keys;
3503 : 0 : p->v.MatchMapping.patterns = patterns;
3504 : 0 : p->v.MatchMapping.rest = rest;
3505 : 0 : p->lineno = lineno;
3506 : 0 : p->col_offset = col_offset;
3507 : 0 : p->end_lineno = end_lineno;
3508 : 0 : p->end_col_offset = end_col_offset;
3509 : 0 : return p;
3510 : : }
3511 : :
3512 : : pattern_ty
3513 : 4 : _PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
3514 : : * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
3515 : : col_offset, int end_lineno, int end_col_offset, PyArena
3516 : : *arena)
3517 : : {
3518 : : pattern_ty p;
3519 [ - + ]: 4 : if (!cls) {
3520 : 0 : PyErr_SetString(PyExc_ValueError,
3521 : : "field 'cls' is required for MatchClass");
3522 : 0 : return NULL;
3523 : : }
3524 : 4 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3525 [ - + ]: 4 : if (!p)
3526 : 0 : return NULL;
3527 : 4 : p->kind = MatchClass_kind;
3528 : 4 : p->v.MatchClass.cls = cls;
3529 : 4 : p->v.MatchClass.patterns = patterns;
3530 : 4 : p->v.MatchClass.kwd_attrs = kwd_attrs;
3531 : 4 : p->v.MatchClass.kwd_patterns = kwd_patterns;
3532 : 4 : p->lineno = lineno;
3533 : 4 : p->col_offset = col_offset;
3534 : 4 : p->end_lineno = end_lineno;
3535 : 4 : p->end_col_offset = end_col_offset;
3536 : 4 : return p;
3537 : : }
3538 : :
3539 : : pattern_ty
3540 : 1 : _PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
3541 : : int end_col_offset, PyArena *arena)
3542 : : {
3543 : : pattern_ty p;
3544 : 1 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3545 [ - + ]: 1 : if (!p)
3546 : 0 : return NULL;
3547 : 1 : p->kind = MatchStar_kind;
3548 : 1 : p->v.MatchStar.name = name;
3549 : 1 : p->lineno = lineno;
3550 : 1 : p->col_offset = col_offset;
3551 : 1 : p->end_lineno = end_lineno;
3552 : 1 : p->end_col_offset = end_col_offset;
3553 : 1 : return p;
3554 : : }
3555 : :
3556 : : pattern_ty
3557 : 4 : _PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
3558 : : int end_lineno, int end_col_offset, PyArena *arena)
3559 : : {
3560 : : pattern_ty p;
3561 : 4 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3562 [ - + ]: 4 : if (!p)
3563 : 0 : return NULL;
3564 : 4 : p->kind = MatchAs_kind;
3565 : 4 : p->v.MatchAs.pattern = pattern;
3566 : 4 : p->v.MatchAs.name = name;
3567 : 4 : p->lineno = lineno;
3568 : 4 : p->col_offset = col_offset;
3569 : 4 : p->end_lineno = end_lineno;
3570 : 4 : p->end_col_offset = end_col_offset;
3571 : 4 : return p;
3572 : : }
3573 : :
3574 : : pattern_ty
3575 : 0 : _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
3576 : : end_lineno, int end_col_offset, PyArena *arena)
3577 : : {
3578 : : pattern_ty p;
3579 : 0 : p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
3580 [ # # ]: 0 : if (!p)
3581 : 0 : return NULL;
3582 : 0 : p->kind = MatchOr_kind;
3583 : 0 : p->v.MatchOr.patterns = patterns;
3584 : 0 : p->lineno = lineno;
3585 : 0 : p->col_offset = col_offset;
3586 : 0 : p->end_lineno = end_lineno;
3587 : 0 : p->end_col_offset = end_col_offset;
3588 : 0 : return p;
3589 : : }
3590 : :
3591 : : type_ignore_ty
3592 : 0 : _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
3593 : : {
3594 : : type_ignore_ty p;
3595 [ # # ]: 0 : if (!tag) {
3596 : 0 : PyErr_SetString(PyExc_ValueError,
3597 : : "field 'tag' is required for TypeIgnore");
3598 : 0 : return NULL;
3599 : : }
3600 : 0 : p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
3601 [ # # ]: 0 : if (!p)
3602 : 0 : return NULL;
3603 : 0 : p->kind = TypeIgnore_kind;
3604 : 0 : p->v.TypeIgnore.lineno = lineno;
3605 : 0 : p->v.TypeIgnore.tag = tag;
3606 : 0 : return p;
3607 : : }
3608 : :
3609 : :
3610 : : PyObject*
3611 : 32 : ast2obj_mod(struct ast_state *state, void* _o)
3612 : : {
3613 : 32 : mod_ty o = (mod_ty)_o;
3614 : 32 : PyObject *result = NULL, *value = NULL;
3615 : : PyTypeObject *tp;
3616 [ - + ]: 32 : if (!o) {
3617 : 0 : Py_RETURN_NONE;
3618 : : }
3619 [ - + ]: 32 : if (++state->recursion_depth > state->recursion_limit) {
3620 : 0 : PyErr_SetString(PyExc_RecursionError,
3621 : : "maximum recursion depth exceeded during ast construction");
3622 : 0 : return 0;
3623 : : }
3624 [ + - + - : 32 : switch (o->kind) {
- ]
3625 : 9 : case Module_kind:
3626 : 9 : tp = (PyTypeObject *)state->Module_type;
3627 : 9 : result = PyType_GenericNew(tp, NULL, NULL);
3628 [ - + ]: 9 : if (!result) goto failed;
3629 : 9 : value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
3630 [ - + ]: 9 : if (!value) goto failed;
3631 [ - + ]: 9 : if (PyObject_SetAttr(result, state->body, value) == -1)
3632 : 0 : goto failed;
3633 : 9 : Py_DECREF(value);
3634 : 9 : value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
3635 : : ast2obj_type_ignore);
3636 [ - + ]: 9 : if (!value) goto failed;
3637 [ - + ]: 9 : if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
3638 : 0 : goto failed;
3639 : 9 : Py_DECREF(value);
3640 : 9 : break;
3641 : 0 : case Interactive_kind:
3642 : 0 : tp = (PyTypeObject *)state->Interactive_type;
3643 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3644 [ # # ]: 0 : if (!result) goto failed;
3645 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
3646 : : ast2obj_stmt);
3647 [ # # ]: 0 : if (!value) goto failed;
3648 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3649 : 0 : goto failed;
3650 : 0 : Py_DECREF(value);
3651 : 0 : break;
3652 : 23 : case Expression_kind:
3653 : 23 : tp = (PyTypeObject *)state->Expression_type;
3654 : 23 : result = PyType_GenericNew(tp, NULL, NULL);
3655 [ - + ]: 23 : if (!result) goto failed;
3656 : 23 : value = ast2obj_expr(state, o->v.Expression.body);
3657 [ - + ]: 23 : if (!value) goto failed;
3658 [ - + ]: 23 : if (PyObject_SetAttr(result, state->body, value) == -1)
3659 : 0 : goto failed;
3660 : 23 : Py_DECREF(value);
3661 : 23 : break;
3662 : 0 : case FunctionType_kind:
3663 : 0 : tp = (PyTypeObject *)state->FunctionType_type;
3664 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3665 [ # # ]: 0 : if (!result) goto failed;
3666 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
3667 : : ast2obj_expr);
3668 [ # # ]: 0 : if (!value) goto failed;
3669 [ # # ]: 0 : if (PyObject_SetAttr(result, state->argtypes, value) == -1)
3670 : 0 : goto failed;
3671 : 0 : Py_DECREF(value);
3672 : 0 : value = ast2obj_expr(state, o->v.FunctionType.returns);
3673 [ # # ]: 0 : if (!value) goto failed;
3674 [ # # ]: 0 : if (PyObject_SetAttr(result, state->returns, value) == -1)
3675 : 0 : goto failed;
3676 : 0 : Py_DECREF(value);
3677 : 0 : break;
3678 : : }
3679 : 32 : state->recursion_depth--;
3680 : 32 : return result;
3681 : 0 : failed:
3682 : 0 : Py_XDECREF(value);
3683 : 0 : Py_XDECREF(result);
3684 : 0 : return NULL;
3685 : : }
3686 : :
3687 : : PyObject*
3688 : 9 : ast2obj_stmt(struct ast_state *state, void* _o)
3689 : : {
3690 : 9 : stmt_ty o = (stmt_ty)_o;
3691 : 9 : PyObject *result = NULL, *value = NULL;
3692 : : PyTypeObject *tp;
3693 [ - + ]: 9 : if (!o) {
3694 : 0 : Py_RETURN_NONE;
3695 : : }
3696 [ - + ]: 9 : if (++state->recursion_depth > state->recursion_limit) {
3697 : 0 : PyErr_SetString(PyExc_RecursionError,
3698 : : "maximum recursion depth exceeded during ast construction");
3699 : 0 : return 0;
3700 : : }
3701 [ - - - - : 9 : switch (o->kind) {
- - - - -
- - - - -
- - - - -
- - - - +
- - - - ]
3702 : 0 : case FunctionDef_kind:
3703 : 0 : tp = (PyTypeObject *)state->FunctionDef_type;
3704 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3705 [ # # ]: 0 : if (!result) goto failed;
3706 : 0 : value = ast2obj_identifier(state, o->v.FunctionDef.name);
3707 [ # # ]: 0 : if (!value) goto failed;
3708 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
3709 : 0 : goto failed;
3710 : 0 : Py_DECREF(value);
3711 : 0 : value = ast2obj_arguments(state, o->v.FunctionDef.args);
3712 [ # # ]: 0 : if (!value) goto failed;
3713 [ # # ]: 0 : if (PyObject_SetAttr(result, state->args, value) == -1)
3714 : 0 : goto failed;
3715 : 0 : Py_DECREF(value);
3716 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
3717 : : ast2obj_stmt);
3718 [ # # ]: 0 : if (!value) goto failed;
3719 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3720 : 0 : goto failed;
3721 : 0 : Py_DECREF(value);
3722 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
3723 : : ast2obj_expr);
3724 [ # # ]: 0 : if (!value) goto failed;
3725 [ # # ]: 0 : if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3726 : 0 : goto failed;
3727 : 0 : Py_DECREF(value);
3728 : 0 : value = ast2obj_expr(state, o->v.FunctionDef.returns);
3729 [ # # ]: 0 : if (!value) goto failed;
3730 [ # # ]: 0 : if (PyObject_SetAttr(result, state->returns, value) == -1)
3731 : 0 : goto failed;
3732 : 0 : Py_DECREF(value);
3733 : 0 : value = ast2obj_string(state, o->v.FunctionDef.type_comment);
3734 [ # # ]: 0 : if (!value) goto failed;
3735 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3736 : 0 : goto failed;
3737 : 0 : Py_DECREF(value);
3738 : 0 : break;
3739 : 0 : case AsyncFunctionDef_kind:
3740 : 0 : tp = (PyTypeObject *)state->AsyncFunctionDef_type;
3741 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3742 [ # # ]: 0 : if (!result) goto failed;
3743 : 0 : value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
3744 [ # # ]: 0 : if (!value) goto failed;
3745 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
3746 : 0 : goto failed;
3747 : 0 : Py_DECREF(value);
3748 : 0 : value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
3749 [ # # ]: 0 : if (!value) goto failed;
3750 [ # # ]: 0 : if (PyObject_SetAttr(result, state->args, value) == -1)
3751 : 0 : goto failed;
3752 : 0 : Py_DECREF(value);
3753 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
3754 : : ast2obj_stmt);
3755 [ # # ]: 0 : if (!value) goto failed;
3756 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3757 : 0 : goto failed;
3758 : 0 : Py_DECREF(value);
3759 : 0 : value = ast2obj_list(state,
3760 : 0 : (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
3761 : : ast2obj_expr);
3762 [ # # ]: 0 : if (!value) goto failed;
3763 [ # # ]: 0 : if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3764 : 0 : goto failed;
3765 : 0 : Py_DECREF(value);
3766 : 0 : value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
3767 [ # # ]: 0 : if (!value) goto failed;
3768 [ # # ]: 0 : if (PyObject_SetAttr(result, state->returns, value) == -1)
3769 : 0 : goto failed;
3770 : 0 : Py_DECREF(value);
3771 : 0 : value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
3772 [ # # ]: 0 : if (!value) goto failed;
3773 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3774 : 0 : goto failed;
3775 : 0 : Py_DECREF(value);
3776 : 0 : break;
3777 : 0 : case ClassDef_kind:
3778 : 0 : tp = (PyTypeObject *)state->ClassDef_type;
3779 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3780 [ # # ]: 0 : if (!result) goto failed;
3781 : 0 : value = ast2obj_identifier(state, o->v.ClassDef.name);
3782 [ # # ]: 0 : if (!value) goto failed;
3783 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
3784 : 0 : goto failed;
3785 : 0 : Py_DECREF(value);
3786 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
3787 : : ast2obj_expr);
3788 [ # # ]: 0 : if (!value) goto failed;
3789 [ # # ]: 0 : if (PyObject_SetAttr(result, state->bases, value) == -1)
3790 : 0 : goto failed;
3791 : 0 : Py_DECREF(value);
3792 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
3793 : : ast2obj_keyword);
3794 [ # # ]: 0 : if (!value) goto failed;
3795 [ # # ]: 0 : if (PyObject_SetAttr(result, state->keywords, value) == -1)
3796 : 0 : goto failed;
3797 : 0 : Py_DECREF(value);
3798 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
3799 : : ast2obj_stmt);
3800 [ # # ]: 0 : if (!value) goto failed;
3801 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3802 : 0 : goto failed;
3803 : 0 : Py_DECREF(value);
3804 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
3805 : : ast2obj_expr);
3806 [ # # ]: 0 : if (!value) goto failed;
3807 [ # # ]: 0 : if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3808 : 0 : goto failed;
3809 : 0 : Py_DECREF(value);
3810 : 0 : break;
3811 : 0 : case Return_kind:
3812 : 0 : tp = (PyTypeObject *)state->Return_type;
3813 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3814 [ # # ]: 0 : if (!result) goto failed;
3815 : 0 : value = ast2obj_expr(state, o->v.Return.value);
3816 [ # # ]: 0 : if (!value) goto failed;
3817 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
3818 : 0 : goto failed;
3819 : 0 : Py_DECREF(value);
3820 : 0 : break;
3821 : 0 : case Delete_kind:
3822 : 0 : tp = (PyTypeObject *)state->Delete_type;
3823 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3824 [ # # ]: 0 : if (!result) goto failed;
3825 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
3826 : : ast2obj_expr);
3827 [ # # ]: 0 : if (!value) goto failed;
3828 [ # # ]: 0 : if (PyObject_SetAttr(result, state->targets, value) == -1)
3829 : 0 : goto failed;
3830 : 0 : Py_DECREF(value);
3831 : 0 : break;
3832 : 0 : case Assign_kind:
3833 : 0 : tp = (PyTypeObject *)state->Assign_type;
3834 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3835 [ # # ]: 0 : if (!result) goto failed;
3836 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
3837 : : ast2obj_expr);
3838 [ # # ]: 0 : if (!value) goto failed;
3839 [ # # ]: 0 : if (PyObject_SetAttr(result, state->targets, value) == -1)
3840 : 0 : goto failed;
3841 : 0 : Py_DECREF(value);
3842 : 0 : value = ast2obj_expr(state, o->v.Assign.value);
3843 [ # # ]: 0 : if (!value) goto failed;
3844 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
3845 : 0 : goto failed;
3846 : 0 : Py_DECREF(value);
3847 : 0 : value = ast2obj_string(state, o->v.Assign.type_comment);
3848 [ # # ]: 0 : if (!value) goto failed;
3849 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3850 : 0 : goto failed;
3851 : 0 : Py_DECREF(value);
3852 : 0 : break;
3853 : 0 : case AugAssign_kind:
3854 : 0 : tp = (PyTypeObject *)state->AugAssign_type;
3855 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3856 [ # # ]: 0 : if (!result) goto failed;
3857 : 0 : value = ast2obj_expr(state, o->v.AugAssign.target);
3858 [ # # ]: 0 : if (!value) goto failed;
3859 [ # # ]: 0 : if (PyObject_SetAttr(result, state->target, value) == -1)
3860 : 0 : goto failed;
3861 : 0 : Py_DECREF(value);
3862 : 0 : value = ast2obj_operator(state, o->v.AugAssign.op);
3863 [ # # ]: 0 : if (!value) goto failed;
3864 [ # # ]: 0 : if (PyObject_SetAttr(result, state->op, value) == -1)
3865 : 0 : goto failed;
3866 : 0 : Py_DECREF(value);
3867 : 0 : value = ast2obj_expr(state, o->v.AugAssign.value);
3868 [ # # ]: 0 : if (!value) goto failed;
3869 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
3870 : 0 : goto failed;
3871 : 0 : Py_DECREF(value);
3872 : 0 : break;
3873 : 0 : case AnnAssign_kind:
3874 : 0 : tp = (PyTypeObject *)state->AnnAssign_type;
3875 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3876 [ # # ]: 0 : if (!result) goto failed;
3877 : 0 : value = ast2obj_expr(state, o->v.AnnAssign.target);
3878 [ # # ]: 0 : if (!value) goto failed;
3879 [ # # ]: 0 : if (PyObject_SetAttr(result, state->target, value) == -1)
3880 : 0 : goto failed;
3881 : 0 : Py_DECREF(value);
3882 : 0 : value = ast2obj_expr(state, o->v.AnnAssign.annotation);
3883 [ # # ]: 0 : if (!value) goto failed;
3884 [ # # ]: 0 : if (PyObject_SetAttr(result, state->annotation, value) == -1)
3885 : 0 : goto failed;
3886 : 0 : Py_DECREF(value);
3887 : 0 : value = ast2obj_expr(state, o->v.AnnAssign.value);
3888 [ # # ]: 0 : if (!value) goto failed;
3889 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
3890 : 0 : goto failed;
3891 : 0 : Py_DECREF(value);
3892 : 0 : value = ast2obj_int(state, o->v.AnnAssign.simple);
3893 [ # # ]: 0 : if (!value) goto failed;
3894 [ # # ]: 0 : if (PyObject_SetAttr(result, state->simple, value) == -1)
3895 : 0 : goto failed;
3896 : 0 : Py_DECREF(value);
3897 : 0 : break;
3898 : 0 : case For_kind:
3899 : 0 : tp = (PyTypeObject *)state->For_type;
3900 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3901 [ # # ]: 0 : if (!result) goto failed;
3902 : 0 : value = ast2obj_expr(state, o->v.For.target);
3903 [ # # ]: 0 : if (!value) goto failed;
3904 [ # # ]: 0 : if (PyObject_SetAttr(result, state->target, value) == -1)
3905 : 0 : goto failed;
3906 : 0 : Py_DECREF(value);
3907 : 0 : value = ast2obj_expr(state, o->v.For.iter);
3908 [ # # ]: 0 : if (!value) goto failed;
3909 [ # # ]: 0 : if (PyObject_SetAttr(result, state->iter, value) == -1)
3910 : 0 : goto failed;
3911 : 0 : Py_DECREF(value);
3912 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
3913 [ # # ]: 0 : if (!value) goto failed;
3914 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3915 : 0 : goto failed;
3916 : 0 : Py_DECREF(value);
3917 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
3918 [ # # ]: 0 : if (!value) goto failed;
3919 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3920 : 0 : goto failed;
3921 : 0 : Py_DECREF(value);
3922 : 0 : value = ast2obj_string(state, o->v.For.type_comment);
3923 [ # # ]: 0 : if (!value) goto failed;
3924 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3925 : 0 : goto failed;
3926 : 0 : Py_DECREF(value);
3927 : 0 : break;
3928 : 0 : case AsyncFor_kind:
3929 : 0 : tp = (PyTypeObject *)state->AsyncFor_type;
3930 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3931 [ # # ]: 0 : if (!result) goto failed;
3932 : 0 : value = ast2obj_expr(state, o->v.AsyncFor.target);
3933 [ # # ]: 0 : if (!value) goto failed;
3934 [ # # ]: 0 : if (PyObject_SetAttr(result, state->target, value) == -1)
3935 : 0 : goto failed;
3936 : 0 : Py_DECREF(value);
3937 : 0 : value = ast2obj_expr(state, o->v.AsyncFor.iter);
3938 [ # # ]: 0 : if (!value) goto failed;
3939 [ # # ]: 0 : if (PyObject_SetAttr(result, state->iter, value) == -1)
3940 : 0 : goto failed;
3941 : 0 : Py_DECREF(value);
3942 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
3943 : : ast2obj_stmt);
3944 [ # # ]: 0 : if (!value) goto failed;
3945 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3946 : 0 : goto failed;
3947 : 0 : Py_DECREF(value);
3948 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
3949 : : ast2obj_stmt);
3950 [ # # ]: 0 : if (!value) goto failed;
3951 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3952 : 0 : goto failed;
3953 : 0 : Py_DECREF(value);
3954 : 0 : value = ast2obj_string(state, o->v.AsyncFor.type_comment);
3955 [ # # ]: 0 : if (!value) goto failed;
3956 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3957 : 0 : goto failed;
3958 : 0 : Py_DECREF(value);
3959 : 0 : break;
3960 : 0 : case While_kind:
3961 : 0 : tp = (PyTypeObject *)state->While_type;
3962 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3963 [ # # ]: 0 : if (!result) goto failed;
3964 : 0 : value = ast2obj_expr(state, o->v.While.test);
3965 [ # # ]: 0 : if (!value) goto failed;
3966 [ # # ]: 0 : if (PyObject_SetAttr(result, state->test, value) == -1)
3967 : 0 : goto failed;
3968 : 0 : Py_DECREF(value);
3969 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
3970 [ # # ]: 0 : if (!value) goto failed;
3971 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3972 : 0 : goto failed;
3973 : 0 : Py_DECREF(value);
3974 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
3975 [ # # ]: 0 : if (!value) goto failed;
3976 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3977 : 0 : goto failed;
3978 : 0 : Py_DECREF(value);
3979 : 0 : break;
3980 : 0 : case If_kind:
3981 : 0 : tp = (PyTypeObject *)state->If_type;
3982 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
3983 [ # # ]: 0 : if (!result) goto failed;
3984 : 0 : value = ast2obj_expr(state, o->v.If.test);
3985 [ # # ]: 0 : if (!value) goto failed;
3986 [ # # ]: 0 : if (PyObject_SetAttr(result, state->test, value) == -1)
3987 : 0 : goto failed;
3988 : 0 : Py_DECREF(value);
3989 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
3990 [ # # ]: 0 : if (!value) goto failed;
3991 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
3992 : 0 : goto failed;
3993 : 0 : Py_DECREF(value);
3994 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
3995 [ # # ]: 0 : if (!value) goto failed;
3996 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
3997 : 0 : goto failed;
3998 : 0 : Py_DECREF(value);
3999 : 0 : break;
4000 : 0 : case With_kind:
4001 : 0 : tp = (PyTypeObject *)state->With_type;
4002 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4003 [ # # ]: 0 : if (!result) goto failed;
4004 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
4005 : : ast2obj_withitem);
4006 [ # # ]: 0 : if (!value) goto failed;
4007 [ # # ]: 0 : if (PyObject_SetAttr(result, state->items, value) == -1)
4008 : 0 : goto failed;
4009 : 0 : Py_DECREF(value);
4010 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
4011 [ # # ]: 0 : if (!value) goto failed;
4012 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4013 : 0 : goto failed;
4014 : 0 : Py_DECREF(value);
4015 : 0 : value = ast2obj_string(state, o->v.With.type_comment);
4016 [ # # ]: 0 : if (!value) goto failed;
4017 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4018 : 0 : goto failed;
4019 : 0 : Py_DECREF(value);
4020 : 0 : break;
4021 : 0 : case AsyncWith_kind:
4022 : 0 : tp = (PyTypeObject *)state->AsyncWith_type;
4023 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4024 [ # # ]: 0 : if (!result) goto failed;
4025 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
4026 : : ast2obj_withitem);
4027 [ # # ]: 0 : if (!value) goto failed;
4028 [ # # ]: 0 : if (PyObject_SetAttr(result, state->items, value) == -1)
4029 : 0 : goto failed;
4030 : 0 : Py_DECREF(value);
4031 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
4032 : : ast2obj_stmt);
4033 [ # # ]: 0 : if (!value) goto failed;
4034 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4035 : 0 : goto failed;
4036 : 0 : Py_DECREF(value);
4037 : 0 : value = ast2obj_string(state, o->v.AsyncWith.type_comment);
4038 [ # # ]: 0 : if (!value) goto failed;
4039 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4040 : 0 : goto failed;
4041 : 0 : Py_DECREF(value);
4042 : 0 : break;
4043 : 0 : case Match_kind:
4044 : 0 : tp = (PyTypeObject *)state->Match_type;
4045 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4046 [ # # ]: 0 : if (!result) goto failed;
4047 : 0 : value = ast2obj_expr(state, o->v.Match.subject);
4048 [ # # ]: 0 : if (!value) goto failed;
4049 [ # # ]: 0 : if (PyObject_SetAttr(result, state->subject, value) == -1)
4050 : 0 : goto failed;
4051 : 0 : Py_DECREF(value);
4052 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
4053 : : ast2obj_match_case);
4054 [ # # ]: 0 : if (!value) goto failed;
4055 [ # # ]: 0 : if (PyObject_SetAttr(result, state->cases, value) == -1)
4056 : 0 : goto failed;
4057 : 0 : Py_DECREF(value);
4058 : 0 : break;
4059 : 0 : case Raise_kind:
4060 : 0 : tp = (PyTypeObject *)state->Raise_type;
4061 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4062 [ # # ]: 0 : if (!result) goto failed;
4063 : 0 : value = ast2obj_expr(state, o->v.Raise.exc);
4064 [ # # ]: 0 : if (!value) goto failed;
4065 [ # # ]: 0 : if (PyObject_SetAttr(result, state->exc, value) == -1)
4066 : 0 : goto failed;
4067 : 0 : Py_DECREF(value);
4068 : 0 : value = ast2obj_expr(state, o->v.Raise.cause);
4069 [ # # ]: 0 : if (!value) goto failed;
4070 [ # # ]: 0 : if (PyObject_SetAttr(result, state->cause, value) == -1)
4071 : 0 : goto failed;
4072 : 0 : Py_DECREF(value);
4073 : 0 : break;
4074 : 0 : case Try_kind:
4075 : 0 : tp = (PyTypeObject *)state->Try_type;
4076 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4077 [ # # ]: 0 : if (!result) goto failed;
4078 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
4079 [ # # ]: 0 : if (!value) goto failed;
4080 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4081 : 0 : goto failed;
4082 : 0 : Py_DECREF(value);
4083 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
4084 : : ast2obj_excepthandler);
4085 [ # # ]: 0 : if (!value) goto failed;
4086 [ # # ]: 0 : if (PyObject_SetAttr(result, state->handlers, value) == -1)
4087 : 0 : goto failed;
4088 : 0 : Py_DECREF(value);
4089 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
4090 [ # # ]: 0 : if (!value) goto failed;
4091 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
4092 : 0 : goto failed;
4093 : 0 : Py_DECREF(value);
4094 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
4095 : : ast2obj_stmt);
4096 [ # # ]: 0 : if (!value) goto failed;
4097 [ # # ]: 0 : if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4098 : 0 : goto failed;
4099 : 0 : Py_DECREF(value);
4100 : 0 : break;
4101 : 0 : case TryStar_kind:
4102 : 0 : tp = (PyTypeObject *)state->TryStar_type;
4103 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4104 [ # # ]: 0 : if (!result) goto failed;
4105 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
4106 [ # # ]: 0 : if (!value) goto failed;
4107 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4108 : 0 : goto failed;
4109 : 0 : Py_DECREF(value);
4110 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
4111 : : ast2obj_excepthandler);
4112 [ # # ]: 0 : if (!value) goto failed;
4113 [ # # ]: 0 : if (PyObject_SetAttr(result, state->handlers, value) == -1)
4114 : 0 : goto failed;
4115 : 0 : Py_DECREF(value);
4116 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
4117 : : ast2obj_stmt);
4118 [ # # ]: 0 : if (!value) goto failed;
4119 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
4120 : 0 : goto failed;
4121 : 0 : Py_DECREF(value);
4122 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
4123 : : ast2obj_stmt);
4124 [ # # ]: 0 : if (!value) goto failed;
4125 [ # # ]: 0 : if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4126 : 0 : goto failed;
4127 : 0 : Py_DECREF(value);
4128 : 0 : break;
4129 : 0 : case Assert_kind:
4130 : 0 : tp = (PyTypeObject *)state->Assert_type;
4131 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4132 [ # # ]: 0 : if (!result) goto failed;
4133 : 0 : value = ast2obj_expr(state, o->v.Assert.test);
4134 [ # # ]: 0 : if (!value) goto failed;
4135 [ # # ]: 0 : if (PyObject_SetAttr(result, state->test, value) == -1)
4136 : 0 : goto failed;
4137 : 0 : Py_DECREF(value);
4138 : 0 : value = ast2obj_expr(state, o->v.Assert.msg);
4139 [ # # ]: 0 : if (!value) goto failed;
4140 [ # # ]: 0 : if (PyObject_SetAttr(result, state->msg, value) == -1)
4141 : 0 : goto failed;
4142 : 0 : Py_DECREF(value);
4143 : 0 : break;
4144 : 0 : case Import_kind:
4145 : 0 : tp = (PyTypeObject *)state->Import_type;
4146 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4147 [ # # ]: 0 : if (!result) goto failed;
4148 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
4149 : : ast2obj_alias);
4150 [ # # ]: 0 : if (!value) goto failed;
4151 [ # # ]: 0 : if (PyObject_SetAttr(result, state->names, value) == -1)
4152 : 0 : goto failed;
4153 : 0 : Py_DECREF(value);
4154 : 0 : break;
4155 : 0 : case ImportFrom_kind:
4156 : 0 : tp = (PyTypeObject *)state->ImportFrom_type;
4157 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4158 [ # # ]: 0 : if (!result) goto failed;
4159 : 0 : value = ast2obj_identifier(state, o->v.ImportFrom.module);
4160 [ # # ]: 0 : if (!value) goto failed;
4161 [ # # ]: 0 : if (PyObject_SetAttr(result, state->module, value) == -1)
4162 : 0 : goto failed;
4163 : 0 : Py_DECREF(value);
4164 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
4165 : : ast2obj_alias);
4166 [ # # ]: 0 : if (!value) goto failed;
4167 [ # # ]: 0 : if (PyObject_SetAttr(result, state->names, value) == -1)
4168 : 0 : goto failed;
4169 : 0 : Py_DECREF(value);
4170 : 0 : value = ast2obj_int(state, o->v.ImportFrom.level);
4171 [ # # ]: 0 : if (!value) goto failed;
4172 [ # # ]: 0 : if (PyObject_SetAttr(result, state->level, value) == -1)
4173 : 0 : goto failed;
4174 : 0 : Py_DECREF(value);
4175 : 0 : break;
4176 : 0 : case Global_kind:
4177 : 0 : tp = (PyTypeObject *)state->Global_type;
4178 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4179 [ # # ]: 0 : if (!result) goto failed;
4180 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
4181 : : ast2obj_identifier);
4182 [ # # ]: 0 : if (!value) goto failed;
4183 [ # # ]: 0 : if (PyObject_SetAttr(result, state->names, value) == -1)
4184 : 0 : goto failed;
4185 : 0 : Py_DECREF(value);
4186 : 0 : break;
4187 : 0 : case Nonlocal_kind:
4188 : 0 : tp = (PyTypeObject *)state->Nonlocal_type;
4189 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4190 [ # # ]: 0 : if (!result) goto failed;
4191 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
4192 : : ast2obj_identifier);
4193 [ # # ]: 0 : if (!value) goto failed;
4194 [ # # ]: 0 : if (PyObject_SetAttr(result, state->names, value) == -1)
4195 : 0 : goto failed;
4196 : 0 : Py_DECREF(value);
4197 : 0 : break;
4198 : 9 : case Expr_kind:
4199 : 9 : tp = (PyTypeObject *)state->Expr_type;
4200 : 9 : result = PyType_GenericNew(tp, NULL, NULL);
4201 [ - + ]: 9 : if (!result) goto failed;
4202 : 9 : value = ast2obj_expr(state, o->v.Expr.value);
4203 [ - + ]: 9 : if (!value) goto failed;
4204 [ - + ]: 9 : if (PyObject_SetAttr(result, state->value, value) == -1)
4205 : 0 : goto failed;
4206 : 9 : Py_DECREF(value);
4207 : 9 : break;
4208 : 0 : case Pass_kind:
4209 : 0 : tp = (PyTypeObject *)state->Pass_type;
4210 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4211 [ # # ]: 0 : if (!result) goto failed;
4212 : 0 : break;
4213 : 0 : case Break_kind:
4214 : 0 : tp = (PyTypeObject *)state->Break_type;
4215 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4216 [ # # ]: 0 : if (!result) goto failed;
4217 : 0 : break;
4218 : 0 : case Continue_kind:
4219 : 0 : tp = (PyTypeObject *)state->Continue_type;
4220 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4221 [ # # ]: 0 : if (!result) goto failed;
4222 : 0 : break;
4223 : : }
4224 : 9 : value = ast2obj_int(state, o->lineno);
4225 [ - + ]: 9 : if (!value) goto failed;
4226 [ - + ]: 9 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
4227 : 0 : goto failed;
4228 : 9 : Py_DECREF(value);
4229 : 9 : value = ast2obj_int(state, o->col_offset);
4230 [ - + ]: 9 : if (!value) goto failed;
4231 [ - + ]: 9 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4232 : 0 : goto failed;
4233 : 9 : Py_DECREF(value);
4234 : 9 : value = ast2obj_int(state, o->end_lineno);
4235 [ - + ]: 9 : if (!value) goto failed;
4236 [ - + ]: 9 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4237 : 0 : goto failed;
4238 : 9 : Py_DECREF(value);
4239 : 9 : value = ast2obj_int(state, o->end_col_offset);
4240 [ - + ]: 9 : if (!value) goto failed;
4241 [ - + ]: 9 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4242 : 0 : goto failed;
4243 : 9 : Py_DECREF(value);
4244 : 9 : state->recursion_depth--;
4245 : 9 : return result;
4246 : 0 : failed:
4247 : 0 : Py_XDECREF(value);
4248 : 0 : Py_XDECREF(result);
4249 : 0 : return NULL;
4250 : : }
4251 : :
4252 : : PyObject*
4253 : 406270 : ast2obj_expr(struct ast_state *state, void* _o)
4254 : : {
4255 : 406270 : expr_ty o = (expr_ty)_o;
4256 : 406270 : PyObject *result = NULL, *value = NULL;
4257 : : PyTypeObject *tp;
4258 [ - + ]: 406270 : if (!o) {
4259 : 0 : Py_RETURN_NONE;
4260 : : }
4261 [ - + ]: 406270 : if (++state->recursion_depth > state->recursion_limit) {
4262 : 0 : PyErr_SetString(PyExc_RecursionError,
4263 : : "maximum recursion depth exceeded during ast construction");
4264 : 0 : return 0;
4265 : : }
4266 [ - - + + : 406270 : switch (o->kind) {
- - - - -
- - - - -
- - + - -
+ - - - +
- + - - ]
4267 : 0 : case BoolOp_kind:
4268 : 0 : tp = (PyTypeObject *)state->BoolOp_type;
4269 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4270 [ # # ]: 0 : if (!result) goto failed;
4271 : 0 : value = ast2obj_boolop(state, o->v.BoolOp.op);
4272 [ # # ]: 0 : if (!value) goto failed;
4273 [ # # ]: 0 : if (PyObject_SetAttr(result, state->op, value) == -1)
4274 : 0 : goto failed;
4275 : 0 : Py_DECREF(value);
4276 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
4277 : : ast2obj_expr);
4278 [ # # ]: 0 : if (!value) goto failed;
4279 [ # # ]: 0 : if (PyObject_SetAttr(result, state->values, value) == -1)
4280 : 0 : goto failed;
4281 : 0 : Py_DECREF(value);
4282 : 0 : break;
4283 : 0 : case NamedExpr_kind:
4284 : 0 : tp = (PyTypeObject *)state->NamedExpr_type;
4285 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4286 [ # # ]: 0 : if (!result) goto failed;
4287 : 0 : value = ast2obj_expr(state, o->v.NamedExpr.target);
4288 [ # # ]: 0 : if (!value) goto failed;
4289 [ # # ]: 0 : if (PyObject_SetAttr(result, state->target, value) == -1)
4290 : 0 : goto failed;
4291 : 0 : Py_DECREF(value);
4292 : 0 : value = ast2obj_expr(state, o->v.NamedExpr.value);
4293 [ # # ]: 0 : if (!value) goto failed;
4294 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4295 : 0 : goto failed;
4296 : 0 : Py_DECREF(value);
4297 : 0 : break;
4298 : 1 : case BinOp_kind:
4299 : 1 : tp = (PyTypeObject *)state->BinOp_type;
4300 : 1 : result = PyType_GenericNew(tp, NULL, NULL);
4301 [ - + ]: 1 : if (!result) goto failed;
4302 : 1 : value = ast2obj_expr(state, o->v.BinOp.left);
4303 [ - + ]: 1 : if (!value) goto failed;
4304 [ - + ]: 1 : if (PyObject_SetAttr(result, state->left, value) == -1)
4305 : 0 : goto failed;
4306 : 1 : Py_DECREF(value);
4307 : 1 : value = ast2obj_operator(state, o->v.BinOp.op);
4308 [ - + ]: 1 : if (!value) goto failed;
4309 [ - + ]: 1 : if (PyObject_SetAttr(result, state->op, value) == -1)
4310 : 0 : goto failed;
4311 : 1 : Py_DECREF(value);
4312 : 1 : value = ast2obj_expr(state, o->v.BinOp.right);
4313 [ - + ]: 1 : if (!value) goto failed;
4314 [ - + ]: 1 : if (PyObject_SetAttr(result, state->right, value) == -1)
4315 : 0 : goto failed;
4316 : 1 : Py_DECREF(value);
4317 : 1 : break;
4318 : 1 : case UnaryOp_kind:
4319 : 1 : tp = (PyTypeObject *)state->UnaryOp_type;
4320 : 1 : result = PyType_GenericNew(tp, NULL, NULL);
4321 [ - + ]: 1 : if (!result) goto failed;
4322 : 1 : value = ast2obj_unaryop(state, o->v.UnaryOp.op);
4323 [ - + ]: 1 : if (!value) goto failed;
4324 [ - + ]: 1 : if (PyObject_SetAttr(result, state->op, value) == -1)
4325 : 0 : goto failed;
4326 : 1 : Py_DECREF(value);
4327 : 1 : value = ast2obj_expr(state, o->v.UnaryOp.operand);
4328 [ - + ]: 1 : if (!value) goto failed;
4329 [ - + ]: 1 : if (PyObject_SetAttr(result, state->operand, value) == -1)
4330 : 0 : goto failed;
4331 : 1 : Py_DECREF(value);
4332 : 1 : break;
4333 : 0 : case Lambda_kind:
4334 : 0 : tp = (PyTypeObject *)state->Lambda_type;
4335 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4336 [ # # ]: 0 : if (!result) goto failed;
4337 : 0 : value = ast2obj_arguments(state, o->v.Lambda.args);
4338 [ # # ]: 0 : if (!value) goto failed;
4339 [ # # ]: 0 : if (PyObject_SetAttr(result, state->args, value) == -1)
4340 : 0 : goto failed;
4341 : 0 : Py_DECREF(value);
4342 : 0 : value = ast2obj_expr(state, o->v.Lambda.body);
4343 [ # # ]: 0 : if (!value) goto failed;
4344 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4345 : 0 : goto failed;
4346 : 0 : Py_DECREF(value);
4347 : 0 : break;
4348 : 0 : case IfExp_kind:
4349 : 0 : tp = (PyTypeObject *)state->IfExp_type;
4350 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4351 [ # # ]: 0 : if (!result) goto failed;
4352 : 0 : value = ast2obj_expr(state, o->v.IfExp.test);
4353 [ # # ]: 0 : if (!value) goto failed;
4354 [ # # ]: 0 : if (PyObject_SetAttr(result, state->test, value) == -1)
4355 : 0 : goto failed;
4356 : 0 : Py_DECREF(value);
4357 : 0 : value = ast2obj_expr(state, o->v.IfExp.body);
4358 [ # # ]: 0 : if (!value) goto failed;
4359 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4360 : 0 : goto failed;
4361 : 0 : Py_DECREF(value);
4362 : 0 : value = ast2obj_expr(state, o->v.IfExp.orelse);
4363 [ # # ]: 0 : if (!value) goto failed;
4364 [ # # ]: 0 : if (PyObject_SetAttr(result, state->orelse, value) == -1)
4365 : 0 : goto failed;
4366 : 0 : Py_DECREF(value);
4367 : 0 : break;
4368 : 0 : case Dict_kind:
4369 : 0 : tp = (PyTypeObject *)state->Dict_type;
4370 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4371 [ # # ]: 0 : if (!result) goto failed;
4372 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
4373 [ # # ]: 0 : if (!value) goto failed;
4374 [ # # ]: 0 : if (PyObject_SetAttr(result, state->keys, value) == -1)
4375 : 0 : goto failed;
4376 : 0 : Py_DECREF(value);
4377 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
4378 [ # # ]: 0 : if (!value) goto failed;
4379 [ # # ]: 0 : if (PyObject_SetAttr(result, state->values, value) == -1)
4380 : 0 : goto failed;
4381 : 0 : Py_DECREF(value);
4382 : 0 : break;
4383 : 0 : case Set_kind:
4384 : 0 : tp = (PyTypeObject *)state->Set_type;
4385 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4386 [ # # ]: 0 : if (!result) goto failed;
4387 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
4388 [ # # ]: 0 : if (!value) goto failed;
4389 [ # # ]: 0 : if (PyObject_SetAttr(result, state->elts, value) == -1)
4390 : 0 : goto failed;
4391 : 0 : Py_DECREF(value);
4392 : 0 : break;
4393 : 0 : case ListComp_kind:
4394 : 0 : tp = (PyTypeObject *)state->ListComp_type;
4395 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4396 [ # # ]: 0 : if (!result) goto failed;
4397 : 0 : value = ast2obj_expr(state, o->v.ListComp.elt);
4398 [ # # ]: 0 : if (!value) goto failed;
4399 [ # # ]: 0 : if (PyObject_SetAttr(result, state->elt, value) == -1)
4400 : 0 : goto failed;
4401 : 0 : Py_DECREF(value);
4402 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
4403 : : ast2obj_comprehension);
4404 [ # # ]: 0 : if (!value) goto failed;
4405 [ # # ]: 0 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4406 : 0 : goto failed;
4407 : 0 : Py_DECREF(value);
4408 : 0 : break;
4409 : 0 : case SetComp_kind:
4410 : 0 : tp = (PyTypeObject *)state->SetComp_type;
4411 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4412 [ # # ]: 0 : if (!result) goto failed;
4413 : 0 : value = ast2obj_expr(state, o->v.SetComp.elt);
4414 [ # # ]: 0 : if (!value) goto failed;
4415 [ # # ]: 0 : if (PyObject_SetAttr(result, state->elt, value) == -1)
4416 : 0 : goto failed;
4417 : 0 : Py_DECREF(value);
4418 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
4419 : : ast2obj_comprehension);
4420 [ # # ]: 0 : if (!value) goto failed;
4421 [ # # ]: 0 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4422 : 0 : goto failed;
4423 : 0 : Py_DECREF(value);
4424 : 0 : break;
4425 : 0 : case DictComp_kind:
4426 : 0 : tp = (PyTypeObject *)state->DictComp_type;
4427 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4428 [ # # ]: 0 : if (!result) goto failed;
4429 : 0 : value = ast2obj_expr(state, o->v.DictComp.key);
4430 [ # # ]: 0 : if (!value) goto failed;
4431 [ # # ]: 0 : if (PyObject_SetAttr(result, state->key, value) == -1)
4432 : 0 : goto failed;
4433 : 0 : Py_DECREF(value);
4434 : 0 : value = ast2obj_expr(state, o->v.DictComp.value);
4435 [ # # ]: 0 : if (!value) goto failed;
4436 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4437 : 0 : goto failed;
4438 : 0 : Py_DECREF(value);
4439 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
4440 : : ast2obj_comprehension);
4441 [ # # ]: 0 : if (!value) goto failed;
4442 [ # # ]: 0 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4443 : 0 : goto failed;
4444 : 0 : Py_DECREF(value);
4445 : 0 : break;
4446 : 0 : case GeneratorExp_kind:
4447 : 0 : tp = (PyTypeObject *)state->GeneratorExp_type;
4448 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4449 [ # # ]: 0 : if (!result) goto failed;
4450 : 0 : value = ast2obj_expr(state, o->v.GeneratorExp.elt);
4451 [ # # ]: 0 : if (!value) goto failed;
4452 [ # # ]: 0 : if (PyObject_SetAttr(result, state->elt, value) == -1)
4453 : 0 : goto failed;
4454 : 0 : Py_DECREF(value);
4455 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
4456 : : ast2obj_comprehension);
4457 [ # # ]: 0 : if (!value) goto failed;
4458 [ # # ]: 0 : if (PyObject_SetAttr(result, state->generators, value) == -1)
4459 : 0 : goto failed;
4460 : 0 : Py_DECREF(value);
4461 : 0 : break;
4462 : 0 : case Await_kind:
4463 : 0 : tp = (PyTypeObject *)state->Await_type;
4464 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4465 [ # # ]: 0 : if (!result) goto failed;
4466 : 0 : value = ast2obj_expr(state, o->v.Await.value);
4467 [ # # ]: 0 : if (!value) goto failed;
4468 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4469 : 0 : goto failed;
4470 : 0 : Py_DECREF(value);
4471 : 0 : break;
4472 : 0 : case Yield_kind:
4473 : 0 : tp = (PyTypeObject *)state->Yield_type;
4474 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4475 [ # # ]: 0 : if (!result) goto failed;
4476 : 0 : value = ast2obj_expr(state, o->v.Yield.value);
4477 [ # # ]: 0 : if (!value) goto failed;
4478 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4479 : 0 : goto failed;
4480 : 0 : Py_DECREF(value);
4481 : 0 : break;
4482 : 0 : case YieldFrom_kind:
4483 : 0 : tp = (PyTypeObject *)state->YieldFrom_type;
4484 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4485 [ # # ]: 0 : if (!result) goto failed;
4486 : 0 : value = ast2obj_expr(state, o->v.YieldFrom.value);
4487 [ # # ]: 0 : if (!value) goto failed;
4488 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4489 : 0 : goto failed;
4490 : 0 : Py_DECREF(value);
4491 : 0 : break;
4492 : 0 : case Compare_kind:
4493 : 0 : tp = (PyTypeObject *)state->Compare_type;
4494 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4495 [ # # ]: 0 : if (!result) goto failed;
4496 : 0 : value = ast2obj_expr(state, o->v.Compare.left);
4497 [ # # ]: 0 : if (!value) goto failed;
4498 [ # # ]: 0 : if (PyObject_SetAttr(result, state->left, value) == -1)
4499 : 0 : goto failed;
4500 : 0 : Py_DECREF(value);
4501 : : {
4502 [ # # ]: 0 : Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
4503 : 0 : value = PyList_New(n);
4504 [ # # ]: 0 : if (!value) goto failed;
4505 [ # # ]: 0 : for(i = 0; i < n; i++)
4506 : 0 : PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
4507 : : }
4508 [ # # ]: 0 : if (!value) goto failed;
4509 [ # # ]: 0 : if (PyObject_SetAttr(result, state->ops, value) == -1)
4510 : 0 : goto failed;
4511 : 0 : Py_DECREF(value);
4512 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
4513 : : ast2obj_expr);
4514 [ # # ]: 0 : if (!value) goto failed;
4515 [ # # ]: 0 : if (PyObject_SetAttr(result, state->comparators, value) == -1)
4516 : 0 : goto failed;
4517 : 0 : Py_DECREF(value);
4518 : 0 : break;
4519 : 8 : case Call_kind:
4520 : 8 : tp = (PyTypeObject *)state->Call_type;
4521 : 8 : result = PyType_GenericNew(tp, NULL, NULL);
4522 [ - + ]: 8 : if (!result) goto failed;
4523 : 8 : value = ast2obj_expr(state, o->v.Call.func);
4524 [ - + ]: 8 : if (!value) goto failed;
4525 [ - + ]: 8 : if (PyObject_SetAttr(result, state->func, value) == -1)
4526 : 0 : goto failed;
4527 : 8 : Py_DECREF(value);
4528 : 8 : value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
4529 [ - + ]: 8 : if (!value) goto failed;
4530 [ - + ]: 8 : if (PyObject_SetAttr(result, state->args, value) == -1)
4531 : 0 : goto failed;
4532 : 8 : Py_DECREF(value);
4533 : 8 : value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
4534 : : ast2obj_keyword);
4535 [ - + ]: 8 : if (!value) goto failed;
4536 [ - + ]: 8 : if (PyObject_SetAttr(result, state->keywords, value) == -1)
4537 : 0 : goto failed;
4538 : 8 : Py_DECREF(value);
4539 : 8 : break;
4540 : 0 : case FormattedValue_kind:
4541 : 0 : tp = (PyTypeObject *)state->FormattedValue_type;
4542 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4543 [ # # ]: 0 : if (!result) goto failed;
4544 : 0 : value = ast2obj_expr(state, o->v.FormattedValue.value);
4545 [ # # ]: 0 : if (!value) goto failed;
4546 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4547 : 0 : goto failed;
4548 : 0 : Py_DECREF(value);
4549 : 0 : value = ast2obj_int(state, o->v.FormattedValue.conversion);
4550 [ # # ]: 0 : if (!value) goto failed;
4551 [ # # ]: 0 : if (PyObject_SetAttr(result, state->conversion, value) == -1)
4552 : 0 : goto failed;
4553 : 0 : Py_DECREF(value);
4554 : 0 : value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
4555 [ # # ]: 0 : if (!value) goto failed;
4556 [ # # ]: 0 : if (PyObject_SetAttr(result, state->format_spec, value) == -1)
4557 : 0 : goto failed;
4558 : 0 : Py_DECREF(value);
4559 : 0 : break;
4560 : 0 : case JoinedStr_kind:
4561 : 0 : tp = (PyTypeObject *)state->JoinedStr_type;
4562 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4563 [ # # ]: 0 : if (!result) goto failed;
4564 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
4565 : : ast2obj_expr);
4566 [ # # ]: 0 : if (!value) goto failed;
4567 [ # # ]: 0 : if (PyObject_SetAttr(result, state->values, value) == -1)
4568 : 0 : goto failed;
4569 : 0 : Py_DECREF(value);
4570 : 0 : break;
4571 : 406221 : case Constant_kind:
4572 : 406221 : tp = (PyTypeObject *)state->Constant_type;
4573 : 406221 : result = PyType_GenericNew(tp, NULL, NULL);
4574 [ - + ]: 406221 : if (!result) goto failed;
4575 : 406221 : value = ast2obj_constant(state, o->v.Constant.value);
4576 [ - + ]: 406221 : if (!value) goto failed;
4577 [ - + ]: 406221 : if (PyObject_SetAttr(result, state->value, value) == -1)
4578 : 0 : goto failed;
4579 : 406221 : Py_DECREF(value);
4580 : 406221 : value = ast2obj_string(state, o->v.Constant.kind);
4581 [ - + ]: 406221 : if (!value) goto failed;
4582 [ - + ]: 406221 : if (PyObject_SetAttr(result, state->kind, value) == -1)
4583 : 0 : goto failed;
4584 : 406221 : Py_DECREF(value);
4585 : 406221 : break;
4586 : 0 : case Attribute_kind:
4587 : 0 : tp = (PyTypeObject *)state->Attribute_type;
4588 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4589 [ # # ]: 0 : if (!result) goto failed;
4590 : 0 : value = ast2obj_expr(state, o->v.Attribute.value);
4591 [ # # ]: 0 : if (!value) goto failed;
4592 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4593 : 0 : goto failed;
4594 : 0 : Py_DECREF(value);
4595 : 0 : value = ast2obj_identifier(state, o->v.Attribute.attr);
4596 [ # # ]: 0 : if (!value) goto failed;
4597 [ # # ]: 0 : if (PyObject_SetAttr(result, state->attr, value) == -1)
4598 : 0 : goto failed;
4599 : 0 : Py_DECREF(value);
4600 : 0 : value = ast2obj_expr_context(state, o->v.Attribute.ctx);
4601 [ # # ]: 0 : if (!value) goto failed;
4602 [ # # ]: 0 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4603 : 0 : goto failed;
4604 : 0 : Py_DECREF(value);
4605 : 0 : break;
4606 : 0 : case Subscript_kind:
4607 : 0 : tp = (PyTypeObject *)state->Subscript_type;
4608 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4609 [ # # ]: 0 : if (!result) goto failed;
4610 : 0 : value = ast2obj_expr(state, o->v.Subscript.value);
4611 [ # # ]: 0 : if (!value) goto failed;
4612 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4613 : 0 : goto failed;
4614 : 0 : Py_DECREF(value);
4615 : 0 : value = ast2obj_expr(state, o->v.Subscript.slice);
4616 [ # # ]: 0 : if (!value) goto failed;
4617 [ # # ]: 0 : if (PyObject_SetAttr(result, state->slice, value) == -1)
4618 : 0 : goto failed;
4619 : 0 : Py_DECREF(value);
4620 : 0 : value = ast2obj_expr_context(state, o->v.Subscript.ctx);
4621 [ # # ]: 0 : if (!value) goto failed;
4622 [ # # ]: 0 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4623 : 0 : goto failed;
4624 : 0 : Py_DECREF(value);
4625 : 0 : break;
4626 : 0 : case Starred_kind:
4627 : 0 : tp = (PyTypeObject *)state->Starred_type;
4628 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4629 [ # # ]: 0 : if (!result) goto failed;
4630 : 0 : value = ast2obj_expr(state, o->v.Starred.value);
4631 [ # # ]: 0 : if (!value) goto failed;
4632 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
4633 : 0 : goto failed;
4634 : 0 : Py_DECREF(value);
4635 : 0 : value = ast2obj_expr_context(state, o->v.Starred.ctx);
4636 [ # # ]: 0 : if (!value) goto failed;
4637 [ # # ]: 0 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4638 : 0 : goto failed;
4639 : 0 : Py_DECREF(value);
4640 : 0 : break;
4641 : 16 : case Name_kind:
4642 : 16 : tp = (PyTypeObject *)state->Name_type;
4643 : 16 : result = PyType_GenericNew(tp, NULL, NULL);
4644 [ - + ]: 16 : if (!result) goto failed;
4645 : 16 : value = ast2obj_identifier(state, o->v.Name.id);
4646 [ - + ]: 16 : if (!value) goto failed;
4647 [ - + ]: 16 : if (PyObject_SetAttr(result, state->id, value) == -1)
4648 : 0 : goto failed;
4649 : 16 : Py_DECREF(value);
4650 : 16 : value = ast2obj_expr_context(state, o->v.Name.ctx);
4651 [ - + ]: 16 : if (!value) goto failed;
4652 [ - + ]: 16 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4653 : 0 : goto failed;
4654 : 16 : Py_DECREF(value);
4655 : 16 : break;
4656 : 0 : case List_kind:
4657 : 0 : tp = (PyTypeObject *)state->List_type;
4658 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4659 [ # # ]: 0 : if (!result) goto failed;
4660 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
4661 [ # # ]: 0 : if (!value) goto failed;
4662 [ # # ]: 0 : if (PyObject_SetAttr(result, state->elts, value) == -1)
4663 : 0 : goto failed;
4664 : 0 : Py_DECREF(value);
4665 : 0 : value = ast2obj_expr_context(state, o->v.List.ctx);
4666 [ # # ]: 0 : if (!value) goto failed;
4667 [ # # ]: 0 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4668 : 0 : goto failed;
4669 : 0 : Py_DECREF(value);
4670 : 0 : break;
4671 : 23 : case Tuple_kind:
4672 : 23 : tp = (PyTypeObject *)state->Tuple_type;
4673 : 23 : result = PyType_GenericNew(tp, NULL, NULL);
4674 [ - + ]: 23 : if (!result) goto failed;
4675 : 23 : value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
4676 [ - + ]: 23 : if (!value) goto failed;
4677 [ - + ]: 23 : if (PyObject_SetAttr(result, state->elts, value) == -1)
4678 : 0 : goto failed;
4679 : 23 : Py_DECREF(value);
4680 : 23 : value = ast2obj_expr_context(state, o->v.Tuple.ctx);
4681 [ - + ]: 23 : if (!value) goto failed;
4682 [ - + ]: 23 : if (PyObject_SetAttr(result, state->ctx, value) == -1)
4683 : 0 : goto failed;
4684 : 23 : Py_DECREF(value);
4685 : 23 : break;
4686 : 0 : case Slice_kind:
4687 : 0 : tp = (PyTypeObject *)state->Slice_type;
4688 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4689 [ # # ]: 0 : if (!result) goto failed;
4690 : 0 : value = ast2obj_expr(state, o->v.Slice.lower);
4691 [ # # ]: 0 : if (!value) goto failed;
4692 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lower, value) == -1)
4693 : 0 : goto failed;
4694 : 0 : Py_DECREF(value);
4695 : 0 : value = ast2obj_expr(state, o->v.Slice.upper);
4696 [ # # ]: 0 : if (!value) goto failed;
4697 [ # # ]: 0 : if (PyObject_SetAttr(result, state->upper, value) == -1)
4698 : 0 : goto failed;
4699 : 0 : Py_DECREF(value);
4700 : 0 : value = ast2obj_expr(state, o->v.Slice.step);
4701 [ # # ]: 0 : if (!value) goto failed;
4702 [ # # ]: 0 : if (PyObject_SetAttr(result, state->step, value) == -1)
4703 : 0 : goto failed;
4704 : 0 : Py_DECREF(value);
4705 : 0 : break;
4706 : : }
4707 : 406270 : value = ast2obj_int(state, o->lineno);
4708 [ - + ]: 406270 : if (!value) goto failed;
4709 [ - + ]: 406270 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
4710 : 0 : goto failed;
4711 : 406270 : Py_DECREF(value);
4712 : 406270 : value = ast2obj_int(state, o->col_offset);
4713 [ - + ]: 406270 : if (!value) goto failed;
4714 [ - + ]: 406270 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4715 : 0 : goto failed;
4716 : 406270 : Py_DECREF(value);
4717 : 406270 : value = ast2obj_int(state, o->end_lineno);
4718 [ - + ]: 406270 : if (!value) goto failed;
4719 [ - + ]: 406270 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4720 : 0 : goto failed;
4721 : 406270 : Py_DECREF(value);
4722 : 406270 : value = ast2obj_int(state, o->end_col_offset);
4723 [ - + ]: 406270 : if (!value) goto failed;
4724 [ - + ]: 406270 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4725 : 0 : goto failed;
4726 : 406270 : Py_DECREF(value);
4727 : 406270 : state->recursion_depth--;
4728 : 406270 : return result;
4729 : 0 : failed:
4730 : 0 : Py_XDECREF(value);
4731 : 0 : Py_XDECREF(result);
4732 : 0 : return NULL;
4733 : : }
4734 : :
4735 : 39 : PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
4736 : : {
4737 [ + - - - ]: 39 : switch(o) {
4738 : 39 : case Load:
4739 : 39 : return Py_NewRef(state->Load_singleton);
4740 : 0 : case Store:
4741 : 0 : return Py_NewRef(state->Store_singleton);
4742 : 0 : case Del:
4743 : 0 : return Py_NewRef(state->Del_singleton);
4744 : : }
4745 : 0 : Py_UNREACHABLE();
4746 : : }
4747 : 0 : PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
4748 : : {
4749 [ # # # ]: 0 : switch(o) {
4750 : 0 : case And:
4751 : 0 : return Py_NewRef(state->And_singleton);
4752 : 0 : case Or:
4753 : 0 : return Py_NewRef(state->Or_singleton);
4754 : : }
4755 : 0 : Py_UNREACHABLE();
4756 : : }
4757 : 1 : PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
4758 : : {
4759 [ - - - - : 1 : switch(o) {
- - + - -
- - - -
- ]
4760 : 0 : case Add:
4761 : 0 : return Py_NewRef(state->Add_singleton);
4762 : 0 : case Sub:
4763 : 0 : return Py_NewRef(state->Sub_singleton);
4764 : 0 : case Mult:
4765 : 0 : return Py_NewRef(state->Mult_singleton);
4766 : 0 : case MatMult:
4767 : 0 : return Py_NewRef(state->MatMult_singleton);
4768 : 0 : case Div:
4769 : 0 : return Py_NewRef(state->Div_singleton);
4770 : 0 : case Mod:
4771 : 0 : return Py_NewRef(state->Mod_singleton);
4772 : 1 : case Pow:
4773 : 1 : return Py_NewRef(state->Pow_singleton);
4774 : 0 : case LShift:
4775 : 0 : return Py_NewRef(state->LShift_singleton);
4776 : 0 : case RShift:
4777 : 0 : return Py_NewRef(state->RShift_singleton);
4778 : 0 : case BitOr:
4779 : 0 : return Py_NewRef(state->BitOr_singleton);
4780 : 0 : case BitXor:
4781 : 0 : return Py_NewRef(state->BitXor_singleton);
4782 : 0 : case BitAnd:
4783 : 0 : return Py_NewRef(state->BitAnd_singleton);
4784 : 0 : case FloorDiv:
4785 : 0 : return Py_NewRef(state->FloorDiv_singleton);
4786 : : }
4787 : 0 : Py_UNREACHABLE();
4788 : : }
4789 : 1 : PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
4790 : : {
4791 [ - - - + : 1 : switch(o) {
- ]
4792 : 0 : case Invert:
4793 : 0 : return Py_NewRef(state->Invert_singleton);
4794 : 0 : case Not:
4795 : 0 : return Py_NewRef(state->Not_singleton);
4796 : 0 : case UAdd:
4797 : 0 : return Py_NewRef(state->UAdd_singleton);
4798 : 1 : case USub:
4799 : 1 : return Py_NewRef(state->USub_singleton);
4800 : : }
4801 : 0 : Py_UNREACHABLE();
4802 : : }
4803 : 0 : PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
4804 : : {
4805 [ # # # # : 0 : switch(o) {
# # # # #
# # ]
4806 : 0 : case Eq:
4807 : 0 : return Py_NewRef(state->Eq_singleton);
4808 : 0 : case NotEq:
4809 : 0 : return Py_NewRef(state->NotEq_singleton);
4810 : 0 : case Lt:
4811 : 0 : return Py_NewRef(state->Lt_singleton);
4812 : 0 : case LtE:
4813 : 0 : return Py_NewRef(state->LtE_singleton);
4814 : 0 : case Gt:
4815 : 0 : return Py_NewRef(state->Gt_singleton);
4816 : 0 : case GtE:
4817 : 0 : return Py_NewRef(state->GtE_singleton);
4818 : 0 : case Is:
4819 : 0 : return Py_NewRef(state->Is_singleton);
4820 : 0 : case IsNot:
4821 : 0 : return Py_NewRef(state->IsNot_singleton);
4822 : 0 : case In:
4823 : 0 : return Py_NewRef(state->In_singleton);
4824 : 0 : case NotIn:
4825 : 0 : return Py_NewRef(state->NotIn_singleton);
4826 : : }
4827 : 0 : Py_UNREACHABLE();
4828 : : }
4829 : : PyObject*
4830 : 0 : ast2obj_comprehension(struct ast_state *state, void* _o)
4831 : : {
4832 : 0 : comprehension_ty o = (comprehension_ty)_o;
4833 : 0 : PyObject *result = NULL, *value = NULL;
4834 : : PyTypeObject *tp;
4835 [ # # ]: 0 : if (!o) {
4836 : 0 : Py_RETURN_NONE;
4837 : : }
4838 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
4839 : 0 : PyErr_SetString(PyExc_RecursionError,
4840 : : "maximum recursion depth exceeded during ast construction");
4841 : 0 : return 0;
4842 : : }
4843 : 0 : tp = (PyTypeObject *)state->comprehension_type;
4844 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4845 [ # # ]: 0 : if (!result) return NULL;
4846 : 0 : value = ast2obj_expr(state, o->target);
4847 [ # # ]: 0 : if (!value) goto failed;
4848 [ # # ]: 0 : if (PyObject_SetAttr(result, state->target, value) == -1)
4849 : 0 : goto failed;
4850 : 0 : Py_DECREF(value);
4851 : 0 : value = ast2obj_expr(state, o->iter);
4852 [ # # ]: 0 : if (!value) goto failed;
4853 [ # # ]: 0 : if (PyObject_SetAttr(result, state->iter, value) == -1)
4854 : 0 : goto failed;
4855 : 0 : Py_DECREF(value);
4856 : 0 : value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
4857 [ # # ]: 0 : if (!value) goto failed;
4858 [ # # ]: 0 : if (PyObject_SetAttr(result, state->ifs, value) == -1)
4859 : 0 : goto failed;
4860 : 0 : Py_DECREF(value);
4861 : 0 : value = ast2obj_int(state, o->is_async);
4862 [ # # ]: 0 : if (!value) goto failed;
4863 [ # # ]: 0 : if (PyObject_SetAttr(result, state->is_async, value) == -1)
4864 : 0 : goto failed;
4865 : 0 : Py_DECREF(value);
4866 : 0 : state->recursion_depth--;
4867 : 0 : return result;
4868 : 0 : failed:
4869 : 0 : Py_XDECREF(value);
4870 : 0 : Py_XDECREF(result);
4871 : 0 : return NULL;
4872 : : }
4873 : :
4874 : : PyObject*
4875 : 0 : ast2obj_excepthandler(struct ast_state *state, void* _o)
4876 : : {
4877 : 0 : excepthandler_ty o = (excepthandler_ty)_o;
4878 : 0 : PyObject *result = NULL, *value = NULL;
4879 : : PyTypeObject *tp;
4880 [ # # ]: 0 : if (!o) {
4881 : 0 : Py_RETURN_NONE;
4882 : : }
4883 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
4884 : 0 : PyErr_SetString(PyExc_RecursionError,
4885 : : "maximum recursion depth exceeded during ast construction");
4886 : 0 : return 0;
4887 : : }
4888 [ # # ]: 0 : switch (o->kind) {
4889 : 0 : case ExceptHandler_kind:
4890 : 0 : tp = (PyTypeObject *)state->ExceptHandler_type;
4891 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4892 [ # # ]: 0 : if (!result) goto failed;
4893 : 0 : value = ast2obj_expr(state, o->v.ExceptHandler.type);
4894 [ # # ]: 0 : if (!value) goto failed;
4895 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type, value) == -1)
4896 : 0 : goto failed;
4897 : 0 : Py_DECREF(value);
4898 : 0 : value = ast2obj_identifier(state, o->v.ExceptHandler.name);
4899 [ # # ]: 0 : if (!value) goto failed;
4900 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
4901 : 0 : goto failed;
4902 : 0 : Py_DECREF(value);
4903 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
4904 : : ast2obj_stmt);
4905 [ # # ]: 0 : if (!value) goto failed;
4906 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
4907 : 0 : goto failed;
4908 : 0 : Py_DECREF(value);
4909 : 0 : break;
4910 : : }
4911 : 0 : value = ast2obj_int(state, o->lineno);
4912 [ # # ]: 0 : if (!value) goto failed;
4913 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
4914 : 0 : goto failed;
4915 : 0 : Py_DECREF(value);
4916 : 0 : value = ast2obj_int(state, o->col_offset);
4917 [ # # ]: 0 : if (!value) goto failed;
4918 [ # # ]: 0 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4919 : 0 : goto failed;
4920 : 0 : Py_DECREF(value);
4921 : 0 : value = ast2obj_int(state, o->end_lineno);
4922 [ # # ]: 0 : if (!value) goto failed;
4923 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4924 : 0 : goto failed;
4925 : 0 : Py_DECREF(value);
4926 : 0 : value = ast2obj_int(state, o->end_col_offset);
4927 [ # # ]: 0 : if (!value) goto failed;
4928 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4929 : 0 : goto failed;
4930 : 0 : Py_DECREF(value);
4931 : 0 : state->recursion_depth--;
4932 : 0 : return result;
4933 : 0 : failed:
4934 : 0 : Py_XDECREF(value);
4935 : 0 : Py_XDECREF(result);
4936 : 0 : return NULL;
4937 : : }
4938 : :
4939 : : PyObject*
4940 : 0 : ast2obj_arguments(struct ast_state *state, void* _o)
4941 : : {
4942 : 0 : arguments_ty o = (arguments_ty)_o;
4943 : 0 : PyObject *result = NULL, *value = NULL;
4944 : : PyTypeObject *tp;
4945 [ # # ]: 0 : if (!o) {
4946 : 0 : Py_RETURN_NONE;
4947 : : }
4948 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
4949 : 0 : PyErr_SetString(PyExc_RecursionError,
4950 : : "maximum recursion depth exceeded during ast construction");
4951 : 0 : return 0;
4952 : : }
4953 : 0 : tp = (PyTypeObject *)state->arguments_type;
4954 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
4955 [ # # ]: 0 : if (!result) return NULL;
4956 : 0 : value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
4957 [ # # ]: 0 : if (!value) goto failed;
4958 [ # # ]: 0 : if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
4959 : 0 : goto failed;
4960 : 0 : Py_DECREF(value);
4961 : 0 : value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
4962 [ # # ]: 0 : if (!value) goto failed;
4963 [ # # ]: 0 : if (PyObject_SetAttr(result, state->args, value) == -1)
4964 : 0 : goto failed;
4965 : 0 : Py_DECREF(value);
4966 : 0 : value = ast2obj_arg(state, o->vararg);
4967 [ # # ]: 0 : if (!value) goto failed;
4968 [ # # ]: 0 : if (PyObject_SetAttr(result, state->vararg, value) == -1)
4969 : 0 : goto failed;
4970 : 0 : Py_DECREF(value);
4971 : 0 : value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
4972 [ # # ]: 0 : if (!value) goto failed;
4973 [ # # ]: 0 : if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
4974 : 0 : goto failed;
4975 : 0 : Py_DECREF(value);
4976 : 0 : value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
4977 [ # # ]: 0 : if (!value) goto failed;
4978 [ # # ]: 0 : if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
4979 : 0 : goto failed;
4980 : 0 : Py_DECREF(value);
4981 : 0 : value = ast2obj_arg(state, o->kwarg);
4982 [ # # ]: 0 : if (!value) goto failed;
4983 [ # # ]: 0 : if (PyObject_SetAttr(result, state->kwarg, value) == -1)
4984 : 0 : goto failed;
4985 : 0 : Py_DECREF(value);
4986 : 0 : value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
4987 [ # # ]: 0 : if (!value) goto failed;
4988 [ # # ]: 0 : if (PyObject_SetAttr(result, state->defaults, value) == -1)
4989 : 0 : goto failed;
4990 : 0 : Py_DECREF(value);
4991 : 0 : state->recursion_depth--;
4992 : 0 : return result;
4993 : 0 : failed:
4994 : 0 : Py_XDECREF(value);
4995 : 0 : Py_XDECREF(result);
4996 : 0 : return NULL;
4997 : : }
4998 : :
4999 : : PyObject*
5000 : 0 : ast2obj_arg(struct ast_state *state, void* _o)
5001 : : {
5002 : 0 : arg_ty o = (arg_ty)_o;
5003 : 0 : PyObject *result = NULL, *value = NULL;
5004 : : PyTypeObject *tp;
5005 [ # # ]: 0 : if (!o) {
5006 : 0 : Py_RETURN_NONE;
5007 : : }
5008 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5009 : 0 : PyErr_SetString(PyExc_RecursionError,
5010 : : "maximum recursion depth exceeded during ast construction");
5011 : 0 : return 0;
5012 : : }
5013 : 0 : tp = (PyTypeObject *)state->arg_type;
5014 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5015 [ # # ]: 0 : if (!result) return NULL;
5016 : 0 : value = ast2obj_identifier(state, o->arg);
5017 [ # # ]: 0 : if (!value) goto failed;
5018 [ # # ]: 0 : if (PyObject_SetAttr(result, state->arg, value) == -1)
5019 : 0 : goto failed;
5020 : 0 : Py_DECREF(value);
5021 : 0 : value = ast2obj_expr(state, o->annotation);
5022 [ # # ]: 0 : if (!value) goto failed;
5023 [ # # ]: 0 : if (PyObject_SetAttr(result, state->annotation, value) == -1)
5024 : 0 : goto failed;
5025 : 0 : Py_DECREF(value);
5026 : 0 : value = ast2obj_string(state, o->type_comment);
5027 [ # # ]: 0 : if (!value) goto failed;
5028 [ # # ]: 0 : if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5029 : 0 : goto failed;
5030 : 0 : Py_DECREF(value);
5031 : 0 : value = ast2obj_int(state, o->lineno);
5032 [ # # ]: 0 : if (!value) goto failed;
5033 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5034 : 0 : goto failed;
5035 : 0 : Py_DECREF(value);
5036 : 0 : value = ast2obj_int(state, o->col_offset);
5037 [ # # ]: 0 : if (!value) goto failed;
5038 [ # # ]: 0 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5039 : 0 : goto failed;
5040 : 0 : Py_DECREF(value);
5041 : 0 : value = ast2obj_int(state, o->end_lineno);
5042 [ # # ]: 0 : if (!value) goto failed;
5043 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5044 : 0 : goto failed;
5045 : 0 : Py_DECREF(value);
5046 : 0 : value = ast2obj_int(state, o->end_col_offset);
5047 [ # # ]: 0 : if (!value) goto failed;
5048 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5049 : 0 : goto failed;
5050 : 0 : Py_DECREF(value);
5051 : 0 : state->recursion_depth--;
5052 : 0 : return result;
5053 : 0 : failed:
5054 : 0 : Py_XDECREF(value);
5055 : 0 : Py_XDECREF(result);
5056 : 0 : return NULL;
5057 : : }
5058 : :
5059 : : PyObject*
5060 : 0 : ast2obj_keyword(struct ast_state *state, void* _o)
5061 : : {
5062 : 0 : keyword_ty o = (keyword_ty)_o;
5063 : 0 : PyObject *result = NULL, *value = NULL;
5064 : : PyTypeObject *tp;
5065 [ # # ]: 0 : if (!o) {
5066 : 0 : Py_RETURN_NONE;
5067 : : }
5068 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5069 : 0 : PyErr_SetString(PyExc_RecursionError,
5070 : : "maximum recursion depth exceeded during ast construction");
5071 : 0 : return 0;
5072 : : }
5073 : 0 : tp = (PyTypeObject *)state->keyword_type;
5074 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5075 [ # # ]: 0 : if (!result) return NULL;
5076 : 0 : value = ast2obj_identifier(state, o->arg);
5077 [ # # ]: 0 : if (!value) goto failed;
5078 [ # # ]: 0 : if (PyObject_SetAttr(result, state->arg, value) == -1)
5079 : 0 : goto failed;
5080 : 0 : Py_DECREF(value);
5081 : 0 : value = ast2obj_expr(state, o->value);
5082 [ # # ]: 0 : if (!value) goto failed;
5083 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
5084 : 0 : goto failed;
5085 : 0 : Py_DECREF(value);
5086 : 0 : value = ast2obj_int(state, o->lineno);
5087 [ # # ]: 0 : if (!value) goto failed;
5088 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5089 : 0 : goto failed;
5090 : 0 : Py_DECREF(value);
5091 : 0 : value = ast2obj_int(state, o->col_offset);
5092 [ # # ]: 0 : if (!value) goto failed;
5093 [ # # ]: 0 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5094 : 0 : goto failed;
5095 : 0 : Py_DECREF(value);
5096 : 0 : value = ast2obj_int(state, o->end_lineno);
5097 [ # # ]: 0 : if (!value) goto failed;
5098 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5099 : 0 : goto failed;
5100 : 0 : Py_DECREF(value);
5101 : 0 : value = ast2obj_int(state, o->end_col_offset);
5102 [ # # ]: 0 : if (!value) goto failed;
5103 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5104 : 0 : goto failed;
5105 : 0 : Py_DECREF(value);
5106 : 0 : state->recursion_depth--;
5107 : 0 : return result;
5108 : 0 : failed:
5109 : 0 : Py_XDECREF(value);
5110 : 0 : Py_XDECREF(result);
5111 : 0 : return NULL;
5112 : : }
5113 : :
5114 : : PyObject*
5115 : 0 : ast2obj_alias(struct ast_state *state, void* _o)
5116 : : {
5117 : 0 : alias_ty o = (alias_ty)_o;
5118 : 0 : PyObject *result = NULL, *value = NULL;
5119 : : PyTypeObject *tp;
5120 [ # # ]: 0 : if (!o) {
5121 : 0 : Py_RETURN_NONE;
5122 : : }
5123 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5124 : 0 : PyErr_SetString(PyExc_RecursionError,
5125 : : "maximum recursion depth exceeded during ast construction");
5126 : 0 : return 0;
5127 : : }
5128 : 0 : tp = (PyTypeObject *)state->alias_type;
5129 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5130 [ # # ]: 0 : if (!result) return NULL;
5131 : 0 : value = ast2obj_identifier(state, o->name);
5132 [ # # ]: 0 : if (!value) goto failed;
5133 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
5134 : 0 : goto failed;
5135 : 0 : Py_DECREF(value);
5136 : 0 : value = ast2obj_identifier(state, o->asname);
5137 [ # # ]: 0 : if (!value) goto failed;
5138 [ # # ]: 0 : if (PyObject_SetAttr(result, state->asname, value) == -1)
5139 : 0 : goto failed;
5140 : 0 : Py_DECREF(value);
5141 : 0 : value = ast2obj_int(state, o->lineno);
5142 [ # # ]: 0 : if (!value) goto failed;
5143 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5144 : 0 : goto failed;
5145 : 0 : Py_DECREF(value);
5146 : 0 : value = ast2obj_int(state, o->col_offset);
5147 [ # # ]: 0 : if (!value) goto failed;
5148 [ # # ]: 0 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5149 : 0 : goto failed;
5150 : 0 : Py_DECREF(value);
5151 : 0 : value = ast2obj_int(state, o->end_lineno);
5152 [ # # ]: 0 : if (!value) goto failed;
5153 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5154 : 0 : goto failed;
5155 : 0 : Py_DECREF(value);
5156 : 0 : value = ast2obj_int(state, o->end_col_offset);
5157 [ # # ]: 0 : if (!value) goto failed;
5158 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5159 : 0 : goto failed;
5160 : 0 : Py_DECREF(value);
5161 : 0 : state->recursion_depth--;
5162 : 0 : return result;
5163 : 0 : failed:
5164 : 0 : Py_XDECREF(value);
5165 : 0 : Py_XDECREF(result);
5166 : 0 : return NULL;
5167 : : }
5168 : :
5169 : : PyObject*
5170 : 0 : ast2obj_withitem(struct ast_state *state, void* _o)
5171 : : {
5172 : 0 : withitem_ty o = (withitem_ty)_o;
5173 : 0 : PyObject *result = NULL, *value = NULL;
5174 : : PyTypeObject *tp;
5175 [ # # ]: 0 : if (!o) {
5176 : 0 : Py_RETURN_NONE;
5177 : : }
5178 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5179 : 0 : PyErr_SetString(PyExc_RecursionError,
5180 : : "maximum recursion depth exceeded during ast construction");
5181 : 0 : return 0;
5182 : : }
5183 : 0 : tp = (PyTypeObject *)state->withitem_type;
5184 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5185 [ # # ]: 0 : if (!result) return NULL;
5186 : 0 : value = ast2obj_expr(state, o->context_expr);
5187 [ # # ]: 0 : if (!value) goto failed;
5188 [ # # ]: 0 : if (PyObject_SetAttr(result, state->context_expr, value) == -1)
5189 : 0 : goto failed;
5190 : 0 : Py_DECREF(value);
5191 : 0 : value = ast2obj_expr(state, o->optional_vars);
5192 [ # # ]: 0 : if (!value) goto failed;
5193 [ # # ]: 0 : if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
5194 : 0 : goto failed;
5195 : 0 : Py_DECREF(value);
5196 : 0 : state->recursion_depth--;
5197 : 0 : return result;
5198 : 0 : failed:
5199 : 0 : Py_XDECREF(value);
5200 : 0 : Py_XDECREF(result);
5201 : 0 : return NULL;
5202 : : }
5203 : :
5204 : : PyObject*
5205 : 0 : ast2obj_match_case(struct ast_state *state, void* _o)
5206 : : {
5207 : 0 : match_case_ty o = (match_case_ty)_o;
5208 : 0 : PyObject *result = NULL, *value = NULL;
5209 : : PyTypeObject *tp;
5210 [ # # ]: 0 : if (!o) {
5211 : 0 : Py_RETURN_NONE;
5212 : : }
5213 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5214 : 0 : PyErr_SetString(PyExc_RecursionError,
5215 : : "maximum recursion depth exceeded during ast construction");
5216 : 0 : return 0;
5217 : : }
5218 : 0 : tp = (PyTypeObject *)state->match_case_type;
5219 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5220 [ # # ]: 0 : if (!result) return NULL;
5221 : 0 : value = ast2obj_pattern(state, o->pattern);
5222 [ # # ]: 0 : if (!value) goto failed;
5223 [ # # ]: 0 : if (PyObject_SetAttr(result, state->pattern, value) == -1)
5224 : 0 : goto failed;
5225 : 0 : Py_DECREF(value);
5226 : 0 : value = ast2obj_expr(state, o->guard);
5227 [ # # ]: 0 : if (!value) goto failed;
5228 [ # # ]: 0 : if (PyObject_SetAttr(result, state->guard, value) == -1)
5229 : 0 : goto failed;
5230 : 0 : Py_DECREF(value);
5231 : 0 : value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
5232 [ # # ]: 0 : if (!value) goto failed;
5233 [ # # ]: 0 : if (PyObject_SetAttr(result, state->body, value) == -1)
5234 : 0 : goto failed;
5235 : 0 : Py_DECREF(value);
5236 : 0 : state->recursion_depth--;
5237 : 0 : return result;
5238 : 0 : failed:
5239 : 0 : Py_XDECREF(value);
5240 : 0 : Py_XDECREF(result);
5241 : 0 : return NULL;
5242 : : }
5243 : :
5244 : : PyObject*
5245 : 0 : ast2obj_pattern(struct ast_state *state, void* _o)
5246 : : {
5247 : 0 : pattern_ty o = (pattern_ty)_o;
5248 : 0 : PyObject *result = NULL, *value = NULL;
5249 : : PyTypeObject *tp;
5250 [ # # ]: 0 : if (!o) {
5251 : 0 : Py_RETURN_NONE;
5252 : : }
5253 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5254 : 0 : PyErr_SetString(PyExc_RecursionError,
5255 : : "maximum recursion depth exceeded during ast construction");
5256 : 0 : return 0;
5257 : : }
5258 [ # # # # : 0 : switch (o->kind) {
# # # #
# ]
5259 : 0 : case MatchValue_kind:
5260 : 0 : tp = (PyTypeObject *)state->MatchValue_type;
5261 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5262 [ # # ]: 0 : if (!result) goto failed;
5263 : 0 : value = ast2obj_expr(state, o->v.MatchValue.value);
5264 [ # # ]: 0 : if (!value) goto failed;
5265 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
5266 : 0 : goto failed;
5267 : 0 : Py_DECREF(value);
5268 : 0 : break;
5269 : 0 : case MatchSingleton_kind:
5270 : 0 : tp = (PyTypeObject *)state->MatchSingleton_type;
5271 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5272 [ # # ]: 0 : if (!result) goto failed;
5273 : 0 : value = ast2obj_constant(state, o->v.MatchSingleton.value);
5274 [ # # ]: 0 : if (!value) goto failed;
5275 [ # # ]: 0 : if (PyObject_SetAttr(result, state->value, value) == -1)
5276 : 0 : goto failed;
5277 : 0 : Py_DECREF(value);
5278 : 0 : break;
5279 : 0 : case MatchSequence_kind:
5280 : 0 : tp = (PyTypeObject *)state->MatchSequence_type;
5281 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5282 [ # # ]: 0 : if (!result) goto failed;
5283 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
5284 : : ast2obj_pattern);
5285 [ # # ]: 0 : if (!value) goto failed;
5286 [ # # ]: 0 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5287 : 0 : goto failed;
5288 : 0 : Py_DECREF(value);
5289 : 0 : break;
5290 : 0 : case MatchMapping_kind:
5291 : 0 : tp = (PyTypeObject *)state->MatchMapping_type;
5292 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5293 [ # # ]: 0 : if (!result) goto failed;
5294 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
5295 : : ast2obj_expr);
5296 [ # # ]: 0 : if (!value) goto failed;
5297 [ # # ]: 0 : if (PyObject_SetAttr(result, state->keys, value) == -1)
5298 : 0 : goto failed;
5299 : 0 : Py_DECREF(value);
5300 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
5301 : : ast2obj_pattern);
5302 [ # # ]: 0 : if (!value) goto failed;
5303 [ # # ]: 0 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5304 : 0 : goto failed;
5305 : 0 : Py_DECREF(value);
5306 : 0 : value = ast2obj_identifier(state, o->v.MatchMapping.rest);
5307 [ # # ]: 0 : if (!value) goto failed;
5308 [ # # ]: 0 : if (PyObject_SetAttr(result, state->rest, value) == -1)
5309 : 0 : goto failed;
5310 : 0 : Py_DECREF(value);
5311 : 0 : break;
5312 : 0 : case MatchClass_kind:
5313 : 0 : tp = (PyTypeObject *)state->MatchClass_type;
5314 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5315 [ # # ]: 0 : if (!result) goto failed;
5316 : 0 : value = ast2obj_expr(state, o->v.MatchClass.cls);
5317 [ # # ]: 0 : if (!value) goto failed;
5318 [ # # ]: 0 : if (PyObject_SetAttr(result, state->cls, value) == -1)
5319 : 0 : goto failed;
5320 : 0 : Py_DECREF(value);
5321 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
5322 : : ast2obj_pattern);
5323 [ # # ]: 0 : if (!value) goto failed;
5324 [ # # ]: 0 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5325 : 0 : goto failed;
5326 : 0 : Py_DECREF(value);
5327 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
5328 : : ast2obj_identifier);
5329 [ # # ]: 0 : if (!value) goto failed;
5330 [ # # ]: 0 : if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
5331 : 0 : goto failed;
5332 : 0 : Py_DECREF(value);
5333 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
5334 : : ast2obj_pattern);
5335 [ # # ]: 0 : if (!value) goto failed;
5336 [ # # ]: 0 : if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
5337 : 0 : goto failed;
5338 : 0 : Py_DECREF(value);
5339 : 0 : break;
5340 : 0 : case MatchStar_kind:
5341 : 0 : tp = (PyTypeObject *)state->MatchStar_type;
5342 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5343 [ # # ]: 0 : if (!result) goto failed;
5344 : 0 : value = ast2obj_identifier(state, o->v.MatchStar.name);
5345 [ # # ]: 0 : if (!value) goto failed;
5346 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
5347 : 0 : goto failed;
5348 : 0 : Py_DECREF(value);
5349 : 0 : break;
5350 : 0 : case MatchAs_kind:
5351 : 0 : tp = (PyTypeObject *)state->MatchAs_type;
5352 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5353 [ # # ]: 0 : if (!result) goto failed;
5354 : 0 : value = ast2obj_pattern(state, o->v.MatchAs.pattern);
5355 [ # # ]: 0 : if (!value) goto failed;
5356 [ # # ]: 0 : if (PyObject_SetAttr(result, state->pattern, value) == -1)
5357 : 0 : goto failed;
5358 : 0 : Py_DECREF(value);
5359 : 0 : value = ast2obj_identifier(state, o->v.MatchAs.name);
5360 [ # # ]: 0 : if (!value) goto failed;
5361 [ # # ]: 0 : if (PyObject_SetAttr(result, state->name, value) == -1)
5362 : 0 : goto failed;
5363 : 0 : Py_DECREF(value);
5364 : 0 : break;
5365 : 0 : case MatchOr_kind:
5366 : 0 : tp = (PyTypeObject *)state->MatchOr_type;
5367 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5368 [ # # ]: 0 : if (!result) goto failed;
5369 : 0 : value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
5370 : : ast2obj_pattern);
5371 [ # # ]: 0 : if (!value) goto failed;
5372 [ # # ]: 0 : if (PyObject_SetAttr(result, state->patterns, value) == -1)
5373 : 0 : goto failed;
5374 : 0 : Py_DECREF(value);
5375 : 0 : break;
5376 : : }
5377 : 0 : value = ast2obj_int(state, o->lineno);
5378 [ # # ]: 0 : if (!value) goto failed;
5379 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lineno, value) < 0)
5380 : 0 : goto failed;
5381 : 0 : Py_DECREF(value);
5382 : 0 : value = ast2obj_int(state, o->col_offset);
5383 [ # # ]: 0 : if (!value) goto failed;
5384 [ # # ]: 0 : if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5385 : 0 : goto failed;
5386 : 0 : Py_DECREF(value);
5387 : 0 : value = ast2obj_int(state, o->end_lineno);
5388 [ # # ]: 0 : if (!value) goto failed;
5389 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5390 : 0 : goto failed;
5391 : 0 : Py_DECREF(value);
5392 : 0 : value = ast2obj_int(state, o->end_col_offset);
5393 [ # # ]: 0 : if (!value) goto failed;
5394 [ # # ]: 0 : if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5395 : 0 : goto failed;
5396 : 0 : Py_DECREF(value);
5397 : 0 : state->recursion_depth--;
5398 : 0 : return result;
5399 : 0 : failed:
5400 : 0 : Py_XDECREF(value);
5401 : 0 : Py_XDECREF(result);
5402 : 0 : return NULL;
5403 : : }
5404 : :
5405 : : PyObject*
5406 : 0 : ast2obj_type_ignore(struct ast_state *state, void* _o)
5407 : : {
5408 : 0 : type_ignore_ty o = (type_ignore_ty)_o;
5409 : 0 : PyObject *result = NULL, *value = NULL;
5410 : : PyTypeObject *tp;
5411 [ # # ]: 0 : if (!o) {
5412 : 0 : Py_RETURN_NONE;
5413 : : }
5414 [ # # ]: 0 : if (++state->recursion_depth > state->recursion_limit) {
5415 : 0 : PyErr_SetString(PyExc_RecursionError,
5416 : : "maximum recursion depth exceeded during ast construction");
5417 : 0 : return 0;
5418 : : }
5419 [ # # ]: 0 : switch (o->kind) {
5420 : 0 : case TypeIgnore_kind:
5421 : 0 : tp = (PyTypeObject *)state->TypeIgnore_type;
5422 : 0 : result = PyType_GenericNew(tp, NULL, NULL);
5423 [ # # ]: 0 : if (!result) goto failed;
5424 : 0 : value = ast2obj_int(state, o->v.TypeIgnore.lineno);
5425 [ # # ]: 0 : if (!value) goto failed;
5426 [ # # ]: 0 : if (PyObject_SetAttr(result, state->lineno, value) == -1)
5427 : 0 : goto failed;
5428 : 0 : Py_DECREF(value);
5429 : 0 : value = ast2obj_string(state, o->v.TypeIgnore.tag);
5430 [ # # ]: 0 : if (!value) goto failed;
5431 [ # # ]: 0 : if (PyObject_SetAttr(result, state->tag, value) == -1)
5432 : 0 : goto failed;
5433 : 0 : Py_DECREF(value);
5434 : 0 : break;
5435 : : }
5436 : 0 : state->recursion_depth--;
5437 : 0 : return result;
5438 : 0 : failed:
5439 : 0 : Py_XDECREF(value);
5440 : 0 : Py_XDECREF(result);
5441 : 0 : return NULL;
5442 : : }
5443 : :
5444 : :
5445 : : int
5446 : 0 : obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
5447 : : {
5448 : : int isinstance;
5449 : :
5450 : 0 : PyObject *tmp = NULL;
5451 : : PyObject *tp;
5452 : :
5453 [ # # ]: 0 : if (obj == Py_None) {
5454 : 0 : *out = NULL;
5455 : 0 : return 0;
5456 : : }
5457 : 0 : tp = state->Module_type;
5458 : 0 : isinstance = PyObject_IsInstance(obj, tp);
5459 [ # # ]: 0 : if (isinstance == -1) {
5460 : 0 : return 1;
5461 : : }
5462 [ # # ]: 0 : if (isinstance) {
5463 : : asdl_stmt_seq* body;
5464 : : asdl_type_ignore_seq* type_ignores;
5465 : :
5466 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5467 : 0 : return 1;
5468 : : }
5469 [ # # ]: 0 : if (tmp == NULL) {
5470 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
5471 : 0 : return 1;
5472 : : }
5473 : : else {
5474 : : int res;
5475 : : Py_ssize_t len;
5476 : : Py_ssize_t i;
5477 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5478 : 0 : PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5479 : 0 : goto failed;
5480 : : }
5481 : 0 : len = PyList_GET_SIZE(tmp);
5482 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
5483 [ # # ]: 0 : if (body == NULL) goto failed;
5484 [ # # ]: 0 : for (i = 0; i < len; i++) {
5485 : : stmt_ty val;
5486 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
5487 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
5488 : 0 : goto failed;
5489 : : }
5490 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
5491 : 0 : _Py_LeaveRecursiveCall();
5492 : 0 : Py_DECREF(tmp2);
5493 [ # # ]: 0 : if (res != 0) goto failed;
5494 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
5495 : 0 : PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
5496 : 0 : goto failed;
5497 : : }
5498 : 0 : asdl_seq_SET(body, i, val);
5499 : : }
5500 [ # # ]: 0 : Py_CLEAR(tmp);
5501 : : }
5502 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_ignores, &tmp) < 0) {
5503 : 0 : return 1;
5504 : : }
5505 [ # # ]: 0 : if (tmp == NULL) {
5506 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"type_ignores\" missing from Module");
5507 : 0 : return 1;
5508 : : }
5509 : : else {
5510 : : int res;
5511 : : Py_ssize_t len;
5512 : : Py_ssize_t i;
5513 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5514 : 0 : PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5515 : 0 : goto failed;
5516 : : }
5517 : 0 : len = PyList_GET_SIZE(tmp);
5518 : 0 : type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
5519 [ # # ]: 0 : if (type_ignores == NULL) goto failed;
5520 [ # # ]: 0 : for (i = 0; i < len; i++) {
5521 : : type_ignore_ty val;
5522 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
5523 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
5524 : 0 : goto failed;
5525 : : }
5526 : 0 : res = obj2ast_type_ignore(state, tmp2, &val, arena);
5527 : 0 : _Py_LeaveRecursiveCall();
5528 : 0 : Py_DECREF(tmp2);
5529 [ # # ]: 0 : if (res != 0) goto failed;
5530 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
5531 : 0 : PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
5532 : 0 : goto failed;
5533 : : }
5534 : 0 : asdl_seq_SET(type_ignores, i, val);
5535 : : }
5536 [ # # ]: 0 : Py_CLEAR(tmp);
5537 : : }
5538 : 0 : *out = _PyAST_Module(body, type_ignores, arena);
5539 [ # # ]: 0 : if (*out == NULL) goto failed;
5540 : 0 : return 0;
5541 : : }
5542 : 0 : tp = state->Interactive_type;
5543 : 0 : isinstance = PyObject_IsInstance(obj, tp);
5544 [ # # ]: 0 : if (isinstance == -1) {
5545 : 0 : return 1;
5546 : : }
5547 [ # # ]: 0 : if (isinstance) {
5548 : : asdl_stmt_seq* body;
5549 : :
5550 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5551 : 0 : return 1;
5552 : : }
5553 [ # # ]: 0 : if (tmp == NULL) {
5554 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
5555 : 0 : return 1;
5556 : : }
5557 : : else {
5558 : : int res;
5559 : : Py_ssize_t len;
5560 : : Py_ssize_t i;
5561 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5562 : 0 : PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5563 : 0 : goto failed;
5564 : : }
5565 : 0 : len = PyList_GET_SIZE(tmp);
5566 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
5567 [ # # ]: 0 : if (body == NULL) goto failed;
5568 [ # # ]: 0 : for (i = 0; i < len; i++) {
5569 : : stmt_ty val;
5570 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
5571 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
5572 : 0 : goto failed;
5573 : : }
5574 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
5575 : 0 : _Py_LeaveRecursiveCall();
5576 : 0 : Py_DECREF(tmp2);
5577 [ # # ]: 0 : if (res != 0) goto failed;
5578 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
5579 : 0 : PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
5580 : 0 : goto failed;
5581 : : }
5582 : 0 : asdl_seq_SET(body, i, val);
5583 : : }
5584 [ # # ]: 0 : Py_CLEAR(tmp);
5585 : : }
5586 : 0 : *out = _PyAST_Interactive(body, arena);
5587 [ # # ]: 0 : if (*out == NULL) goto failed;
5588 : 0 : return 0;
5589 : : }
5590 : 0 : tp = state->Expression_type;
5591 : 0 : isinstance = PyObject_IsInstance(obj, tp);
5592 [ # # ]: 0 : if (isinstance == -1) {
5593 : 0 : return 1;
5594 : : }
5595 [ # # ]: 0 : if (isinstance) {
5596 : : expr_ty body;
5597 : :
5598 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5599 : 0 : return 1;
5600 : : }
5601 [ # # ]: 0 : if (tmp == NULL) {
5602 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
5603 : 0 : return 1;
5604 : : }
5605 : : else {
5606 : : int res;
5607 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
5608 : 0 : goto failed;
5609 : : }
5610 : 0 : res = obj2ast_expr(state, tmp, &body, arena);
5611 : 0 : _Py_LeaveRecursiveCall();
5612 [ # # ]: 0 : if (res != 0) goto failed;
5613 [ # # ]: 0 : Py_CLEAR(tmp);
5614 : : }
5615 : 0 : *out = _PyAST_Expression(body, arena);
5616 [ # # ]: 0 : if (*out == NULL) goto failed;
5617 : 0 : return 0;
5618 : : }
5619 : 0 : tp = state->FunctionType_type;
5620 : 0 : isinstance = PyObject_IsInstance(obj, tp);
5621 [ # # ]: 0 : if (isinstance == -1) {
5622 : 0 : return 1;
5623 : : }
5624 [ # # ]: 0 : if (isinstance) {
5625 : : asdl_expr_seq* argtypes;
5626 : : expr_ty returns;
5627 : :
5628 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->argtypes, &tmp) < 0) {
5629 : 0 : return 1;
5630 : : }
5631 [ # # ]: 0 : if (tmp == NULL) {
5632 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"argtypes\" missing from FunctionType");
5633 : 0 : return 1;
5634 : : }
5635 : : else {
5636 : : int res;
5637 : : Py_ssize_t len;
5638 : : Py_ssize_t i;
5639 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5640 : 0 : PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5641 : 0 : goto failed;
5642 : : }
5643 : 0 : len = PyList_GET_SIZE(tmp);
5644 : 0 : argtypes = _Py_asdl_expr_seq_new(len, arena);
5645 [ # # ]: 0 : if (argtypes == NULL) goto failed;
5646 [ # # ]: 0 : for (i = 0; i < len; i++) {
5647 : : expr_ty val;
5648 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
5649 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
5650 : 0 : goto failed;
5651 : : }
5652 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
5653 : 0 : _Py_LeaveRecursiveCall();
5654 : 0 : Py_DECREF(tmp2);
5655 [ # # ]: 0 : if (res != 0) goto failed;
5656 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
5657 : 0 : PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
5658 : 0 : goto failed;
5659 : : }
5660 : 0 : asdl_seq_SET(argtypes, i, val);
5661 : : }
5662 [ # # ]: 0 : Py_CLEAR(tmp);
5663 : : }
5664 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5665 : 0 : return 1;
5666 : : }
5667 [ # # ]: 0 : if (tmp == NULL) {
5668 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
5669 : 0 : return 1;
5670 : : }
5671 : : else {
5672 : : int res;
5673 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
5674 : 0 : goto failed;
5675 : : }
5676 : 0 : res = obj2ast_expr(state, tmp, &returns, arena);
5677 : 0 : _Py_LeaveRecursiveCall();
5678 [ # # ]: 0 : if (res != 0) goto failed;
5679 [ # # ]: 0 : Py_CLEAR(tmp);
5680 : : }
5681 : 0 : *out = _PyAST_FunctionType(argtypes, returns, arena);
5682 [ # # ]: 0 : if (*out == NULL) goto failed;
5683 : 0 : return 0;
5684 : : }
5685 : :
5686 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
5687 : 0 : failed:
5688 : 0 : Py_XDECREF(tmp);
5689 : 0 : return 1;
5690 : : }
5691 : :
5692 : : int
5693 : 0 : obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
5694 : : arena)
5695 : : {
5696 : : int isinstance;
5697 : :
5698 : 0 : PyObject *tmp = NULL;
5699 : : PyObject *tp;
5700 : : int lineno;
5701 : : int col_offset;
5702 : : int end_lineno;
5703 : : int end_col_offset;
5704 : :
5705 [ # # ]: 0 : if (obj == Py_None) {
5706 : 0 : *out = NULL;
5707 : 0 : return 0;
5708 : : }
5709 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
5710 : 0 : return 1;
5711 : : }
5712 [ # # ]: 0 : if (tmp == NULL) {
5713 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
5714 : 0 : return 1;
5715 : : }
5716 : : else {
5717 : : int res;
5718 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5719 : 0 : goto failed;
5720 : : }
5721 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
5722 : 0 : _Py_LeaveRecursiveCall();
5723 [ # # ]: 0 : if (res != 0) goto failed;
5724 [ # # ]: 0 : Py_CLEAR(tmp);
5725 : : }
5726 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
5727 : 0 : return 1;
5728 : : }
5729 [ # # ]: 0 : if (tmp == NULL) {
5730 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
5731 : 0 : return 1;
5732 : : }
5733 : : else {
5734 : : int res;
5735 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5736 : 0 : goto failed;
5737 : : }
5738 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
5739 : 0 : _Py_LeaveRecursiveCall();
5740 [ # # ]: 0 : if (res != 0) goto failed;
5741 [ # # ]: 0 : Py_CLEAR(tmp);
5742 : : }
5743 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
5744 : 0 : return 1;
5745 : : }
5746 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
5747 [ # # ]: 0 : Py_CLEAR(tmp);
5748 : 0 : end_lineno = lineno;
5749 : : }
5750 : : else {
5751 : : int res;
5752 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5753 : 0 : goto failed;
5754 : : }
5755 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
5756 : 0 : _Py_LeaveRecursiveCall();
5757 [ # # ]: 0 : if (res != 0) goto failed;
5758 [ # # ]: 0 : Py_CLEAR(tmp);
5759 : : }
5760 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
5761 : 0 : return 1;
5762 : : }
5763 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
5764 [ # # ]: 0 : Py_CLEAR(tmp);
5765 : 0 : end_col_offset = col_offset;
5766 : : }
5767 : : else {
5768 : : int res;
5769 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
5770 : 0 : goto failed;
5771 : : }
5772 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
5773 : 0 : _Py_LeaveRecursiveCall();
5774 [ # # ]: 0 : if (res != 0) goto failed;
5775 [ # # ]: 0 : Py_CLEAR(tmp);
5776 : : }
5777 : 0 : tp = state->FunctionDef_type;
5778 : 0 : isinstance = PyObject_IsInstance(obj, tp);
5779 [ # # ]: 0 : if (isinstance == -1) {
5780 : 0 : return 1;
5781 : : }
5782 [ # # ]: 0 : if (isinstance) {
5783 : : identifier name;
5784 : : arguments_ty args;
5785 : : asdl_stmt_seq* body;
5786 : : asdl_expr_seq* decorator_list;
5787 : : expr_ty returns;
5788 : : string type_comment;
5789 : :
5790 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5791 : 0 : return 1;
5792 : : }
5793 [ # # ]: 0 : if (tmp == NULL) {
5794 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
5795 : 0 : return 1;
5796 : : }
5797 : : else {
5798 : : int res;
5799 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5800 : 0 : goto failed;
5801 : : }
5802 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
5803 : 0 : _Py_LeaveRecursiveCall();
5804 [ # # ]: 0 : if (res != 0) goto failed;
5805 [ # # ]: 0 : Py_CLEAR(tmp);
5806 : : }
5807 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5808 : 0 : return 1;
5809 : : }
5810 [ # # ]: 0 : if (tmp == NULL) {
5811 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
5812 : 0 : return 1;
5813 : : }
5814 : : else {
5815 : : int res;
5816 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5817 : 0 : goto failed;
5818 : : }
5819 : 0 : res = obj2ast_arguments(state, tmp, &args, arena);
5820 : 0 : _Py_LeaveRecursiveCall();
5821 [ # # ]: 0 : if (res != 0) goto failed;
5822 [ # # ]: 0 : Py_CLEAR(tmp);
5823 : : }
5824 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5825 : 0 : return 1;
5826 : : }
5827 [ # # ]: 0 : if (tmp == NULL) {
5828 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
5829 : 0 : return 1;
5830 : : }
5831 : : else {
5832 : : int res;
5833 : : Py_ssize_t len;
5834 : : Py_ssize_t i;
5835 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5836 : 0 : PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5837 : 0 : goto failed;
5838 : : }
5839 : 0 : len = PyList_GET_SIZE(tmp);
5840 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
5841 [ # # ]: 0 : if (body == NULL) goto failed;
5842 [ # # ]: 0 : for (i = 0; i < len; i++) {
5843 : : stmt_ty val;
5844 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
5845 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5846 : 0 : goto failed;
5847 : : }
5848 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
5849 : 0 : _Py_LeaveRecursiveCall();
5850 : 0 : Py_DECREF(tmp2);
5851 [ # # ]: 0 : if (res != 0) goto failed;
5852 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
5853 : 0 : PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
5854 : 0 : goto failed;
5855 : : }
5856 : 0 : asdl_seq_SET(body, i, val);
5857 : : }
5858 [ # # ]: 0 : Py_CLEAR(tmp);
5859 : : }
5860 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
5861 : 0 : return 1;
5862 : : }
5863 [ # # ]: 0 : if (tmp == NULL) {
5864 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
5865 : 0 : return 1;
5866 : : }
5867 : : else {
5868 : : int res;
5869 : : Py_ssize_t len;
5870 : : Py_ssize_t i;
5871 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5872 : 0 : PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5873 : 0 : goto failed;
5874 : : }
5875 : 0 : len = PyList_GET_SIZE(tmp);
5876 : 0 : decorator_list = _Py_asdl_expr_seq_new(len, arena);
5877 [ # # ]: 0 : if (decorator_list == NULL) goto failed;
5878 [ # # ]: 0 : for (i = 0; i < len; i++) {
5879 : : expr_ty val;
5880 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
5881 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5882 : 0 : goto failed;
5883 : : }
5884 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
5885 : 0 : _Py_LeaveRecursiveCall();
5886 : 0 : Py_DECREF(tmp2);
5887 [ # # ]: 0 : if (res != 0) goto failed;
5888 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
5889 : 0 : PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
5890 : 0 : goto failed;
5891 : : }
5892 : 0 : asdl_seq_SET(decorator_list, i, val);
5893 : : }
5894 [ # # ]: 0 : Py_CLEAR(tmp);
5895 : : }
5896 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5897 : 0 : return 1;
5898 : : }
5899 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
5900 [ # # ]: 0 : Py_CLEAR(tmp);
5901 : 0 : returns = NULL;
5902 : : }
5903 : : else {
5904 : : int res;
5905 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5906 : 0 : goto failed;
5907 : : }
5908 : 0 : res = obj2ast_expr(state, tmp, &returns, arena);
5909 : 0 : _Py_LeaveRecursiveCall();
5910 [ # # ]: 0 : if (res != 0) goto failed;
5911 [ # # ]: 0 : Py_CLEAR(tmp);
5912 : : }
5913 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
5914 : 0 : return 1;
5915 : : }
5916 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
5917 [ # # ]: 0 : Py_CLEAR(tmp);
5918 : 0 : type_comment = NULL;
5919 : : }
5920 : : else {
5921 : : int res;
5922 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
5923 : 0 : goto failed;
5924 : : }
5925 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
5926 : 0 : _Py_LeaveRecursiveCall();
5927 [ # # ]: 0 : if (res != 0) goto failed;
5928 [ # # ]: 0 : Py_CLEAR(tmp);
5929 : : }
5930 : 0 : *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
5931 : : type_comment, lineno, col_offset, end_lineno,
5932 : : end_col_offset, arena);
5933 [ # # ]: 0 : if (*out == NULL) goto failed;
5934 : 0 : return 0;
5935 : : }
5936 : 0 : tp = state->AsyncFunctionDef_type;
5937 : 0 : isinstance = PyObject_IsInstance(obj, tp);
5938 [ # # ]: 0 : if (isinstance == -1) {
5939 : 0 : return 1;
5940 : : }
5941 [ # # ]: 0 : if (isinstance) {
5942 : : identifier name;
5943 : : arguments_ty args;
5944 : : asdl_stmt_seq* body;
5945 : : asdl_expr_seq* decorator_list;
5946 : : expr_ty returns;
5947 : : string type_comment;
5948 : :
5949 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5950 : 0 : return 1;
5951 : : }
5952 [ # # ]: 0 : if (tmp == NULL) {
5953 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
5954 : 0 : return 1;
5955 : : }
5956 : : else {
5957 : : int res;
5958 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5959 : 0 : goto failed;
5960 : : }
5961 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
5962 : 0 : _Py_LeaveRecursiveCall();
5963 [ # # ]: 0 : if (res != 0) goto failed;
5964 [ # # ]: 0 : Py_CLEAR(tmp);
5965 : : }
5966 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5967 : 0 : return 1;
5968 : : }
5969 [ # # ]: 0 : if (tmp == NULL) {
5970 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
5971 : 0 : return 1;
5972 : : }
5973 : : else {
5974 : : int res;
5975 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
5976 : 0 : goto failed;
5977 : : }
5978 : 0 : res = obj2ast_arguments(state, tmp, &args, arena);
5979 : 0 : _Py_LeaveRecursiveCall();
5980 [ # # ]: 0 : if (res != 0) goto failed;
5981 [ # # ]: 0 : Py_CLEAR(tmp);
5982 : : }
5983 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5984 : 0 : return 1;
5985 : : }
5986 [ # # ]: 0 : if (tmp == NULL) {
5987 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFunctionDef");
5988 : 0 : return 1;
5989 : : }
5990 : : else {
5991 : : int res;
5992 : : Py_ssize_t len;
5993 : : Py_ssize_t i;
5994 [ # # ]: 0 : if (!PyList_Check(tmp)) {
5995 : 0 : PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
5996 : 0 : goto failed;
5997 : : }
5998 : 0 : len = PyList_GET_SIZE(tmp);
5999 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
6000 [ # # ]: 0 : if (body == NULL) goto failed;
6001 [ # # ]: 0 : for (i = 0; i < len; i++) {
6002 : : stmt_ty val;
6003 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6004 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6005 : 0 : goto failed;
6006 : : }
6007 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6008 : 0 : _Py_LeaveRecursiveCall();
6009 : 0 : Py_DECREF(tmp2);
6010 [ # # ]: 0 : if (res != 0) goto failed;
6011 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6012 : 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
6013 : 0 : goto failed;
6014 : : }
6015 : 0 : asdl_seq_SET(body, i, val);
6016 : : }
6017 [ # # ]: 0 : Py_CLEAR(tmp);
6018 : : }
6019 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
6020 : 0 : return 1;
6021 : : }
6022 [ # # ]: 0 : if (tmp == NULL) {
6023 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from AsyncFunctionDef");
6024 : 0 : return 1;
6025 : : }
6026 : : else {
6027 : : int res;
6028 : : Py_ssize_t len;
6029 : : Py_ssize_t i;
6030 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6031 : 0 : PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6032 : 0 : goto failed;
6033 : : }
6034 : 0 : len = PyList_GET_SIZE(tmp);
6035 : 0 : decorator_list = _Py_asdl_expr_seq_new(len, arena);
6036 [ # # ]: 0 : if (decorator_list == NULL) goto failed;
6037 [ # # ]: 0 : for (i = 0; i < len; i++) {
6038 : : expr_ty val;
6039 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6040 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6041 : 0 : goto failed;
6042 : : }
6043 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
6044 : 0 : _Py_LeaveRecursiveCall();
6045 : 0 : Py_DECREF(tmp2);
6046 [ # # ]: 0 : if (res != 0) goto failed;
6047 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6048 : 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
6049 : 0 : goto failed;
6050 : : }
6051 : 0 : asdl_seq_SET(decorator_list, i, val);
6052 : : }
6053 [ # # ]: 0 : Py_CLEAR(tmp);
6054 : : }
6055 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
6056 : 0 : return 1;
6057 : : }
6058 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6059 [ # # ]: 0 : Py_CLEAR(tmp);
6060 : 0 : returns = NULL;
6061 : : }
6062 : : else {
6063 : : int res;
6064 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6065 : 0 : goto failed;
6066 : : }
6067 : 0 : res = obj2ast_expr(state, tmp, &returns, arena);
6068 : 0 : _Py_LeaveRecursiveCall();
6069 [ # # ]: 0 : if (res != 0) goto failed;
6070 [ # # ]: 0 : Py_CLEAR(tmp);
6071 : : }
6072 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6073 : 0 : return 1;
6074 : : }
6075 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6076 [ # # ]: 0 : Py_CLEAR(tmp);
6077 : 0 : type_comment = NULL;
6078 : : }
6079 : : else {
6080 : : int res;
6081 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
6082 : 0 : goto failed;
6083 : : }
6084 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6085 : 0 : _Py_LeaveRecursiveCall();
6086 [ # # ]: 0 : if (res != 0) goto failed;
6087 [ # # ]: 0 : Py_CLEAR(tmp);
6088 : : }
6089 : 0 : *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
6090 : : returns, type_comment, lineno,
6091 : : col_offset, end_lineno, end_col_offset,
6092 : : arena);
6093 [ # # ]: 0 : if (*out == NULL) goto failed;
6094 : 0 : return 0;
6095 : : }
6096 : 0 : tp = state->ClassDef_type;
6097 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6098 [ # # ]: 0 : if (isinstance == -1) {
6099 : 0 : return 1;
6100 : : }
6101 [ # # ]: 0 : if (isinstance) {
6102 : : identifier name;
6103 : : asdl_expr_seq* bases;
6104 : : asdl_keyword_seq* keywords;
6105 : : asdl_stmt_seq* body;
6106 : : asdl_expr_seq* decorator_list;
6107 : :
6108 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
6109 : 0 : return 1;
6110 : : }
6111 [ # # ]: 0 : if (tmp == NULL) {
6112 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
6113 : 0 : return 1;
6114 : : }
6115 : : else {
6116 : : int res;
6117 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6118 : 0 : goto failed;
6119 : : }
6120 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
6121 : 0 : _Py_LeaveRecursiveCall();
6122 [ # # ]: 0 : if (res != 0) goto failed;
6123 [ # # ]: 0 : Py_CLEAR(tmp);
6124 : : }
6125 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->bases, &tmp) < 0) {
6126 : 0 : return 1;
6127 : : }
6128 [ # # ]: 0 : if (tmp == NULL) {
6129 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
6130 : 0 : return 1;
6131 : : }
6132 : : else {
6133 : : int res;
6134 : : Py_ssize_t len;
6135 : : Py_ssize_t i;
6136 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6137 : 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6138 : 0 : goto failed;
6139 : : }
6140 : 0 : len = PyList_GET_SIZE(tmp);
6141 : 0 : bases = _Py_asdl_expr_seq_new(len, arena);
6142 [ # # ]: 0 : if (bases == NULL) goto failed;
6143 [ # # ]: 0 : for (i = 0; i < len; i++) {
6144 : : expr_ty val;
6145 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6146 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6147 : 0 : goto failed;
6148 : : }
6149 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
6150 : 0 : _Py_LeaveRecursiveCall();
6151 : 0 : Py_DECREF(tmp2);
6152 [ # # ]: 0 : if (res != 0) goto failed;
6153 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6154 : 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
6155 : 0 : goto failed;
6156 : : }
6157 : 0 : asdl_seq_SET(bases, i, val);
6158 : : }
6159 [ # # ]: 0 : Py_CLEAR(tmp);
6160 : : }
6161 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
6162 : 0 : return 1;
6163 : : }
6164 [ # # ]: 0 : if (tmp == NULL) {
6165 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
6166 : 0 : return 1;
6167 : : }
6168 : : else {
6169 : : int res;
6170 : : Py_ssize_t len;
6171 : : Py_ssize_t i;
6172 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6173 : 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6174 : 0 : goto failed;
6175 : : }
6176 : 0 : len = PyList_GET_SIZE(tmp);
6177 : 0 : keywords = _Py_asdl_keyword_seq_new(len, arena);
6178 [ # # ]: 0 : if (keywords == NULL) goto failed;
6179 [ # # ]: 0 : for (i = 0; i < len; i++) {
6180 : : keyword_ty val;
6181 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6182 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6183 : 0 : goto failed;
6184 : : }
6185 : 0 : res = obj2ast_keyword(state, tmp2, &val, arena);
6186 : 0 : _Py_LeaveRecursiveCall();
6187 : 0 : Py_DECREF(tmp2);
6188 [ # # ]: 0 : if (res != 0) goto failed;
6189 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6190 : 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
6191 : 0 : goto failed;
6192 : : }
6193 : 0 : asdl_seq_SET(keywords, i, val);
6194 : : }
6195 [ # # ]: 0 : Py_CLEAR(tmp);
6196 : : }
6197 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6198 : 0 : return 1;
6199 : : }
6200 [ # # ]: 0 : if (tmp == NULL) {
6201 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
6202 : 0 : return 1;
6203 : : }
6204 : : else {
6205 : : int res;
6206 : : Py_ssize_t len;
6207 : : Py_ssize_t i;
6208 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6209 : 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6210 : 0 : goto failed;
6211 : : }
6212 : 0 : len = PyList_GET_SIZE(tmp);
6213 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
6214 [ # # ]: 0 : if (body == NULL) goto failed;
6215 [ # # ]: 0 : for (i = 0; i < len; i++) {
6216 : : stmt_ty val;
6217 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6218 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6219 : 0 : goto failed;
6220 : : }
6221 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6222 : 0 : _Py_LeaveRecursiveCall();
6223 : 0 : Py_DECREF(tmp2);
6224 [ # # ]: 0 : if (res != 0) goto failed;
6225 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6226 : 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
6227 : 0 : goto failed;
6228 : : }
6229 : 0 : asdl_seq_SET(body, i, val);
6230 : : }
6231 [ # # ]: 0 : Py_CLEAR(tmp);
6232 : : }
6233 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
6234 : 0 : return 1;
6235 : : }
6236 [ # # ]: 0 : if (tmp == NULL) {
6237 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
6238 : 0 : return 1;
6239 : : }
6240 : : else {
6241 : : int res;
6242 : : Py_ssize_t len;
6243 : : Py_ssize_t i;
6244 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6245 : 0 : PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6246 : 0 : goto failed;
6247 : : }
6248 : 0 : len = PyList_GET_SIZE(tmp);
6249 : 0 : decorator_list = _Py_asdl_expr_seq_new(len, arena);
6250 [ # # ]: 0 : if (decorator_list == NULL) goto failed;
6251 [ # # ]: 0 : for (i = 0; i < len; i++) {
6252 : : expr_ty val;
6253 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6254 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
6255 : 0 : goto failed;
6256 : : }
6257 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
6258 : 0 : _Py_LeaveRecursiveCall();
6259 : 0 : Py_DECREF(tmp2);
6260 [ # # ]: 0 : if (res != 0) goto failed;
6261 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6262 : 0 : PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
6263 : 0 : goto failed;
6264 : : }
6265 : 0 : asdl_seq_SET(decorator_list, i, val);
6266 : : }
6267 [ # # ]: 0 : Py_CLEAR(tmp);
6268 : : }
6269 : 0 : *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
6270 : : lineno, col_offset, end_lineno, end_col_offset,
6271 : : arena);
6272 [ # # ]: 0 : if (*out == NULL) goto failed;
6273 : 0 : return 0;
6274 : : }
6275 : 0 : tp = state->Return_type;
6276 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6277 [ # # ]: 0 : if (isinstance == -1) {
6278 : 0 : return 1;
6279 : : }
6280 [ # # ]: 0 : if (isinstance) {
6281 : : expr_ty value;
6282 : :
6283 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6284 : 0 : return 1;
6285 : : }
6286 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6287 [ # # ]: 0 : Py_CLEAR(tmp);
6288 : 0 : value = NULL;
6289 : : }
6290 : : else {
6291 : : int res;
6292 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
6293 : 0 : goto failed;
6294 : : }
6295 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
6296 : 0 : _Py_LeaveRecursiveCall();
6297 [ # # ]: 0 : if (res != 0) goto failed;
6298 [ # # ]: 0 : Py_CLEAR(tmp);
6299 : : }
6300 : 0 : *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
6301 : : end_col_offset, arena);
6302 [ # # ]: 0 : if (*out == NULL) goto failed;
6303 : 0 : return 0;
6304 : : }
6305 : 0 : tp = state->Delete_type;
6306 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6307 [ # # ]: 0 : if (isinstance == -1) {
6308 : 0 : return 1;
6309 : : }
6310 [ # # ]: 0 : if (isinstance) {
6311 : : asdl_expr_seq* targets;
6312 : :
6313 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6314 : 0 : return 1;
6315 : : }
6316 [ # # ]: 0 : if (tmp == NULL) {
6317 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
6318 : 0 : return 1;
6319 : : }
6320 : : else {
6321 : : int res;
6322 : : Py_ssize_t len;
6323 : : Py_ssize_t i;
6324 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6325 : 0 : PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6326 : 0 : goto failed;
6327 : : }
6328 : 0 : len = PyList_GET_SIZE(tmp);
6329 : 0 : targets = _Py_asdl_expr_seq_new(len, arena);
6330 [ # # ]: 0 : if (targets == NULL) goto failed;
6331 [ # # ]: 0 : for (i = 0; i < len; i++) {
6332 : : expr_ty val;
6333 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6334 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
6335 : 0 : goto failed;
6336 : : }
6337 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
6338 : 0 : _Py_LeaveRecursiveCall();
6339 : 0 : Py_DECREF(tmp2);
6340 [ # # ]: 0 : if (res != 0) goto failed;
6341 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6342 : 0 : PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
6343 : 0 : goto failed;
6344 : : }
6345 : 0 : asdl_seq_SET(targets, i, val);
6346 : : }
6347 [ # # ]: 0 : Py_CLEAR(tmp);
6348 : : }
6349 : 0 : *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
6350 : : end_col_offset, arena);
6351 [ # # ]: 0 : if (*out == NULL) goto failed;
6352 : 0 : return 0;
6353 : : }
6354 : 0 : tp = state->Assign_type;
6355 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6356 [ # # ]: 0 : if (isinstance == -1) {
6357 : 0 : return 1;
6358 : : }
6359 [ # # ]: 0 : if (isinstance) {
6360 : : asdl_expr_seq* targets;
6361 : : expr_ty value;
6362 : : string type_comment;
6363 : :
6364 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6365 : 0 : return 1;
6366 : : }
6367 [ # # ]: 0 : if (tmp == NULL) {
6368 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
6369 : 0 : return 1;
6370 : : }
6371 : : else {
6372 : : int res;
6373 : : Py_ssize_t len;
6374 : : Py_ssize_t i;
6375 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6376 : 0 : PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6377 : 0 : goto failed;
6378 : : }
6379 : 0 : len = PyList_GET_SIZE(tmp);
6380 : 0 : targets = _Py_asdl_expr_seq_new(len, arena);
6381 [ # # ]: 0 : if (targets == NULL) goto failed;
6382 [ # # ]: 0 : for (i = 0; i < len; i++) {
6383 : : expr_ty val;
6384 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6385 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6386 : 0 : goto failed;
6387 : : }
6388 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
6389 : 0 : _Py_LeaveRecursiveCall();
6390 : 0 : Py_DECREF(tmp2);
6391 [ # # ]: 0 : if (res != 0) goto failed;
6392 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6393 : 0 : PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
6394 : 0 : goto failed;
6395 : : }
6396 : 0 : asdl_seq_SET(targets, i, val);
6397 : : }
6398 [ # # ]: 0 : Py_CLEAR(tmp);
6399 : : }
6400 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6401 : 0 : return 1;
6402 : : }
6403 [ # # ]: 0 : if (tmp == NULL) {
6404 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
6405 : 0 : return 1;
6406 : : }
6407 : : else {
6408 : : int res;
6409 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6410 : 0 : goto failed;
6411 : : }
6412 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
6413 : 0 : _Py_LeaveRecursiveCall();
6414 [ # # ]: 0 : if (res != 0) goto failed;
6415 [ # # ]: 0 : Py_CLEAR(tmp);
6416 : : }
6417 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6418 : 0 : return 1;
6419 : : }
6420 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6421 [ # # ]: 0 : Py_CLEAR(tmp);
6422 : 0 : type_comment = NULL;
6423 : : }
6424 : : else {
6425 : : int res;
6426 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
6427 : 0 : goto failed;
6428 : : }
6429 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6430 : 0 : _Py_LeaveRecursiveCall();
6431 [ # # ]: 0 : if (res != 0) goto failed;
6432 [ # # ]: 0 : Py_CLEAR(tmp);
6433 : : }
6434 : 0 : *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
6435 : : end_lineno, end_col_offset, arena);
6436 [ # # ]: 0 : if (*out == NULL) goto failed;
6437 : 0 : return 0;
6438 : : }
6439 : 0 : tp = state->AugAssign_type;
6440 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6441 [ # # ]: 0 : if (isinstance == -1) {
6442 : 0 : return 1;
6443 : : }
6444 [ # # ]: 0 : if (isinstance) {
6445 : : expr_ty target;
6446 : : operator_ty op;
6447 : : expr_ty value;
6448 : :
6449 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6450 : 0 : return 1;
6451 : : }
6452 [ # # ]: 0 : if (tmp == NULL) {
6453 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
6454 : 0 : return 1;
6455 : : }
6456 : : else {
6457 : : int res;
6458 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6459 : 0 : goto failed;
6460 : : }
6461 : 0 : res = obj2ast_expr(state, tmp, &target, arena);
6462 : 0 : _Py_LeaveRecursiveCall();
6463 [ # # ]: 0 : if (res != 0) goto failed;
6464 [ # # ]: 0 : Py_CLEAR(tmp);
6465 : : }
6466 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
6467 : 0 : return 1;
6468 : : }
6469 [ # # ]: 0 : if (tmp == NULL) {
6470 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
6471 : 0 : return 1;
6472 : : }
6473 : : else {
6474 : : int res;
6475 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6476 : 0 : goto failed;
6477 : : }
6478 : 0 : res = obj2ast_operator(state, tmp, &op, arena);
6479 : 0 : _Py_LeaveRecursiveCall();
6480 [ # # ]: 0 : if (res != 0) goto failed;
6481 [ # # ]: 0 : Py_CLEAR(tmp);
6482 : : }
6483 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6484 : 0 : return 1;
6485 : : }
6486 [ # # ]: 0 : if (tmp == NULL) {
6487 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
6488 : 0 : return 1;
6489 : : }
6490 : : else {
6491 : : int res;
6492 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
6493 : 0 : goto failed;
6494 : : }
6495 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
6496 : 0 : _Py_LeaveRecursiveCall();
6497 [ # # ]: 0 : if (res != 0) goto failed;
6498 [ # # ]: 0 : Py_CLEAR(tmp);
6499 : : }
6500 : 0 : *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
6501 : : end_lineno, end_col_offset, arena);
6502 [ # # ]: 0 : if (*out == NULL) goto failed;
6503 : 0 : return 0;
6504 : : }
6505 : 0 : tp = state->AnnAssign_type;
6506 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6507 [ # # ]: 0 : if (isinstance == -1) {
6508 : 0 : return 1;
6509 : : }
6510 [ # # ]: 0 : if (isinstance) {
6511 : : expr_ty target;
6512 : : expr_ty annotation;
6513 : : expr_ty value;
6514 : : int simple;
6515 : :
6516 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6517 : 0 : return 1;
6518 : : }
6519 [ # # ]: 0 : if (tmp == NULL) {
6520 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
6521 : 0 : return 1;
6522 : : }
6523 : : else {
6524 : : int res;
6525 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6526 : 0 : goto failed;
6527 : : }
6528 : 0 : res = obj2ast_expr(state, tmp, &target, arena);
6529 : 0 : _Py_LeaveRecursiveCall();
6530 [ # # ]: 0 : if (res != 0) goto failed;
6531 [ # # ]: 0 : Py_CLEAR(tmp);
6532 : : }
6533 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
6534 : 0 : return 1;
6535 : : }
6536 [ # # ]: 0 : if (tmp == NULL) {
6537 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
6538 : 0 : return 1;
6539 : : }
6540 : : else {
6541 : : int res;
6542 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6543 : 0 : goto failed;
6544 : : }
6545 : 0 : res = obj2ast_expr(state, tmp, &annotation, arena);
6546 : 0 : _Py_LeaveRecursiveCall();
6547 [ # # ]: 0 : if (res != 0) goto failed;
6548 [ # # ]: 0 : Py_CLEAR(tmp);
6549 : : }
6550 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6551 : 0 : return 1;
6552 : : }
6553 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6554 [ # # ]: 0 : Py_CLEAR(tmp);
6555 : 0 : value = NULL;
6556 : : }
6557 : : else {
6558 : : int res;
6559 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6560 : 0 : goto failed;
6561 : : }
6562 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
6563 : 0 : _Py_LeaveRecursiveCall();
6564 [ # # ]: 0 : if (res != 0) goto failed;
6565 [ # # ]: 0 : Py_CLEAR(tmp);
6566 : : }
6567 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->simple, &tmp) < 0) {
6568 : 0 : return 1;
6569 : : }
6570 [ # # ]: 0 : if (tmp == NULL) {
6571 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
6572 : 0 : return 1;
6573 : : }
6574 : : else {
6575 : : int res;
6576 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
6577 : 0 : goto failed;
6578 : : }
6579 : 0 : res = obj2ast_int(state, tmp, &simple, arena);
6580 : 0 : _Py_LeaveRecursiveCall();
6581 [ # # ]: 0 : if (res != 0) goto failed;
6582 [ # # ]: 0 : Py_CLEAR(tmp);
6583 : : }
6584 : 0 : *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
6585 : : col_offset, end_lineno, end_col_offset, arena);
6586 [ # # ]: 0 : if (*out == NULL) goto failed;
6587 : 0 : return 0;
6588 : : }
6589 : 0 : tp = state->For_type;
6590 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6591 [ # # ]: 0 : if (isinstance == -1) {
6592 : 0 : return 1;
6593 : : }
6594 [ # # ]: 0 : if (isinstance) {
6595 : : expr_ty target;
6596 : : expr_ty iter;
6597 : : asdl_stmt_seq* body;
6598 : : asdl_stmt_seq* orelse;
6599 : : string type_comment;
6600 : :
6601 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6602 : 0 : return 1;
6603 : : }
6604 [ # # ]: 0 : if (tmp == NULL) {
6605 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
6606 : 0 : return 1;
6607 : : }
6608 : : else {
6609 : : int res;
6610 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6611 : 0 : goto failed;
6612 : : }
6613 : 0 : res = obj2ast_expr(state, tmp, &target, arena);
6614 : 0 : _Py_LeaveRecursiveCall();
6615 [ # # ]: 0 : if (res != 0) goto failed;
6616 [ # # ]: 0 : Py_CLEAR(tmp);
6617 : : }
6618 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6619 : 0 : return 1;
6620 : : }
6621 [ # # ]: 0 : if (tmp == NULL) {
6622 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
6623 : 0 : return 1;
6624 : : }
6625 : : else {
6626 : : int res;
6627 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6628 : 0 : goto failed;
6629 : : }
6630 : 0 : res = obj2ast_expr(state, tmp, &iter, arena);
6631 : 0 : _Py_LeaveRecursiveCall();
6632 [ # # ]: 0 : if (res != 0) goto failed;
6633 [ # # ]: 0 : Py_CLEAR(tmp);
6634 : : }
6635 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6636 : 0 : return 1;
6637 : : }
6638 [ # # ]: 0 : if (tmp == NULL) {
6639 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
6640 : 0 : return 1;
6641 : : }
6642 : : else {
6643 : : int res;
6644 : : Py_ssize_t len;
6645 : : Py_ssize_t i;
6646 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6647 : 0 : PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6648 : 0 : goto failed;
6649 : : }
6650 : 0 : len = PyList_GET_SIZE(tmp);
6651 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
6652 [ # # ]: 0 : if (body == NULL) goto failed;
6653 [ # # ]: 0 : for (i = 0; i < len; i++) {
6654 : : stmt_ty val;
6655 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6656 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6657 : 0 : goto failed;
6658 : : }
6659 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6660 : 0 : _Py_LeaveRecursiveCall();
6661 : 0 : Py_DECREF(tmp2);
6662 [ # # ]: 0 : if (res != 0) goto failed;
6663 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6664 : 0 : PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
6665 : 0 : goto failed;
6666 : : }
6667 : 0 : asdl_seq_SET(body, i, val);
6668 : : }
6669 [ # # ]: 0 : Py_CLEAR(tmp);
6670 : : }
6671 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6672 : 0 : return 1;
6673 : : }
6674 [ # # ]: 0 : if (tmp == NULL) {
6675 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
6676 : 0 : return 1;
6677 : : }
6678 : : else {
6679 : : int res;
6680 : : Py_ssize_t len;
6681 : : Py_ssize_t i;
6682 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6683 : 0 : PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6684 : 0 : goto failed;
6685 : : }
6686 : 0 : len = PyList_GET_SIZE(tmp);
6687 : 0 : orelse = _Py_asdl_stmt_seq_new(len, arena);
6688 [ # # ]: 0 : if (orelse == NULL) goto failed;
6689 [ # # ]: 0 : for (i = 0; i < len; i++) {
6690 : : stmt_ty val;
6691 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6692 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6693 : 0 : goto failed;
6694 : : }
6695 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6696 : 0 : _Py_LeaveRecursiveCall();
6697 : 0 : Py_DECREF(tmp2);
6698 [ # # ]: 0 : if (res != 0) goto failed;
6699 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6700 : 0 : PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
6701 : 0 : goto failed;
6702 : : }
6703 : 0 : asdl_seq_SET(orelse, i, val);
6704 : : }
6705 [ # # ]: 0 : Py_CLEAR(tmp);
6706 : : }
6707 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6708 : 0 : return 1;
6709 : : }
6710 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6711 [ # # ]: 0 : Py_CLEAR(tmp);
6712 : 0 : type_comment = NULL;
6713 : : }
6714 : : else {
6715 : : int res;
6716 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
6717 : 0 : goto failed;
6718 : : }
6719 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6720 : 0 : _Py_LeaveRecursiveCall();
6721 [ # # ]: 0 : if (res != 0) goto failed;
6722 [ # # ]: 0 : Py_CLEAR(tmp);
6723 : : }
6724 : 0 : *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
6725 : : col_offset, end_lineno, end_col_offset, arena);
6726 [ # # ]: 0 : if (*out == NULL) goto failed;
6727 : 0 : return 0;
6728 : : }
6729 : 0 : tp = state->AsyncFor_type;
6730 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6731 [ # # ]: 0 : if (isinstance == -1) {
6732 : 0 : return 1;
6733 : : }
6734 [ # # ]: 0 : if (isinstance) {
6735 : : expr_ty target;
6736 : : expr_ty iter;
6737 : : asdl_stmt_seq* body;
6738 : : asdl_stmt_seq* orelse;
6739 : : string type_comment;
6740 : :
6741 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6742 : 0 : return 1;
6743 : : }
6744 [ # # ]: 0 : if (tmp == NULL) {
6745 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
6746 : 0 : return 1;
6747 : : }
6748 : : else {
6749 : : int res;
6750 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6751 : 0 : goto failed;
6752 : : }
6753 : 0 : res = obj2ast_expr(state, tmp, &target, arena);
6754 : 0 : _Py_LeaveRecursiveCall();
6755 [ # # ]: 0 : if (res != 0) goto failed;
6756 [ # # ]: 0 : Py_CLEAR(tmp);
6757 : : }
6758 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6759 : 0 : return 1;
6760 : : }
6761 [ # # ]: 0 : if (tmp == NULL) {
6762 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
6763 : 0 : return 1;
6764 : : }
6765 : : else {
6766 : : int res;
6767 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6768 : 0 : goto failed;
6769 : : }
6770 : 0 : res = obj2ast_expr(state, tmp, &iter, arena);
6771 : 0 : _Py_LeaveRecursiveCall();
6772 [ # # ]: 0 : if (res != 0) goto failed;
6773 [ # # ]: 0 : Py_CLEAR(tmp);
6774 : : }
6775 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6776 : 0 : return 1;
6777 : : }
6778 [ # # ]: 0 : if (tmp == NULL) {
6779 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFor");
6780 : 0 : return 1;
6781 : : }
6782 : : else {
6783 : : int res;
6784 : : Py_ssize_t len;
6785 : : Py_ssize_t i;
6786 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6787 : 0 : PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6788 : 0 : goto failed;
6789 : : }
6790 : 0 : len = PyList_GET_SIZE(tmp);
6791 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
6792 [ # # ]: 0 : if (body == NULL) goto failed;
6793 [ # # ]: 0 : for (i = 0; i < len; i++) {
6794 : : stmt_ty val;
6795 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6796 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6797 : 0 : goto failed;
6798 : : }
6799 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6800 : 0 : _Py_LeaveRecursiveCall();
6801 : 0 : Py_DECREF(tmp2);
6802 [ # # ]: 0 : if (res != 0) goto failed;
6803 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6804 : 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
6805 : 0 : goto failed;
6806 : : }
6807 : 0 : asdl_seq_SET(body, i, val);
6808 : : }
6809 [ # # ]: 0 : Py_CLEAR(tmp);
6810 : : }
6811 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6812 : 0 : return 1;
6813 : : }
6814 [ # # ]: 0 : if (tmp == NULL) {
6815 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from AsyncFor");
6816 : 0 : return 1;
6817 : : }
6818 : : else {
6819 : : int res;
6820 : : Py_ssize_t len;
6821 : : Py_ssize_t i;
6822 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6823 : 0 : PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6824 : 0 : goto failed;
6825 : : }
6826 : 0 : len = PyList_GET_SIZE(tmp);
6827 : 0 : orelse = _Py_asdl_stmt_seq_new(len, arena);
6828 [ # # ]: 0 : if (orelse == NULL) goto failed;
6829 [ # # ]: 0 : for (i = 0; i < len; i++) {
6830 : : stmt_ty val;
6831 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6832 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6833 : 0 : goto failed;
6834 : : }
6835 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6836 : 0 : _Py_LeaveRecursiveCall();
6837 : 0 : Py_DECREF(tmp2);
6838 [ # # ]: 0 : if (res != 0) goto failed;
6839 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6840 : 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
6841 : 0 : goto failed;
6842 : : }
6843 : 0 : asdl_seq_SET(orelse, i, val);
6844 : : }
6845 [ # # ]: 0 : Py_CLEAR(tmp);
6846 : : }
6847 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6848 : 0 : return 1;
6849 : : }
6850 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
6851 [ # # ]: 0 : Py_CLEAR(tmp);
6852 : 0 : type_comment = NULL;
6853 : : }
6854 : : else {
6855 : : int res;
6856 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
6857 : 0 : goto failed;
6858 : : }
6859 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
6860 : 0 : _Py_LeaveRecursiveCall();
6861 [ # # ]: 0 : if (res != 0) goto failed;
6862 [ # # ]: 0 : Py_CLEAR(tmp);
6863 : : }
6864 : 0 : *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
6865 : : lineno, col_offset, end_lineno, end_col_offset,
6866 : : arena);
6867 [ # # ]: 0 : if (*out == NULL) goto failed;
6868 : 0 : return 0;
6869 : : }
6870 : 0 : tp = state->While_type;
6871 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6872 [ # # ]: 0 : if (isinstance == -1) {
6873 : 0 : return 1;
6874 : : }
6875 [ # # ]: 0 : if (isinstance) {
6876 : : expr_ty test;
6877 : : asdl_stmt_seq* body;
6878 : : asdl_stmt_seq* orelse;
6879 : :
6880 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6881 : 0 : return 1;
6882 : : }
6883 [ # # ]: 0 : if (tmp == NULL) {
6884 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
6885 : 0 : return 1;
6886 : : }
6887 : : else {
6888 : : int res;
6889 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6890 : 0 : goto failed;
6891 : : }
6892 : 0 : res = obj2ast_expr(state, tmp, &test, arena);
6893 : 0 : _Py_LeaveRecursiveCall();
6894 [ # # ]: 0 : if (res != 0) goto failed;
6895 [ # # ]: 0 : Py_CLEAR(tmp);
6896 : : }
6897 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6898 : 0 : return 1;
6899 : : }
6900 [ # # ]: 0 : if (tmp == NULL) {
6901 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
6902 : 0 : return 1;
6903 : : }
6904 : : else {
6905 : : int res;
6906 : : Py_ssize_t len;
6907 : : Py_ssize_t i;
6908 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6909 : 0 : PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6910 : 0 : goto failed;
6911 : : }
6912 : 0 : len = PyList_GET_SIZE(tmp);
6913 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
6914 [ # # ]: 0 : if (body == NULL) goto failed;
6915 [ # # ]: 0 : for (i = 0; i < len; i++) {
6916 : : stmt_ty val;
6917 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6918 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6919 : 0 : goto failed;
6920 : : }
6921 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6922 : 0 : _Py_LeaveRecursiveCall();
6923 : 0 : Py_DECREF(tmp2);
6924 [ # # ]: 0 : if (res != 0) goto failed;
6925 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6926 : 0 : PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
6927 : 0 : goto failed;
6928 : : }
6929 : 0 : asdl_seq_SET(body, i, val);
6930 : : }
6931 [ # # ]: 0 : Py_CLEAR(tmp);
6932 : : }
6933 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6934 : 0 : return 1;
6935 : : }
6936 [ # # ]: 0 : if (tmp == NULL) {
6937 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
6938 : 0 : return 1;
6939 : : }
6940 : : else {
6941 : : int res;
6942 : : Py_ssize_t len;
6943 : : Py_ssize_t i;
6944 [ # # ]: 0 : if (!PyList_Check(tmp)) {
6945 : 0 : PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
6946 : 0 : goto failed;
6947 : : }
6948 : 0 : len = PyList_GET_SIZE(tmp);
6949 : 0 : orelse = _Py_asdl_stmt_seq_new(len, arena);
6950 [ # # ]: 0 : if (orelse == NULL) goto failed;
6951 [ # # ]: 0 : for (i = 0; i < len; i++) {
6952 : : stmt_ty val;
6953 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
6954 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
6955 : 0 : goto failed;
6956 : : }
6957 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
6958 : 0 : _Py_LeaveRecursiveCall();
6959 : 0 : Py_DECREF(tmp2);
6960 [ # # ]: 0 : if (res != 0) goto failed;
6961 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
6962 : 0 : PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
6963 : 0 : goto failed;
6964 : : }
6965 : 0 : asdl_seq_SET(orelse, i, val);
6966 : : }
6967 [ # # ]: 0 : Py_CLEAR(tmp);
6968 : : }
6969 : 0 : *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
6970 : : end_col_offset, arena);
6971 [ # # ]: 0 : if (*out == NULL) goto failed;
6972 : 0 : return 0;
6973 : : }
6974 : 0 : tp = state->If_type;
6975 : 0 : isinstance = PyObject_IsInstance(obj, tp);
6976 [ # # ]: 0 : if (isinstance == -1) {
6977 : 0 : return 1;
6978 : : }
6979 [ # # ]: 0 : if (isinstance) {
6980 : : expr_ty test;
6981 : : asdl_stmt_seq* body;
6982 : : asdl_stmt_seq* orelse;
6983 : :
6984 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6985 : 0 : return 1;
6986 : : }
6987 [ # # ]: 0 : if (tmp == NULL) {
6988 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
6989 : 0 : return 1;
6990 : : }
6991 : : else {
6992 : : int res;
6993 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
6994 : 0 : goto failed;
6995 : : }
6996 : 0 : res = obj2ast_expr(state, tmp, &test, arena);
6997 : 0 : _Py_LeaveRecursiveCall();
6998 [ # # ]: 0 : if (res != 0) goto failed;
6999 [ # # ]: 0 : Py_CLEAR(tmp);
7000 : : }
7001 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7002 : 0 : return 1;
7003 : : }
7004 [ # # ]: 0 : if (tmp == NULL) {
7005 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
7006 : 0 : return 1;
7007 : : }
7008 : : else {
7009 : : int res;
7010 : : Py_ssize_t len;
7011 : : Py_ssize_t i;
7012 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7013 : 0 : PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7014 : 0 : goto failed;
7015 : : }
7016 : 0 : len = PyList_GET_SIZE(tmp);
7017 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
7018 [ # # ]: 0 : if (body == NULL) goto failed;
7019 [ # # ]: 0 : for (i = 0; i < len; i++) {
7020 : : stmt_ty val;
7021 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7022 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
7023 : 0 : goto failed;
7024 : : }
7025 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7026 : 0 : _Py_LeaveRecursiveCall();
7027 : 0 : Py_DECREF(tmp2);
7028 [ # # ]: 0 : if (res != 0) goto failed;
7029 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7030 : 0 : PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
7031 : 0 : goto failed;
7032 : : }
7033 : 0 : asdl_seq_SET(body, i, val);
7034 : : }
7035 [ # # ]: 0 : Py_CLEAR(tmp);
7036 : : }
7037 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7038 : 0 : return 1;
7039 : : }
7040 [ # # ]: 0 : if (tmp == NULL) {
7041 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
7042 : 0 : return 1;
7043 : : }
7044 : : else {
7045 : : int res;
7046 : : Py_ssize_t len;
7047 : : Py_ssize_t i;
7048 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7049 : 0 : PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7050 : 0 : goto failed;
7051 : : }
7052 : 0 : len = PyList_GET_SIZE(tmp);
7053 : 0 : orelse = _Py_asdl_stmt_seq_new(len, arena);
7054 [ # # ]: 0 : if (orelse == NULL) goto failed;
7055 [ # # ]: 0 : for (i = 0; i < len; i++) {
7056 : : stmt_ty val;
7057 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7058 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
7059 : 0 : goto failed;
7060 : : }
7061 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7062 : 0 : _Py_LeaveRecursiveCall();
7063 : 0 : Py_DECREF(tmp2);
7064 [ # # ]: 0 : if (res != 0) goto failed;
7065 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7066 : 0 : PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
7067 : 0 : goto failed;
7068 : : }
7069 : 0 : asdl_seq_SET(orelse, i, val);
7070 : : }
7071 [ # # ]: 0 : Py_CLEAR(tmp);
7072 : : }
7073 : 0 : *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
7074 : : end_col_offset, arena);
7075 [ # # ]: 0 : if (*out == NULL) goto failed;
7076 : 0 : return 0;
7077 : : }
7078 : 0 : tp = state->With_type;
7079 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7080 [ # # ]: 0 : if (isinstance == -1) {
7081 : 0 : return 1;
7082 : : }
7083 [ # # ]: 0 : if (isinstance) {
7084 : : asdl_withitem_seq* items;
7085 : : asdl_stmt_seq* body;
7086 : : string type_comment;
7087 : :
7088 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7089 : 0 : return 1;
7090 : : }
7091 [ # # ]: 0 : if (tmp == NULL) {
7092 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
7093 : 0 : return 1;
7094 : : }
7095 : : else {
7096 : : int res;
7097 : : Py_ssize_t len;
7098 : : Py_ssize_t i;
7099 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7100 : 0 : PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7101 : 0 : goto failed;
7102 : : }
7103 : 0 : len = PyList_GET_SIZE(tmp);
7104 : 0 : items = _Py_asdl_withitem_seq_new(len, arena);
7105 [ # # ]: 0 : if (items == NULL) goto failed;
7106 [ # # ]: 0 : for (i = 0; i < len; i++) {
7107 : : withitem_ty val;
7108 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7109 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7110 : 0 : goto failed;
7111 : : }
7112 : 0 : res = obj2ast_withitem(state, tmp2, &val, arena);
7113 : 0 : _Py_LeaveRecursiveCall();
7114 : 0 : Py_DECREF(tmp2);
7115 [ # # ]: 0 : if (res != 0) goto failed;
7116 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7117 : 0 : PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
7118 : 0 : goto failed;
7119 : : }
7120 : 0 : asdl_seq_SET(items, i, val);
7121 : : }
7122 [ # # ]: 0 : Py_CLEAR(tmp);
7123 : : }
7124 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7125 : 0 : return 1;
7126 : : }
7127 [ # # ]: 0 : if (tmp == NULL) {
7128 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
7129 : 0 : return 1;
7130 : : }
7131 : : else {
7132 : : int res;
7133 : : Py_ssize_t len;
7134 : : Py_ssize_t i;
7135 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7136 : 0 : PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7137 : 0 : goto failed;
7138 : : }
7139 : 0 : len = PyList_GET_SIZE(tmp);
7140 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
7141 [ # # ]: 0 : if (body == NULL) goto failed;
7142 [ # # ]: 0 : for (i = 0; i < len; i++) {
7143 : : stmt_ty val;
7144 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7145 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7146 : 0 : goto failed;
7147 : : }
7148 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7149 : 0 : _Py_LeaveRecursiveCall();
7150 : 0 : Py_DECREF(tmp2);
7151 [ # # ]: 0 : if (res != 0) goto failed;
7152 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7153 : 0 : PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
7154 : 0 : goto failed;
7155 : : }
7156 : 0 : asdl_seq_SET(body, i, val);
7157 : : }
7158 [ # # ]: 0 : Py_CLEAR(tmp);
7159 : : }
7160 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7161 : 0 : return 1;
7162 : : }
7163 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7164 [ # # ]: 0 : Py_CLEAR(tmp);
7165 : 0 : type_comment = NULL;
7166 : : }
7167 : : else {
7168 : : int res;
7169 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
7170 : 0 : goto failed;
7171 : : }
7172 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
7173 : 0 : _Py_LeaveRecursiveCall();
7174 [ # # ]: 0 : if (res != 0) goto failed;
7175 [ # # ]: 0 : Py_CLEAR(tmp);
7176 : : }
7177 : 0 : *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
7178 : : end_lineno, end_col_offset, arena);
7179 [ # # ]: 0 : if (*out == NULL) goto failed;
7180 : 0 : return 0;
7181 : : }
7182 : 0 : tp = state->AsyncWith_type;
7183 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7184 [ # # ]: 0 : if (isinstance == -1) {
7185 : 0 : return 1;
7186 : : }
7187 [ # # ]: 0 : if (isinstance) {
7188 : : asdl_withitem_seq* items;
7189 : : asdl_stmt_seq* body;
7190 : : string type_comment;
7191 : :
7192 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7193 : 0 : return 1;
7194 : : }
7195 [ # # ]: 0 : if (tmp == NULL) {
7196 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from AsyncWith");
7197 : 0 : return 1;
7198 : : }
7199 : : else {
7200 : : int res;
7201 : : Py_ssize_t len;
7202 : : Py_ssize_t i;
7203 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7204 : 0 : PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7205 : 0 : goto failed;
7206 : : }
7207 : 0 : len = PyList_GET_SIZE(tmp);
7208 : 0 : items = _Py_asdl_withitem_seq_new(len, arena);
7209 [ # # ]: 0 : if (items == NULL) goto failed;
7210 [ # # ]: 0 : for (i = 0; i < len; i++) {
7211 : : withitem_ty val;
7212 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7213 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7214 : 0 : goto failed;
7215 : : }
7216 : 0 : res = obj2ast_withitem(state, tmp2, &val, arena);
7217 : 0 : _Py_LeaveRecursiveCall();
7218 : 0 : Py_DECREF(tmp2);
7219 [ # # ]: 0 : if (res != 0) goto failed;
7220 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7221 : 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
7222 : 0 : goto failed;
7223 : : }
7224 : 0 : asdl_seq_SET(items, i, val);
7225 : : }
7226 [ # # ]: 0 : Py_CLEAR(tmp);
7227 : : }
7228 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7229 : 0 : return 1;
7230 : : }
7231 [ # # ]: 0 : if (tmp == NULL) {
7232 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncWith");
7233 : 0 : return 1;
7234 : : }
7235 : : else {
7236 : : int res;
7237 : : Py_ssize_t len;
7238 : : Py_ssize_t i;
7239 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7240 : 0 : PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7241 : 0 : goto failed;
7242 : : }
7243 : 0 : len = PyList_GET_SIZE(tmp);
7244 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
7245 [ # # ]: 0 : if (body == NULL) goto failed;
7246 [ # # ]: 0 : for (i = 0; i < len; i++) {
7247 : : stmt_ty val;
7248 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7249 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7250 : 0 : goto failed;
7251 : : }
7252 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7253 : 0 : _Py_LeaveRecursiveCall();
7254 : 0 : Py_DECREF(tmp2);
7255 [ # # ]: 0 : if (res != 0) goto failed;
7256 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7257 : 0 : PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
7258 : 0 : goto failed;
7259 : : }
7260 : 0 : asdl_seq_SET(body, i, val);
7261 : : }
7262 [ # # ]: 0 : Py_CLEAR(tmp);
7263 : : }
7264 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7265 : 0 : return 1;
7266 : : }
7267 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7268 [ # # ]: 0 : Py_CLEAR(tmp);
7269 : 0 : type_comment = NULL;
7270 : : }
7271 : : else {
7272 : : int res;
7273 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
7274 : 0 : goto failed;
7275 : : }
7276 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
7277 : 0 : _Py_LeaveRecursiveCall();
7278 [ # # ]: 0 : if (res != 0) goto failed;
7279 [ # # ]: 0 : Py_CLEAR(tmp);
7280 : : }
7281 : 0 : *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
7282 : : end_lineno, end_col_offset, arena);
7283 [ # # ]: 0 : if (*out == NULL) goto failed;
7284 : 0 : return 0;
7285 : : }
7286 : 0 : tp = state->Match_type;
7287 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7288 [ # # ]: 0 : if (isinstance == -1) {
7289 : 0 : return 1;
7290 : : }
7291 [ # # ]: 0 : if (isinstance) {
7292 : : expr_ty subject;
7293 : : asdl_match_case_seq* cases;
7294 : :
7295 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) {
7296 : 0 : return 1;
7297 : : }
7298 [ # # ]: 0 : if (tmp == NULL) {
7299 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
7300 : 0 : return 1;
7301 : : }
7302 : : else {
7303 : : int res;
7304 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
7305 : 0 : goto failed;
7306 : : }
7307 : 0 : res = obj2ast_expr(state, tmp, &subject, arena);
7308 : 0 : _Py_LeaveRecursiveCall();
7309 [ # # ]: 0 : if (res != 0) goto failed;
7310 [ # # ]: 0 : Py_CLEAR(tmp);
7311 : : }
7312 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->cases, &tmp) < 0) {
7313 : 0 : return 1;
7314 : : }
7315 [ # # ]: 0 : if (tmp == NULL) {
7316 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"cases\" missing from Match");
7317 : 0 : return 1;
7318 : : }
7319 : : else {
7320 : : int res;
7321 : : Py_ssize_t len;
7322 : : Py_ssize_t i;
7323 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7324 : 0 : PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7325 : 0 : goto failed;
7326 : : }
7327 : 0 : len = PyList_GET_SIZE(tmp);
7328 : 0 : cases = _Py_asdl_match_case_seq_new(len, arena);
7329 [ # # ]: 0 : if (cases == NULL) goto failed;
7330 [ # # ]: 0 : for (i = 0; i < len; i++) {
7331 : : match_case_ty val;
7332 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7333 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
7334 : 0 : goto failed;
7335 : : }
7336 : 0 : res = obj2ast_match_case(state, tmp2, &val, arena);
7337 : 0 : _Py_LeaveRecursiveCall();
7338 : 0 : Py_DECREF(tmp2);
7339 [ # # ]: 0 : if (res != 0) goto failed;
7340 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7341 : 0 : PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
7342 : 0 : goto failed;
7343 : : }
7344 : 0 : asdl_seq_SET(cases, i, val);
7345 : : }
7346 [ # # ]: 0 : Py_CLEAR(tmp);
7347 : : }
7348 : 0 : *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
7349 : : end_col_offset, arena);
7350 [ # # ]: 0 : if (*out == NULL) goto failed;
7351 : 0 : return 0;
7352 : : }
7353 : 0 : tp = state->Raise_type;
7354 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7355 [ # # ]: 0 : if (isinstance == -1) {
7356 : 0 : return 1;
7357 : : }
7358 [ # # ]: 0 : if (isinstance) {
7359 : : expr_ty exc;
7360 : : expr_ty cause;
7361 : :
7362 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->exc, &tmp) < 0) {
7363 : 0 : return 1;
7364 : : }
7365 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7366 [ # # ]: 0 : Py_CLEAR(tmp);
7367 : 0 : exc = NULL;
7368 : : }
7369 : : else {
7370 : : int res;
7371 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
7372 : 0 : goto failed;
7373 : : }
7374 : 0 : res = obj2ast_expr(state, tmp, &exc, arena);
7375 : 0 : _Py_LeaveRecursiveCall();
7376 [ # # ]: 0 : if (res != 0) goto failed;
7377 [ # # ]: 0 : Py_CLEAR(tmp);
7378 : : }
7379 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->cause, &tmp) < 0) {
7380 : 0 : return 1;
7381 : : }
7382 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7383 [ # # ]: 0 : Py_CLEAR(tmp);
7384 : 0 : cause = NULL;
7385 : : }
7386 : : else {
7387 : : int res;
7388 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
7389 : 0 : goto failed;
7390 : : }
7391 : 0 : res = obj2ast_expr(state, tmp, &cause, arena);
7392 : 0 : _Py_LeaveRecursiveCall();
7393 [ # # ]: 0 : if (res != 0) goto failed;
7394 [ # # ]: 0 : Py_CLEAR(tmp);
7395 : : }
7396 : 0 : *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
7397 : : end_col_offset, arena);
7398 [ # # ]: 0 : if (*out == NULL) goto failed;
7399 : 0 : return 0;
7400 : : }
7401 : 0 : tp = state->Try_type;
7402 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7403 [ # # ]: 0 : if (isinstance == -1) {
7404 : 0 : return 1;
7405 : : }
7406 [ # # ]: 0 : if (isinstance) {
7407 : : asdl_stmt_seq* body;
7408 : : asdl_excepthandler_seq* handlers;
7409 : : asdl_stmt_seq* orelse;
7410 : : asdl_stmt_seq* finalbody;
7411 : :
7412 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7413 : 0 : return 1;
7414 : : }
7415 [ # # ]: 0 : if (tmp == NULL) {
7416 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
7417 : 0 : return 1;
7418 : : }
7419 : : else {
7420 : : int res;
7421 : : Py_ssize_t len;
7422 : : Py_ssize_t i;
7423 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7424 : 0 : PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7425 : 0 : goto failed;
7426 : : }
7427 : 0 : len = PyList_GET_SIZE(tmp);
7428 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
7429 [ # # ]: 0 : if (body == NULL) goto failed;
7430 [ # # ]: 0 : for (i = 0; i < len; i++) {
7431 : : stmt_ty val;
7432 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7433 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7434 : 0 : goto failed;
7435 : : }
7436 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7437 : 0 : _Py_LeaveRecursiveCall();
7438 : 0 : Py_DECREF(tmp2);
7439 [ # # ]: 0 : if (res != 0) goto failed;
7440 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7441 : 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
7442 : 0 : goto failed;
7443 : : }
7444 : 0 : asdl_seq_SET(body, i, val);
7445 : : }
7446 [ # # ]: 0 : Py_CLEAR(tmp);
7447 : : }
7448 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7449 : 0 : return 1;
7450 : : }
7451 [ # # ]: 0 : if (tmp == NULL) {
7452 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
7453 : 0 : return 1;
7454 : : }
7455 : : else {
7456 : : int res;
7457 : : Py_ssize_t len;
7458 : : Py_ssize_t i;
7459 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7460 : 0 : PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7461 : 0 : goto failed;
7462 : : }
7463 : 0 : len = PyList_GET_SIZE(tmp);
7464 : 0 : handlers = _Py_asdl_excepthandler_seq_new(len, arena);
7465 [ # # ]: 0 : if (handlers == NULL) goto failed;
7466 [ # # ]: 0 : for (i = 0; i < len; i++) {
7467 : : excepthandler_ty val;
7468 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7469 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7470 : 0 : goto failed;
7471 : : }
7472 : 0 : res = obj2ast_excepthandler(state, tmp2, &val, arena);
7473 : 0 : _Py_LeaveRecursiveCall();
7474 : 0 : Py_DECREF(tmp2);
7475 [ # # ]: 0 : if (res != 0) goto failed;
7476 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7477 : 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
7478 : 0 : goto failed;
7479 : : }
7480 : 0 : asdl_seq_SET(handlers, i, val);
7481 : : }
7482 [ # # ]: 0 : Py_CLEAR(tmp);
7483 : : }
7484 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7485 : 0 : return 1;
7486 : : }
7487 [ # # ]: 0 : if (tmp == NULL) {
7488 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
7489 : 0 : return 1;
7490 : : }
7491 : : else {
7492 : : int res;
7493 : : Py_ssize_t len;
7494 : : Py_ssize_t i;
7495 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7496 : 0 : PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7497 : 0 : goto failed;
7498 : : }
7499 : 0 : len = PyList_GET_SIZE(tmp);
7500 : 0 : orelse = _Py_asdl_stmt_seq_new(len, arena);
7501 [ # # ]: 0 : if (orelse == NULL) goto failed;
7502 [ # # ]: 0 : for (i = 0; i < len; i++) {
7503 : : stmt_ty val;
7504 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7505 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7506 : 0 : goto failed;
7507 : : }
7508 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7509 : 0 : _Py_LeaveRecursiveCall();
7510 : 0 : Py_DECREF(tmp2);
7511 [ # # ]: 0 : if (res != 0) goto failed;
7512 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7513 : 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
7514 : 0 : goto failed;
7515 : : }
7516 : 0 : asdl_seq_SET(orelse, i, val);
7517 : : }
7518 [ # # ]: 0 : Py_CLEAR(tmp);
7519 : : }
7520 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7521 : 0 : return 1;
7522 : : }
7523 [ # # ]: 0 : if (tmp == NULL) {
7524 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
7525 : 0 : return 1;
7526 : : }
7527 : : else {
7528 : : int res;
7529 : : Py_ssize_t len;
7530 : : Py_ssize_t i;
7531 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7532 : 0 : PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7533 : 0 : goto failed;
7534 : : }
7535 : 0 : len = PyList_GET_SIZE(tmp);
7536 : 0 : finalbody = _Py_asdl_stmt_seq_new(len, arena);
7537 [ # # ]: 0 : if (finalbody == NULL) goto failed;
7538 [ # # ]: 0 : for (i = 0; i < len; i++) {
7539 : : stmt_ty val;
7540 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7541 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
7542 : 0 : goto failed;
7543 : : }
7544 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7545 : 0 : _Py_LeaveRecursiveCall();
7546 : 0 : Py_DECREF(tmp2);
7547 [ # # ]: 0 : if (res != 0) goto failed;
7548 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7549 : 0 : PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
7550 : 0 : goto failed;
7551 : : }
7552 : 0 : asdl_seq_SET(finalbody, i, val);
7553 : : }
7554 [ # # ]: 0 : Py_CLEAR(tmp);
7555 : : }
7556 : 0 : *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
7557 : : col_offset, end_lineno, end_col_offset, arena);
7558 [ # # ]: 0 : if (*out == NULL) goto failed;
7559 : 0 : return 0;
7560 : : }
7561 : 0 : tp = state->TryStar_type;
7562 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7563 [ # # ]: 0 : if (isinstance == -1) {
7564 : 0 : return 1;
7565 : : }
7566 [ # # ]: 0 : if (isinstance) {
7567 : : asdl_stmt_seq* body;
7568 : : asdl_excepthandler_seq* handlers;
7569 : : asdl_stmt_seq* orelse;
7570 : : asdl_stmt_seq* finalbody;
7571 : :
7572 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7573 : 0 : return 1;
7574 : : }
7575 [ # # ]: 0 : if (tmp == NULL) {
7576 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from TryStar");
7577 : 0 : return 1;
7578 : : }
7579 : : else {
7580 : : int res;
7581 : : Py_ssize_t len;
7582 : : Py_ssize_t i;
7583 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7584 : 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7585 : 0 : goto failed;
7586 : : }
7587 : 0 : len = PyList_GET_SIZE(tmp);
7588 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
7589 [ # # ]: 0 : if (body == NULL) goto failed;
7590 [ # # ]: 0 : for (i = 0; i < len; i++) {
7591 : : stmt_ty val;
7592 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7593 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7594 : 0 : goto failed;
7595 : : }
7596 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7597 : 0 : _Py_LeaveRecursiveCall();
7598 : 0 : Py_DECREF(tmp2);
7599 [ # # ]: 0 : if (res != 0) goto failed;
7600 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7601 : 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
7602 : 0 : goto failed;
7603 : : }
7604 : 0 : asdl_seq_SET(body, i, val);
7605 : : }
7606 [ # # ]: 0 : Py_CLEAR(tmp);
7607 : : }
7608 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7609 : 0 : return 1;
7610 : : }
7611 [ # # ]: 0 : if (tmp == NULL) {
7612 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from TryStar");
7613 : 0 : return 1;
7614 : : }
7615 : : else {
7616 : : int res;
7617 : : Py_ssize_t len;
7618 : : Py_ssize_t i;
7619 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7620 : 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7621 : 0 : goto failed;
7622 : : }
7623 : 0 : len = PyList_GET_SIZE(tmp);
7624 : 0 : handlers = _Py_asdl_excepthandler_seq_new(len, arena);
7625 [ # # ]: 0 : if (handlers == NULL) goto failed;
7626 [ # # ]: 0 : for (i = 0; i < len; i++) {
7627 : : excepthandler_ty val;
7628 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7629 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7630 : 0 : goto failed;
7631 : : }
7632 : 0 : res = obj2ast_excepthandler(state, tmp2, &val, arena);
7633 : 0 : _Py_LeaveRecursiveCall();
7634 : 0 : Py_DECREF(tmp2);
7635 [ # # ]: 0 : if (res != 0) goto failed;
7636 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7637 : 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
7638 : 0 : goto failed;
7639 : : }
7640 : 0 : asdl_seq_SET(handlers, i, val);
7641 : : }
7642 [ # # ]: 0 : Py_CLEAR(tmp);
7643 : : }
7644 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7645 : 0 : return 1;
7646 : : }
7647 [ # # ]: 0 : if (tmp == NULL) {
7648 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from TryStar");
7649 : 0 : return 1;
7650 : : }
7651 : : else {
7652 : : int res;
7653 : : Py_ssize_t len;
7654 : : Py_ssize_t i;
7655 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7656 : 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7657 : 0 : goto failed;
7658 : : }
7659 : 0 : len = PyList_GET_SIZE(tmp);
7660 : 0 : orelse = _Py_asdl_stmt_seq_new(len, arena);
7661 [ # # ]: 0 : if (orelse == NULL) goto failed;
7662 [ # # ]: 0 : for (i = 0; i < len; i++) {
7663 : : stmt_ty val;
7664 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7665 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7666 : 0 : goto failed;
7667 : : }
7668 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7669 : 0 : _Py_LeaveRecursiveCall();
7670 : 0 : Py_DECREF(tmp2);
7671 [ # # ]: 0 : if (res != 0) goto failed;
7672 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7673 : 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
7674 : 0 : goto failed;
7675 : : }
7676 : 0 : asdl_seq_SET(orelse, i, val);
7677 : : }
7678 [ # # ]: 0 : Py_CLEAR(tmp);
7679 : : }
7680 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7681 : 0 : return 1;
7682 : : }
7683 [ # # ]: 0 : if (tmp == NULL) {
7684 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from TryStar");
7685 : 0 : return 1;
7686 : : }
7687 : : else {
7688 : : int res;
7689 : : Py_ssize_t len;
7690 : : Py_ssize_t i;
7691 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7692 : 0 : PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7693 : 0 : goto failed;
7694 : : }
7695 : 0 : len = PyList_GET_SIZE(tmp);
7696 : 0 : finalbody = _Py_asdl_stmt_seq_new(len, arena);
7697 [ # # ]: 0 : if (finalbody == NULL) goto failed;
7698 [ # # ]: 0 : for (i = 0; i < len; i++) {
7699 : : stmt_ty val;
7700 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7701 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
7702 : 0 : goto failed;
7703 : : }
7704 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
7705 : 0 : _Py_LeaveRecursiveCall();
7706 : 0 : Py_DECREF(tmp2);
7707 [ # # ]: 0 : if (res != 0) goto failed;
7708 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7709 : 0 : PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
7710 : 0 : goto failed;
7711 : : }
7712 : 0 : asdl_seq_SET(finalbody, i, val);
7713 : : }
7714 [ # # ]: 0 : Py_CLEAR(tmp);
7715 : : }
7716 : 0 : *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
7717 : : col_offset, end_lineno, end_col_offset, arena);
7718 [ # # ]: 0 : if (*out == NULL) goto failed;
7719 : 0 : return 0;
7720 : : }
7721 : 0 : tp = state->Assert_type;
7722 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7723 [ # # ]: 0 : if (isinstance == -1) {
7724 : 0 : return 1;
7725 : : }
7726 [ # # ]: 0 : if (isinstance) {
7727 : : expr_ty test;
7728 : : expr_ty msg;
7729 : :
7730 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
7731 : 0 : return 1;
7732 : : }
7733 [ # # ]: 0 : if (tmp == NULL) {
7734 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
7735 : 0 : return 1;
7736 : : }
7737 : : else {
7738 : : int res;
7739 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
7740 : 0 : goto failed;
7741 : : }
7742 : 0 : res = obj2ast_expr(state, tmp, &test, arena);
7743 : 0 : _Py_LeaveRecursiveCall();
7744 [ # # ]: 0 : if (res != 0) goto failed;
7745 [ # # ]: 0 : Py_CLEAR(tmp);
7746 : : }
7747 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->msg, &tmp) < 0) {
7748 : 0 : return 1;
7749 : : }
7750 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7751 [ # # ]: 0 : Py_CLEAR(tmp);
7752 : 0 : msg = NULL;
7753 : : }
7754 : : else {
7755 : : int res;
7756 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
7757 : 0 : goto failed;
7758 : : }
7759 : 0 : res = obj2ast_expr(state, tmp, &msg, arena);
7760 : 0 : _Py_LeaveRecursiveCall();
7761 [ # # ]: 0 : if (res != 0) goto failed;
7762 [ # # ]: 0 : Py_CLEAR(tmp);
7763 : : }
7764 : 0 : *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
7765 : : end_col_offset, arena);
7766 [ # # ]: 0 : if (*out == NULL) goto failed;
7767 : 0 : return 0;
7768 : : }
7769 : 0 : tp = state->Import_type;
7770 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7771 [ # # ]: 0 : if (isinstance == -1) {
7772 : 0 : return 1;
7773 : : }
7774 [ # # ]: 0 : if (isinstance) {
7775 : : asdl_alias_seq* names;
7776 : :
7777 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7778 : 0 : return 1;
7779 : : }
7780 [ # # ]: 0 : if (tmp == NULL) {
7781 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
7782 : 0 : return 1;
7783 : : }
7784 : : else {
7785 : : int res;
7786 : : Py_ssize_t len;
7787 : : Py_ssize_t i;
7788 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7789 : 0 : PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7790 : 0 : goto failed;
7791 : : }
7792 : 0 : len = PyList_GET_SIZE(tmp);
7793 : 0 : names = _Py_asdl_alias_seq_new(len, arena);
7794 [ # # ]: 0 : if (names == NULL) goto failed;
7795 [ # # ]: 0 : for (i = 0; i < len; i++) {
7796 : : alias_ty val;
7797 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7798 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
7799 : 0 : goto failed;
7800 : : }
7801 : 0 : res = obj2ast_alias(state, tmp2, &val, arena);
7802 : 0 : _Py_LeaveRecursiveCall();
7803 : 0 : Py_DECREF(tmp2);
7804 [ # # ]: 0 : if (res != 0) goto failed;
7805 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7806 : 0 : PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
7807 : 0 : goto failed;
7808 : : }
7809 : 0 : asdl_seq_SET(names, i, val);
7810 : : }
7811 [ # # ]: 0 : Py_CLEAR(tmp);
7812 : : }
7813 : 0 : *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
7814 : : end_col_offset, arena);
7815 [ # # ]: 0 : if (*out == NULL) goto failed;
7816 : 0 : return 0;
7817 : : }
7818 : 0 : tp = state->ImportFrom_type;
7819 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7820 [ # # ]: 0 : if (isinstance == -1) {
7821 : 0 : return 1;
7822 : : }
7823 [ # # ]: 0 : if (isinstance) {
7824 : : identifier module;
7825 : : asdl_alias_seq* names;
7826 : : int level;
7827 : :
7828 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->module, &tmp) < 0) {
7829 : 0 : return 1;
7830 : : }
7831 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7832 [ # # ]: 0 : Py_CLEAR(tmp);
7833 : 0 : module = NULL;
7834 : : }
7835 : : else {
7836 : : int res;
7837 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7838 : 0 : goto failed;
7839 : : }
7840 : 0 : res = obj2ast_identifier(state, tmp, &module, arena);
7841 : 0 : _Py_LeaveRecursiveCall();
7842 [ # # ]: 0 : if (res != 0) goto failed;
7843 [ # # ]: 0 : Py_CLEAR(tmp);
7844 : : }
7845 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7846 : 0 : return 1;
7847 : : }
7848 [ # # ]: 0 : if (tmp == NULL) {
7849 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
7850 : 0 : return 1;
7851 : : }
7852 : : else {
7853 : : int res;
7854 : : Py_ssize_t len;
7855 : : Py_ssize_t i;
7856 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7857 : 0 : PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7858 : 0 : goto failed;
7859 : : }
7860 : 0 : len = PyList_GET_SIZE(tmp);
7861 : 0 : names = _Py_asdl_alias_seq_new(len, arena);
7862 [ # # ]: 0 : if (names == NULL) goto failed;
7863 [ # # ]: 0 : for (i = 0; i < len; i++) {
7864 : : alias_ty val;
7865 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7866 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7867 : 0 : goto failed;
7868 : : }
7869 : 0 : res = obj2ast_alias(state, tmp2, &val, arena);
7870 : 0 : _Py_LeaveRecursiveCall();
7871 : 0 : Py_DECREF(tmp2);
7872 [ # # ]: 0 : if (res != 0) goto failed;
7873 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7874 : 0 : PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
7875 : 0 : goto failed;
7876 : : }
7877 : 0 : asdl_seq_SET(names, i, val);
7878 : : }
7879 [ # # ]: 0 : Py_CLEAR(tmp);
7880 : : }
7881 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->level, &tmp) < 0) {
7882 : 0 : return 1;
7883 : : }
7884 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
7885 [ # # ]: 0 : Py_CLEAR(tmp);
7886 : 0 : level = 0;
7887 : : }
7888 : : else {
7889 : : int res;
7890 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
7891 : 0 : goto failed;
7892 : : }
7893 : 0 : res = obj2ast_int(state, tmp, &level, arena);
7894 : 0 : _Py_LeaveRecursiveCall();
7895 [ # # ]: 0 : if (res != 0) goto failed;
7896 [ # # ]: 0 : Py_CLEAR(tmp);
7897 : : }
7898 : 0 : *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
7899 : : end_lineno, end_col_offset, arena);
7900 [ # # ]: 0 : if (*out == NULL) goto failed;
7901 : 0 : return 0;
7902 : : }
7903 : 0 : tp = state->Global_type;
7904 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7905 [ # # ]: 0 : if (isinstance == -1) {
7906 : 0 : return 1;
7907 : : }
7908 [ # # ]: 0 : if (isinstance) {
7909 : : asdl_identifier_seq* names;
7910 : :
7911 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7912 : 0 : return 1;
7913 : : }
7914 [ # # ]: 0 : if (tmp == NULL) {
7915 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
7916 : 0 : return 1;
7917 : : }
7918 : : else {
7919 : : int res;
7920 : : Py_ssize_t len;
7921 : : Py_ssize_t i;
7922 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7923 : 0 : PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7924 : 0 : goto failed;
7925 : : }
7926 : 0 : len = PyList_GET_SIZE(tmp);
7927 : 0 : names = _Py_asdl_identifier_seq_new(len, arena);
7928 [ # # ]: 0 : if (names == NULL) goto failed;
7929 [ # # ]: 0 : for (i = 0; i < len; i++) {
7930 : : identifier val;
7931 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7932 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
7933 : 0 : goto failed;
7934 : : }
7935 : 0 : res = obj2ast_identifier(state, tmp2, &val, arena);
7936 : 0 : _Py_LeaveRecursiveCall();
7937 : 0 : Py_DECREF(tmp2);
7938 [ # # ]: 0 : if (res != 0) goto failed;
7939 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7940 : 0 : PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
7941 : 0 : goto failed;
7942 : : }
7943 : 0 : asdl_seq_SET(names, i, val);
7944 : : }
7945 [ # # ]: 0 : Py_CLEAR(tmp);
7946 : : }
7947 : 0 : *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
7948 : : end_col_offset, arena);
7949 [ # # ]: 0 : if (*out == NULL) goto failed;
7950 : 0 : return 0;
7951 : : }
7952 : 0 : tp = state->Nonlocal_type;
7953 : 0 : isinstance = PyObject_IsInstance(obj, tp);
7954 [ # # ]: 0 : if (isinstance == -1) {
7955 : 0 : return 1;
7956 : : }
7957 [ # # ]: 0 : if (isinstance) {
7958 : : asdl_identifier_seq* names;
7959 : :
7960 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7961 : 0 : return 1;
7962 : : }
7963 [ # # ]: 0 : if (tmp == NULL) {
7964 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
7965 : 0 : return 1;
7966 : : }
7967 : : else {
7968 : : int res;
7969 : : Py_ssize_t len;
7970 : : Py_ssize_t i;
7971 [ # # ]: 0 : if (!PyList_Check(tmp)) {
7972 : 0 : PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
7973 : 0 : goto failed;
7974 : : }
7975 : 0 : len = PyList_GET_SIZE(tmp);
7976 : 0 : names = _Py_asdl_identifier_seq_new(len, arena);
7977 [ # # ]: 0 : if (names == NULL) goto failed;
7978 [ # # ]: 0 : for (i = 0; i < len; i++) {
7979 : : identifier val;
7980 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7981 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
7982 : 0 : goto failed;
7983 : : }
7984 : 0 : res = obj2ast_identifier(state, tmp2, &val, arena);
7985 : 0 : _Py_LeaveRecursiveCall();
7986 : 0 : Py_DECREF(tmp2);
7987 [ # # ]: 0 : if (res != 0) goto failed;
7988 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
7989 : 0 : PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
7990 : 0 : goto failed;
7991 : : }
7992 : 0 : asdl_seq_SET(names, i, val);
7993 : : }
7994 [ # # ]: 0 : Py_CLEAR(tmp);
7995 : : }
7996 : 0 : *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
7997 : : end_col_offset, arena);
7998 [ # # ]: 0 : if (*out == NULL) goto failed;
7999 : 0 : return 0;
8000 : : }
8001 : 0 : tp = state->Expr_type;
8002 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8003 [ # # ]: 0 : if (isinstance == -1) {
8004 : 0 : return 1;
8005 : : }
8006 [ # # ]: 0 : if (isinstance) {
8007 : : expr_ty value;
8008 : :
8009 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8010 : 0 : return 1;
8011 : : }
8012 [ # # ]: 0 : if (tmp == NULL) {
8013 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
8014 : 0 : return 1;
8015 : : }
8016 : : else {
8017 : : int res;
8018 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
8019 : 0 : goto failed;
8020 : : }
8021 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
8022 : 0 : _Py_LeaveRecursiveCall();
8023 [ # # ]: 0 : if (res != 0) goto failed;
8024 [ # # ]: 0 : Py_CLEAR(tmp);
8025 : : }
8026 : 0 : *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
8027 : : end_col_offset, arena);
8028 [ # # ]: 0 : if (*out == NULL) goto failed;
8029 : 0 : return 0;
8030 : : }
8031 : 0 : tp = state->Pass_type;
8032 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8033 [ # # ]: 0 : if (isinstance == -1) {
8034 : 0 : return 1;
8035 : : }
8036 [ # # ]: 0 : if (isinstance) {
8037 : :
8038 : 0 : *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
8039 : : arena);
8040 [ # # ]: 0 : if (*out == NULL) goto failed;
8041 : 0 : return 0;
8042 : : }
8043 : 0 : tp = state->Break_type;
8044 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8045 [ # # ]: 0 : if (isinstance == -1) {
8046 : 0 : return 1;
8047 : : }
8048 [ # # ]: 0 : if (isinstance) {
8049 : :
8050 : 0 : *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
8051 : : arena);
8052 [ # # ]: 0 : if (*out == NULL) goto failed;
8053 : 0 : return 0;
8054 : : }
8055 : 0 : tp = state->Continue_type;
8056 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8057 [ # # ]: 0 : if (isinstance == -1) {
8058 : 0 : return 1;
8059 : : }
8060 [ # # ]: 0 : if (isinstance) {
8061 : :
8062 : 0 : *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
8063 : : arena);
8064 [ # # ]: 0 : if (*out == NULL) goto failed;
8065 : 0 : return 0;
8066 : : }
8067 : :
8068 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
8069 : 0 : failed:
8070 : 0 : Py_XDECREF(tmp);
8071 : 0 : return 1;
8072 : : }
8073 : :
8074 : : int
8075 : 0 : obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
8076 : : arena)
8077 : : {
8078 : : int isinstance;
8079 : :
8080 : 0 : PyObject *tmp = NULL;
8081 : : PyObject *tp;
8082 : : int lineno;
8083 : : int col_offset;
8084 : : int end_lineno;
8085 : : int end_col_offset;
8086 : :
8087 [ # # ]: 0 : if (obj == Py_None) {
8088 : 0 : *out = NULL;
8089 : 0 : return 0;
8090 : : }
8091 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
8092 : 0 : return 1;
8093 : : }
8094 [ # # ]: 0 : if (tmp == NULL) {
8095 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
8096 : 0 : return 1;
8097 : : }
8098 : : else {
8099 : : int res;
8100 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8101 : 0 : goto failed;
8102 : : }
8103 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
8104 : 0 : _Py_LeaveRecursiveCall();
8105 [ # # ]: 0 : if (res != 0) goto failed;
8106 [ # # ]: 0 : Py_CLEAR(tmp);
8107 : : }
8108 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
8109 : 0 : return 1;
8110 : : }
8111 [ # # ]: 0 : if (tmp == NULL) {
8112 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
8113 : 0 : return 1;
8114 : : }
8115 : : else {
8116 : : int res;
8117 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8118 : 0 : goto failed;
8119 : : }
8120 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
8121 : 0 : _Py_LeaveRecursiveCall();
8122 [ # # ]: 0 : if (res != 0) goto failed;
8123 [ # # ]: 0 : Py_CLEAR(tmp);
8124 : : }
8125 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
8126 : 0 : return 1;
8127 : : }
8128 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
8129 [ # # ]: 0 : Py_CLEAR(tmp);
8130 : 0 : end_lineno = lineno;
8131 : : }
8132 : : else {
8133 : : int res;
8134 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8135 : 0 : goto failed;
8136 : : }
8137 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
8138 : 0 : _Py_LeaveRecursiveCall();
8139 [ # # ]: 0 : if (res != 0) goto failed;
8140 [ # # ]: 0 : Py_CLEAR(tmp);
8141 : : }
8142 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
8143 : 0 : return 1;
8144 : : }
8145 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
8146 [ # # ]: 0 : Py_CLEAR(tmp);
8147 : 0 : end_col_offset = col_offset;
8148 : : }
8149 : : else {
8150 : : int res;
8151 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
8152 : 0 : goto failed;
8153 : : }
8154 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
8155 : 0 : _Py_LeaveRecursiveCall();
8156 [ # # ]: 0 : if (res != 0) goto failed;
8157 [ # # ]: 0 : Py_CLEAR(tmp);
8158 : : }
8159 : 0 : tp = state->BoolOp_type;
8160 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8161 [ # # ]: 0 : if (isinstance == -1) {
8162 : 0 : return 1;
8163 : : }
8164 [ # # ]: 0 : if (isinstance) {
8165 : : boolop_ty op;
8166 : : asdl_expr_seq* values;
8167 : :
8168 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8169 : 0 : return 1;
8170 : : }
8171 [ # # ]: 0 : if (tmp == NULL) {
8172 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
8173 : 0 : return 1;
8174 : : }
8175 : : else {
8176 : : int res;
8177 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
8178 : 0 : goto failed;
8179 : : }
8180 : 0 : res = obj2ast_boolop(state, tmp, &op, arena);
8181 : 0 : _Py_LeaveRecursiveCall();
8182 [ # # ]: 0 : if (res != 0) goto failed;
8183 [ # # ]: 0 : Py_CLEAR(tmp);
8184 : : }
8185 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8186 : 0 : return 1;
8187 : : }
8188 [ # # ]: 0 : if (tmp == NULL) {
8189 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
8190 : 0 : return 1;
8191 : : }
8192 : : else {
8193 : : int res;
8194 : : Py_ssize_t len;
8195 : : Py_ssize_t i;
8196 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8197 : 0 : PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8198 : 0 : goto failed;
8199 : : }
8200 : 0 : len = PyList_GET_SIZE(tmp);
8201 : 0 : values = _Py_asdl_expr_seq_new(len, arena);
8202 [ # # ]: 0 : if (values == NULL) goto failed;
8203 [ # # ]: 0 : for (i = 0; i < len; i++) {
8204 : : expr_ty val;
8205 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8206 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
8207 : 0 : goto failed;
8208 : : }
8209 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
8210 : 0 : _Py_LeaveRecursiveCall();
8211 : 0 : Py_DECREF(tmp2);
8212 [ # # ]: 0 : if (res != 0) goto failed;
8213 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8214 : 0 : PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
8215 : 0 : goto failed;
8216 : : }
8217 : 0 : asdl_seq_SET(values, i, val);
8218 : : }
8219 [ # # ]: 0 : Py_CLEAR(tmp);
8220 : : }
8221 : 0 : *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
8222 : : end_col_offset, arena);
8223 [ # # ]: 0 : if (*out == NULL) goto failed;
8224 : 0 : return 0;
8225 : : }
8226 : 0 : tp = state->NamedExpr_type;
8227 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8228 [ # # ]: 0 : if (isinstance == -1) {
8229 : 0 : return 1;
8230 : : }
8231 [ # # ]: 0 : if (isinstance) {
8232 : : expr_ty target;
8233 : : expr_ty value;
8234 : :
8235 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
8236 : 0 : return 1;
8237 : : }
8238 [ # # ]: 0 : if (tmp == NULL) {
8239 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
8240 : 0 : return 1;
8241 : : }
8242 : : else {
8243 : : int res;
8244 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
8245 : 0 : goto failed;
8246 : : }
8247 : 0 : res = obj2ast_expr(state, tmp, &target, arena);
8248 : 0 : _Py_LeaveRecursiveCall();
8249 [ # # ]: 0 : if (res != 0) goto failed;
8250 [ # # ]: 0 : Py_CLEAR(tmp);
8251 : : }
8252 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8253 : 0 : return 1;
8254 : : }
8255 [ # # ]: 0 : if (tmp == NULL) {
8256 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
8257 : 0 : return 1;
8258 : : }
8259 : : else {
8260 : : int res;
8261 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
8262 : 0 : goto failed;
8263 : : }
8264 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
8265 : 0 : _Py_LeaveRecursiveCall();
8266 [ # # ]: 0 : if (res != 0) goto failed;
8267 [ # # ]: 0 : Py_CLEAR(tmp);
8268 : : }
8269 : 0 : *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
8270 : : end_col_offset, arena);
8271 [ # # ]: 0 : if (*out == NULL) goto failed;
8272 : 0 : return 0;
8273 : : }
8274 : 0 : tp = state->BinOp_type;
8275 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8276 [ # # ]: 0 : if (isinstance == -1) {
8277 : 0 : return 1;
8278 : : }
8279 [ # # ]: 0 : if (isinstance) {
8280 : : expr_ty left;
8281 : : operator_ty op;
8282 : : expr_ty right;
8283 : :
8284 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
8285 : 0 : return 1;
8286 : : }
8287 [ # # ]: 0 : if (tmp == NULL) {
8288 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
8289 : 0 : return 1;
8290 : : }
8291 : : else {
8292 : : int res;
8293 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8294 : 0 : goto failed;
8295 : : }
8296 : 0 : res = obj2ast_expr(state, tmp, &left, arena);
8297 : 0 : _Py_LeaveRecursiveCall();
8298 [ # # ]: 0 : if (res != 0) goto failed;
8299 [ # # ]: 0 : Py_CLEAR(tmp);
8300 : : }
8301 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8302 : 0 : return 1;
8303 : : }
8304 [ # # ]: 0 : if (tmp == NULL) {
8305 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
8306 : 0 : return 1;
8307 : : }
8308 : : else {
8309 : : int res;
8310 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8311 : 0 : goto failed;
8312 : : }
8313 : 0 : res = obj2ast_operator(state, tmp, &op, arena);
8314 : 0 : _Py_LeaveRecursiveCall();
8315 [ # # ]: 0 : if (res != 0) goto failed;
8316 [ # # ]: 0 : Py_CLEAR(tmp);
8317 : : }
8318 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->right, &tmp) < 0) {
8319 : 0 : return 1;
8320 : : }
8321 [ # # ]: 0 : if (tmp == NULL) {
8322 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
8323 : 0 : return 1;
8324 : : }
8325 : : else {
8326 : : int res;
8327 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
8328 : 0 : goto failed;
8329 : : }
8330 : 0 : res = obj2ast_expr(state, tmp, &right, arena);
8331 : 0 : _Py_LeaveRecursiveCall();
8332 [ # # ]: 0 : if (res != 0) goto failed;
8333 [ # # ]: 0 : Py_CLEAR(tmp);
8334 : : }
8335 : 0 : *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
8336 : : end_col_offset, arena);
8337 [ # # ]: 0 : if (*out == NULL) goto failed;
8338 : 0 : return 0;
8339 : : }
8340 : 0 : tp = state->UnaryOp_type;
8341 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8342 [ # # ]: 0 : if (isinstance == -1) {
8343 : 0 : return 1;
8344 : : }
8345 [ # # ]: 0 : if (isinstance) {
8346 : : unaryop_ty op;
8347 : : expr_ty operand;
8348 : :
8349 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8350 : 0 : return 1;
8351 : : }
8352 [ # # ]: 0 : if (tmp == NULL) {
8353 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
8354 : 0 : return 1;
8355 : : }
8356 : : else {
8357 : : int res;
8358 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
8359 : 0 : goto failed;
8360 : : }
8361 : 0 : res = obj2ast_unaryop(state, tmp, &op, arena);
8362 : 0 : _Py_LeaveRecursiveCall();
8363 [ # # ]: 0 : if (res != 0) goto failed;
8364 [ # # ]: 0 : Py_CLEAR(tmp);
8365 : : }
8366 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->operand, &tmp) < 0) {
8367 : 0 : return 1;
8368 : : }
8369 [ # # ]: 0 : if (tmp == NULL) {
8370 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
8371 : 0 : return 1;
8372 : : }
8373 : : else {
8374 : : int res;
8375 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
8376 : 0 : goto failed;
8377 : : }
8378 : 0 : res = obj2ast_expr(state, tmp, &operand, arena);
8379 : 0 : _Py_LeaveRecursiveCall();
8380 [ # # ]: 0 : if (res != 0) goto failed;
8381 [ # # ]: 0 : Py_CLEAR(tmp);
8382 : : }
8383 : 0 : *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
8384 : : end_col_offset, arena);
8385 [ # # ]: 0 : if (*out == NULL) goto failed;
8386 : 0 : return 0;
8387 : : }
8388 : 0 : tp = state->Lambda_type;
8389 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8390 [ # # ]: 0 : if (isinstance == -1) {
8391 : 0 : return 1;
8392 : : }
8393 [ # # ]: 0 : if (isinstance) {
8394 : : arguments_ty args;
8395 : : expr_ty body;
8396 : :
8397 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
8398 : 0 : return 1;
8399 : : }
8400 [ # # ]: 0 : if (tmp == NULL) {
8401 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
8402 : 0 : return 1;
8403 : : }
8404 : : else {
8405 : : int res;
8406 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
8407 : 0 : goto failed;
8408 : : }
8409 : 0 : res = obj2ast_arguments(state, tmp, &args, arena);
8410 : 0 : _Py_LeaveRecursiveCall();
8411 [ # # ]: 0 : if (res != 0) goto failed;
8412 [ # # ]: 0 : Py_CLEAR(tmp);
8413 : : }
8414 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8415 : 0 : return 1;
8416 : : }
8417 [ # # ]: 0 : if (tmp == NULL) {
8418 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
8419 : 0 : return 1;
8420 : : }
8421 : : else {
8422 : : int res;
8423 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
8424 : 0 : goto failed;
8425 : : }
8426 : 0 : res = obj2ast_expr(state, tmp, &body, arena);
8427 : 0 : _Py_LeaveRecursiveCall();
8428 [ # # ]: 0 : if (res != 0) goto failed;
8429 [ # # ]: 0 : Py_CLEAR(tmp);
8430 : : }
8431 : 0 : *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
8432 : : end_col_offset, arena);
8433 [ # # ]: 0 : if (*out == NULL) goto failed;
8434 : 0 : return 0;
8435 : : }
8436 : 0 : tp = state->IfExp_type;
8437 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8438 [ # # ]: 0 : if (isinstance == -1) {
8439 : 0 : return 1;
8440 : : }
8441 [ # # ]: 0 : if (isinstance) {
8442 : : expr_ty test;
8443 : : expr_ty body;
8444 : : expr_ty orelse;
8445 : :
8446 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
8447 : 0 : return 1;
8448 : : }
8449 [ # # ]: 0 : if (tmp == NULL) {
8450 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
8451 : 0 : return 1;
8452 : : }
8453 : : else {
8454 : : int res;
8455 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8456 : 0 : goto failed;
8457 : : }
8458 : 0 : res = obj2ast_expr(state, tmp, &test, arena);
8459 : 0 : _Py_LeaveRecursiveCall();
8460 [ # # ]: 0 : if (res != 0) goto failed;
8461 [ # # ]: 0 : Py_CLEAR(tmp);
8462 : : }
8463 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8464 : 0 : return 1;
8465 : : }
8466 [ # # ]: 0 : if (tmp == NULL) {
8467 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
8468 : 0 : return 1;
8469 : : }
8470 : : else {
8471 : : int res;
8472 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8473 : 0 : goto failed;
8474 : : }
8475 : 0 : res = obj2ast_expr(state, tmp, &body, arena);
8476 : 0 : _Py_LeaveRecursiveCall();
8477 [ # # ]: 0 : if (res != 0) goto failed;
8478 [ # # ]: 0 : Py_CLEAR(tmp);
8479 : : }
8480 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
8481 : 0 : return 1;
8482 : : }
8483 [ # # ]: 0 : if (tmp == NULL) {
8484 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
8485 : 0 : return 1;
8486 : : }
8487 : : else {
8488 : : int res;
8489 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
8490 : 0 : goto failed;
8491 : : }
8492 : 0 : res = obj2ast_expr(state, tmp, &orelse, arena);
8493 : 0 : _Py_LeaveRecursiveCall();
8494 [ # # ]: 0 : if (res != 0) goto failed;
8495 [ # # ]: 0 : Py_CLEAR(tmp);
8496 : : }
8497 : 0 : *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
8498 : : end_col_offset, arena);
8499 [ # # ]: 0 : if (*out == NULL) goto failed;
8500 : 0 : return 0;
8501 : : }
8502 : 0 : tp = state->Dict_type;
8503 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8504 [ # # ]: 0 : if (isinstance == -1) {
8505 : 0 : return 1;
8506 : : }
8507 [ # # ]: 0 : if (isinstance) {
8508 : : asdl_expr_seq* keys;
8509 : : asdl_expr_seq* values;
8510 : :
8511 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
8512 : 0 : return 1;
8513 : : }
8514 [ # # ]: 0 : if (tmp == NULL) {
8515 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
8516 : 0 : return 1;
8517 : : }
8518 : : else {
8519 : : int res;
8520 : : Py_ssize_t len;
8521 : : Py_ssize_t i;
8522 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8523 : 0 : PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8524 : 0 : goto failed;
8525 : : }
8526 : 0 : len = PyList_GET_SIZE(tmp);
8527 : 0 : keys = _Py_asdl_expr_seq_new(len, arena);
8528 [ # # ]: 0 : if (keys == NULL) goto failed;
8529 [ # # ]: 0 : for (i = 0; i < len; i++) {
8530 : : expr_ty val;
8531 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8532 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
8533 : 0 : goto failed;
8534 : : }
8535 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
8536 : 0 : _Py_LeaveRecursiveCall();
8537 : 0 : Py_DECREF(tmp2);
8538 [ # # ]: 0 : if (res != 0) goto failed;
8539 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8540 : 0 : PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
8541 : 0 : goto failed;
8542 : : }
8543 : 0 : asdl_seq_SET(keys, i, val);
8544 : : }
8545 [ # # ]: 0 : Py_CLEAR(tmp);
8546 : : }
8547 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8548 : 0 : return 1;
8549 : : }
8550 [ # # ]: 0 : if (tmp == NULL) {
8551 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
8552 : 0 : return 1;
8553 : : }
8554 : : else {
8555 : : int res;
8556 : : Py_ssize_t len;
8557 : : Py_ssize_t i;
8558 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8559 : 0 : PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8560 : 0 : goto failed;
8561 : : }
8562 : 0 : len = PyList_GET_SIZE(tmp);
8563 : 0 : values = _Py_asdl_expr_seq_new(len, arena);
8564 [ # # ]: 0 : if (values == NULL) goto failed;
8565 [ # # ]: 0 : for (i = 0; i < len; i++) {
8566 : : expr_ty val;
8567 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8568 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
8569 : 0 : goto failed;
8570 : : }
8571 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
8572 : 0 : _Py_LeaveRecursiveCall();
8573 : 0 : Py_DECREF(tmp2);
8574 [ # # ]: 0 : if (res != 0) goto failed;
8575 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8576 : 0 : PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
8577 : 0 : goto failed;
8578 : : }
8579 : 0 : asdl_seq_SET(values, i, val);
8580 : : }
8581 [ # # ]: 0 : Py_CLEAR(tmp);
8582 : : }
8583 : 0 : *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
8584 : : end_col_offset, arena);
8585 [ # # ]: 0 : if (*out == NULL) goto failed;
8586 : 0 : return 0;
8587 : : }
8588 : 0 : tp = state->Set_type;
8589 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8590 [ # # ]: 0 : if (isinstance == -1) {
8591 : 0 : return 1;
8592 : : }
8593 [ # # ]: 0 : if (isinstance) {
8594 : : asdl_expr_seq* elts;
8595 : :
8596 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
8597 : 0 : return 1;
8598 : : }
8599 [ # # ]: 0 : if (tmp == NULL) {
8600 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
8601 : 0 : return 1;
8602 : : }
8603 : : else {
8604 : : int res;
8605 : : Py_ssize_t len;
8606 : : Py_ssize_t i;
8607 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8608 : 0 : PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8609 : 0 : goto failed;
8610 : : }
8611 : 0 : len = PyList_GET_SIZE(tmp);
8612 : 0 : elts = _Py_asdl_expr_seq_new(len, arena);
8613 [ # # ]: 0 : if (elts == NULL) goto failed;
8614 [ # # ]: 0 : for (i = 0; i < len; i++) {
8615 : : expr_ty val;
8616 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8617 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
8618 : 0 : goto failed;
8619 : : }
8620 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
8621 : 0 : _Py_LeaveRecursiveCall();
8622 : 0 : Py_DECREF(tmp2);
8623 [ # # ]: 0 : if (res != 0) goto failed;
8624 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8625 : 0 : PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
8626 : 0 : goto failed;
8627 : : }
8628 : 0 : asdl_seq_SET(elts, i, val);
8629 : : }
8630 [ # # ]: 0 : Py_CLEAR(tmp);
8631 : : }
8632 : 0 : *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
8633 : : arena);
8634 [ # # ]: 0 : if (*out == NULL) goto failed;
8635 : 0 : return 0;
8636 : : }
8637 : 0 : tp = state->ListComp_type;
8638 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8639 [ # # ]: 0 : if (isinstance == -1) {
8640 : 0 : return 1;
8641 : : }
8642 [ # # ]: 0 : if (isinstance) {
8643 : : expr_ty elt;
8644 : : asdl_comprehension_seq* generators;
8645 : :
8646 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8647 : 0 : return 1;
8648 : : }
8649 [ # # ]: 0 : if (tmp == NULL) {
8650 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
8651 : 0 : return 1;
8652 : : }
8653 : : else {
8654 : : int res;
8655 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
8656 : 0 : goto failed;
8657 : : }
8658 : 0 : res = obj2ast_expr(state, tmp, &elt, arena);
8659 : 0 : _Py_LeaveRecursiveCall();
8660 [ # # ]: 0 : if (res != 0) goto failed;
8661 [ # # ]: 0 : Py_CLEAR(tmp);
8662 : : }
8663 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8664 : 0 : return 1;
8665 : : }
8666 [ # # ]: 0 : if (tmp == NULL) {
8667 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
8668 : 0 : return 1;
8669 : : }
8670 : : else {
8671 : : int res;
8672 : : Py_ssize_t len;
8673 : : Py_ssize_t i;
8674 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8675 : 0 : PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8676 : 0 : goto failed;
8677 : : }
8678 : 0 : len = PyList_GET_SIZE(tmp);
8679 : 0 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8680 [ # # ]: 0 : if (generators == NULL) goto failed;
8681 [ # # ]: 0 : for (i = 0; i < len; i++) {
8682 : : comprehension_ty val;
8683 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8684 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
8685 : 0 : goto failed;
8686 : : }
8687 : 0 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8688 : 0 : _Py_LeaveRecursiveCall();
8689 : 0 : Py_DECREF(tmp2);
8690 [ # # ]: 0 : if (res != 0) goto failed;
8691 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8692 : 0 : PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
8693 : 0 : goto failed;
8694 : : }
8695 : 0 : asdl_seq_SET(generators, i, val);
8696 : : }
8697 [ # # ]: 0 : Py_CLEAR(tmp);
8698 : : }
8699 : 0 : *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
8700 : : end_col_offset, arena);
8701 [ # # ]: 0 : if (*out == NULL) goto failed;
8702 : 0 : return 0;
8703 : : }
8704 : 0 : tp = state->SetComp_type;
8705 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8706 [ # # ]: 0 : if (isinstance == -1) {
8707 : 0 : return 1;
8708 : : }
8709 [ # # ]: 0 : if (isinstance) {
8710 : : expr_ty elt;
8711 : : asdl_comprehension_seq* generators;
8712 : :
8713 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8714 : 0 : return 1;
8715 : : }
8716 [ # # ]: 0 : if (tmp == NULL) {
8717 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
8718 : 0 : return 1;
8719 : : }
8720 : : else {
8721 : : int res;
8722 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
8723 : 0 : goto failed;
8724 : : }
8725 : 0 : res = obj2ast_expr(state, tmp, &elt, arena);
8726 : 0 : _Py_LeaveRecursiveCall();
8727 [ # # ]: 0 : if (res != 0) goto failed;
8728 [ # # ]: 0 : Py_CLEAR(tmp);
8729 : : }
8730 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8731 : 0 : return 1;
8732 : : }
8733 [ # # ]: 0 : if (tmp == NULL) {
8734 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
8735 : 0 : return 1;
8736 : : }
8737 : : else {
8738 : : int res;
8739 : : Py_ssize_t len;
8740 : : Py_ssize_t i;
8741 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8742 : 0 : PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8743 : 0 : goto failed;
8744 : : }
8745 : 0 : len = PyList_GET_SIZE(tmp);
8746 : 0 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8747 [ # # ]: 0 : if (generators == NULL) goto failed;
8748 [ # # ]: 0 : for (i = 0; i < len; i++) {
8749 : : comprehension_ty val;
8750 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8751 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
8752 : 0 : goto failed;
8753 : : }
8754 : 0 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8755 : 0 : _Py_LeaveRecursiveCall();
8756 : 0 : Py_DECREF(tmp2);
8757 [ # # ]: 0 : if (res != 0) goto failed;
8758 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8759 : 0 : PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
8760 : 0 : goto failed;
8761 : : }
8762 : 0 : asdl_seq_SET(generators, i, val);
8763 : : }
8764 [ # # ]: 0 : Py_CLEAR(tmp);
8765 : : }
8766 : 0 : *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
8767 : : end_col_offset, arena);
8768 [ # # ]: 0 : if (*out == NULL) goto failed;
8769 : 0 : return 0;
8770 : : }
8771 : 0 : tp = state->DictComp_type;
8772 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8773 [ # # ]: 0 : if (isinstance == -1) {
8774 : 0 : return 1;
8775 : : }
8776 [ # # ]: 0 : if (isinstance) {
8777 : : expr_ty key;
8778 : : expr_ty value;
8779 : : asdl_comprehension_seq* generators;
8780 : :
8781 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->key, &tmp) < 0) {
8782 : 0 : return 1;
8783 : : }
8784 [ # # ]: 0 : if (tmp == NULL) {
8785 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
8786 : 0 : return 1;
8787 : : }
8788 : : else {
8789 : : int res;
8790 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8791 : 0 : goto failed;
8792 : : }
8793 : 0 : res = obj2ast_expr(state, tmp, &key, arena);
8794 : 0 : _Py_LeaveRecursiveCall();
8795 [ # # ]: 0 : if (res != 0) goto failed;
8796 [ # # ]: 0 : Py_CLEAR(tmp);
8797 : : }
8798 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8799 : 0 : return 1;
8800 : : }
8801 [ # # ]: 0 : if (tmp == NULL) {
8802 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
8803 : 0 : return 1;
8804 : : }
8805 : : else {
8806 : : int res;
8807 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8808 : 0 : goto failed;
8809 : : }
8810 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
8811 : 0 : _Py_LeaveRecursiveCall();
8812 [ # # ]: 0 : if (res != 0) goto failed;
8813 [ # # ]: 0 : Py_CLEAR(tmp);
8814 : : }
8815 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8816 : 0 : return 1;
8817 : : }
8818 [ # # ]: 0 : if (tmp == NULL) {
8819 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
8820 : 0 : return 1;
8821 : : }
8822 : : else {
8823 : : int res;
8824 : : Py_ssize_t len;
8825 : : Py_ssize_t i;
8826 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8827 : 0 : PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8828 : 0 : goto failed;
8829 : : }
8830 : 0 : len = PyList_GET_SIZE(tmp);
8831 : 0 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8832 [ # # ]: 0 : if (generators == NULL) goto failed;
8833 [ # # ]: 0 : for (i = 0; i < len; i++) {
8834 : : comprehension_ty val;
8835 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8836 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
8837 : 0 : goto failed;
8838 : : }
8839 : 0 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8840 : 0 : _Py_LeaveRecursiveCall();
8841 : 0 : Py_DECREF(tmp2);
8842 [ # # ]: 0 : if (res != 0) goto failed;
8843 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8844 : 0 : PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
8845 : 0 : goto failed;
8846 : : }
8847 : 0 : asdl_seq_SET(generators, i, val);
8848 : : }
8849 [ # # ]: 0 : Py_CLEAR(tmp);
8850 : : }
8851 : 0 : *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
8852 : : end_lineno, end_col_offset, arena);
8853 [ # # ]: 0 : if (*out == NULL) goto failed;
8854 : 0 : return 0;
8855 : : }
8856 : 0 : tp = state->GeneratorExp_type;
8857 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8858 [ # # ]: 0 : if (isinstance == -1) {
8859 : 0 : return 1;
8860 : : }
8861 [ # # ]: 0 : if (isinstance) {
8862 : : expr_ty elt;
8863 : : asdl_comprehension_seq* generators;
8864 : :
8865 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8866 : 0 : return 1;
8867 : : }
8868 [ # # ]: 0 : if (tmp == NULL) {
8869 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
8870 : 0 : return 1;
8871 : : }
8872 : : else {
8873 : : int res;
8874 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
8875 : 0 : goto failed;
8876 : : }
8877 : 0 : res = obj2ast_expr(state, tmp, &elt, arena);
8878 : 0 : _Py_LeaveRecursiveCall();
8879 [ # # ]: 0 : if (res != 0) goto failed;
8880 [ # # ]: 0 : Py_CLEAR(tmp);
8881 : : }
8882 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8883 : 0 : return 1;
8884 : : }
8885 [ # # ]: 0 : if (tmp == NULL) {
8886 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
8887 : 0 : return 1;
8888 : : }
8889 : : else {
8890 : : int res;
8891 : : Py_ssize_t len;
8892 : : Py_ssize_t i;
8893 [ # # ]: 0 : if (!PyList_Check(tmp)) {
8894 : 0 : PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
8895 : 0 : goto failed;
8896 : : }
8897 : 0 : len = PyList_GET_SIZE(tmp);
8898 : 0 : generators = _Py_asdl_comprehension_seq_new(len, arena);
8899 [ # # ]: 0 : if (generators == NULL) goto failed;
8900 [ # # ]: 0 : for (i = 0; i < len; i++) {
8901 : : comprehension_ty val;
8902 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8903 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
8904 : 0 : goto failed;
8905 : : }
8906 : 0 : res = obj2ast_comprehension(state, tmp2, &val, arena);
8907 : 0 : _Py_LeaveRecursiveCall();
8908 : 0 : Py_DECREF(tmp2);
8909 [ # # ]: 0 : if (res != 0) goto failed;
8910 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
8911 : 0 : PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
8912 : 0 : goto failed;
8913 : : }
8914 : 0 : asdl_seq_SET(generators, i, val);
8915 : : }
8916 [ # # ]: 0 : Py_CLEAR(tmp);
8917 : : }
8918 : 0 : *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
8919 : : end_lineno, end_col_offset, arena);
8920 [ # # ]: 0 : if (*out == NULL) goto failed;
8921 : 0 : return 0;
8922 : : }
8923 : 0 : tp = state->Await_type;
8924 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8925 [ # # ]: 0 : if (isinstance == -1) {
8926 : 0 : return 1;
8927 : : }
8928 [ # # ]: 0 : if (isinstance) {
8929 : : expr_ty value;
8930 : :
8931 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8932 : 0 : return 1;
8933 : : }
8934 [ # # ]: 0 : if (tmp == NULL) {
8935 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
8936 : 0 : return 1;
8937 : : }
8938 : : else {
8939 : : int res;
8940 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
8941 : 0 : goto failed;
8942 : : }
8943 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
8944 : 0 : _Py_LeaveRecursiveCall();
8945 [ # # ]: 0 : if (res != 0) goto failed;
8946 [ # # ]: 0 : Py_CLEAR(tmp);
8947 : : }
8948 : 0 : *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
8949 : : end_col_offset, arena);
8950 [ # # ]: 0 : if (*out == NULL) goto failed;
8951 : 0 : return 0;
8952 : : }
8953 : 0 : tp = state->Yield_type;
8954 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8955 [ # # ]: 0 : if (isinstance == -1) {
8956 : 0 : return 1;
8957 : : }
8958 [ # # ]: 0 : if (isinstance) {
8959 : : expr_ty value;
8960 : :
8961 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8962 : 0 : return 1;
8963 : : }
8964 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
8965 [ # # ]: 0 : Py_CLEAR(tmp);
8966 : 0 : value = NULL;
8967 : : }
8968 : : else {
8969 : : int res;
8970 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
8971 : 0 : goto failed;
8972 : : }
8973 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
8974 : 0 : _Py_LeaveRecursiveCall();
8975 [ # # ]: 0 : if (res != 0) goto failed;
8976 [ # # ]: 0 : Py_CLEAR(tmp);
8977 : : }
8978 : 0 : *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
8979 : : end_col_offset, arena);
8980 [ # # ]: 0 : if (*out == NULL) goto failed;
8981 : 0 : return 0;
8982 : : }
8983 : 0 : tp = state->YieldFrom_type;
8984 : 0 : isinstance = PyObject_IsInstance(obj, tp);
8985 [ # # ]: 0 : if (isinstance == -1) {
8986 : 0 : return 1;
8987 : : }
8988 [ # # ]: 0 : if (isinstance) {
8989 : : expr_ty value;
8990 : :
8991 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8992 : 0 : return 1;
8993 : : }
8994 [ # # ]: 0 : if (tmp == NULL) {
8995 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
8996 : 0 : return 1;
8997 : : }
8998 : : else {
8999 : : int res;
9000 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
9001 : 0 : goto failed;
9002 : : }
9003 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
9004 : 0 : _Py_LeaveRecursiveCall();
9005 [ # # ]: 0 : if (res != 0) goto failed;
9006 [ # # ]: 0 : Py_CLEAR(tmp);
9007 : : }
9008 : 0 : *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
9009 : : end_col_offset, arena);
9010 [ # # ]: 0 : if (*out == NULL) goto failed;
9011 : 0 : return 0;
9012 : : }
9013 : 0 : tp = state->Compare_type;
9014 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9015 [ # # ]: 0 : if (isinstance == -1) {
9016 : 0 : return 1;
9017 : : }
9018 [ # # ]: 0 : if (isinstance) {
9019 : : expr_ty left;
9020 : : asdl_int_seq* ops;
9021 : : asdl_expr_seq* comparators;
9022 : :
9023 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
9024 : 0 : return 1;
9025 : : }
9026 [ # # ]: 0 : if (tmp == NULL) {
9027 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
9028 : 0 : return 1;
9029 : : }
9030 : : else {
9031 : : int res;
9032 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9033 : 0 : goto failed;
9034 : : }
9035 : 0 : res = obj2ast_expr(state, tmp, &left, arena);
9036 : 0 : _Py_LeaveRecursiveCall();
9037 [ # # ]: 0 : if (res != 0) goto failed;
9038 [ # # ]: 0 : Py_CLEAR(tmp);
9039 : : }
9040 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ops, &tmp) < 0) {
9041 : 0 : return 1;
9042 : : }
9043 [ # # ]: 0 : if (tmp == NULL) {
9044 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
9045 : 0 : return 1;
9046 : : }
9047 : : else {
9048 : : int res;
9049 : : Py_ssize_t len;
9050 : : Py_ssize_t i;
9051 [ # # ]: 0 : if (!PyList_Check(tmp)) {
9052 : 0 : PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9053 : 0 : goto failed;
9054 : : }
9055 : 0 : len = PyList_GET_SIZE(tmp);
9056 : 0 : ops = _Py_asdl_int_seq_new(len, arena);
9057 [ # # ]: 0 : if (ops == NULL) goto failed;
9058 [ # # ]: 0 : for (i = 0; i < len; i++) {
9059 : : cmpop_ty val;
9060 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9061 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9062 : 0 : goto failed;
9063 : : }
9064 : 0 : res = obj2ast_cmpop(state, tmp2, &val, arena);
9065 : 0 : _Py_LeaveRecursiveCall();
9066 : 0 : Py_DECREF(tmp2);
9067 [ # # ]: 0 : if (res != 0) goto failed;
9068 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
9069 : 0 : PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
9070 : 0 : goto failed;
9071 : : }
9072 : 0 : asdl_seq_SET(ops, i, val);
9073 : : }
9074 [ # # ]: 0 : Py_CLEAR(tmp);
9075 : : }
9076 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->comparators, &tmp) < 0) {
9077 : 0 : return 1;
9078 : : }
9079 [ # # ]: 0 : if (tmp == NULL) {
9080 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
9081 : 0 : return 1;
9082 : : }
9083 : : else {
9084 : : int res;
9085 : : Py_ssize_t len;
9086 : : Py_ssize_t i;
9087 [ # # ]: 0 : if (!PyList_Check(tmp)) {
9088 : 0 : PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9089 : 0 : goto failed;
9090 : : }
9091 : 0 : len = PyList_GET_SIZE(tmp);
9092 : 0 : comparators = _Py_asdl_expr_seq_new(len, arena);
9093 [ # # ]: 0 : if (comparators == NULL) goto failed;
9094 [ # # ]: 0 : for (i = 0; i < len; i++) {
9095 : : expr_ty val;
9096 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9097 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
9098 : 0 : goto failed;
9099 : : }
9100 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
9101 : 0 : _Py_LeaveRecursiveCall();
9102 : 0 : Py_DECREF(tmp2);
9103 [ # # ]: 0 : if (res != 0) goto failed;
9104 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
9105 : 0 : PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
9106 : 0 : goto failed;
9107 : : }
9108 : 0 : asdl_seq_SET(comparators, i, val);
9109 : : }
9110 [ # # ]: 0 : Py_CLEAR(tmp);
9111 : : }
9112 : 0 : *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
9113 : : end_lineno, end_col_offset, arena);
9114 [ # # ]: 0 : if (*out == NULL) goto failed;
9115 : 0 : return 0;
9116 : : }
9117 : 0 : tp = state->Call_type;
9118 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9119 [ # # ]: 0 : if (isinstance == -1) {
9120 : 0 : return 1;
9121 : : }
9122 [ # # ]: 0 : if (isinstance) {
9123 : : expr_ty func;
9124 : : asdl_expr_seq* args;
9125 : : asdl_keyword_seq* keywords;
9126 : :
9127 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->func, &tmp) < 0) {
9128 : 0 : return 1;
9129 : : }
9130 [ # # ]: 0 : if (tmp == NULL) {
9131 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
9132 : 0 : return 1;
9133 : : }
9134 : : else {
9135 : : int res;
9136 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9137 : 0 : goto failed;
9138 : : }
9139 : 0 : res = obj2ast_expr(state, tmp, &func, arena);
9140 : 0 : _Py_LeaveRecursiveCall();
9141 [ # # ]: 0 : if (res != 0) goto failed;
9142 [ # # ]: 0 : Py_CLEAR(tmp);
9143 : : }
9144 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
9145 : 0 : return 1;
9146 : : }
9147 [ # # ]: 0 : if (tmp == NULL) {
9148 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
9149 : 0 : return 1;
9150 : : }
9151 : : else {
9152 : : int res;
9153 : : Py_ssize_t len;
9154 : : Py_ssize_t i;
9155 [ # # ]: 0 : if (!PyList_Check(tmp)) {
9156 : 0 : PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9157 : 0 : goto failed;
9158 : : }
9159 : 0 : len = PyList_GET_SIZE(tmp);
9160 : 0 : args = _Py_asdl_expr_seq_new(len, arena);
9161 [ # # ]: 0 : if (args == NULL) goto failed;
9162 [ # # ]: 0 : for (i = 0; i < len; i++) {
9163 : : expr_ty val;
9164 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9165 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9166 : 0 : goto failed;
9167 : : }
9168 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
9169 : 0 : _Py_LeaveRecursiveCall();
9170 : 0 : Py_DECREF(tmp2);
9171 [ # # ]: 0 : if (res != 0) goto failed;
9172 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
9173 : 0 : PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
9174 : 0 : goto failed;
9175 : : }
9176 : 0 : asdl_seq_SET(args, i, val);
9177 : : }
9178 [ # # ]: 0 : Py_CLEAR(tmp);
9179 : : }
9180 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
9181 : 0 : return 1;
9182 : : }
9183 [ # # ]: 0 : if (tmp == NULL) {
9184 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
9185 : 0 : return 1;
9186 : : }
9187 : : else {
9188 : : int res;
9189 : : Py_ssize_t len;
9190 : : Py_ssize_t i;
9191 [ # # ]: 0 : if (!PyList_Check(tmp)) {
9192 : 0 : PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9193 : 0 : goto failed;
9194 : : }
9195 : 0 : len = PyList_GET_SIZE(tmp);
9196 : 0 : keywords = _Py_asdl_keyword_seq_new(len, arena);
9197 [ # # ]: 0 : if (keywords == NULL) goto failed;
9198 [ # # ]: 0 : for (i = 0; i < len; i++) {
9199 : : keyword_ty val;
9200 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9201 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
9202 : 0 : goto failed;
9203 : : }
9204 : 0 : res = obj2ast_keyword(state, tmp2, &val, arena);
9205 : 0 : _Py_LeaveRecursiveCall();
9206 : 0 : Py_DECREF(tmp2);
9207 [ # # ]: 0 : if (res != 0) goto failed;
9208 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
9209 : 0 : PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
9210 : 0 : goto failed;
9211 : : }
9212 : 0 : asdl_seq_SET(keywords, i, val);
9213 : : }
9214 [ # # ]: 0 : Py_CLEAR(tmp);
9215 : : }
9216 : 0 : *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
9217 : : end_lineno, end_col_offset, arena);
9218 [ # # ]: 0 : if (*out == NULL) goto failed;
9219 : 0 : return 0;
9220 : : }
9221 : 0 : tp = state->FormattedValue_type;
9222 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9223 [ # # ]: 0 : if (isinstance == -1) {
9224 : 0 : return 1;
9225 : : }
9226 [ # # ]: 0 : if (isinstance) {
9227 : : expr_ty value;
9228 : : int conversion;
9229 : : expr_ty format_spec;
9230 : :
9231 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9232 : 0 : return 1;
9233 : : }
9234 [ # # ]: 0 : if (tmp == NULL) {
9235 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
9236 : 0 : return 1;
9237 : : }
9238 : : else {
9239 : : int res;
9240 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9241 : 0 : goto failed;
9242 : : }
9243 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
9244 : 0 : _Py_LeaveRecursiveCall();
9245 [ # # ]: 0 : if (res != 0) goto failed;
9246 [ # # ]: 0 : Py_CLEAR(tmp);
9247 : : }
9248 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->conversion, &tmp) < 0) {
9249 : 0 : return 1;
9250 : : }
9251 [ # # ]: 0 : if (tmp == NULL) {
9252 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
9253 : 0 : return 1;
9254 : : }
9255 : : else {
9256 : : int res;
9257 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9258 : 0 : goto failed;
9259 : : }
9260 : 0 : res = obj2ast_int(state, tmp, &conversion, arena);
9261 : 0 : _Py_LeaveRecursiveCall();
9262 [ # # ]: 0 : if (res != 0) goto failed;
9263 [ # # ]: 0 : Py_CLEAR(tmp);
9264 : : }
9265 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->format_spec, &tmp) < 0) {
9266 : 0 : return 1;
9267 : : }
9268 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
9269 [ # # ]: 0 : Py_CLEAR(tmp);
9270 : 0 : format_spec = NULL;
9271 : : }
9272 : : else {
9273 : : int res;
9274 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
9275 : 0 : goto failed;
9276 : : }
9277 : 0 : res = obj2ast_expr(state, tmp, &format_spec, arena);
9278 : 0 : _Py_LeaveRecursiveCall();
9279 [ # # ]: 0 : if (res != 0) goto failed;
9280 [ # # ]: 0 : Py_CLEAR(tmp);
9281 : : }
9282 : 0 : *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
9283 : : col_offset, end_lineno, end_col_offset,
9284 : : arena);
9285 [ # # ]: 0 : if (*out == NULL) goto failed;
9286 : 0 : return 0;
9287 : : }
9288 : 0 : tp = state->JoinedStr_type;
9289 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9290 [ # # ]: 0 : if (isinstance == -1) {
9291 : 0 : return 1;
9292 : : }
9293 [ # # ]: 0 : if (isinstance) {
9294 : : asdl_expr_seq* values;
9295 : :
9296 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
9297 : 0 : return 1;
9298 : : }
9299 [ # # ]: 0 : if (tmp == NULL) {
9300 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
9301 : 0 : return 1;
9302 : : }
9303 : : else {
9304 : : int res;
9305 : : Py_ssize_t len;
9306 : : Py_ssize_t i;
9307 [ # # ]: 0 : if (!PyList_Check(tmp)) {
9308 : 0 : PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9309 : 0 : goto failed;
9310 : : }
9311 : 0 : len = PyList_GET_SIZE(tmp);
9312 : 0 : values = _Py_asdl_expr_seq_new(len, arena);
9313 [ # # ]: 0 : if (values == NULL) goto failed;
9314 [ # # ]: 0 : for (i = 0; i < len; i++) {
9315 : : expr_ty val;
9316 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9317 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
9318 : 0 : goto failed;
9319 : : }
9320 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
9321 : 0 : _Py_LeaveRecursiveCall();
9322 : 0 : Py_DECREF(tmp2);
9323 [ # # ]: 0 : if (res != 0) goto failed;
9324 [ # # ]: 0 : 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 : 0 : asdl_seq_SET(values, i, val);
9329 : : }
9330 [ # # ]: 0 : Py_CLEAR(tmp);
9331 : : }
9332 : 0 : *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
9333 : : end_col_offset, arena);
9334 [ # # ]: 0 : if (*out == NULL) goto failed;
9335 : 0 : return 0;
9336 : : }
9337 : 0 : tp = state->Constant_type;
9338 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9339 [ # # ]: 0 : if (isinstance == -1) {
9340 : 0 : return 1;
9341 : : }
9342 [ # # ]: 0 : if (isinstance) {
9343 : : constant value;
9344 : : string kind;
9345 : :
9346 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9347 : 0 : return 1;
9348 : : }
9349 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
9356 : 0 : goto failed;
9357 : : }
9358 : 0 : res = obj2ast_constant(state, tmp, &value, arena);
9359 : 0 : _Py_LeaveRecursiveCall();
9360 [ # # ]: 0 : if (res != 0) goto failed;
9361 [ # # ]: 0 : Py_CLEAR(tmp);
9362 : : }
9363 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->kind, &tmp) < 0) {
9364 : 0 : return 1;
9365 : : }
9366 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
9367 [ # # ]: 0 : Py_CLEAR(tmp);
9368 : 0 : 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 : 0 : *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
9381 : : end_col_offset, arena);
9382 [ # # ]: 0 : if (*out == NULL) goto failed;
9383 : 0 : return 0;
9384 : : }
9385 : 0 : tp = state->Attribute_type;
9386 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9387 [ # # ]: 0 : if (isinstance == -1) {
9388 : 0 : return 1;
9389 : : }
9390 [ # # ]: 0 : if (isinstance) {
9391 : : expr_ty value;
9392 : : identifier attr;
9393 : : expr_context_ty ctx;
9394 : :
9395 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9396 : 0 : return 1;
9397 : : }
9398 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9405 : 0 : goto failed;
9406 : : }
9407 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
9408 : 0 : _Py_LeaveRecursiveCall();
9409 [ # # ]: 0 : if (res != 0) goto failed;
9410 [ # # ]: 0 : Py_CLEAR(tmp);
9411 : : }
9412 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->attr, &tmp) < 0) {
9413 : 0 : return 1;
9414 : : }
9415 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9422 : 0 : goto failed;
9423 : : }
9424 : 0 : res = obj2ast_identifier(state, tmp, &attr, arena);
9425 : 0 : _Py_LeaveRecursiveCall();
9426 [ # # ]: 0 : if (res != 0) goto failed;
9427 [ # # ]: 0 : Py_CLEAR(tmp);
9428 : : }
9429 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9430 : 0 : return 1;
9431 : : }
9432 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
9439 : 0 : goto failed;
9440 : : }
9441 : 0 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9442 : 0 : _Py_LeaveRecursiveCall();
9443 [ # # ]: 0 : if (res != 0) goto failed;
9444 [ # # ]: 0 : Py_CLEAR(tmp);
9445 : : }
9446 : 0 : *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
9447 : : end_lineno, end_col_offset, arena);
9448 [ # # ]: 0 : if (*out == NULL) goto failed;
9449 : 0 : return 0;
9450 : : }
9451 : 0 : tp = state->Subscript_type;
9452 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9453 [ # # ]: 0 : if (isinstance == -1) {
9454 : 0 : return 1;
9455 : : }
9456 [ # # ]: 0 : if (isinstance) {
9457 : : expr_ty value;
9458 : : expr_ty slice;
9459 : : expr_context_ty ctx;
9460 : :
9461 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9462 : 0 : return 1;
9463 : : }
9464 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9471 : 0 : goto failed;
9472 : : }
9473 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
9474 : 0 : _Py_LeaveRecursiveCall();
9475 [ # # ]: 0 : if (res != 0) goto failed;
9476 [ # # ]: 0 : Py_CLEAR(tmp);
9477 : : }
9478 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->slice, &tmp) < 0) {
9479 : 0 : return 1;
9480 : : }
9481 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9488 : 0 : goto failed;
9489 : : }
9490 : 0 : res = obj2ast_expr(state, tmp, &slice, arena);
9491 : 0 : _Py_LeaveRecursiveCall();
9492 [ # # ]: 0 : if (res != 0) goto failed;
9493 [ # # ]: 0 : Py_CLEAR(tmp);
9494 : : }
9495 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9496 : 0 : return 1;
9497 : : }
9498 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
9505 : 0 : goto failed;
9506 : : }
9507 : 0 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9508 : 0 : _Py_LeaveRecursiveCall();
9509 [ # # ]: 0 : if (res != 0) goto failed;
9510 [ # # ]: 0 : Py_CLEAR(tmp);
9511 : : }
9512 : 0 : *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
9513 : : end_lineno, end_col_offset, arena);
9514 [ # # ]: 0 : if (*out == NULL) goto failed;
9515 : 0 : return 0;
9516 : : }
9517 : 0 : tp = state->Starred_type;
9518 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9519 [ # # ]: 0 : if (isinstance == -1) {
9520 : 0 : return 1;
9521 : : }
9522 [ # # ]: 0 : if (isinstance) {
9523 : : expr_ty value;
9524 : : expr_context_ty ctx;
9525 : :
9526 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9527 : 0 : return 1;
9528 : : }
9529 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
9536 : 0 : goto failed;
9537 : : }
9538 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
9539 : 0 : _Py_LeaveRecursiveCall();
9540 [ # # ]: 0 : if (res != 0) goto failed;
9541 [ # # ]: 0 : Py_CLEAR(tmp);
9542 : : }
9543 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9544 : 0 : return 1;
9545 : : }
9546 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
9553 : 0 : goto failed;
9554 : : }
9555 : 0 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9556 : 0 : _Py_LeaveRecursiveCall();
9557 [ # # ]: 0 : if (res != 0) goto failed;
9558 [ # # ]: 0 : Py_CLEAR(tmp);
9559 : : }
9560 : 0 : *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
9561 : : end_col_offset, arena);
9562 [ # # ]: 0 : if (*out == NULL) goto failed;
9563 : 0 : return 0;
9564 : : }
9565 : 0 : tp = state->Name_type;
9566 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9567 [ # # ]: 0 : if (isinstance == -1) {
9568 : 0 : return 1;
9569 : : }
9570 [ # # ]: 0 : if (isinstance) {
9571 : : identifier id;
9572 : : expr_context_ty ctx;
9573 : :
9574 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->id, &tmp) < 0) {
9575 : 0 : return 1;
9576 : : }
9577 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
9584 : 0 : goto failed;
9585 : : }
9586 : 0 : res = obj2ast_identifier(state, tmp, &id, arena);
9587 : 0 : _Py_LeaveRecursiveCall();
9588 [ # # ]: 0 : if (res != 0) goto failed;
9589 [ # # ]: 0 : Py_CLEAR(tmp);
9590 : : }
9591 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9592 : 0 : return 1;
9593 : : }
9594 [ # # ]: 0 : 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 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
9601 : 0 : goto failed;
9602 : : }
9603 : 0 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9604 : 0 : _Py_LeaveRecursiveCall();
9605 [ # # ]: 0 : if (res != 0) goto failed;
9606 [ # # ]: 0 : Py_CLEAR(tmp);
9607 : : }
9608 : 0 : *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
9609 : : end_col_offset, arena);
9610 [ # # ]: 0 : if (*out == NULL) goto failed;
9611 : 0 : return 0;
9612 : : }
9613 : 0 : tp = state->List_type;
9614 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9615 [ # # ]: 0 : if (isinstance == -1) {
9616 : 0 : return 1;
9617 : : }
9618 [ # # ]: 0 : if (isinstance) {
9619 : : asdl_expr_seq* elts;
9620 : : expr_context_ty ctx;
9621 : :
9622 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9623 : 0 : return 1;
9624 : : }
9625 [ # # ]: 0 : 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 [ # # ]: 0 : 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 : 0 : len = PyList_GET_SIZE(tmp);
9638 : 0 : elts = _Py_asdl_expr_seq_new(len, arena);
9639 [ # # ]: 0 : if (elts == NULL) goto failed;
9640 [ # # ]: 0 : for (i = 0; i < len; i++) {
9641 : : expr_ty val;
9642 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9643 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
9644 : 0 : goto failed;
9645 : : }
9646 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
9647 : 0 : _Py_LeaveRecursiveCall();
9648 : 0 : Py_DECREF(tmp2);
9649 [ # # ]: 0 : if (res != 0) goto failed;
9650 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
9651 : 0 : PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
9652 : 0 : goto failed;
9653 : : }
9654 : 0 : asdl_seq_SET(elts, i, val);
9655 : : }
9656 [ # # ]: 0 : Py_CLEAR(tmp);
9657 : : }
9658 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9659 : 0 : return 1;
9660 : : }
9661 [ # # ]: 0 : if (tmp == NULL) {
9662 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
9663 : 0 : return 1;
9664 : : }
9665 : : else {
9666 : : int res;
9667 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
9668 : 0 : goto failed;
9669 : : }
9670 : 0 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9671 : 0 : _Py_LeaveRecursiveCall();
9672 [ # # ]: 0 : if (res != 0) goto failed;
9673 [ # # ]: 0 : Py_CLEAR(tmp);
9674 : : }
9675 : 0 : *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
9676 : : end_col_offset, arena);
9677 [ # # ]: 0 : if (*out == NULL) goto failed;
9678 : 0 : return 0;
9679 : : }
9680 : 0 : tp = state->Tuple_type;
9681 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9682 [ # # ]: 0 : if (isinstance == -1) {
9683 : 0 : return 1;
9684 : : }
9685 [ # # ]: 0 : if (isinstance) {
9686 : : asdl_expr_seq* elts;
9687 : : expr_context_ty ctx;
9688 : :
9689 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9690 : 0 : return 1;
9691 : : }
9692 [ # # ]: 0 : if (tmp == NULL) {
9693 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
9694 : 0 : return 1;
9695 : : }
9696 : : else {
9697 : : int res;
9698 : : Py_ssize_t len;
9699 : : Py_ssize_t i;
9700 [ # # ]: 0 : if (!PyList_Check(tmp)) {
9701 : 0 : PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
9702 : 0 : goto failed;
9703 : : }
9704 : 0 : len = PyList_GET_SIZE(tmp);
9705 : 0 : elts = _Py_asdl_expr_seq_new(len, arena);
9706 [ # # ]: 0 : if (elts == NULL) goto failed;
9707 [ # # ]: 0 : for (i = 0; i < len; i++) {
9708 : : expr_ty val;
9709 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9710 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
9711 : 0 : goto failed;
9712 : : }
9713 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
9714 : 0 : _Py_LeaveRecursiveCall();
9715 : 0 : Py_DECREF(tmp2);
9716 [ # # ]: 0 : if (res != 0) goto failed;
9717 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
9718 : 0 : PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
9719 : 0 : goto failed;
9720 : : }
9721 : 0 : asdl_seq_SET(elts, i, val);
9722 : : }
9723 [ # # ]: 0 : Py_CLEAR(tmp);
9724 : : }
9725 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9726 : 0 : return 1;
9727 : : }
9728 [ # # ]: 0 : if (tmp == NULL) {
9729 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
9730 : 0 : return 1;
9731 : : }
9732 : : else {
9733 : : int res;
9734 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
9735 : 0 : goto failed;
9736 : : }
9737 : 0 : res = obj2ast_expr_context(state, tmp, &ctx, arena);
9738 : 0 : _Py_LeaveRecursiveCall();
9739 [ # # ]: 0 : if (res != 0) goto failed;
9740 [ # # ]: 0 : Py_CLEAR(tmp);
9741 : : }
9742 : 0 : *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
9743 : : end_col_offset, arena);
9744 [ # # ]: 0 : if (*out == NULL) goto failed;
9745 : 0 : return 0;
9746 : : }
9747 : 0 : tp = state->Slice_type;
9748 : 0 : isinstance = PyObject_IsInstance(obj, tp);
9749 [ # # ]: 0 : if (isinstance == -1) {
9750 : 0 : return 1;
9751 : : }
9752 [ # # ]: 0 : if (isinstance) {
9753 : : expr_ty lower;
9754 : : expr_ty upper;
9755 : : expr_ty step;
9756 : :
9757 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lower, &tmp) < 0) {
9758 : 0 : return 1;
9759 : : }
9760 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
9761 [ # # ]: 0 : Py_CLEAR(tmp);
9762 : 0 : lower = NULL;
9763 : : }
9764 : : else {
9765 : : int res;
9766 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9767 : 0 : goto failed;
9768 : : }
9769 : 0 : res = obj2ast_expr(state, tmp, &lower, arena);
9770 : 0 : _Py_LeaveRecursiveCall();
9771 [ # # ]: 0 : if (res != 0) goto failed;
9772 [ # # ]: 0 : Py_CLEAR(tmp);
9773 : : }
9774 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->upper, &tmp) < 0) {
9775 : 0 : return 1;
9776 : : }
9777 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
9778 [ # # ]: 0 : Py_CLEAR(tmp);
9779 : 0 : upper = NULL;
9780 : : }
9781 : : else {
9782 : : int res;
9783 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9784 : 0 : goto failed;
9785 : : }
9786 : 0 : res = obj2ast_expr(state, tmp, &upper, arena);
9787 : 0 : _Py_LeaveRecursiveCall();
9788 [ # # ]: 0 : if (res != 0) goto failed;
9789 [ # # ]: 0 : Py_CLEAR(tmp);
9790 : : }
9791 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->step, &tmp) < 0) {
9792 : 0 : return 1;
9793 : : }
9794 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
9795 [ # # ]: 0 : Py_CLEAR(tmp);
9796 : 0 : step = NULL;
9797 : : }
9798 : : else {
9799 : : int res;
9800 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
9801 : 0 : goto failed;
9802 : : }
9803 : 0 : res = obj2ast_expr(state, tmp, &step, arena);
9804 : 0 : _Py_LeaveRecursiveCall();
9805 [ # # ]: 0 : if (res != 0) goto failed;
9806 [ # # ]: 0 : Py_CLEAR(tmp);
9807 : : }
9808 : 0 : *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
9809 : : end_col_offset, arena);
9810 [ # # ]: 0 : if (*out == NULL) goto failed;
9811 : 0 : return 0;
9812 : : }
9813 : :
9814 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
9815 : 0 : failed:
9816 : 0 : Py_XDECREF(tmp);
9817 : 0 : return 1;
9818 : : }
9819 : :
9820 : : int
9821 : 0 : obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
9822 : : out, PyArena* arena)
9823 : : {
9824 : : int isinstance;
9825 : :
9826 : 0 : isinstance = PyObject_IsInstance(obj, state->Load_type);
9827 [ # # ]: 0 : if (isinstance == -1) {
9828 : 0 : return 1;
9829 : : }
9830 [ # # ]: 0 : if (isinstance) {
9831 : 0 : *out = Load;
9832 : 0 : return 0;
9833 : : }
9834 : 0 : isinstance = PyObject_IsInstance(obj, state->Store_type);
9835 [ # # ]: 0 : if (isinstance == -1) {
9836 : 0 : return 1;
9837 : : }
9838 [ # # ]: 0 : if (isinstance) {
9839 : 0 : *out = Store;
9840 : 0 : return 0;
9841 : : }
9842 : 0 : isinstance = PyObject_IsInstance(obj, state->Del_type);
9843 [ # # ]: 0 : if (isinstance == -1) {
9844 : 0 : return 1;
9845 : : }
9846 [ # # ]: 0 : if (isinstance) {
9847 : 0 : *out = Del;
9848 : 0 : return 0;
9849 : : }
9850 : :
9851 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
9852 : 0 : return 1;
9853 : : }
9854 : :
9855 : : int
9856 : 0 : obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
9857 : : arena)
9858 : : {
9859 : : int isinstance;
9860 : :
9861 : 0 : isinstance = PyObject_IsInstance(obj, state->And_type);
9862 [ # # ]: 0 : if (isinstance == -1) {
9863 : 0 : return 1;
9864 : : }
9865 [ # # ]: 0 : if (isinstance) {
9866 : 0 : *out = And;
9867 : 0 : return 0;
9868 : : }
9869 : 0 : isinstance = PyObject_IsInstance(obj, state->Or_type);
9870 [ # # ]: 0 : if (isinstance == -1) {
9871 : 0 : return 1;
9872 : : }
9873 [ # # ]: 0 : if (isinstance) {
9874 : 0 : *out = Or;
9875 : 0 : return 0;
9876 : : }
9877 : :
9878 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
9879 : 0 : return 1;
9880 : : }
9881 : :
9882 : : int
9883 : 0 : obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
9884 : : PyArena* arena)
9885 : : {
9886 : : int isinstance;
9887 : :
9888 : 0 : isinstance = PyObject_IsInstance(obj, state->Add_type);
9889 [ # # ]: 0 : if (isinstance == -1) {
9890 : 0 : return 1;
9891 : : }
9892 [ # # ]: 0 : if (isinstance) {
9893 : 0 : *out = Add;
9894 : 0 : return 0;
9895 : : }
9896 : 0 : isinstance = PyObject_IsInstance(obj, state->Sub_type);
9897 [ # # ]: 0 : if (isinstance == -1) {
9898 : 0 : return 1;
9899 : : }
9900 [ # # ]: 0 : if (isinstance) {
9901 : 0 : *out = Sub;
9902 : 0 : return 0;
9903 : : }
9904 : 0 : isinstance = PyObject_IsInstance(obj, state->Mult_type);
9905 [ # # ]: 0 : if (isinstance == -1) {
9906 : 0 : return 1;
9907 : : }
9908 [ # # ]: 0 : if (isinstance) {
9909 : 0 : *out = Mult;
9910 : 0 : return 0;
9911 : : }
9912 : 0 : isinstance = PyObject_IsInstance(obj, state->MatMult_type);
9913 [ # # ]: 0 : if (isinstance == -1) {
9914 : 0 : return 1;
9915 : : }
9916 [ # # ]: 0 : if (isinstance) {
9917 : 0 : *out = MatMult;
9918 : 0 : return 0;
9919 : : }
9920 : 0 : isinstance = PyObject_IsInstance(obj, state->Div_type);
9921 [ # # ]: 0 : if (isinstance == -1) {
9922 : 0 : return 1;
9923 : : }
9924 [ # # ]: 0 : if (isinstance) {
9925 : 0 : *out = Div;
9926 : 0 : return 0;
9927 : : }
9928 : 0 : isinstance = PyObject_IsInstance(obj, state->Mod_type);
9929 [ # # ]: 0 : if (isinstance == -1) {
9930 : 0 : return 1;
9931 : : }
9932 [ # # ]: 0 : if (isinstance) {
9933 : 0 : *out = Mod;
9934 : 0 : return 0;
9935 : : }
9936 : 0 : isinstance = PyObject_IsInstance(obj, state->Pow_type);
9937 [ # # ]: 0 : if (isinstance == -1) {
9938 : 0 : return 1;
9939 : : }
9940 [ # # ]: 0 : if (isinstance) {
9941 : 0 : *out = Pow;
9942 : 0 : return 0;
9943 : : }
9944 : 0 : isinstance = PyObject_IsInstance(obj, state->LShift_type);
9945 [ # # ]: 0 : if (isinstance == -1) {
9946 : 0 : return 1;
9947 : : }
9948 [ # # ]: 0 : if (isinstance) {
9949 : 0 : *out = LShift;
9950 : 0 : return 0;
9951 : : }
9952 : 0 : isinstance = PyObject_IsInstance(obj, state->RShift_type);
9953 [ # # ]: 0 : if (isinstance == -1) {
9954 : 0 : return 1;
9955 : : }
9956 [ # # ]: 0 : if (isinstance) {
9957 : 0 : *out = RShift;
9958 : 0 : return 0;
9959 : : }
9960 : 0 : isinstance = PyObject_IsInstance(obj, state->BitOr_type);
9961 [ # # ]: 0 : if (isinstance == -1) {
9962 : 0 : return 1;
9963 : : }
9964 [ # # ]: 0 : if (isinstance) {
9965 : 0 : *out = BitOr;
9966 : 0 : return 0;
9967 : : }
9968 : 0 : isinstance = PyObject_IsInstance(obj, state->BitXor_type);
9969 [ # # ]: 0 : if (isinstance == -1) {
9970 : 0 : return 1;
9971 : : }
9972 [ # # ]: 0 : if (isinstance) {
9973 : 0 : *out = BitXor;
9974 : 0 : return 0;
9975 : : }
9976 : 0 : isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
9977 [ # # ]: 0 : if (isinstance == -1) {
9978 : 0 : return 1;
9979 : : }
9980 [ # # ]: 0 : if (isinstance) {
9981 : 0 : *out = BitAnd;
9982 : 0 : return 0;
9983 : : }
9984 : 0 : isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
9985 [ # # ]: 0 : if (isinstance == -1) {
9986 : 0 : return 1;
9987 : : }
9988 [ # # ]: 0 : if (isinstance) {
9989 : 0 : *out = FloorDiv;
9990 : 0 : return 0;
9991 : : }
9992 : :
9993 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
9994 : 0 : return 1;
9995 : : }
9996 : :
9997 : : int
9998 : 0 : obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
9999 : : PyArena* arena)
10000 : : {
10001 : : int isinstance;
10002 : :
10003 : 0 : isinstance = PyObject_IsInstance(obj, state->Invert_type);
10004 [ # # ]: 0 : if (isinstance == -1) {
10005 : 0 : return 1;
10006 : : }
10007 [ # # ]: 0 : if (isinstance) {
10008 : 0 : *out = Invert;
10009 : 0 : return 0;
10010 : : }
10011 : 0 : isinstance = PyObject_IsInstance(obj, state->Not_type);
10012 [ # # ]: 0 : if (isinstance == -1) {
10013 : 0 : return 1;
10014 : : }
10015 [ # # ]: 0 : if (isinstance) {
10016 : 0 : *out = Not;
10017 : 0 : return 0;
10018 : : }
10019 : 0 : isinstance = PyObject_IsInstance(obj, state->UAdd_type);
10020 [ # # ]: 0 : if (isinstance == -1) {
10021 : 0 : return 1;
10022 : : }
10023 [ # # ]: 0 : if (isinstance) {
10024 : 0 : *out = UAdd;
10025 : 0 : return 0;
10026 : : }
10027 : 0 : isinstance = PyObject_IsInstance(obj, state->USub_type);
10028 [ # # ]: 0 : if (isinstance == -1) {
10029 : 0 : return 1;
10030 : : }
10031 [ # # ]: 0 : if (isinstance) {
10032 : 0 : *out = USub;
10033 : 0 : return 0;
10034 : : }
10035 : :
10036 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
10037 : 0 : return 1;
10038 : : }
10039 : :
10040 : : int
10041 : 0 : obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
10042 : : arena)
10043 : : {
10044 : : int isinstance;
10045 : :
10046 : 0 : isinstance = PyObject_IsInstance(obj, state->Eq_type);
10047 [ # # ]: 0 : if (isinstance == -1) {
10048 : 0 : return 1;
10049 : : }
10050 [ # # ]: 0 : if (isinstance) {
10051 : 0 : *out = Eq;
10052 : 0 : return 0;
10053 : : }
10054 : 0 : isinstance = PyObject_IsInstance(obj, state->NotEq_type);
10055 [ # # ]: 0 : if (isinstance == -1) {
10056 : 0 : return 1;
10057 : : }
10058 [ # # ]: 0 : if (isinstance) {
10059 : 0 : *out = NotEq;
10060 : 0 : return 0;
10061 : : }
10062 : 0 : isinstance = PyObject_IsInstance(obj, state->Lt_type);
10063 [ # # ]: 0 : if (isinstance == -1) {
10064 : 0 : return 1;
10065 : : }
10066 [ # # ]: 0 : if (isinstance) {
10067 : 0 : *out = Lt;
10068 : 0 : return 0;
10069 : : }
10070 : 0 : isinstance = PyObject_IsInstance(obj, state->LtE_type);
10071 [ # # ]: 0 : if (isinstance == -1) {
10072 : 0 : return 1;
10073 : : }
10074 [ # # ]: 0 : if (isinstance) {
10075 : 0 : *out = LtE;
10076 : 0 : return 0;
10077 : : }
10078 : 0 : isinstance = PyObject_IsInstance(obj, state->Gt_type);
10079 [ # # ]: 0 : if (isinstance == -1) {
10080 : 0 : return 1;
10081 : : }
10082 [ # # ]: 0 : if (isinstance) {
10083 : 0 : *out = Gt;
10084 : 0 : return 0;
10085 : : }
10086 : 0 : isinstance = PyObject_IsInstance(obj, state->GtE_type);
10087 [ # # ]: 0 : if (isinstance == -1) {
10088 : 0 : return 1;
10089 : : }
10090 [ # # ]: 0 : if (isinstance) {
10091 : 0 : *out = GtE;
10092 : 0 : return 0;
10093 : : }
10094 : 0 : isinstance = PyObject_IsInstance(obj, state->Is_type);
10095 [ # # ]: 0 : if (isinstance == -1) {
10096 : 0 : return 1;
10097 : : }
10098 [ # # ]: 0 : if (isinstance) {
10099 : 0 : *out = Is;
10100 : 0 : return 0;
10101 : : }
10102 : 0 : isinstance = PyObject_IsInstance(obj, state->IsNot_type);
10103 [ # # ]: 0 : if (isinstance == -1) {
10104 : 0 : return 1;
10105 : : }
10106 [ # # ]: 0 : if (isinstance) {
10107 : 0 : *out = IsNot;
10108 : 0 : return 0;
10109 : : }
10110 : 0 : isinstance = PyObject_IsInstance(obj, state->In_type);
10111 [ # # ]: 0 : if (isinstance == -1) {
10112 : 0 : return 1;
10113 : : }
10114 [ # # ]: 0 : if (isinstance) {
10115 : 0 : *out = In;
10116 : 0 : return 0;
10117 : : }
10118 : 0 : isinstance = PyObject_IsInstance(obj, state->NotIn_type);
10119 [ # # ]: 0 : if (isinstance == -1) {
10120 : 0 : return 1;
10121 : : }
10122 [ # # ]: 0 : if (isinstance) {
10123 : 0 : *out = NotIn;
10124 : 0 : return 0;
10125 : : }
10126 : :
10127 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
10128 : 0 : return 1;
10129 : : }
10130 : :
10131 : : int
10132 : 0 : obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
10133 : : out, PyArena* arena)
10134 : : {
10135 : 0 : PyObject* tmp = NULL;
10136 : : expr_ty target;
10137 : : expr_ty iter;
10138 : : asdl_expr_seq* ifs;
10139 : : int is_async;
10140 : :
10141 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
10142 : 0 : return 1;
10143 : : }
10144 [ # # ]: 0 : if (tmp == NULL) {
10145 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
10146 : 0 : return 1;
10147 : : }
10148 : : else {
10149 : : int res;
10150 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10151 : 0 : goto failed;
10152 : : }
10153 : 0 : res = obj2ast_expr(state, tmp, &target, arena);
10154 : 0 : _Py_LeaveRecursiveCall();
10155 [ # # ]: 0 : if (res != 0) goto failed;
10156 [ # # ]: 0 : Py_CLEAR(tmp);
10157 : : }
10158 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
10159 : 0 : return 1;
10160 : : }
10161 [ # # ]: 0 : if (tmp == NULL) {
10162 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
10163 : 0 : return 1;
10164 : : }
10165 : : else {
10166 : : int res;
10167 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10168 : 0 : goto failed;
10169 : : }
10170 : 0 : res = obj2ast_expr(state, tmp, &iter, arena);
10171 : 0 : _Py_LeaveRecursiveCall();
10172 [ # # ]: 0 : if (res != 0) goto failed;
10173 [ # # ]: 0 : Py_CLEAR(tmp);
10174 : : }
10175 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->ifs, &tmp) < 0) {
10176 : 0 : return 1;
10177 : : }
10178 [ # # ]: 0 : if (tmp == NULL) {
10179 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
10180 : 0 : return 1;
10181 : : }
10182 : : else {
10183 : : int res;
10184 : : Py_ssize_t len;
10185 : : Py_ssize_t i;
10186 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10187 : 0 : PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10188 : 0 : goto failed;
10189 : : }
10190 : 0 : len = PyList_GET_SIZE(tmp);
10191 : 0 : ifs = _Py_asdl_expr_seq_new(len, arena);
10192 [ # # ]: 0 : if (ifs == NULL) goto failed;
10193 [ # # ]: 0 : for (i = 0; i < len; i++) {
10194 : : expr_ty val;
10195 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10196 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10197 : 0 : goto failed;
10198 : : }
10199 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
10200 : 0 : _Py_LeaveRecursiveCall();
10201 : 0 : Py_DECREF(tmp2);
10202 [ # # ]: 0 : if (res != 0) goto failed;
10203 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10204 : 0 : PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
10205 : 0 : goto failed;
10206 : : }
10207 : 0 : asdl_seq_SET(ifs, i, val);
10208 : : }
10209 [ # # ]: 0 : Py_CLEAR(tmp);
10210 : : }
10211 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->is_async, &tmp) < 0) {
10212 : 0 : return 1;
10213 : : }
10214 [ # # ]: 0 : if (tmp == NULL) {
10215 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
10216 : 0 : return 1;
10217 : : }
10218 : : else {
10219 : : int res;
10220 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
10221 : 0 : goto failed;
10222 : : }
10223 : 0 : res = obj2ast_int(state, tmp, &is_async, arena);
10224 : 0 : _Py_LeaveRecursiveCall();
10225 [ # # ]: 0 : if (res != 0) goto failed;
10226 [ # # ]: 0 : Py_CLEAR(tmp);
10227 : : }
10228 : 0 : *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
10229 : 0 : return 0;
10230 : 0 : failed:
10231 : 0 : Py_XDECREF(tmp);
10232 : 0 : return 1;
10233 : : }
10234 : :
10235 : : int
10236 : 0 : obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
10237 : : out, PyArena* arena)
10238 : : {
10239 : : int isinstance;
10240 : :
10241 : 0 : PyObject *tmp = NULL;
10242 : : PyObject *tp;
10243 : : int lineno;
10244 : : int col_offset;
10245 : : int end_lineno;
10246 : : int end_col_offset;
10247 : :
10248 [ # # ]: 0 : if (obj == Py_None) {
10249 : 0 : *out = NULL;
10250 : 0 : return 0;
10251 : : }
10252 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10253 : 0 : return 1;
10254 : : }
10255 [ # # ]: 0 : if (tmp == NULL) {
10256 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
10257 : 0 : return 1;
10258 : : }
10259 : : else {
10260 : : int res;
10261 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10262 : 0 : goto failed;
10263 : : }
10264 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
10265 : 0 : _Py_LeaveRecursiveCall();
10266 [ # # ]: 0 : if (res != 0) goto failed;
10267 [ # # ]: 0 : Py_CLEAR(tmp);
10268 : : }
10269 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10270 : 0 : return 1;
10271 : : }
10272 [ # # ]: 0 : if (tmp == NULL) {
10273 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
10274 : 0 : return 1;
10275 : : }
10276 : : else {
10277 : : int res;
10278 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10279 : 0 : goto failed;
10280 : : }
10281 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
10282 : 0 : _Py_LeaveRecursiveCall();
10283 [ # # ]: 0 : if (res != 0) goto failed;
10284 [ # # ]: 0 : Py_CLEAR(tmp);
10285 : : }
10286 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10287 : 0 : return 1;
10288 : : }
10289 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10290 [ # # ]: 0 : Py_CLEAR(tmp);
10291 : 0 : end_lineno = lineno;
10292 : : }
10293 : : else {
10294 : : int res;
10295 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10296 : 0 : goto failed;
10297 : : }
10298 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
10299 : 0 : _Py_LeaveRecursiveCall();
10300 [ # # ]: 0 : if (res != 0) goto failed;
10301 [ # # ]: 0 : Py_CLEAR(tmp);
10302 : : }
10303 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10304 : 0 : return 1;
10305 : : }
10306 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10307 [ # # ]: 0 : Py_CLEAR(tmp);
10308 : 0 : end_col_offset = col_offset;
10309 : : }
10310 : : else {
10311 : : int res;
10312 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
10313 : 0 : goto failed;
10314 : : }
10315 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
10316 : 0 : _Py_LeaveRecursiveCall();
10317 [ # # ]: 0 : if (res != 0) goto failed;
10318 [ # # ]: 0 : Py_CLEAR(tmp);
10319 : : }
10320 : 0 : tp = state->ExceptHandler_type;
10321 : 0 : isinstance = PyObject_IsInstance(obj, tp);
10322 [ # # ]: 0 : if (isinstance == -1) {
10323 : 0 : return 1;
10324 : : }
10325 [ # # ]: 0 : if (isinstance) {
10326 : : expr_ty type;
10327 : : identifier name;
10328 : : asdl_stmt_seq* body;
10329 : :
10330 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type, &tmp) < 0) {
10331 : 0 : return 1;
10332 : : }
10333 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10334 [ # # ]: 0 : Py_CLEAR(tmp);
10335 : 0 : type = NULL;
10336 : : }
10337 : : else {
10338 : : int res;
10339 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10340 : 0 : goto failed;
10341 : : }
10342 : 0 : res = obj2ast_expr(state, tmp, &type, arena);
10343 : 0 : _Py_LeaveRecursiveCall();
10344 [ # # ]: 0 : if (res != 0) goto failed;
10345 [ # # ]: 0 : Py_CLEAR(tmp);
10346 : : }
10347 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10348 : 0 : return 1;
10349 : : }
10350 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10351 [ # # ]: 0 : Py_CLEAR(tmp);
10352 : 0 : name = NULL;
10353 : : }
10354 : : else {
10355 : : int res;
10356 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10357 : 0 : goto failed;
10358 : : }
10359 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
10360 : 0 : _Py_LeaveRecursiveCall();
10361 [ # # ]: 0 : if (res != 0) goto failed;
10362 [ # # ]: 0 : Py_CLEAR(tmp);
10363 : : }
10364 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
10365 : 0 : return 1;
10366 : : }
10367 [ # # ]: 0 : if (tmp == NULL) {
10368 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
10369 : 0 : return 1;
10370 : : }
10371 : : else {
10372 : : int res;
10373 : : Py_ssize_t len;
10374 : : Py_ssize_t i;
10375 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10376 : 0 : PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10377 : 0 : goto failed;
10378 : : }
10379 : 0 : len = PyList_GET_SIZE(tmp);
10380 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
10381 [ # # ]: 0 : if (body == NULL) goto failed;
10382 [ # # ]: 0 : for (i = 0; i < len; i++) {
10383 : : stmt_ty val;
10384 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10385 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
10386 : 0 : goto failed;
10387 : : }
10388 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
10389 : 0 : _Py_LeaveRecursiveCall();
10390 : 0 : Py_DECREF(tmp2);
10391 [ # # ]: 0 : if (res != 0) goto failed;
10392 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10393 : 0 : PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
10394 : 0 : goto failed;
10395 : : }
10396 : 0 : asdl_seq_SET(body, i, val);
10397 : : }
10398 [ # # ]: 0 : Py_CLEAR(tmp);
10399 : : }
10400 : 0 : *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
10401 : : end_lineno, end_col_offset, arena);
10402 [ # # ]: 0 : if (*out == NULL) goto failed;
10403 : 0 : return 0;
10404 : : }
10405 : :
10406 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
10407 : 0 : failed:
10408 : 0 : Py_XDECREF(tmp);
10409 : 0 : return 1;
10410 : : }
10411 : :
10412 : : int
10413 : 0 : obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
10414 : : PyArena* arena)
10415 : : {
10416 : 0 : PyObject* tmp = NULL;
10417 : : asdl_arg_seq* posonlyargs;
10418 : : asdl_arg_seq* args;
10419 : : arg_ty vararg;
10420 : : asdl_arg_seq* kwonlyargs;
10421 : : asdl_expr_seq* kw_defaults;
10422 : : arg_ty kwarg;
10423 : : asdl_expr_seq* defaults;
10424 : :
10425 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->posonlyargs, &tmp) < 0) {
10426 : 0 : return 1;
10427 : : }
10428 [ # # ]: 0 : if (tmp == NULL) {
10429 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"posonlyargs\" missing from arguments");
10430 : 0 : return 1;
10431 : : }
10432 : : else {
10433 : : int res;
10434 : : Py_ssize_t len;
10435 : : Py_ssize_t i;
10436 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10437 : 0 : PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10438 : 0 : goto failed;
10439 : : }
10440 : 0 : len = PyList_GET_SIZE(tmp);
10441 : 0 : posonlyargs = _Py_asdl_arg_seq_new(len, arena);
10442 [ # # ]: 0 : if (posonlyargs == NULL) goto failed;
10443 [ # # ]: 0 : for (i = 0; i < len; i++) {
10444 : : arg_ty val;
10445 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10446 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10447 : 0 : goto failed;
10448 : : }
10449 : 0 : res = obj2ast_arg(state, tmp2, &val, arena);
10450 : 0 : _Py_LeaveRecursiveCall();
10451 : 0 : Py_DECREF(tmp2);
10452 [ # # ]: 0 : if (res != 0) goto failed;
10453 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10454 : 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
10455 : 0 : goto failed;
10456 : : }
10457 : 0 : asdl_seq_SET(posonlyargs, i, val);
10458 : : }
10459 [ # # ]: 0 : Py_CLEAR(tmp);
10460 : : }
10461 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
10462 : 0 : return 1;
10463 : : }
10464 [ # # ]: 0 : if (tmp == NULL) {
10465 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
10466 : 0 : return 1;
10467 : : }
10468 : : else {
10469 : : int res;
10470 : : Py_ssize_t len;
10471 : : Py_ssize_t i;
10472 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10473 : 0 : PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10474 : 0 : goto failed;
10475 : : }
10476 : 0 : len = PyList_GET_SIZE(tmp);
10477 : 0 : args = _Py_asdl_arg_seq_new(len, arena);
10478 [ # # ]: 0 : if (args == NULL) goto failed;
10479 [ # # ]: 0 : for (i = 0; i < len; i++) {
10480 : : arg_ty val;
10481 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10482 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10483 : 0 : goto failed;
10484 : : }
10485 : 0 : res = obj2ast_arg(state, tmp2, &val, arena);
10486 : 0 : _Py_LeaveRecursiveCall();
10487 : 0 : Py_DECREF(tmp2);
10488 [ # # ]: 0 : if (res != 0) goto failed;
10489 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10490 : 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
10491 : 0 : goto failed;
10492 : : }
10493 : 0 : asdl_seq_SET(args, i, val);
10494 : : }
10495 [ # # ]: 0 : Py_CLEAR(tmp);
10496 : : }
10497 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->vararg, &tmp) < 0) {
10498 : 0 : return 1;
10499 : : }
10500 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10501 [ # # ]: 0 : Py_CLEAR(tmp);
10502 : 0 : vararg = NULL;
10503 : : }
10504 : : else {
10505 : : int res;
10506 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10507 : 0 : goto failed;
10508 : : }
10509 : 0 : res = obj2ast_arg(state, tmp, &vararg, arena);
10510 : 0 : _Py_LeaveRecursiveCall();
10511 [ # # ]: 0 : if (res != 0) goto failed;
10512 [ # # ]: 0 : Py_CLEAR(tmp);
10513 : : }
10514 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->kwonlyargs, &tmp) < 0) {
10515 : 0 : return 1;
10516 : : }
10517 [ # # ]: 0 : if (tmp == NULL) {
10518 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
10519 : 0 : return 1;
10520 : : }
10521 : : else {
10522 : : int res;
10523 : : Py_ssize_t len;
10524 : : Py_ssize_t i;
10525 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10526 : 0 : PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10527 : 0 : goto failed;
10528 : : }
10529 : 0 : len = PyList_GET_SIZE(tmp);
10530 : 0 : kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
10531 [ # # ]: 0 : if (kwonlyargs == NULL) goto failed;
10532 [ # # ]: 0 : for (i = 0; i < len; i++) {
10533 : : arg_ty val;
10534 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10535 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10536 : 0 : goto failed;
10537 : : }
10538 : 0 : res = obj2ast_arg(state, tmp2, &val, arena);
10539 : 0 : _Py_LeaveRecursiveCall();
10540 : 0 : Py_DECREF(tmp2);
10541 [ # # ]: 0 : if (res != 0) goto failed;
10542 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10543 : 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
10544 : 0 : goto failed;
10545 : : }
10546 : 0 : asdl_seq_SET(kwonlyargs, i, val);
10547 : : }
10548 [ # # ]: 0 : Py_CLEAR(tmp);
10549 : : }
10550 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->kw_defaults, &tmp) < 0) {
10551 : 0 : return 1;
10552 : : }
10553 [ # # ]: 0 : if (tmp == NULL) {
10554 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
10555 : 0 : return 1;
10556 : : }
10557 : : else {
10558 : : int res;
10559 : : Py_ssize_t len;
10560 : : Py_ssize_t i;
10561 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10562 : 0 : PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10563 : 0 : goto failed;
10564 : : }
10565 : 0 : len = PyList_GET_SIZE(tmp);
10566 : 0 : kw_defaults = _Py_asdl_expr_seq_new(len, arena);
10567 [ # # ]: 0 : if (kw_defaults == NULL) goto failed;
10568 [ # # ]: 0 : for (i = 0; i < len; i++) {
10569 : : expr_ty val;
10570 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10571 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10572 : 0 : goto failed;
10573 : : }
10574 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
10575 : 0 : _Py_LeaveRecursiveCall();
10576 : 0 : Py_DECREF(tmp2);
10577 [ # # ]: 0 : if (res != 0) goto failed;
10578 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10579 : 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
10580 : 0 : goto failed;
10581 : : }
10582 : 0 : asdl_seq_SET(kw_defaults, i, val);
10583 : : }
10584 [ # # ]: 0 : Py_CLEAR(tmp);
10585 : : }
10586 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->kwarg, &tmp) < 0) {
10587 : 0 : return 1;
10588 : : }
10589 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10590 [ # # ]: 0 : Py_CLEAR(tmp);
10591 : 0 : kwarg = NULL;
10592 : : }
10593 : : else {
10594 : : int res;
10595 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10596 : 0 : goto failed;
10597 : : }
10598 : 0 : res = obj2ast_arg(state, tmp, &kwarg, arena);
10599 : 0 : _Py_LeaveRecursiveCall();
10600 [ # # ]: 0 : if (res != 0) goto failed;
10601 [ # # ]: 0 : Py_CLEAR(tmp);
10602 : : }
10603 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->defaults, &tmp) < 0) {
10604 : 0 : return 1;
10605 : : }
10606 [ # # ]: 0 : if (tmp == NULL) {
10607 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
10608 : 0 : return 1;
10609 : : }
10610 : : else {
10611 : : int res;
10612 : : Py_ssize_t len;
10613 : : Py_ssize_t i;
10614 [ # # ]: 0 : if (!PyList_Check(tmp)) {
10615 : 0 : PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10616 : 0 : goto failed;
10617 : : }
10618 : 0 : len = PyList_GET_SIZE(tmp);
10619 : 0 : defaults = _Py_asdl_expr_seq_new(len, arena);
10620 [ # # ]: 0 : if (defaults == NULL) goto failed;
10621 [ # # ]: 0 : for (i = 0; i < len; i++) {
10622 : : expr_ty val;
10623 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10624 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
10625 : 0 : goto failed;
10626 : : }
10627 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
10628 : 0 : _Py_LeaveRecursiveCall();
10629 : 0 : Py_DECREF(tmp2);
10630 [ # # ]: 0 : if (res != 0) goto failed;
10631 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
10632 : 0 : PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
10633 : 0 : goto failed;
10634 : : }
10635 : 0 : asdl_seq_SET(defaults, i, val);
10636 : : }
10637 [ # # ]: 0 : Py_CLEAR(tmp);
10638 : : }
10639 : 0 : *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
10640 : : kwarg, defaults, arena);
10641 : 0 : return 0;
10642 : 0 : failed:
10643 : 0 : Py_XDECREF(tmp);
10644 : 0 : return 1;
10645 : : }
10646 : :
10647 : : int
10648 : 0 : obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
10649 : : {
10650 : 0 : PyObject* tmp = NULL;
10651 : : identifier arg;
10652 : : expr_ty annotation;
10653 : : string type_comment;
10654 : : int lineno;
10655 : : int col_offset;
10656 : : int end_lineno;
10657 : : int end_col_offset;
10658 : :
10659 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10660 : 0 : return 1;
10661 : : }
10662 [ # # ]: 0 : if (tmp == NULL) {
10663 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
10664 : 0 : return 1;
10665 : : }
10666 : : else {
10667 : : int res;
10668 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10669 : 0 : goto failed;
10670 : : }
10671 : 0 : res = obj2ast_identifier(state, tmp, &arg, arena);
10672 : 0 : _Py_LeaveRecursiveCall();
10673 [ # # ]: 0 : if (res != 0) goto failed;
10674 [ # # ]: 0 : Py_CLEAR(tmp);
10675 : : }
10676 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
10677 : 0 : return 1;
10678 : : }
10679 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10680 [ # # ]: 0 : Py_CLEAR(tmp);
10681 : 0 : annotation = NULL;
10682 : : }
10683 : : else {
10684 : : int res;
10685 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10686 : 0 : goto failed;
10687 : : }
10688 : 0 : res = obj2ast_expr(state, tmp, &annotation, arena);
10689 : 0 : _Py_LeaveRecursiveCall();
10690 [ # # ]: 0 : if (res != 0) goto failed;
10691 [ # # ]: 0 : Py_CLEAR(tmp);
10692 : : }
10693 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
10694 : 0 : return 1;
10695 : : }
10696 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10697 [ # # ]: 0 : Py_CLEAR(tmp);
10698 : 0 : type_comment = NULL;
10699 : : }
10700 : : else {
10701 : : int res;
10702 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10703 : 0 : goto failed;
10704 : : }
10705 : 0 : res = obj2ast_string(state, tmp, &type_comment, arena);
10706 : 0 : _Py_LeaveRecursiveCall();
10707 [ # # ]: 0 : if (res != 0) goto failed;
10708 [ # # ]: 0 : Py_CLEAR(tmp);
10709 : : }
10710 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10711 : 0 : return 1;
10712 : : }
10713 [ # # ]: 0 : if (tmp == NULL) {
10714 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
10715 : 0 : return 1;
10716 : : }
10717 : : else {
10718 : : int res;
10719 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10720 : 0 : goto failed;
10721 : : }
10722 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
10723 : 0 : _Py_LeaveRecursiveCall();
10724 [ # # ]: 0 : if (res != 0) goto failed;
10725 [ # # ]: 0 : Py_CLEAR(tmp);
10726 : : }
10727 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10728 : 0 : return 1;
10729 : : }
10730 [ # # ]: 0 : if (tmp == NULL) {
10731 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
10732 : 0 : return 1;
10733 : : }
10734 : : else {
10735 : : int res;
10736 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10737 : 0 : goto failed;
10738 : : }
10739 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
10740 : 0 : _Py_LeaveRecursiveCall();
10741 [ # # ]: 0 : if (res != 0) goto failed;
10742 [ # # ]: 0 : Py_CLEAR(tmp);
10743 : : }
10744 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10745 : 0 : return 1;
10746 : : }
10747 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10748 [ # # ]: 0 : Py_CLEAR(tmp);
10749 : 0 : end_lineno = lineno;
10750 : : }
10751 : : else {
10752 : : int res;
10753 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10754 : 0 : goto failed;
10755 : : }
10756 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
10757 : 0 : _Py_LeaveRecursiveCall();
10758 [ # # ]: 0 : if (res != 0) goto failed;
10759 [ # # ]: 0 : Py_CLEAR(tmp);
10760 : : }
10761 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10762 : 0 : return 1;
10763 : : }
10764 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10765 [ # # ]: 0 : Py_CLEAR(tmp);
10766 : 0 : end_col_offset = col_offset;
10767 : : }
10768 : : else {
10769 : : int res;
10770 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
10771 : 0 : goto failed;
10772 : : }
10773 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
10774 : 0 : _Py_LeaveRecursiveCall();
10775 [ # # ]: 0 : if (res != 0) goto failed;
10776 [ # # ]: 0 : Py_CLEAR(tmp);
10777 : : }
10778 : 0 : *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
10779 : : end_lineno, end_col_offset, arena);
10780 : 0 : return 0;
10781 : 0 : failed:
10782 : 0 : Py_XDECREF(tmp);
10783 : 0 : return 1;
10784 : : }
10785 : :
10786 : : int
10787 : 0 : obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
10788 : : PyArena* arena)
10789 : : {
10790 : 0 : PyObject* tmp = NULL;
10791 : : identifier arg;
10792 : : expr_ty value;
10793 : : int lineno;
10794 : : int col_offset;
10795 : : int end_lineno;
10796 : : int end_col_offset;
10797 : :
10798 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10799 : 0 : return 1;
10800 : : }
10801 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10802 [ # # ]: 0 : Py_CLEAR(tmp);
10803 : 0 : arg = NULL;
10804 : : }
10805 : : else {
10806 : : int res;
10807 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10808 : 0 : goto failed;
10809 : : }
10810 : 0 : res = obj2ast_identifier(state, tmp, &arg, arena);
10811 : 0 : _Py_LeaveRecursiveCall();
10812 [ # # ]: 0 : if (res != 0) goto failed;
10813 [ # # ]: 0 : Py_CLEAR(tmp);
10814 : : }
10815 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
10816 : 0 : return 1;
10817 : : }
10818 [ # # ]: 0 : if (tmp == NULL) {
10819 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
10820 : 0 : return 1;
10821 : : }
10822 : : else {
10823 : : int res;
10824 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10825 : 0 : goto failed;
10826 : : }
10827 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
10828 : 0 : _Py_LeaveRecursiveCall();
10829 [ # # ]: 0 : if (res != 0) goto failed;
10830 [ # # ]: 0 : Py_CLEAR(tmp);
10831 : : }
10832 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10833 : 0 : return 1;
10834 : : }
10835 [ # # ]: 0 : if (tmp == NULL) {
10836 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
10837 : 0 : return 1;
10838 : : }
10839 : : else {
10840 : : int res;
10841 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10842 : 0 : goto failed;
10843 : : }
10844 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
10845 : 0 : _Py_LeaveRecursiveCall();
10846 [ # # ]: 0 : if (res != 0) goto failed;
10847 [ # # ]: 0 : Py_CLEAR(tmp);
10848 : : }
10849 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10850 : 0 : return 1;
10851 : : }
10852 [ # # ]: 0 : if (tmp == NULL) {
10853 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
10854 : 0 : return 1;
10855 : : }
10856 : : else {
10857 : : int res;
10858 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10859 : 0 : goto failed;
10860 : : }
10861 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
10862 : 0 : _Py_LeaveRecursiveCall();
10863 [ # # ]: 0 : if (res != 0) goto failed;
10864 [ # # ]: 0 : Py_CLEAR(tmp);
10865 : : }
10866 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10867 : 0 : return 1;
10868 : : }
10869 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10870 [ # # ]: 0 : Py_CLEAR(tmp);
10871 : 0 : end_lineno = lineno;
10872 : : }
10873 : : else {
10874 : : int res;
10875 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10876 : 0 : goto failed;
10877 : : }
10878 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
10879 : 0 : _Py_LeaveRecursiveCall();
10880 [ # # ]: 0 : if (res != 0) goto failed;
10881 [ # # ]: 0 : Py_CLEAR(tmp);
10882 : : }
10883 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10884 : 0 : return 1;
10885 : : }
10886 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10887 [ # # ]: 0 : Py_CLEAR(tmp);
10888 : 0 : end_col_offset = col_offset;
10889 : : }
10890 : : else {
10891 : : int res;
10892 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
10893 : 0 : goto failed;
10894 : : }
10895 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
10896 : 0 : _Py_LeaveRecursiveCall();
10897 [ # # ]: 0 : if (res != 0) goto failed;
10898 [ # # ]: 0 : Py_CLEAR(tmp);
10899 : : }
10900 : 0 : *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
10901 : : end_col_offset, arena);
10902 : 0 : return 0;
10903 : 0 : failed:
10904 : 0 : Py_XDECREF(tmp);
10905 : 0 : return 1;
10906 : : }
10907 : :
10908 : : int
10909 : 0 : obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
10910 : : arena)
10911 : : {
10912 : 0 : PyObject* tmp = NULL;
10913 : : identifier name;
10914 : : identifier asname;
10915 : : int lineno;
10916 : : int col_offset;
10917 : : int end_lineno;
10918 : : int end_col_offset;
10919 : :
10920 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10921 : 0 : return 1;
10922 : : }
10923 [ # # ]: 0 : if (tmp == NULL) {
10924 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
10925 : 0 : return 1;
10926 : : }
10927 : : else {
10928 : : int res;
10929 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10930 : 0 : goto failed;
10931 : : }
10932 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
10933 : 0 : _Py_LeaveRecursiveCall();
10934 [ # # ]: 0 : if (res != 0) goto failed;
10935 [ # # ]: 0 : Py_CLEAR(tmp);
10936 : : }
10937 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->asname, &tmp) < 0) {
10938 : 0 : return 1;
10939 : : }
10940 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10941 [ # # ]: 0 : Py_CLEAR(tmp);
10942 : 0 : asname = NULL;
10943 : : }
10944 : : else {
10945 : : int res;
10946 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10947 : 0 : goto failed;
10948 : : }
10949 : 0 : res = obj2ast_identifier(state, tmp, &asname, arena);
10950 : 0 : _Py_LeaveRecursiveCall();
10951 [ # # ]: 0 : if (res != 0) goto failed;
10952 [ # # ]: 0 : Py_CLEAR(tmp);
10953 : : }
10954 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10955 : 0 : return 1;
10956 : : }
10957 [ # # ]: 0 : if (tmp == NULL) {
10958 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
10959 : 0 : return 1;
10960 : : }
10961 : : else {
10962 : : int res;
10963 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10964 : 0 : goto failed;
10965 : : }
10966 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
10967 : 0 : _Py_LeaveRecursiveCall();
10968 [ # # ]: 0 : if (res != 0) goto failed;
10969 [ # # ]: 0 : Py_CLEAR(tmp);
10970 : : }
10971 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10972 : 0 : return 1;
10973 : : }
10974 [ # # ]: 0 : if (tmp == NULL) {
10975 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
10976 : 0 : return 1;
10977 : : }
10978 : : else {
10979 : : int res;
10980 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10981 : 0 : goto failed;
10982 : : }
10983 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
10984 : 0 : _Py_LeaveRecursiveCall();
10985 [ # # ]: 0 : if (res != 0) goto failed;
10986 [ # # ]: 0 : Py_CLEAR(tmp);
10987 : : }
10988 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10989 : 0 : return 1;
10990 : : }
10991 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
10992 [ # # ]: 0 : Py_CLEAR(tmp);
10993 : 0 : end_lineno = lineno;
10994 : : }
10995 : : else {
10996 : : int res;
10997 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
10998 : 0 : goto failed;
10999 : : }
11000 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
11001 : 0 : _Py_LeaveRecursiveCall();
11002 [ # # ]: 0 : if (res != 0) goto failed;
11003 [ # # ]: 0 : Py_CLEAR(tmp);
11004 : : }
11005 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11006 : 0 : return 1;
11007 : : }
11008 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11009 [ # # ]: 0 : Py_CLEAR(tmp);
11010 : 0 : end_col_offset = col_offset;
11011 : : }
11012 : : else {
11013 : : int res;
11014 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
11015 : 0 : goto failed;
11016 : : }
11017 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
11018 : 0 : _Py_LeaveRecursiveCall();
11019 [ # # ]: 0 : if (res != 0) goto failed;
11020 [ # # ]: 0 : Py_CLEAR(tmp);
11021 : : }
11022 : 0 : *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
11023 : : end_col_offset, arena);
11024 : 0 : return 0;
11025 : 0 : failed:
11026 : 0 : Py_XDECREF(tmp);
11027 : 0 : return 1;
11028 : : }
11029 : :
11030 : : int
11031 : 0 : obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
11032 : : PyArena* arena)
11033 : : {
11034 : 0 : PyObject* tmp = NULL;
11035 : : expr_ty context_expr;
11036 : : expr_ty optional_vars;
11037 : :
11038 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->context_expr, &tmp) < 0) {
11039 : 0 : return 1;
11040 : : }
11041 [ # # ]: 0 : if (tmp == NULL) {
11042 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
11043 : 0 : return 1;
11044 : : }
11045 : : else {
11046 : : int res;
11047 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
11048 : 0 : goto failed;
11049 : : }
11050 : 0 : res = obj2ast_expr(state, tmp, &context_expr, arena);
11051 : 0 : _Py_LeaveRecursiveCall();
11052 [ # # ]: 0 : if (res != 0) goto failed;
11053 [ # # ]: 0 : Py_CLEAR(tmp);
11054 : : }
11055 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->optional_vars, &tmp) < 0) {
11056 : 0 : return 1;
11057 : : }
11058 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11059 [ # # ]: 0 : Py_CLEAR(tmp);
11060 : 0 : optional_vars = NULL;
11061 : : }
11062 : : else {
11063 : : int res;
11064 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
11065 : 0 : goto failed;
11066 : : }
11067 : 0 : res = obj2ast_expr(state, tmp, &optional_vars, arena);
11068 : 0 : _Py_LeaveRecursiveCall();
11069 [ # # ]: 0 : if (res != 0) goto failed;
11070 [ # # ]: 0 : Py_CLEAR(tmp);
11071 : : }
11072 : 0 : *out = _PyAST_withitem(context_expr, optional_vars, arena);
11073 : 0 : return 0;
11074 : 0 : failed:
11075 : 0 : Py_XDECREF(tmp);
11076 : 0 : return 1;
11077 : : }
11078 : :
11079 : : int
11080 : 0 : obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
11081 : : PyArena* arena)
11082 : : {
11083 : 0 : PyObject* tmp = NULL;
11084 : : pattern_ty pattern;
11085 : : expr_ty guard;
11086 : : asdl_stmt_seq* body;
11087 : :
11088 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11089 : 0 : return 1;
11090 : : }
11091 [ # # ]: 0 : if (tmp == NULL) {
11092 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
11093 : 0 : return 1;
11094 : : }
11095 : : else {
11096 : : int res;
11097 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11098 : 0 : goto failed;
11099 : : }
11100 : 0 : res = obj2ast_pattern(state, tmp, &pattern, arena);
11101 : 0 : _Py_LeaveRecursiveCall();
11102 [ # # ]: 0 : if (res != 0) goto failed;
11103 [ # # ]: 0 : Py_CLEAR(tmp);
11104 : : }
11105 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) {
11106 : 0 : return 1;
11107 : : }
11108 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11109 [ # # ]: 0 : Py_CLEAR(tmp);
11110 : 0 : guard = NULL;
11111 : : }
11112 : : else {
11113 : : int res;
11114 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11115 : 0 : goto failed;
11116 : : }
11117 : 0 : res = obj2ast_expr(state, tmp, &guard, arena);
11118 : 0 : _Py_LeaveRecursiveCall();
11119 [ # # ]: 0 : if (res != 0) goto failed;
11120 [ # # ]: 0 : Py_CLEAR(tmp);
11121 : : }
11122 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
11123 : 0 : return 1;
11124 : : }
11125 [ # # ]: 0 : if (tmp == NULL) {
11126 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from match_case");
11127 : 0 : return 1;
11128 : : }
11129 : : else {
11130 : : int res;
11131 : : Py_ssize_t len;
11132 : : Py_ssize_t i;
11133 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11134 : 0 : PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11135 : 0 : goto failed;
11136 : : }
11137 : 0 : len = PyList_GET_SIZE(tmp);
11138 : 0 : body = _Py_asdl_stmt_seq_new(len, arena);
11139 [ # # ]: 0 : if (body == NULL) goto failed;
11140 [ # # ]: 0 : for (i = 0; i < len; i++) {
11141 : : stmt_ty val;
11142 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11143 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
11144 : 0 : goto failed;
11145 : : }
11146 : 0 : res = obj2ast_stmt(state, tmp2, &val, arena);
11147 : 0 : _Py_LeaveRecursiveCall();
11148 : 0 : Py_DECREF(tmp2);
11149 [ # # ]: 0 : if (res != 0) goto failed;
11150 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11151 : 0 : PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
11152 : 0 : goto failed;
11153 : : }
11154 : 0 : asdl_seq_SET(body, i, val);
11155 : : }
11156 [ # # ]: 0 : Py_CLEAR(tmp);
11157 : : }
11158 : 0 : *out = _PyAST_match_case(pattern, guard, body, arena);
11159 : 0 : return 0;
11160 : 0 : failed:
11161 : 0 : Py_XDECREF(tmp);
11162 : 0 : return 1;
11163 : : }
11164 : :
11165 : : int
11166 : 0 : obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
11167 : : PyArena* arena)
11168 : : {
11169 : : int isinstance;
11170 : :
11171 : 0 : PyObject *tmp = NULL;
11172 : : PyObject *tp;
11173 : : int lineno;
11174 : : int col_offset;
11175 : : int end_lineno;
11176 : : int end_col_offset;
11177 : :
11178 [ # # ]: 0 : if (obj == Py_None) {
11179 : 0 : *out = NULL;
11180 : 0 : return 0;
11181 : : }
11182 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11183 : 0 : return 1;
11184 : : }
11185 [ # # ]: 0 : if (tmp == NULL) {
11186 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
11187 : 0 : return 1;
11188 : : }
11189 : : else {
11190 : : int res;
11191 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11192 : 0 : goto failed;
11193 : : }
11194 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
11195 : 0 : _Py_LeaveRecursiveCall();
11196 [ # # ]: 0 : if (res != 0) goto failed;
11197 [ # # ]: 0 : Py_CLEAR(tmp);
11198 : : }
11199 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
11200 : 0 : return 1;
11201 : : }
11202 [ # # ]: 0 : if (tmp == NULL) {
11203 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
11204 : 0 : return 1;
11205 : : }
11206 : : else {
11207 : : int res;
11208 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11209 : 0 : goto failed;
11210 : : }
11211 : 0 : res = obj2ast_int(state, tmp, &col_offset, arena);
11212 : 0 : _Py_LeaveRecursiveCall();
11213 [ # # ]: 0 : if (res != 0) goto failed;
11214 [ # # ]: 0 : Py_CLEAR(tmp);
11215 : : }
11216 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
11217 : 0 : return 1;
11218 : : }
11219 [ # # ]: 0 : if (tmp == NULL) {
11220 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
11221 : 0 : return 1;
11222 : : }
11223 : : else {
11224 : : int res;
11225 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11226 : 0 : goto failed;
11227 : : }
11228 : 0 : res = obj2ast_int(state, tmp, &end_lineno, arena);
11229 : 0 : _Py_LeaveRecursiveCall();
11230 [ # # ]: 0 : if (res != 0) goto failed;
11231 [ # # ]: 0 : Py_CLEAR(tmp);
11232 : : }
11233 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11234 : 0 : return 1;
11235 : : }
11236 [ # # ]: 0 : if (tmp == NULL) {
11237 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
11238 : 0 : return 1;
11239 : : }
11240 : : else {
11241 : : int res;
11242 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
11243 : 0 : goto failed;
11244 : : }
11245 : 0 : res = obj2ast_int(state, tmp, &end_col_offset, arena);
11246 : 0 : _Py_LeaveRecursiveCall();
11247 [ # # ]: 0 : if (res != 0) goto failed;
11248 [ # # ]: 0 : Py_CLEAR(tmp);
11249 : : }
11250 : 0 : tp = state->MatchValue_type;
11251 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11252 [ # # ]: 0 : if (isinstance == -1) {
11253 : 0 : return 1;
11254 : : }
11255 [ # # ]: 0 : if (isinstance) {
11256 : : expr_ty value;
11257 : :
11258 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11259 : 0 : return 1;
11260 : : }
11261 [ # # ]: 0 : if (tmp == NULL) {
11262 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
11263 : 0 : return 1;
11264 : : }
11265 : : else {
11266 : : int res;
11267 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
11268 : 0 : goto failed;
11269 : : }
11270 : 0 : res = obj2ast_expr(state, tmp, &value, arena);
11271 : 0 : _Py_LeaveRecursiveCall();
11272 [ # # ]: 0 : if (res != 0) goto failed;
11273 [ # # ]: 0 : Py_CLEAR(tmp);
11274 : : }
11275 : 0 : *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
11276 : : end_col_offset, arena);
11277 [ # # ]: 0 : if (*out == NULL) goto failed;
11278 : 0 : return 0;
11279 : : }
11280 : 0 : tp = state->MatchSingleton_type;
11281 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11282 [ # # ]: 0 : if (isinstance == -1) {
11283 : 0 : return 1;
11284 : : }
11285 [ # # ]: 0 : if (isinstance) {
11286 : : constant value;
11287 : :
11288 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11289 : 0 : return 1;
11290 : : }
11291 [ # # ]: 0 : if (tmp == NULL) {
11292 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
11293 : 0 : return 1;
11294 : : }
11295 : : else {
11296 : : int res;
11297 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
11298 : 0 : goto failed;
11299 : : }
11300 : 0 : res = obj2ast_constant(state, tmp, &value, arena);
11301 : 0 : _Py_LeaveRecursiveCall();
11302 [ # # ]: 0 : if (res != 0) goto failed;
11303 [ # # ]: 0 : Py_CLEAR(tmp);
11304 : : }
11305 : 0 : *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
11306 : : end_col_offset, arena);
11307 [ # # ]: 0 : if (*out == NULL) goto failed;
11308 : 0 : return 0;
11309 : : }
11310 : 0 : tp = state->MatchSequence_type;
11311 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11312 [ # # ]: 0 : if (isinstance == -1) {
11313 : 0 : return 1;
11314 : : }
11315 [ # # ]: 0 : if (isinstance) {
11316 : : asdl_pattern_seq* patterns;
11317 : :
11318 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11319 : 0 : return 1;
11320 : : }
11321 [ # # ]: 0 : if (tmp == NULL) {
11322 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchSequence");
11323 : 0 : return 1;
11324 : : }
11325 : : else {
11326 : : int res;
11327 : : Py_ssize_t len;
11328 : : Py_ssize_t i;
11329 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11330 : 0 : PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11331 : 0 : goto failed;
11332 : : }
11333 : 0 : len = PyList_GET_SIZE(tmp);
11334 : 0 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11335 [ # # ]: 0 : if (patterns == NULL) goto failed;
11336 [ # # ]: 0 : for (i = 0; i < len; i++) {
11337 : : pattern_ty val;
11338 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11339 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
11340 : 0 : goto failed;
11341 : : }
11342 : 0 : res = obj2ast_pattern(state, tmp2, &val, arena);
11343 : 0 : _Py_LeaveRecursiveCall();
11344 : 0 : Py_DECREF(tmp2);
11345 [ # # ]: 0 : if (res != 0) goto failed;
11346 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11347 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
11348 : 0 : goto failed;
11349 : : }
11350 : 0 : asdl_seq_SET(patterns, i, val);
11351 : : }
11352 [ # # ]: 0 : Py_CLEAR(tmp);
11353 : : }
11354 : 0 : *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
11355 : : end_col_offset, arena);
11356 [ # # ]: 0 : if (*out == NULL) goto failed;
11357 : 0 : return 0;
11358 : : }
11359 : 0 : tp = state->MatchMapping_type;
11360 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11361 [ # # ]: 0 : if (isinstance == -1) {
11362 : 0 : return 1;
11363 : : }
11364 [ # # ]: 0 : if (isinstance) {
11365 : : asdl_expr_seq* keys;
11366 : : asdl_pattern_seq* patterns;
11367 : : identifier rest;
11368 : :
11369 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
11370 : 0 : return 1;
11371 : : }
11372 [ # # ]: 0 : if (tmp == NULL) {
11373 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from MatchMapping");
11374 : 0 : return 1;
11375 : : }
11376 : : else {
11377 : : int res;
11378 : : Py_ssize_t len;
11379 : : Py_ssize_t i;
11380 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11381 : 0 : PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11382 : 0 : goto failed;
11383 : : }
11384 : 0 : len = PyList_GET_SIZE(tmp);
11385 : 0 : keys = _Py_asdl_expr_seq_new(len, arena);
11386 [ # # ]: 0 : if (keys == NULL) goto failed;
11387 [ # # ]: 0 : for (i = 0; i < len; i++) {
11388 : : expr_ty val;
11389 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11390 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11391 : 0 : goto failed;
11392 : : }
11393 : 0 : res = obj2ast_expr(state, tmp2, &val, arena);
11394 : 0 : _Py_LeaveRecursiveCall();
11395 : 0 : Py_DECREF(tmp2);
11396 [ # # ]: 0 : if (res != 0) goto failed;
11397 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11398 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
11399 : 0 : goto failed;
11400 : : }
11401 : 0 : asdl_seq_SET(keys, i, val);
11402 : : }
11403 [ # # ]: 0 : Py_CLEAR(tmp);
11404 : : }
11405 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11406 : 0 : return 1;
11407 : : }
11408 [ # # ]: 0 : if (tmp == NULL) {
11409 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchMapping");
11410 : 0 : return 1;
11411 : : }
11412 : : else {
11413 : : int res;
11414 : : Py_ssize_t len;
11415 : : Py_ssize_t i;
11416 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11417 : 0 : PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11418 : 0 : goto failed;
11419 : : }
11420 : 0 : len = PyList_GET_SIZE(tmp);
11421 : 0 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11422 [ # # ]: 0 : if (patterns == NULL) goto failed;
11423 [ # # ]: 0 : for (i = 0; i < len; i++) {
11424 : : pattern_ty val;
11425 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11426 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11427 : 0 : goto failed;
11428 : : }
11429 : 0 : res = obj2ast_pattern(state, tmp2, &val, arena);
11430 : 0 : _Py_LeaveRecursiveCall();
11431 : 0 : Py_DECREF(tmp2);
11432 [ # # ]: 0 : if (res != 0) goto failed;
11433 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11434 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
11435 : 0 : goto failed;
11436 : : }
11437 : 0 : asdl_seq_SET(patterns, i, val);
11438 : : }
11439 [ # # ]: 0 : Py_CLEAR(tmp);
11440 : : }
11441 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->rest, &tmp) < 0) {
11442 : 0 : return 1;
11443 : : }
11444 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11445 [ # # ]: 0 : Py_CLEAR(tmp);
11446 : 0 : rest = NULL;
11447 : : }
11448 : : else {
11449 : : int res;
11450 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
11451 : 0 : goto failed;
11452 : : }
11453 : 0 : res = obj2ast_identifier(state, tmp, &rest, arena);
11454 : 0 : _Py_LeaveRecursiveCall();
11455 [ # # ]: 0 : if (res != 0) goto failed;
11456 [ # # ]: 0 : Py_CLEAR(tmp);
11457 : : }
11458 : 0 : *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
11459 : : end_lineno, end_col_offset, arena);
11460 [ # # ]: 0 : if (*out == NULL) goto failed;
11461 : 0 : return 0;
11462 : : }
11463 : 0 : tp = state->MatchClass_type;
11464 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11465 [ # # ]: 0 : if (isinstance == -1) {
11466 : 0 : return 1;
11467 : : }
11468 [ # # ]: 0 : if (isinstance) {
11469 : : expr_ty cls;
11470 : : asdl_pattern_seq* patterns;
11471 : : asdl_identifier_seq* kwd_attrs;
11472 : : asdl_pattern_seq* kwd_patterns;
11473 : :
11474 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->cls, &tmp) < 0) {
11475 : 0 : return 1;
11476 : : }
11477 [ # # ]: 0 : if (tmp == NULL) {
11478 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
11479 : 0 : return 1;
11480 : : }
11481 : : else {
11482 : : int res;
11483 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11484 : 0 : goto failed;
11485 : : }
11486 : 0 : res = obj2ast_expr(state, tmp, &cls, arena);
11487 : 0 : _Py_LeaveRecursiveCall();
11488 [ # # ]: 0 : if (res != 0) goto failed;
11489 [ # # ]: 0 : Py_CLEAR(tmp);
11490 : : }
11491 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11492 : 0 : return 1;
11493 : : }
11494 [ # # ]: 0 : if (tmp == NULL) {
11495 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchClass");
11496 : 0 : return 1;
11497 : : }
11498 : : else {
11499 : : int res;
11500 : : Py_ssize_t len;
11501 : : Py_ssize_t i;
11502 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11503 : 0 : PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11504 : 0 : goto failed;
11505 : : }
11506 : 0 : len = PyList_GET_SIZE(tmp);
11507 : 0 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11508 [ # # ]: 0 : if (patterns == NULL) goto failed;
11509 [ # # ]: 0 : for (i = 0; i < len; i++) {
11510 : : pattern_ty val;
11511 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11512 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11513 : 0 : goto failed;
11514 : : }
11515 : 0 : res = obj2ast_pattern(state, tmp2, &val, arena);
11516 : 0 : _Py_LeaveRecursiveCall();
11517 : 0 : Py_DECREF(tmp2);
11518 [ # # ]: 0 : if (res != 0) goto failed;
11519 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11520 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
11521 : 0 : goto failed;
11522 : : }
11523 : 0 : asdl_seq_SET(patterns, i, val);
11524 : : }
11525 [ # # ]: 0 : Py_CLEAR(tmp);
11526 : : }
11527 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->kwd_attrs, &tmp) < 0) {
11528 : 0 : return 1;
11529 : : }
11530 [ # # ]: 0 : if (tmp == NULL) {
11531 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"kwd_attrs\" missing from MatchClass");
11532 : 0 : return 1;
11533 : : }
11534 : : else {
11535 : : int res;
11536 : : Py_ssize_t len;
11537 : : Py_ssize_t i;
11538 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11539 : 0 : PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11540 : 0 : goto failed;
11541 : : }
11542 : 0 : len = PyList_GET_SIZE(tmp);
11543 : 0 : kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
11544 [ # # ]: 0 : if (kwd_attrs == NULL) goto failed;
11545 [ # # ]: 0 : for (i = 0; i < len; i++) {
11546 : : identifier val;
11547 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11548 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11549 : 0 : goto failed;
11550 : : }
11551 : 0 : res = obj2ast_identifier(state, tmp2, &val, arena);
11552 : 0 : _Py_LeaveRecursiveCall();
11553 : 0 : Py_DECREF(tmp2);
11554 [ # # ]: 0 : if (res != 0) goto failed;
11555 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11556 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
11557 : 0 : goto failed;
11558 : : }
11559 : 0 : asdl_seq_SET(kwd_attrs, i, val);
11560 : : }
11561 [ # # ]: 0 : Py_CLEAR(tmp);
11562 : : }
11563 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->kwd_patterns, &tmp) < 0) {
11564 : 0 : return 1;
11565 : : }
11566 [ # # ]: 0 : if (tmp == NULL) {
11567 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"kwd_patterns\" missing from MatchClass");
11568 : 0 : return 1;
11569 : : }
11570 : : else {
11571 : : int res;
11572 : : Py_ssize_t len;
11573 : : Py_ssize_t i;
11574 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11575 : 0 : PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11576 : 0 : goto failed;
11577 : : }
11578 : 0 : len = PyList_GET_SIZE(tmp);
11579 : 0 : kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
11580 [ # # ]: 0 : if (kwd_patterns == NULL) goto failed;
11581 [ # # ]: 0 : for (i = 0; i < len; i++) {
11582 : : pattern_ty val;
11583 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11584 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
11585 : 0 : goto failed;
11586 : : }
11587 : 0 : res = obj2ast_pattern(state, tmp2, &val, arena);
11588 : 0 : _Py_LeaveRecursiveCall();
11589 : 0 : Py_DECREF(tmp2);
11590 [ # # ]: 0 : if (res != 0) goto failed;
11591 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11592 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
11593 : 0 : goto failed;
11594 : : }
11595 : 0 : asdl_seq_SET(kwd_patterns, i, val);
11596 : : }
11597 [ # # ]: 0 : Py_CLEAR(tmp);
11598 : : }
11599 : 0 : *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
11600 : : lineno, col_offset, end_lineno,
11601 : : end_col_offset, arena);
11602 [ # # ]: 0 : if (*out == NULL) goto failed;
11603 : 0 : return 0;
11604 : : }
11605 : 0 : tp = state->MatchStar_type;
11606 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11607 [ # # ]: 0 : if (isinstance == -1) {
11608 : 0 : return 1;
11609 : : }
11610 [ # # ]: 0 : if (isinstance) {
11611 : : identifier name;
11612 : :
11613 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11614 : 0 : return 1;
11615 : : }
11616 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11617 [ # # ]: 0 : Py_CLEAR(tmp);
11618 : 0 : name = NULL;
11619 : : }
11620 : : else {
11621 : : int res;
11622 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
11623 : 0 : goto failed;
11624 : : }
11625 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
11626 : 0 : _Py_LeaveRecursiveCall();
11627 [ # # ]: 0 : if (res != 0) goto failed;
11628 [ # # ]: 0 : Py_CLEAR(tmp);
11629 : : }
11630 : 0 : *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
11631 : : end_col_offset, arena);
11632 [ # # ]: 0 : if (*out == NULL) goto failed;
11633 : 0 : return 0;
11634 : : }
11635 : 0 : tp = state->MatchAs_type;
11636 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11637 [ # # ]: 0 : if (isinstance == -1) {
11638 : 0 : return 1;
11639 : : }
11640 [ # # ]: 0 : if (isinstance) {
11641 : : pattern_ty pattern;
11642 : : identifier name;
11643 : :
11644 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11645 : 0 : return 1;
11646 : : }
11647 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11648 [ # # ]: 0 : Py_CLEAR(tmp);
11649 : 0 : pattern = NULL;
11650 : : }
11651 : : else {
11652 : : int res;
11653 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
11654 : 0 : goto failed;
11655 : : }
11656 : 0 : res = obj2ast_pattern(state, tmp, &pattern, arena);
11657 : 0 : _Py_LeaveRecursiveCall();
11658 [ # # ]: 0 : if (res != 0) goto failed;
11659 [ # # ]: 0 : Py_CLEAR(tmp);
11660 : : }
11661 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11662 : 0 : return 1;
11663 : : }
11664 [ # # # # ]: 0 : if (tmp == NULL || tmp == Py_None) {
11665 [ # # ]: 0 : Py_CLEAR(tmp);
11666 : 0 : name = NULL;
11667 : : }
11668 : : else {
11669 : : int res;
11670 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
11671 : 0 : goto failed;
11672 : : }
11673 : 0 : res = obj2ast_identifier(state, tmp, &name, arena);
11674 : 0 : _Py_LeaveRecursiveCall();
11675 [ # # ]: 0 : if (res != 0) goto failed;
11676 [ # # ]: 0 : Py_CLEAR(tmp);
11677 : : }
11678 : 0 : *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
11679 : : end_col_offset, arena);
11680 [ # # ]: 0 : if (*out == NULL) goto failed;
11681 : 0 : return 0;
11682 : : }
11683 : 0 : tp = state->MatchOr_type;
11684 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11685 [ # # ]: 0 : if (isinstance == -1) {
11686 : 0 : return 1;
11687 : : }
11688 [ # # ]: 0 : if (isinstance) {
11689 : : asdl_pattern_seq* patterns;
11690 : :
11691 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11692 : 0 : return 1;
11693 : : }
11694 [ # # ]: 0 : if (tmp == NULL) {
11695 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchOr");
11696 : 0 : return 1;
11697 : : }
11698 : : else {
11699 : : int res;
11700 : : Py_ssize_t len;
11701 : : Py_ssize_t i;
11702 [ # # ]: 0 : if (!PyList_Check(tmp)) {
11703 : 0 : PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11704 : 0 : goto failed;
11705 : : }
11706 : 0 : len = PyList_GET_SIZE(tmp);
11707 : 0 : patterns = _Py_asdl_pattern_seq_new(len, arena);
11708 [ # # ]: 0 : if (patterns == NULL) goto failed;
11709 [ # # ]: 0 : for (i = 0; i < len; i++) {
11710 : : pattern_ty val;
11711 : 0 : PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11712 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
11713 : 0 : goto failed;
11714 : : }
11715 : 0 : res = obj2ast_pattern(state, tmp2, &val, arena);
11716 : 0 : _Py_LeaveRecursiveCall();
11717 : 0 : Py_DECREF(tmp2);
11718 [ # # ]: 0 : if (res != 0) goto failed;
11719 [ # # ]: 0 : if (len != PyList_GET_SIZE(tmp)) {
11720 : 0 : PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
11721 : 0 : goto failed;
11722 : : }
11723 : 0 : asdl_seq_SET(patterns, i, val);
11724 : : }
11725 [ # # ]: 0 : Py_CLEAR(tmp);
11726 : : }
11727 : 0 : *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
11728 : : end_col_offset, arena);
11729 [ # # ]: 0 : if (*out == NULL) goto failed;
11730 : 0 : return 0;
11731 : : }
11732 : :
11733 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
11734 : 0 : failed:
11735 : 0 : Py_XDECREF(tmp);
11736 : 0 : return 1;
11737 : : }
11738 : :
11739 : : int
11740 : 0 : obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
11741 : : out, PyArena* arena)
11742 : : {
11743 : : int isinstance;
11744 : :
11745 : 0 : PyObject *tmp = NULL;
11746 : : PyObject *tp;
11747 : :
11748 [ # # ]: 0 : if (obj == Py_None) {
11749 : 0 : *out = NULL;
11750 : 0 : return 0;
11751 : : }
11752 : 0 : tp = state->TypeIgnore_type;
11753 : 0 : isinstance = PyObject_IsInstance(obj, tp);
11754 [ # # ]: 0 : if (isinstance == -1) {
11755 : 0 : return 1;
11756 : : }
11757 [ # # ]: 0 : if (isinstance) {
11758 : : int lineno;
11759 : : string tag;
11760 : :
11761 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11762 : 0 : return 1;
11763 : : }
11764 [ # # ]: 0 : if (tmp == NULL) {
11765 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
11766 : 0 : return 1;
11767 : : }
11768 : : else {
11769 : : int res;
11770 [ # # ]: 0 : if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
11771 : 0 : goto failed;
11772 : : }
11773 : 0 : res = obj2ast_int(state, tmp, &lineno, arena);
11774 : 0 : _Py_LeaveRecursiveCall();
11775 [ # # ]: 0 : if (res != 0) goto failed;
11776 [ # # ]: 0 : Py_CLEAR(tmp);
11777 : : }
11778 [ # # ]: 0 : if (_PyObject_LookupAttr(obj, state->tag, &tmp) < 0) {
11779 : 0 : return 1;
11780 : : }
11781 [ # # ]: 0 : if (tmp == NULL) {
11782 : 0 : PyErr_SetString(PyExc_TypeError, "required field \"tag\" 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_string(state, tmp, &tag, arena);
11791 : 0 : _Py_LeaveRecursiveCall();
11792 [ # # ]: 0 : if (res != 0) goto failed;
11793 [ # # ]: 0 : Py_CLEAR(tmp);
11794 : : }
11795 : 0 : *out = _PyAST_TypeIgnore(lineno, tag, arena);
11796 [ # # ]: 0 : if (*out == NULL) goto failed;
11797 : 0 : return 0;
11798 : : }
11799 : :
11800 : 0 : PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
11801 : 0 : failed:
11802 : 0 : Py_XDECREF(tmp);
11803 : 0 : return 1;
11804 : : }
11805 : :
11806 : :
11807 : : static int
11808 : 4 : astmodule_exec(PyObject *m)
11809 : : {
11810 : 4 : struct ast_state *state = get_ast_state();
11811 [ - + ]: 4 : if (state == NULL) {
11812 : 0 : return -1;
11813 : : }
11814 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
11815 : 0 : return -1;
11816 : : }
11817 [ - + ]: 4 : if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
11818 : 0 : return -1;
11819 : : }
11820 [ - + ]: 4 : if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
11821 : 0 : return -1;
11822 : : }
11823 [ - + ]: 4 : if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
11824 : 0 : return -1;
11825 : : }
11826 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
11827 : 0 : return -1;
11828 : : }
11829 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
11830 : 0 : return -1;
11831 : : }
11832 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
11833 : 0 : return -1;
11834 : : }
11835 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
11836 : 0 : return -1;
11837 : : }
11838 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
11839 : : {
11840 : 0 : return -1;
11841 : : }
11842 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
11843 : 0 : return -1;
11844 : : }
11845 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
11846 : 0 : return -1;
11847 : : }
11848 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
11849 : : state->AsyncFunctionDef_type) < 0) {
11850 : 0 : return -1;
11851 : : }
11852 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
11853 : 0 : return -1;
11854 : : }
11855 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
11856 : 0 : return -1;
11857 : : }
11858 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
11859 : 0 : return -1;
11860 : : }
11861 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
11862 : 0 : return -1;
11863 : : }
11864 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
11865 : 0 : return -1;
11866 : : }
11867 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
11868 : 0 : return -1;
11869 : : }
11870 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
11871 : 0 : return -1;
11872 : : }
11873 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
11874 : 0 : return -1;
11875 : : }
11876 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
11877 : 0 : return -1;
11878 : : }
11879 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
11880 : 0 : return -1;
11881 : : }
11882 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
11883 : 0 : return -1;
11884 : : }
11885 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
11886 : 0 : return -1;
11887 : : }
11888 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
11889 : 0 : return -1;
11890 : : }
11891 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
11892 : 0 : return -1;
11893 : : }
11894 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
11895 : 0 : return -1;
11896 : : }
11897 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
11898 : 0 : return -1;
11899 : : }
11900 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
11901 : 0 : return -1;
11902 : : }
11903 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
11904 : 0 : return -1;
11905 : : }
11906 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
11907 : 0 : return -1;
11908 : : }
11909 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
11910 : 0 : return -1;
11911 : : }
11912 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
11913 : 0 : return -1;
11914 : : }
11915 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
11916 : 0 : return -1;
11917 : : }
11918 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
11919 : 0 : return -1;
11920 : : }
11921 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
11922 : 0 : return -1;
11923 : : }
11924 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
11925 : 0 : return -1;
11926 : : }
11927 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
11928 : 0 : return -1;
11929 : : }
11930 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
11931 : 0 : return -1;
11932 : : }
11933 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
11934 : 0 : return -1;
11935 : : }
11936 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
11937 : 0 : return -1;
11938 : : }
11939 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
11940 : 0 : return -1;
11941 : : }
11942 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
11943 : 0 : return -1;
11944 : : }
11945 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
11946 : 0 : return -1;
11947 : : }
11948 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
11949 : 0 : return -1;
11950 : : }
11951 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
11952 : 0 : return -1;
11953 : : }
11954 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
11955 : 0 : return -1;
11956 : : }
11957 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
11958 : 0 : return -1;
11959 : : }
11960 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
11961 : 0 : return -1;
11962 : : }
11963 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
11964 : : {
11965 : 0 : return -1;
11966 : : }
11967 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
11968 : 0 : return -1;
11969 : : }
11970 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
11971 : 0 : return -1;
11972 : : }
11973 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
11974 : 0 : return -1;
11975 : : }
11976 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
11977 : 0 : return -1;
11978 : : }
11979 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
11980 : 0 : return -1;
11981 : : }
11982 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
11983 : : < 0) {
11984 : 0 : return -1;
11985 : : }
11986 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
11987 : 0 : return -1;
11988 : : }
11989 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
11990 : 0 : return -1;
11991 : : }
11992 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
11993 : 0 : return -1;
11994 : : }
11995 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
11996 : 0 : return -1;
11997 : : }
11998 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
11999 : 0 : return -1;
12000 : : }
12001 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
12002 : 0 : return -1;
12003 : : }
12004 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
12005 : 0 : return -1;
12006 : : }
12007 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
12008 : 0 : return -1;
12009 : : }
12010 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
12011 : 0 : return -1;
12012 : : }
12013 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
12014 : : {
12015 : 0 : return -1;
12016 : : }
12017 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
12018 : 0 : return -1;
12019 : : }
12020 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
12021 : 0 : return -1;
12022 : : }
12023 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
12024 : 0 : return -1;
12025 : : }
12026 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
12027 : 0 : return -1;
12028 : : }
12029 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
12030 : 0 : return -1;
12031 : : }
12032 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
12033 : 0 : return -1;
12034 : : }
12035 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
12036 : 0 : return -1;
12037 : : }
12038 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
12039 : 0 : return -1;
12040 : : }
12041 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
12042 : 0 : return -1;
12043 : : }
12044 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
12045 : 0 : return -1;
12046 : : }
12047 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
12048 : 0 : return -1;
12049 : : }
12050 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
12051 : 0 : return -1;
12052 : : }
12053 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
12054 : 0 : return -1;
12055 : : }
12056 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
12057 : 0 : return -1;
12058 : : }
12059 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
12060 : 0 : return -1;
12061 : : }
12062 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
12063 : 0 : return -1;
12064 : : }
12065 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
12066 : 0 : return -1;
12067 : : }
12068 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
12069 : 0 : return -1;
12070 : : }
12071 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
12072 : 0 : return -1;
12073 : : }
12074 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
12075 : 0 : return -1;
12076 : : }
12077 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
12078 : 0 : return -1;
12079 : : }
12080 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
12081 : 0 : return -1;
12082 : : }
12083 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
12084 : 0 : return -1;
12085 : : }
12086 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
12087 : 0 : return -1;
12088 : : }
12089 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
12090 : 0 : return -1;
12091 : : }
12092 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
12093 : 0 : return -1;
12094 : : }
12095 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
12096 : 0 : return -1;
12097 : : }
12098 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
12099 : 0 : return -1;
12100 : : }
12101 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
12102 : 0 : return -1;
12103 : : }
12104 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
12105 : 0 : return -1;
12106 : : }
12107 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
12108 : 0 : return -1;
12109 : : }
12110 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
12111 : 0 : return -1;
12112 : : }
12113 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
12114 : 0 : return -1;
12115 : : }
12116 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
12117 : 0 : return -1;
12118 : : }
12119 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
12120 : 0 : return -1;
12121 : : }
12122 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
12123 : 0 : return -1;
12124 : : }
12125 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
12126 : : 0) {
12127 : 0 : return -1;
12128 : : }
12129 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
12130 : : 0) {
12131 : 0 : return -1;
12132 : : }
12133 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
12134 : : 0) {
12135 : 0 : return -1;
12136 : : }
12137 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
12138 : 0 : return -1;
12139 : : }
12140 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
12141 : 0 : return -1;
12142 : : }
12143 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
12144 : 0 : return -1;
12145 : : }
12146 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
12147 : 0 : return -1;
12148 : : }
12149 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
12150 : 0 : return -1;
12151 : : }
12152 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
12153 : 0 : return -1;
12154 : : }
12155 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
12156 : 0 : return -1;
12157 : : }
12158 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
12159 : 0 : return -1;
12160 : : }
12161 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
12162 : : < 0) {
12163 : 0 : return -1;
12164 : : }
12165 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
12166 : : 0) {
12167 : 0 : return -1;
12168 : : }
12169 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
12170 : : {
12171 : 0 : return -1;
12172 : : }
12173 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
12174 : 0 : return -1;
12175 : : }
12176 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
12177 : 0 : return -1;
12178 : : }
12179 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
12180 : 0 : return -1;
12181 : : }
12182 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
12183 : 0 : return -1;
12184 : : }
12185 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
12186 : 0 : return -1;
12187 : : }
12188 [ - + ]: 4 : if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
12189 : 0 : return -1;
12190 : : }
12191 : 4 : return 0;
12192 : : }
12193 : :
12194 : : static PyModuleDef_Slot astmodule_slots[] = {
12195 : : {Py_mod_exec, astmodule_exec},
12196 : : {0, NULL}
12197 : : };
12198 : :
12199 : : static struct PyModuleDef _astmodule = {
12200 : : PyModuleDef_HEAD_INIT,
12201 : : .m_name = "_ast",
12202 : : // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
12203 : : .m_size = 0,
12204 : : .m_slots = astmodule_slots,
12205 : : };
12206 : :
12207 : : PyMODINIT_FUNC
12208 : 4 : PyInit__ast(void)
12209 : : {
12210 : 4 : return PyModuleDef_Init(&_astmodule);
12211 : : }
12212 : :
12213 : :
12214 : 32 : PyObject* PyAST_mod2obj(mod_ty t)
12215 : : {
12216 : 32 : struct ast_state *state = get_ast_state();
12217 [ - + ]: 32 : if (state == NULL) {
12218 : 0 : return NULL;
12219 : : }
12220 : :
12221 : : int starting_recursion_depth;
12222 : : /* Be careful here to prevent overflow. */
12223 : 32 : int COMPILER_STACK_FRAME_SCALE = 3;
12224 : 32 : PyThreadState *tstate = _PyThreadState_GET();
12225 [ - + ]: 32 : if (!tstate) {
12226 : 0 : return 0;
12227 : : }
12228 : 32 : state->recursion_limit = C_RECURSION_LIMIT * COMPILER_STACK_FRAME_SCALE;
12229 : 32 : int recursion_depth = C_RECURSION_LIMIT - tstate->c_recursion_remaining;
12230 : 32 : starting_recursion_depth = recursion_depth * COMPILER_STACK_FRAME_SCALE;
12231 : 32 : state->recursion_depth = starting_recursion_depth;
12232 : :
12233 : 32 : PyObject *result = ast2obj_mod(state, t);
12234 : :
12235 : : /* Check that the recursion depth counting balanced correctly */
12236 [ + - - + ]: 32 : if (result && state->recursion_depth != starting_recursion_depth) {
12237 : 0 : PyErr_Format(PyExc_SystemError,
12238 : : "AST constructor recursion depth mismatch (before=%d, after=%d)",
12239 : : starting_recursion_depth, state->recursion_depth);
12240 : 0 : return 0;
12241 : : }
12242 : 32 : return result;
12243 : : }
12244 : :
12245 : : /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
12246 : 0 : mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
12247 : : {
12248 : 0 : const char * const req_name[] = {"Module", "Expression", "Interactive"};
12249 : : int isinstance;
12250 : :
12251 [ # # ]: 0 : if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
12252 : 0 : return NULL;
12253 : : }
12254 : :
12255 : 0 : struct ast_state *state = get_ast_state();
12256 [ # # ]: 0 : if (state == NULL) {
12257 : 0 : return NULL;
12258 : : }
12259 : :
12260 : : PyObject *req_type[3];
12261 : 0 : req_type[0] = state->Module_type;
12262 : 0 : req_type[1] = state->Expression_type;
12263 : 0 : req_type[2] = state->Interactive_type;
12264 : :
12265 : : assert(0 <= mode && mode <= 2);
12266 : :
12267 : 0 : isinstance = PyObject_IsInstance(ast, req_type[mode]);
12268 [ # # ]: 0 : if (isinstance == -1)
12269 : 0 : return NULL;
12270 [ # # ]: 0 : if (!isinstance) {
12271 : 0 : PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
12272 : : req_name[mode], _PyType_Name(Py_TYPE(ast)));
12273 : 0 : return NULL;
12274 : : }
12275 : :
12276 : 0 : mod_ty res = NULL;
12277 [ # # ]: 0 : if (obj2ast_mod(state, ast, &res, arena) != 0)
12278 : 0 : return NULL;
12279 : : else
12280 : 0 : return res;
12281 : : }
12282 : :
12283 : 267 : int PyAST_Check(PyObject* obj)
12284 : : {
12285 : 267 : struct ast_state *state = get_ast_state();
12286 [ - + ]: 267 : if (state == NULL) {
12287 : 0 : return -1;
12288 : : }
12289 : 267 : return PyObject_IsInstance(obj, state->AST_type);
12290 : : }
12291 : :
12292 : :
|