Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(12995)

Delta Between Two Patch Sets: Python/Python-ast.c

Issue 11682: PEP 380 reference implementation for 3.3
Left Patch Set: Created 7 years, 10 months ago
Right Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* File automatically generated by Parser/asdl_c.py. */ 1 /* File automatically generated by Parser/asdl_c.py. */
2
3
4 /*
5 __version__ e0e663132363.
6
7 This module must be committed separately after each AST grammar change;
8 The __version__ number is set to the revision number of the commit
9 containing the grammar change.
10 */
11 2
12 #include "Python.h" 3 #include "Python.h"
13 #include "Python-ast.h" 4 #include "Python-ast.h"
14 5
15 static PyTypeObject AST_type; 6 static PyTypeObject AST_type;
16 static PyTypeObject *mod_type; 7 static PyTypeObject *mod_type;
17 static PyObject* ast2obj_mod(void*); 8 static PyObject* ast2obj_mod(void*);
18 static PyTypeObject *Module_type; 9 static PyTypeObject *Module_type;
10 _Py_IDENTIFIER(body);
19 static char *Module_fields[]={ 11 static char *Module_fields[]={
20 "body", 12 "body",
21 }; 13 };
22 static PyTypeObject *Interactive_type; 14 static PyTypeObject *Interactive_type;
23 static char *Interactive_fields[]={ 15 static char *Interactive_fields[]={
24 "body", 16 "body",
25 }; 17 };
26 static PyTypeObject *Expression_type; 18 static PyTypeObject *Expression_type;
27 static char *Expression_fields[]={ 19 static char *Expression_fields[]={
28 "body", 20 "body",
29 }; 21 };
30 static PyTypeObject *Suite_type; 22 static PyTypeObject *Suite_type;
31 static char *Suite_fields[]={ 23 static char *Suite_fields[]={
32 "body", 24 "body",
33 }; 25 };
34 static PyTypeObject *stmt_type; 26 static PyTypeObject *stmt_type;
27 _Py_IDENTIFIER(lineno);
28 _Py_IDENTIFIER(col_offset);
35 static char *stmt_attributes[] = { 29 static char *stmt_attributes[] = {
36 "lineno", 30 "lineno",
37 "col_offset", 31 "col_offset",
38 }; 32 };
39 static PyObject* ast2obj_stmt(void*); 33 static PyObject* ast2obj_stmt(void*);
40 static PyTypeObject *FunctionDef_type; 34 static PyTypeObject *FunctionDef_type;
35 _Py_IDENTIFIER(name);
36 _Py_IDENTIFIER(args);
37 _Py_IDENTIFIER(decorator_list);
38 _Py_IDENTIFIER(returns);
41 static char *FunctionDef_fields[]={ 39 static char *FunctionDef_fields[]={
42 "name", 40 "name",
43 "args", 41 "args",
44 "body", 42 "body",
45 "decorator_list", 43 "decorator_list",
46 "returns", 44 "returns",
47 }; 45 };
48 static PyTypeObject *ClassDef_type; 46 static PyTypeObject *ClassDef_type;
47 _Py_IDENTIFIER(bases);
48 _Py_IDENTIFIER(keywords);
49 _Py_IDENTIFIER(starargs);
50 _Py_IDENTIFIER(kwargs);
49 static char *ClassDef_fields[]={ 51 static char *ClassDef_fields[]={
50 "name", 52 "name",
51 "bases", 53 "bases",
52 "keywords", 54 "keywords",
53 "starargs", 55 "starargs",
54 "kwargs", 56 "kwargs",
55 "body", 57 "body",
56 "decorator_list", 58 "decorator_list",
57 }; 59 };
58 static PyTypeObject *Return_type; 60 static PyTypeObject *Return_type;
61 _Py_IDENTIFIER(value);
59 static char *Return_fields[]={ 62 static char *Return_fields[]={
60 "value", 63 "value",
61 }; 64 };
62 static PyTypeObject *Delete_type; 65 static PyTypeObject *Delete_type;
66 _Py_IDENTIFIER(targets);
63 static char *Delete_fields[]={ 67 static char *Delete_fields[]={
64 "targets", 68 "targets",
65 }; 69 };
66 static PyTypeObject *Assign_type; 70 static PyTypeObject *Assign_type;
67 static char *Assign_fields[]={ 71 static char *Assign_fields[]={
68 "targets", 72 "targets",
69 "value", 73 "value",
70 }; 74 };
71 static PyTypeObject *AugAssign_type; 75 static PyTypeObject *AugAssign_type;
76 _Py_IDENTIFIER(target);
77 _Py_IDENTIFIER(op);
72 static char *AugAssign_fields[]={ 78 static char *AugAssign_fields[]={
73 "target", 79 "target",
74 "op", 80 "op",
75 "value", 81 "value",
76 }; 82 };
77 static PyTypeObject *For_type; 83 static PyTypeObject *For_type;
84 _Py_IDENTIFIER(iter);
85 _Py_IDENTIFIER(orelse);
78 static char *For_fields[]={ 86 static char *For_fields[]={
79 "target", 87 "target",
80 "iter", 88 "iter",
81 "body", 89 "body",
82 "orelse", 90 "orelse",
83 }; 91 };
84 static PyTypeObject *While_type; 92 static PyTypeObject *While_type;
93 _Py_IDENTIFIER(test);
85 static char *While_fields[]={ 94 static char *While_fields[]={
86 "test", 95 "test",
87 "body", 96 "body",
88 "orelse", 97 "orelse",
89 }; 98 };
90 static PyTypeObject *If_type; 99 static PyTypeObject *If_type;
91 static char *If_fields[]={ 100 static char *If_fields[]={
92 "test", 101 "test",
93 "body", 102 "body",
94 "orelse", 103 "orelse",
95 }; 104 };
96 static PyTypeObject *With_type; 105 static PyTypeObject *With_type;
106 _Py_IDENTIFIER(items);
97 static char *With_fields[]={ 107 static char *With_fields[]={
98 "items", 108 "items",
99 "body", 109 "body",
100 }; 110 };
101 static PyTypeObject *Raise_type; 111 static PyTypeObject *Raise_type;
112 _Py_IDENTIFIER(exc);
113 _Py_IDENTIFIER(cause);
102 static char *Raise_fields[]={ 114 static char *Raise_fields[]={
103 "exc", 115 "exc",
104 "cause", 116 "cause",
105 }; 117 };
106 static PyTypeObject *Try_type; 118 static PyTypeObject *Try_type;
119 _Py_IDENTIFIER(handlers);
120 _Py_IDENTIFIER(finalbody);
107 static char *Try_fields[]={ 121 static char *Try_fields[]={
108 "body", 122 "body",
109 "handlers", 123 "handlers",
110 "orelse", 124 "orelse",
111 "finalbody", 125 "finalbody",
112 }; 126 };
113 static PyTypeObject *Assert_type; 127 static PyTypeObject *Assert_type;
128 _Py_IDENTIFIER(msg);
114 static char *Assert_fields[]={ 129 static char *Assert_fields[]={
115 "test", 130 "test",
116 "msg", 131 "msg",
117 }; 132 };
118 static PyTypeObject *Import_type; 133 static PyTypeObject *Import_type;
134 _Py_IDENTIFIER(names);
119 static char *Import_fields[]={ 135 static char *Import_fields[]={
120 "names", 136 "names",
121 }; 137 };
122 static PyTypeObject *ImportFrom_type; 138 static PyTypeObject *ImportFrom_type;
139 _Py_IDENTIFIER(module);
140 _Py_IDENTIFIER(level);
123 static char *ImportFrom_fields[]={ 141 static char *ImportFrom_fields[]={
124 "module", 142 "module",
125 "names", 143 "names",
126 "level", 144 "level",
127 }; 145 };
128 static PyTypeObject *Global_type; 146 static PyTypeObject *Global_type;
129 static char *Global_fields[]={ 147 static char *Global_fields[]={
130 "names", 148 "names",
131 }; 149 };
132 static PyTypeObject *Nonlocal_type; 150 static PyTypeObject *Nonlocal_type;
133 static char *Nonlocal_fields[]={ 151 static char *Nonlocal_fields[]={
134 "names", 152 "names",
135 }; 153 };
136 static PyTypeObject *Expr_type; 154 static PyTypeObject *Expr_type;
137 static char *Expr_fields[]={ 155 static char *Expr_fields[]={
138 "value", 156 "value",
139 }; 157 };
140 static PyTypeObject *Pass_type; 158 static PyTypeObject *Pass_type;
141 static PyTypeObject *Break_type; 159 static PyTypeObject *Break_type;
142 static PyTypeObject *Continue_type; 160 static PyTypeObject *Continue_type;
143 static PyTypeObject *expr_type; 161 static PyTypeObject *expr_type;
144 static char *expr_attributes[] = { 162 static char *expr_attributes[] = {
145 "lineno", 163 "lineno",
146 "col_offset", 164 "col_offset",
147 }; 165 };
148 static PyObject* ast2obj_expr(void*); 166 static PyObject* ast2obj_expr(void*);
149 static PyTypeObject *BoolOp_type; 167 static PyTypeObject *BoolOp_type;
168 _Py_IDENTIFIER(values);
150 static char *BoolOp_fields[]={ 169 static char *BoolOp_fields[]={
151 "op", 170 "op",
152 "values", 171 "values",
153 }; 172 };
154 static PyTypeObject *BinOp_type; 173 static PyTypeObject *BinOp_type;
174 _Py_IDENTIFIER(left);
175 _Py_IDENTIFIER(right);
155 static char *BinOp_fields[]={ 176 static char *BinOp_fields[]={
156 "left", 177 "left",
157 "op", 178 "op",
158 "right", 179 "right",
159 }; 180 };
160 static PyTypeObject *UnaryOp_type; 181 static PyTypeObject *UnaryOp_type;
182 _Py_IDENTIFIER(operand);
161 static char *UnaryOp_fields[]={ 183 static char *UnaryOp_fields[]={
162 "op", 184 "op",
163 "operand", 185 "operand",
164 }; 186 };
165 static PyTypeObject *Lambda_type; 187 static PyTypeObject *Lambda_type;
166 static char *Lambda_fields[]={ 188 static char *Lambda_fields[]={
167 "args", 189 "args",
168 "body", 190 "body",
169 }; 191 };
170 static PyTypeObject *IfExp_type; 192 static PyTypeObject *IfExp_type;
171 static char *IfExp_fields[]={ 193 static char *IfExp_fields[]={
172 "test", 194 "test",
173 "body", 195 "body",
174 "orelse", 196 "orelse",
175 }; 197 };
176 static PyTypeObject *Dict_type; 198 static PyTypeObject *Dict_type;
199 _Py_IDENTIFIER(keys);
177 static char *Dict_fields[]={ 200 static char *Dict_fields[]={
178 "keys", 201 "keys",
179 "values", 202 "values",
180 }; 203 };
181 static PyTypeObject *Set_type; 204 static PyTypeObject *Set_type;
205 _Py_IDENTIFIER(elts);
182 static char *Set_fields[]={ 206 static char *Set_fields[]={
183 "elts", 207 "elts",
184 }; 208 };
185 static PyTypeObject *ListComp_type; 209 static PyTypeObject *ListComp_type;
210 _Py_IDENTIFIER(elt);
211 _Py_IDENTIFIER(generators);
186 static char *ListComp_fields[]={ 212 static char *ListComp_fields[]={
187 "elt", 213 "elt",
188 "generators", 214 "generators",
189 }; 215 };
190 static PyTypeObject *SetComp_type; 216 static PyTypeObject *SetComp_type;
191 static char *SetComp_fields[]={ 217 static char *SetComp_fields[]={
192 "elt", 218 "elt",
193 "generators", 219 "generators",
194 }; 220 };
195 static PyTypeObject *DictComp_type; 221 static PyTypeObject *DictComp_type;
222 _Py_IDENTIFIER(key);
196 static char *DictComp_fields[]={ 223 static char *DictComp_fields[]={
197 "key", 224 "key",
198 "value", 225 "value",
199 "generators", 226 "generators",
200 }; 227 };
201 static PyTypeObject *GeneratorExp_type; 228 static PyTypeObject *GeneratorExp_type;
202 static char *GeneratorExp_fields[]={ 229 static char *GeneratorExp_fields[]={
203 "elt", 230 "elt",
204 "generators", 231 "generators",
205 }; 232 };
206 static PyTypeObject *Yield_type; 233 static PyTypeObject *Yield_type;
234 _Py_IDENTIFIER(is_from);
207 static char *Yield_fields[]={ 235 static char *Yield_fields[]={
208 "is_from", 236 "is_from",
209 "value", 237 "value",
210 }; 238 };
211 static PyTypeObject *Compare_type; 239 static PyTypeObject *Compare_type;
240 _Py_IDENTIFIER(ops);
241 _Py_IDENTIFIER(comparators);
212 static char *Compare_fields[]={ 242 static char *Compare_fields[]={
213 "left", 243 "left",
214 "ops", 244 "ops",
215 "comparators", 245 "comparators",
216 }; 246 };
217 static PyTypeObject *Call_type; 247 static PyTypeObject *Call_type;
248 _Py_IDENTIFIER(func);
218 static char *Call_fields[]={ 249 static char *Call_fields[]={
219 "func", 250 "func",
220 "args", 251 "args",
221 "keywords", 252 "keywords",
222 "starargs", 253 "starargs",
223 "kwargs", 254 "kwargs",
224 }; 255 };
225 static PyTypeObject *Num_type; 256 static PyTypeObject *Num_type;
257 _Py_IDENTIFIER(n);
226 static char *Num_fields[]={ 258 static char *Num_fields[]={
227 "n", 259 "n",
228 }; 260 };
229 static PyTypeObject *Str_type; 261 static PyTypeObject *Str_type;
262 _Py_IDENTIFIER(s);
230 static char *Str_fields[]={ 263 static char *Str_fields[]={
231 "s", 264 "s",
232 }; 265 };
233 static PyTypeObject *Bytes_type; 266 static PyTypeObject *Bytes_type;
234 static char *Bytes_fields[]={ 267 static char *Bytes_fields[]={
235 "s", 268 "s",
236 }; 269 };
237 static PyTypeObject *Ellipsis_type; 270 static PyTypeObject *Ellipsis_type;
238 static PyTypeObject *Attribute_type; 271 static PyTypeObject *Attribute_type;
272 _Py_IDENTIFIER(attr);
273 _Py_IDENTIFIER(ctx);
239 static char *Attribute_fields[]={ 274 static char *Attribute_fields[]={
240 "value", 275 "value",
241 "attr", 276 "attr",
242 "ctx", 277 "ctx",
243 }; 278 };
244 static PyTypeObject *Subscript_type; 279 static PyTypeObject *Subscript_type;
280 _Py_IDENTIFIER(slice);
245 static char *Subscript_fields[]={ 281 static char *Subscript_fields[]={
246 "value", 282 "value",
247 "slice", 283 "slice",
248 "ctx", 284 "ctx",
249 }; 285 };
250 static PyTypeObject *Starred_type; 286 static PyTypeObject *Starred_type;
251 static char *Starred_fields[]={ 287 static char *Starred_fields[]={
252 "value", 288 "value",
253 "ctx", 289 "ctx",
254 }; 290 };
255 static PyTypeObject *Name_type; 291 static PyTypeObject *Name_type;
292 _Py_IDENTIFIER(id);
256 static char *Name_fields[]={ 293 static char *Name_fields[]={
257 "id", 294 "id",
258 "ctx", 295 "ctx",
259 }; 296 };
260 static PyTypeObject *List_type; 297 static PyTypeObject *List_type;
261 static char *List_fields[]={ 298 static char *List_fields[]={
262 "elts", 299 "elts",
263 "ctx", 300 "ctx",
264 }; 301 };
265 static PyTypeObject *Tuple_type; 302 static PyTypeObject *Tuple_type;
266 static char *Tuple_fields[]={ 303 static char *Tuple_fields[]={
267 "elts", 304 "elts",
268 "ctx", 305 "ctx",
269 }; 306 };
270 static PyTypeObject *expr_context_type; 307 static PyTypeObject *expr_context_type;
271 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, 308 static PyObject *Load_singleton, *Store_singleton, *Del_singleton,
272 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; 309 *AugLoad_singleton, *AugStore_singleton, *Param_singleton;
273 static PyObject* ast2obj_expr_context(expr_context_ty); 310 static PyObject* ast2obj_expr_context(expr_context_ty);
274 static PyTypeObject *Load_type; 311 static PyTypeObject *Load_type;
275 static PyTypeObject *Store_type; 312 static PyTypeObject *Store_type;
276 static PyTypeObject *Del_type; 313 static PyTypeObject *Del_type;
277 static PyTypeObject *AugLoad_type; 314 static PyTypeObject *AugLoad_type;
278 static PyTypeObject *AugStore_type; 315 static PyTypeObject *AugStore_type;
279 static PyTypeObject *Param_type; 316 static PyTypeObject *Param_type;
280 static PyTypeObject *slice_type; 317 static PyTypeObject *slice_type;
281 static PyObject* ast2obj_slice(void*); 318 static PyObject* ast2obj_slice(void*);
282 static PyTypeObject *Slice_type; 319 static PyTypeObject *Slice_type;
320 _Py_IDENTIFIER(lower);
321 _Py_IDENTIFIER(upper);
322 _Py_IDENTIFIER(step);
283 static char *Slice_fields[]={ 323 static char *Slice_fields[]={
284 "lower", 324 "lower",
285 "upper", 325 "upper",
286 "step", 326 "step",
287 }; 327 };
288 static PyTypeObject *ExtSlice_type; 328 static PyTypeObject *ExtSlice_type;
329 _Py_IDENTIFIER(dims);
289 static char *ExtSlice_fields[]={ 330 static char *ExtSlice_fields[]={
290 "dims", 331 "dims",
291 }; 332 };
292 static PyTypeObject *Index_type; 333 static PyTypeObject *Index_type;
293 static char *Index_fields[]={ 334 static char *Index_fields[]={
294 "value", 335 "value",
295 }; 336 };
296 static PyTypeObject *boolop_type; 337 static PyTypeObject *boolop_type;
297 static PyObject *And_singleton, *Or_singleton; 338 static PyObject *And_singleton, *Or_singleton;
298 static PyObject* ast2obj_boolop(boolop_ty); 339 static PyObject* ast2obj_boolop(boolop_ty);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 static PyTypeObject *Lt_type; 375 static PyTypeObject *Lt_type;
335 static PyTypeObject *LtE_type; 376 static PyTypeObject *LtE_type;
336 static PyTypeObject *Gt_type; 377 static PyTypeObject *Gt_type;
337 static PyTypeObject *GtE_type; 378 static PyTypeObject *GtE_type;
338 static PyTypeObject *Is_type; 379 static PyTypeObject *Is_type;
339 static PyTypeObject *IsNot_type; 380 static PyTypeObject *IsNot_type;
340 static PyTypeObject *In_type; 381 static PyTypeObject *In_type;
341 static PyTypeObject *NotIn_type; 382 static PyTypeObject *NotIn_type;
342 static PyTypeObject *comprehension_type; 383 static PyTypeObject *comprehension_type;
343 static PyObject* ast2obj_comprehension(void*); 384 static PyObject* ast2obj_comprehension(void*);
385 _Py_IDENTIFIER(ifs);
344 static char *comprehension_fields[]={ 386 static char *comprehension_fields[]={
345 "target", 387 "target",
346 "iter", 388 "iter",
347 "ifs", 389 "ifs",
348 }; 390 };
349 static PyTypeObject *excepthandler_type; 391 static PyTypeObject *excepthandler_type;
350 static char *excepthandler_attributes[] = { 392 static char *excepthandler_attributes[] = {
351 "lineno", 393 "lineno",
352 "col_offset", 394 "col_offset",
353 }; 395 };
354 static PyObject* ast2obj_excepthandler(void*); 396 static PyObject* ast2obj_excepthandler(void*);
355 static PyTypeObject *ExceptHandler_type; 397 static PyTypeObject *ExceptHandler_type;
398 _Py_IDENTIFIER(type);
356 static char *ExceptHandler_fields[]={ 399 static char *ExceptHandler_fields[]={
357 "type", 400 "type",
358 "name", 401 "name",
359 "body", 402 "body",
360 }; 403 };
361 static PyTypeObject *arguments_type; 404 static PyTypeObject *arguments_type;
362 static PyObject* ast2obj_arguments(void*); 405 static PyObject* ast2obj_arguments(void*);
406 _Py_IDENTIFIER(vararg);
407 _Py_IDENTIFIER(varargannotation);
408 _Py_IDENTIFIER(kwonlyargs);
409 _Py_IDENTIFIER(kwarg);
410 _Py_IDENTIFIER(kwargannotation);
411 _Py_IDENTIFIER(defaults);
412 _Py_IDENTIFIER(kw_defaults);
363 static char *arguments_fields[]={ 413 static char *arguments_fields[]={
364 "args", 414 "args",
365 "vararg", 415 "vararg",
366 "varargannotation", 416 "varargannotation",
367 "kwonlyargs", 417 "kwonlyargs",
368 "kwarg", 418 "kwarg",
369 "kwargannotation", 419 "kwargannotation",
370 "defaults", 420 "defaults",
371 "kw_defaults", 421 "kw_defaults",
372 }; 422 };
373 static PyTypeObject *arg_type; 423 static PyTypeObject *arg_type;
374 static PyObject* ast2obj_arg(void*); 424 static PyObject* ast2obj_arg(void*);
425 _Py_IDENTIFIER(arg);
426 _Py_IDENTIFIER(annotation);
375 static char *arg_fields[]={ 427 static char *arg_fields[]={
376 "arg", 428 "arg",
377 "annotation", 429 "annotation",
378 }; 430 };
379 static PyTypeObject *keyword_type; 431 static PyTypeObject *keyword_type;
380 static PyObject* ast2obj_keyword(void*); 432 static PyObject* ast2obj_keyword(void*);
381 static char *keyword_fields[]={ 433 static char *keyword_fields[]={
382 "arg", 434 "arg",
383 "value", 435 "value",
384 }; 436 };
385 static PyTypeObject *alias_type; 437 static PyTypeObject *alias_type;
386 static PyObject* ast2obj_alias(void*); 438 static PyObject* ast2obj_alias(void*);
439 _Py_IDENTIFIER(asname);
387 static char *alias_fields[]={ 440 static char *alias_fields[]={
388 "name", 441 "name",
389 "asname", 442 "asname",
390 }; 443 };
391 static PyTypeObject *withitem_type; 444 static PyTypeObject *withitem_type;
392 static PyObject* ast2obj_withitem(void*); 445 static PyObject* ast2obj_withitem(void*);
446 _Py_IDENTIFIER(context_expr);
447 _Py_IDENTIFIER(optional_vars);
393 static char *withitem_fields[]={ 448 static char *withitem_fields[]={
394 "context_expr", 449 "context_expr",
395 "optional_vars", 450 "optional_vars",
396 }; 451 };
397 452
398 453
399 static int 454 static int
400 ast_type_init(PyObject *self, PyObject *args, PyObject *kw) 455 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
401 { 456 {
457 _Py_IDENTIFIER(_fields);
402 Py_ssize_t i, numfields = 0; 458 Py_ssize_t i, numfields = 0;
403 int res = -1; 459 int res = -1;
404 PyObject *key, *value, *fields; 460 PyObject *key, *value, *fields;
405 fields = PyObject_GetAttrString((PyObject*)Py_TYPE(self), "_fields"); 461 fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields);
406 if (!fields) 462 if (!fields)
407 PyErr_Clear(); 463 PyErr_Clear();
408 if (fields) { 464 if (fields) {
409 numfields = PySequence_Size(fields); 465 numfields = PySequence_Size(fields);
410 if (numfields == -1) 466 if (numfields == -1)
411 goto cleanup; 467 goto cleanup;
412 } 468 }
413 res = 0; /* if no error occurs, this stays 0 to the end */ 469 res = 0; /* if no error occurs, this stays 0 to the end */
414 if (PyTuple_GET_SIZE(args) > 0) { 470 if (PyTuple_GET_SIZE(args) > 0) {
415 if (numfields != PyTuple_GET_SIZE(args)) { 471 if (numfields != PyTuple_GET_SIZE(args)) {
(...skipping 29 matching lines...) Expand all
445 cleanup: 501 cleanup:
446 Py_XDECREF(fields); 502 Py_XDECREF(fields);
447 return res; 503 return res;
448 } 504 }
449 505
450 /* Pickling support */ 506 /* Pickling support */
451 static PyObject * 507 static PyObject *
452 ast_type_reduce(PyObject *self, PyObject *unused) 508 ast_type_reduce(PyObject *self, PyObject *unused)
453 { 509 {
454 PyObject *res; 510 PyObject *res;
455 PyObject *dict = PyObject_GetAttrString(self, "__dict__"); 511 _Py_IDENTIFIER(__dict__);
512 PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
456 if (dict == NULL) { 513 if (dict == NULL) {
457 if (PyErr_ExceptionMatches(PyExc_AttributeError)) 514 if (PyErr_ExceptionMatches(PyExc_AttributeError))
458 PyErr_Clear(); 515 PyErr_Clear();
459 else 516 else
460 return NULL; 517 return NULL;
461 } 518 }
462 if (dict) { 519 if (dict) {
463 res = Py_BuildValue("O()O", Py_TYPE(self), dict); 520 res = Py_BuildValue("O()O", Py_TYPE(self), dict);
464 Py_DECREF(dict); 521 Py_DECREF(dict);
465 return res; 522 return res;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 588 }
532 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}", 589 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
533 type, base, "_fields", fnames, "__module__", "_ast"); 590 type, base, "_fields", fnames, "__module__", "_ast");
534 Py_DECREF(fnames); 591 Py_DECREF(fnames);
535 return (PyTypeObject*)result; 592 return (PyTypeObject*)result;
536 } 593 }
537 594
538 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) 595 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
539 { 596 {
540 int i, result; 597 int i, result;
598 _Py_IDENTIFIER(_attributes);
541 PyObject *s, *l = PyTuple_New(num_fields); 599 PyObject *s, *l = PyTuple_New(num_fields);
542 if (!l) 600 if (!l)
543 return 0; 601 return 0;
544 for (i = 0; i < num_fields; i++) { 602 for (i = 0; i < num_fields; i++) {
545 s = PyUnicode_FromString(attrs[i]); 603 s = PyUnicode_FromString(attrs[i]);
546 if (!s) { 604 if (!s) {
547 Py_DECREF(l); 605 Py_DECREF(l);
548 return 0; 606 return 0;
549 } 607 }
550 PyTuple_SET_ITEM(l, i, s); 608 PyTuple_SET_ITEM(l, i, s);
551 } 609 }
552 result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; 610 result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0;
553 Py_DECREF(l); 611 Py_DECREF(l);
554 return result; 612 return result;
555 } 613 }
556 614
557 /* Conversion AST -> Python */ 615 /* Conversion AST -> Python */
558 616
559 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*)) 617 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
560 { 618 {
561 int i, n = asdl_seq_LEN(seq); 619 int i, n = asdl_seq_LEN(seq);
562 PyObject *result = PyList_New(n); 620 PyObject *result = PyList_New(n);
(...skipping 13 matching lines...) Expand all
576 634
577 static PyObject* ast2obj_object(void *o) 635 static PyObject* ast2obj_object(void *o)
578 { 636 {
579 if (!o) 637 if (!o)
580 o = Py_None; 638 o = Py_None;
581 Py_INCREF((PyObject*)o); 639 Py_INCREF((PyObject*)o);
582 return (PyObject*)o; 640 return (PyObject*)o;
583 } 641 }
584 #define ast2obj_identifier ast2obj_object 642 #define ast2obj_identifier ast2obj_object
585 #define ast2obj_string ast2obj_object 643 #define ast2obj_string ast2obj_object
644 #define ast2obj_bytes ast2obj_object
586 645
587 static PyObject* ast2obj_int(long b) 646 static PyObject* ast2obj_int(long b)
588 { 647 {
589 return PyLong_FromLong(b); 648 return PyLong_FromLong(b);
590 } 649 }
591 650
592 /* Conversion Python -> AST */ 651 /* Conversion Python -> AST */
593 652
594 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) 653 static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
595 { 654 {
596 if (obj == Py_None) 655 if (obj == Py_None)
597 obj = NULL; 656 obj = NULL;
598 if (obj) 657 if (obj)
599 PyArena_AddPyObject(arena, obj); 658 PyArena_AddPyObject(arena, obj);
600 Py_XINCREF(obj); 659 Py_XINCREF(obj);
601 *out = obj; 660 *out = obj;
602 return 0; 661 return 0;
603 } 662 }
604 663
605 #define obj2ast_identifier obj2ast_object 664 static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
606 #define obj2ast_string obj2ast_object 665 {
666 if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
667 PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
668 return 1;
669 }
670 return obj2ast_object(obj, out, arena);
671 }
672
673 static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
674 {
675 if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
676 PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
677 return 1;
678 }
679 return obj2ast_object(obj, out, arena);
680 }
681
682 static int obj2ast_bytes(PyObject* obj, PyObject** out, PyArena* arena)
683 {
684 if (!PyBytes_CheckExact(obj)) {
685 PyErr_SetString(PyExc_TypeError, "AST bytes must be of type bytes");
686 return 1;
687 }
688 return obj2ast_object(obj, out, arena);
689 }
607 690
608 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) 691 static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
609 { 692 {
610 int i; 693 int i;
611 if (!PyLong_Check(obj)) { 694 if (!PyLong_Check(obj)) {
612 PyObject *s = PyObject_Repr(obj); 695 PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
613 if (s == NULL) return 1;
614 PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
615 PyBytes_AS_STRING(s));
616 Py_DECREF(s);
617 return 1; 696 return 1;
618 } 697 }
619 698
620 i = (int)PyLong_AsLong(obj); 699 i = (int)PyLong_AsLong(obj);
621 if (i == -1 && PyErr_Occurred()) 700 if (i == -1 && PyErr_Occurred())
622 return 1; 701 return 1;
623 *out = i; 702 *out = i;
624 return 0; 703 return 0;
625 } 704 }
626 705
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 if (!p) 1841 if (!p)
1763 return NULL; 1842 return NULL;
1764 p->kind = Str_kind; 1843 p->kind = Str_kind;
1765 p->v.Str.s = s; 1844 p->v.Str.s = s;
1766 p->lineno = lineno; 1845 p->lineno = lineno;
1767 p->col_offset = col_offset; 1846 p->col_offset = col_offset;
1768 return p; 1847 return p;
1769 } 1848 }
1770 1849
1771 expr_ty 1850 expr_ty
1772 Bytes(string s, int lineno, int col_offset, PyArena *arena) 1851 Bytes(bytes s, int lineno, int col_offset, PyArena *arena)
1773 { 1852 {
1774 expr_ty p; 1853 expr_ty p;
1775 if (!s) { 1854 if (!s) {
1776 PyErr_SetString(PyExc_ValueError, 1855 PyErr_SetString(PyExc_ValueError,
1777 "field s is required for Bytes"); 1856 "field s is required for Bytes");
1778 return NULL; 1857 return NULL;
1779 } 1858 }
1780 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1859 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1781 if (!p) 1860 if (!p)
1782 return NULL; 1861 return NULL;
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 Py_INCREF(Py_None); 2223 Py_INCREF(Py_None);
2145 return Py_None; 2224 return Py_None;
2146 } 2225 }
2147 2226
2148 switch (o->kind) { 2227 switch (o->kind) {
2149 case Module_kind: 2228 case Module_kind:
2150 result = PyType_GenericNew(Module_type, NULL, NULL); 2229 result = PyType_GenericNew(Module_type, NULL, NULL);
2151 if (!result) goto failed; 2230 if (!result) goto failed;
2152 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); 2231 value = ast2obj_list(o->v.Module.body, ast2obj_stmt);
2153 if (!value) goto failed; 2232 if (!value) goto failed;
2154 if (PyObject_SetAttrString(result, "body", value) == -1) 2233 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2155 goto failed; 2234 goto failed;
2156 Py_DECREF(value); 2235 Py_DECREF(value);
2157 break; 2236 break;
2158 case Interactive_kind: 2237 case Interactive_kind:
2159 result = PyType_GenericNew(Interactive_type, NULL, NULL); 2238 result = PyType_GenericNew(Interactive_type, NULL, NULL);
2160 if (!result) goto failed; 2239 if (!result) goto failed;
2161 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); 2240 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt);
2162 if (!value) goto failed; 2241 if (!value) goto failed;
2163 if (PyObject_SetAttrString(result, "body", value) == -1) 2242 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2164 goto failed; 2243 goto failed;
2165 Py_DECREF(value); 2244 Py_DECREF(value);
2166 break; 2245 break;
2167 case Expression_kind: 2246 case Expression_kind:
2168 result = PyType_GenericNew(Expression_type, NULL, NULL); 2247 result = PyType_GenericNew(Expression_type, NULL, NULL);
2169 if (!result) goto failed; 2248 if (!result) goto failed;
2170 value = ast2obj_expr(o->v.Expression.body); 2249 value = ast2obj_expr(o->v.Expression.body);
2171 if (!value) goto failed; 2250 if (!value) goto failed;
2172 if (PyObject_SetAttrString(result, "body", value) == -1) 2251 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2173 goto failed; 2252 goto failed;
2174 Py_DECREF(value); 2253 Py_DECREF(value);
2175 break; 2254 break;
2176 case Suite_kind: 2255 case Suite_kind:
2177 result = PyType_GenericNew(Suite_type, NULL, NULL); 2256 result = PyType_GenericNew(Suite_type, NULL, NULL);
2178 if (!result) goto failed; 2257 if (!result) goto failed;
2179 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); 2258 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt);
2180 if (!value) goto failed; 2259 if (!value) goto failed;
2181 if (PyObject_SetAttrString(result, "body", value) == -1) 2260 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2182 goto failed; 2261 goto failed;
2183 Py_DECREF(value); 2262 Py_DECREF(value);
2184 break; 2263 break;
2185 } 2264 }
2186 return result; 2265 return result;
2187 failed: 2266 failed:
2188 Py_XDECREF(value); 2267 Py_XDECREF(value);
2189 Py_XDECREF(result); 2268 Py_XDECREF(result);
2190 return NULL; 2269 return NULL;
2191 } 2270 }
2192 2271
2193 PyObject* 2272 PyObject*
2194 ast2obj_stmt(void* _o) 2273 ast2obj_stmt(void* _o)
2195 { 2274 {
2196 stmt_ty o = (stmt_ty)_o; 2275 stmt_ty o = (stmt_ty)_o;
2197 PyObject *result = NULL, *value = NULL; 2276 PyObject *result = NULL, *value = NULL;
2198 if (!o) { 2277 if (!o) {
2199 Py_INCREF(Py_None); 2278 Py_INCREF(Py_None);
2200 return Py_None; 2279 return Py_None;
2201 } 2280 }
2202 2281
2203 switch (o->kind) { 2282 switch (o->kind) {
2204 case FunctionDef_kind: 2283 case FunctionDef_kind:
2205 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); 2284 result = PyType_GenericNew(FunctionDef_type, NULL, NULL);
2206 if (!result) goto failed; 2285 if (!result) goto failed;
2207 value = ast2obj_identifier(o->v.FunctionDef.name); 2286 value = ast2obj_identifier(o->v.FunctionDef.name);
2208 if (!value) goto failed; 2287 if (!value) goto failed;
2209 if (PyObject_SetAttrString(result, "name", value) == -1) 2288 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
2210 goto failed; 2289 goto failed;
2211 Py_DECREF(value); 2290 Py_DECREF(value);
2212 value = ast2obj_arguments(o->v.FunctionDef.args); 2291 value = ast2obj_arguments(o->v.FunctionDef.args);
2213 if (!value) goto failed; 2292 if (!value) goto failed;
2214 if (PyObject_SetAttrString(result, "args", value) == -1) 2293 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
2215 goto failed; 2294 goto failed;
2216 Py_DECREF(value); 2295 Py_DECREF(value);
2217 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); 2296 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt);
2218 if (!value) goto failed; 2297 if (!value) goto failed;
2219 if (PyObject_SetAttrString(result, "body", value) == -1) 2298 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2220 goto failed; 2299 goto failed;
2221 Py_DECREF(value); 2300 Py_DECREF(value);
2222 value = ast2obj_list(o->v.FunctionDef.decorator_list, 2301 value = ast2obj_list(o->v.FunctionDef.decorator_list,
2223 ast2obj_expr); 2302 ast2obj_expr);
2224 if (!value) goto failed; 2303 if (!value) goto failed;
2225 if (PyObject_SetAttrString(result, "decorator_list", value) == 2304 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) ==
2226 -1) 2305 -1)
2227 goto failed; 2306 goto failed;
2228 Py_DECREF(value); 2307 Py_DECREF(value);
2229 value = ast2obj_expr(o->v.FunctionDef.returns); 2308 value = ast2obj_expr(o->v.FunctionDef.returns);
2230 if (!value) goto failed; 2309 if (!value) goto failed;
2231 if (PyObject_SetAttrString(result, "returns", value) == -1) 2310 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1)
2232 goto failed; 2311 goto failed;
2233 Py_DECREF(value); 2312 Py_DECREF(value);
2234 break; 2313 break;
2235 case ClassDef_kind: 2314 case ClassDef_kind:
2236 result = PyType_GenericNew(ClassDef_type, NULL, NULL); 2315 result = PyType_GenericNew(ClassDef_type, NULL, NULL);
2237 if (!result) goto failed; 2316 if (!result) goto failed;
2238 value = ast2obj_identifier(o->v.ClassDef.name); 2317 value = ast2obj_identifier(o->v.ClassDef.name);
2239 if (!value) goto failed; 2318 if (!value) goto failed;
2240 if (PyObject_SetAttrString(result, "name", value) == -1) 2319 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
2241 goto failed; 2320 goto failed;
2242 Py_DECREF(value); 2321 Py_DECREF(value);
2243 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); 2322 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr);
2244 if (!value) goto failed; 2323 if (!value) goto failed;
2245 if (PyObject_SetAttrString(result, "bases", value) == -1) 2324 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1)
2246 goto failed; 2325 goto failed;
2247 Py_DECREF(value); 2326 Py_DECREF(value);
2248 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword); 2327 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword);
2249 if (!value) goto failed; 2328 if (!value) goto failed;
2250 if (PyObject_SetAttrString(result, "keywords", value) == -1) 2329 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
2251 goto failed; 2330 goto failed;
2252 Py_DECREF(value); 2331 Py_DECREF(value);
2253 value = ast2obj_expr(o->v.ClassDef.starargs); 2332 value = ast2obj_expr(o->v.ClassDef.starargs);
2254 if (!value) goto failed; 2333 if (!value) goto failed;
2255 if (PyObject_SetAttrString(result, "starargs", value) == -1) 2334 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
2256 goto failed; 2335 goto failed;
2257 Py_DECREF(value); 2336 Py_DECREF(value);
2258 value = ast2obj_expr(o->v.ClassDef.kwargs); 2337 value = ast2obj_expr(o->v.ClassDef.kwargs);
2259 if (!value) goto failed; 2338 if (!value) goto failed;
2260 if (PyObject_SetAttrString(result, "kwargs", value) == -1) 2339 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
2261 goto failed; 2340 goto failed;
2262 Py_DECREF(value); 2341 Py_DECREF(value);
2263 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); 2342 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt);
2264 if (!value) goto failed; 2343 if (!value) goto failed;
2265 if (PyObject_SetAttrString(result, "body", value) == -1) 2344 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2266 goto failed; 2345 goto failed;
2267 Py_DECREF(value); 2346 Py_DECREF(value);
2268 value = ast2obj_list(o->v.ClassDef.decorator_list, 2347 value = ast2obj_list(o->v.ClassDef.decorator_list,
2269 ast2obj_expr); 2348 ast2obj_expr);
2270 if (!value) goto failed; 2349 if (!value) goto failed;
2271 if (PyObject_SetAttrString(result, "decorator_list", value) == 2350 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) ==
2272 -1) 2351 -1)
2273 goto failed; 2352 goto failed;
2274 Py_DECREF(value); 2353 Py_DECREF(value);
2275 break; 2354 break;
2276 case Return_kind: 2355 case Return_kind:
2277 result = PyType_GenericNew(Return_type, NULL, NULL); 2356 result = PyType_GenericNew(Return_type, NULL, NULL);
2278 if (!result) goto failed; 2357 if (!result) goto failed;
2279 value = ast2obj_expr(o->v.Return.value); 2358 value = ast2obj_expr(o->v.Return.value);
2280 if (!value) goto failed; 2359 if (!value) goto failed;
2281 if (PyObject_SetAttrString(result, "value", value) == -1) 2360 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2282 goto failed; 2361 goto failed;
2283 Py_DECREF(value); 2362 Py_DECREF(value);
2284 break; 2363 break;
2285 case Delete_kind: 2364 case Delete_kind:
2286 result = PyType_GenericNew(Delete_type, NULL, NULL); 2365 result = PyType_GenericNew(Delete_type, NULL, NULL);
2287 if (!result) goto failed; 2366 if (!result) goto failed;
2288 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); 2367 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr);
2289 if (!value) goto failed; 2368 if (!value) goto failed;
2290 if (PyObject_SetAttrString(result, "targets", value) == -1) 2369 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
2291 goto failed; 2370 goto failed;
2292 Py_DECREF(value); 2371 Py_DECREF(value);
2293 break; 2372 break;
2294 case Assign_kind: 2373 case Assign_kind:
2295 result = PyType_GenericNew(Assign_type, NULL, NULL); 2374 result = PyType_GenericNew(Assign_type, NULL, NULL);
2296 if (!result) goto failed; 2375 if (!result) goto failed;
2297 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); 2376 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr);
2298 if (!value) goto failed; 2377 if (!value) goto failed;
2299 if (PyObject_SetAttrString(result, "targets", value) == -1) 2378 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
2300 goto failed; 2379 goto failed;
2301 Py_DECREF(value); 2380 Py_DECREF(value);
2302 value = ast2obj_expr(o->v.Assign.value); 2381 value = ast2obj_expr(o->v.Assign.value);
2303 if (!value) goto failed; 2382 if (!value) goto failed;
2304 if (PyObject_SetAttrString(result, "value", value) == -1) 2383 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2305 goto failed; 2384 goto failed;
2306 Py_DECREF(value); 2385 Py_DECREF(value);
2307 break; 2386 break;
2308 case AugAssign_kind: 2387 case AugAssign_kind:
2309 result = PyType_GenericNew(AugAssign_type, NULL, NULL); 2388 result = PyType_GenericNew(AugAssign_type, NULL, NULL);
2310 if (!result) goto failed; 2389 if (!result) goto failed;
2311 value = ast2obj_expr(o->v.AugAssign.target); 2390 value = ast2obj_expr(o->v.AugAssign.target);
2312 if (!value) goto failed; 2391 if (!value) goto failed;
2313 if (PyObject_SetAttrString(result, "target", value) == -1) 2392 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
2314 goto failed; 2393 goto failed;
2315 Py_DECREF(value); 2394 Py_DECREF(value);
2316 value = ast2obj_operator(o->v.AugAssign.op); 2395 value = ast2obj_operator(o->v.AugAssign.op);
2317 if (!value) goto failed; 2396 if (!value) goto failed;
2318 if (PyObject_SetAttrString(result, "op", value) == -1) 2397 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2319 goto failed; 2398 goto failed;
2320 Py_DECREF(value); 2399 Py_DECREF(value);
2321 value = ast2obj_expr(o->v.AugAssign.value); 2400 value = ast2obj_expr(o->v.AugAssign.value);
2322 if (!value) goto failed; 2401 if (!value) goto failed;
2323 if (PyObject_SetAttrString(result, "value", value) == -1) 2402 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2324 goto failed; 2403 goto failed;
2325 Py_DECREF(value); 2404 Py_DECREF(value);
2326 break; 2405 break;
2327 case For_kind: 2406 case For_kind:
2328 result = PyType_GenericNew(For_type, NULL, NULL); 2407 result = PyType_GenericNew(For_type, NULL, NULL);
2329 if (!result) goto failed; 2408 if (!result) goto failed;
2330 value = ast2obj_expr(o->v.For.target); 2409 value = ast2obj_expr(o->v.For.target);
2331 if (!value) goto failed; 2410 if (!value) goto failed;
2332 if (PyObject_SetAttrString(result, "target", value) == -1) 2411 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
2333 goto failed; 2412 goto failed;
2334 Py_DECREF(value); 2413 Py_DECREF(value);
2335 value = ast2obj_expr(o->v.For.iter); 2414 value = ast2obj_expr(o->v.For.iter);
2336 if (!value) goto failed; 2415 if (!value) goto failed;
2337 if (PyObject_SetAttrString(result, "iter", value) == -1) 2416 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
2338 goto failed; 2417 goto failed;
2339 Py_DECREF(value); 2418 Py_DECREF(value);
2340 value = ast2obj_list(o->v.For.body, ast2obj_stmt); 2419 value = ast2obj_list(o->v.For.body, ast2obj_stmt);
2341 if (!value) goto failed; 2420 if (!value) goto failed;
2342 if (PyObject_SetAttrString(result, "body", value) == -1) 2421 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2343 goto failed; 2422 goto failed;
2344 Py_DECREF(value); 2423 Py_DECREF(value);
2345 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); 2424 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt);
2346 if (!value) goto failed; 2425 if (!value) goto failed;
2347 if (PyObject_SetAttrString(result, "orelse", value) == -1) 2426 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2348 goto failed; 2427 goto failed;
2349 Py_DECREF(value); 2428 Py_DECREF(value);
2350 break; 2429 break;
2351 case While_kind: 2430 case While_kind:
2352 result = PyType_GenericNew(While_type, NULL, NULL); 2431 result = PyType_GenericNew(While_type, NULL, NULL);
2353 if (!result) goto failed; 2432 if (!result) goto failed;
2354 value = ast2obj_expr(o->v.While.test); 2433 value = ast2obj_expr(o->v.While.test);
2355 if (!value) goto failed; 2434 if (!value) goto failed;
2356 if (PyObject_SetAttrString(result, "test", value) == -1) 2435 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2357 goto failed; 2436 goto failed;
2358 Py_DECREF(value); 2437 Py_DECREF(value);
2359 value = ast2obj_list(o->v.While.body, ast2obj_stmt); 2438 value = ast2obj_list(o->v.While.body, ast2obj_stmt);
2360 if (!value) goto failed; 2439 if (!value) goto failed;
2361 if (PyObject_SetAttrString(result, "body", value) == -1) 2440 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2362 goto failed; 2441 goto failed;
2363 Py_DECREF(value); 2442 Py_DECREF(value);
2364 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); 2443 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt);
2365 if (!value) goto failed; 2444 if (!value) goto failed;
2366 if (PyObject_SetAttrString(result, "orelse", value) == -1) 2445 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2367 goto failed; 2446 goto failed;
2368 Py_DECREF(value); 2447 Py_DECREF(value);
2369 break; 2448 break;
2370 case If_kind: 2449 case If_kind:
2371 result = PyType_GenericNew(If_type, NULL, NULL); 2450 result = PyType_GenericNew(If_type, NULL, NULL);
2372 if (!result) goto failed; 2451 if (!result) goto failed;
2373 value = ast2obj_expr(o->v.If.test); 2452 value = ast2obj_expr(o->v.If.test);
2374 if (!value) goto failed; 2453 if (!value) goto failed;
2375 if (PyObject_SetAttrString(result, "test", value) == -1) 2454 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2376 goto failed; 2455 goto failed;
2377 Py_DECREF(value); 2456 Py_DECREF(value);
2378 value = ast2obj_list(o->v.If.body, ast2obj_stmt); 2457 value = ast2obj_list(o->v.If.body, ast2obj_stmt);
2379 if (!value) goto failed; 2458 if (!value) goto failed;
2380 if (PyObject_SetAttrString(result, "body", value) == -1) 2459 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2381 goto failed; 2460 goto failed;
2382 Py_DECREF(value); 2461 Py_DECREF(value);
2383 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); 2462 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt);
2384 if (!value) goto failed; 2463 if (!value) goto failed;
2385 if (PyObject_SetAttrString(result, "orelse", value) == -1) 2464 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2386 goto failed; 2465 goto failed;
2387 Py_DECREF(value); 2466 Py_DECREF(value);
2388 break; 2467 break;
2389 case With_kind: 2468 case With_kind:
2390 result = PyType_GenericNew(With_type, NULL, NULL); 2469 result = PyType_GenericNew(With_type, NULL, NULL);
2391 if (!result) goto failed; 2470 if (!result) goto failed;
2392 value = ast2obj_list(o->v.With.items, ast2obj_withitem); 2471 value = ast2obj_list(o->v.With.items, ast2obj_withitem);
2393 if (!value) goto failed; 2472 if (!value) goto failed;
2394 if (PyObject_SetAttrString(result, "items", value) == -1) 2473 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1)
2395 goto failed; 2474 goto failed;
2396 Py_DECREF(value); 2475 Py_DECREF(value);
2397 value = ast2obj_list(o->v.With.body, ast2obj_stmt); 2476 value = ast2obj_list(o->v.With.body, ast2obj_stmt);
2398 if (!value) goto failed; 2477 if (!value) goto failed;
2399 if (PyObject_SetAttrString(result, "body", value) == -1) 2478 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2400 goto failed; 2479 goto failed;
2401 Py_DECREF(value); 2480 Py_DECREF(value);
2402 break; 2481 break;
2403 case Raise_kind: 2482 case Raise_kind:
2404 result = PyType_GenericNew(Raise_type, NULL, NULL); 2483 result = PyType_GenericNew(Raise_type, NULL, NULL);
2405 if (!result) goto failed; 2484 if (!result) goto failed;
2406 value = ast2obj_expr(o->v.Raise.exc); 2485 value = ast2obj_expr(o->v.Raise.exc);
2407 if (!value) goto failed; 2486 if (!value) goto failed;
2408 if (PyObject_SetAttrString(result, "exc", value) == -1) 2487 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1)
2409 goto failed; 2488 goto failed;
2410 Py_DECREF(value); 2489 Py_DECREF(value);
2411 value = ast2obj_expr(o->v.Raise.cause); 2490 value = ast2obj_expr(o->v.Raise.cause);
2412 if (!value) goto failed; 2491 if (!value) goto failed;
2413 if (PyObject_SetAttrString(result, "cause", value) == -1) 2492 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1)
2414 goto failed; 2493 goto failed;
2415 Py_DECREF(value); 2494 Py_DECREF(value);
2416 break; 2495 break;
2417 case Try_kind: 2496 case Try_kind:
2418 result = PyType_GenericNew(Try_type, NULL, NULL); 2497 result = PyType_GenericNew(Try_type, NULL, NULL);
2419 if (!result) goto failed; 2498 if (!result) goto failed;
2420 value = ast2obj_list(o->v.Try.body, ast2obj_stmt); 2499 value = ast2obj_list(o->v.Try.body, ast2obj_stmt);
2421 if (!value) goto failed; 2500 if (!value) goto failed;
2422 if (PyObject_SetAttrString(result, "body", value) == -1) 2501 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2423 goto failed; 2502 goto failed;
2424 Py_DECREF(value); 2503 Py_DECREF(value);
2425 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler); 2504 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler);
2426 if (!value) goto failed; 2505 if (!value) goto failed;
2427 if (PyObject_SetAttrString(result, "handlers", value) == -1) 2506 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1)
2428 goto failed; 2507 goto failed;
2429 Py_DECREF(value); 2508 Py_DECREF(value);
2430 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt); 2509 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt);
2431 if (!value) goto failed; 2510 if (!value) goto failed;
2432 if (PyObject_SetAttrString(result, "orelse", value) == -1) 2511 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2433 goto failed; 2512 goto failed;
2434 Py_DECREF(value); 2513 Py_DECREF(value);
2435 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt); 2514 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt);
2436 if (!value) goto failed; 2515 if (!value) goto failed;
2437 if (PyObject_SetAttrString(result, "finalbody", value) == -1) 2516 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1)
2438 goto failed; 2517 goto failed;
2439 Py_DECREF(value); 2518 Py_DECREF(value);
2440 break; 2519 break;
2441 case Assert_kind: 2520 case Assert_kind:
2442 result = PyType_GenericNew(Assert_type, NULL, NULL); 2521 result = PyType_GenericNew(Assert_type, NULL, NULL);
2443 if (!result) goto failed; 2522 if (!result) goto failed;
2444 value = ast2obj_expr(o->v.Assert.test); 2523 value = ast2obj_expr(o->v.Assert.test);
2445 if (!value) goto failed; 2524 if (!value) goto failed;
2446 if (PyObject_SetAttrString(result, "test", value) == -1) 2525 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2447 goto failed; 2526 goto failed;
2448 Py_DECREF(value); 2527 Py_DECREF(value);
2449 value = ast2obj_expr(o->v.Assert.msg); 2528 value = ast2obj_expr(o->v.Assert.msg);
2450 if (!value) goto failed; 2529 if (!value) goto failed;
2451 if (PyObject_SetAttrString(result, "msg", value) == -1) 2530 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1)
2452 goto failed; 2531 goto failed;
2453 Py_DECREF(value); 2532 Py_DECREF(value);
2454 break; 2533 break;
2455 case Import_kind: 2534 case Import_kind:
2456 result = PyType_GenericNew(Import_type, NULL, NULL); 2535 result = PyType_GenericNew(Import_type, NULL, NULL);
2457 if (!result) goto failed; 2536 if (!result) goto failed;
2458 value = ast2obj_list(o->v.Import.names, ast2obj_alias); 2537 value = ast2obj_list(o->v.Import.names, ast2obj_alias);
2459 if (!value) goto failed; 2538 if (!value) goto failed;
2460 if (PyObject_SetAttrString(result, "names", value) == -1) 2539 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2461 goto failed; 2540 goto failed;
2462 Py_DECREF(value); 2541 Py_DECREF(value);
2463 break; 2542 break;
2464 case ImportFrom_kind: 2543 case ImportFrom_kind:
2465 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); 2544 result = PyType_GenericNew(ImportFrom_type, NULL, NULL);
2466 if (!result) goto failed; 2545 if (!result) goto failed;
2467 value = ast2obj_identifier(o->v.ImportFrom.module); 2546 value = ast2obj_identifier(o->v.ImportFrom.module);
2468 if (!value) goto failed; 2547 if (!value) goto failed;
2469 if (PyObject_SetAttrString(result, "module", value) == -1) 2548 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1)
2470 goto failed; 2549 goto failed;
2471 Py_DECREF(value); 2550 Py_DECREF(value);
2472 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); 2551 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias);
2473 if (!value) goto failed; 2552 if (!value) goto failed;
2474 if (PyObject_SetAttrString(result, "names", value) == -1) 2553 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2475 goto failed; 2554 goto failed;
2476 Py_DECREF(value); 2555 Py_DECREF(value);
2477 value = ast2obj_int(o->v.ImportFrom.level); 2556 value = ast2obj_int(o->v.ImportFrom.level);
2478 if (!value) goto failed; 2557 if (!value) goto failed;
2479 if (PyObject_SetAttrString(result, "level", value) == -1) 2558 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1)
2480 goto failed; 2559 goto failed;
2481 Py_DECREF(value); 2560 Py_DECREF(value);
2482 break; 2561 break;
2483 case Global_kind: 2562 case Global_kind:
2484 result = PyType_GenericNew(Global_type, NULL, NULL); 2563 result = PyType_GenericNew(Global_type, NULL, NULL);
2485 if (!result) goto failed; 2564 if (!result) goto failed;
2486 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); 2565 value = ast2obj_list(o->v.Global.names, ast2obj_identifier);
2487 if (!value) goto failed; 2566 if (!value) goto failed;
2488 if (PyObject_SetAttrString(result, "names", value) == -1) 2567 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2489 goto failed; 2568 goto failed;
2490 Py_DECREF(value); 2569 Py_DECREF(value);
2491 break; 2570 break;
2492 case Nonlocal_kind: 2571 case Nonlocal_kind:
2493 result = PyType_GenericNew(Nonlocal_type, NULL, NULL); 2572 result = PyType_GenericNew(Nonlocal_type, NULL, NULL);
2494 if (!result) goto failed; 2573 if (!result) goto failed;
2495 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier); 2574 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier);
2496 if (!value) goto failed; 2575 if (!value) goto failed;
2497 if (PyObject_SetAttrString(result, "names", value) == -1) 2576 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2498 goto failed; 2577 goto failed;
2499 Py_DECREF(value); 2578 Py_DECREF(value);
2500 break; 2579 break;
2501 case Expr_kind: 2580 case Expr_kind:
2502 result = PyType_GenericNew(Expr_type, NULL, NULL); 2581 result = PyType_GenericNew(Expr_type, NULL, NULL);
2503 if (!result) goto failed; 2582 if (!result) goto failed;
2504 value = ast2obj_expr(o->v.Expr.value); 2583 value = ast2obj_expr(o->v.Expr.value);
2505 if (!value) goto failed; 2584 if (!value) goto failed;
2506 if (PyObject_SetAttrString(result, "value", value) == -1) 2585 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2507 goto failed; 2586 goto failed;
2508 Py_DECREF(value); 2587 Py_DECREF(value);
2509 break; 2588 break;
2510 case Pass_kind: 2589 case Pass_kind:
2511 result = PyType_GenericNew(Pass_type, NULL, NULL); 2590 result = PyType_GenericNew(Pass_type, NULL, NULL);
2512 if (!result) goto failed; 2591 if (!result) goto failed;
2513 break; 2592 break;
2514 case Break_kind: 2593 case Break_kind:
2515 result = PyType_GenericNew(Break_type, NULL, NULL); 2594 result = PyType_GenericNew(Break_type, NULL, NULL);
2516 if (!result) goto failed; 2595 if (!result) goto failed;
2517 break; 2596 break;
2518 case Continue_kind: 2597 case Continue_kind:
2519 result = PyType_GenericNew(Continue_type, NULL, NULL); 2598 result = PyType_GenericNew(Continue_type, NULL, NULL);
2520 if (!result) goto failed; 2599 if (!result) goto failed;
2521 break; 2600 break;
2522 } 2601 }
2523 value = ast2obj_int(o->lineno); 2602 value = ast2obj_int(o->lineno);
2524 if (!value) goto failed; 2603 if (!value) goto failed;
2525 if (PyObject_SetAttrString(result, "lineno", value) < 0) 2604 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
2526 goto failed; 2605 goto failed;
2527 Py_DECREF(value); 2606 Py_DECREF(value);
2528 value = ast2obj_int(o->col_offset); 2607 value = ast2obj_int(o->col_offset);
2529 if (!value) goto failed; 2608 if (!value) goto failed;
2530 if (PyObject_SetAttrString(result, "col_offset", value) < 0) 2609 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
2531 goto failed; 2610 goto failed;
2532 Py_DECREF(value); 2611 Py_DECREF(value);
2533 return result; 2612 return result;
2534 failed: 2613 failed:
2535 Py_XDECREF(value); 2614 Py_XDECREF(value);
2536 Py_XDECREF(result); 2615 Py_XDECREF(result);
2537 return NULL; 2616 return NULL;
2538 } 2617 }
2539 2618
2540 PyObject* 2619 PyObject*
2541 ast2obj_expr(void* _o) 2620 ast2obj_expr(void* _o)
2542 { 2621 {
2543 expr_ty o = (expr_ty)_o; 2622 expr_ty o = (expr_ty)_o;
2544 PyObject *result = NULL, *value = NULL; 2623 PyObject *result = NULL, *value = NULL;
2545 if (!o) { 2624 if (!o) {
2546 Py_INCREF(Py_None); 2625 Py_INCREF(Py_None);
2547 return Py_None; 2626 return Py_None;
2548 } 2627 }
2549 2628
2550 switch (o->kind) { 2629 switch (o->kind) {
2551 case BoolOp_kind: 2630 case BoolOp_kind:
2552 result = PyType_GenericNew(BoolOp_type, NULL, NULL); 2631 result = PyType_GenericNew(BoolOp_type, NULL, NULL);
2553 if (!result) goto failed; 2632 if (!result) goto failed;
2554 value = ast2obj_boolop(o->v.BoolOp.op); 2633 value = ast2obj_boolop(o->v.BoolOp.op);
2555 if (!value) goto failed; 2634 if (!value) goto failed;
2556 if (PyObject_SetAttrString(result, "op", value) == -1) 2635 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2557 goto failed; 2636 goto failed;
2558 Py_DECREF(value); 2637 Py_DECREF(value);
2559 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); 2638 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr);
2560 if (!value) goto failed; 2639 if (!value) goto failed;
2561 if (PyObject_SetAttrString(result, "values", value) == -1) 2640 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
2562 goto failed; 2641 goto failed;
2563 Py_DECREF(value); 2642 Py_DECREF(value);
2564 break; 2643 break;
2565 case BinOp_kind: 2644 case BinOp_kind:
2566 result = PyType_GenericNew(BinOp_type, NULL, NULL); 2645 result = PyType_GenericNew(BinOp_type, NULL, NULL);
2567 if (!result) goto failed; 2646 if (!result) goto failed;
2568 value = ast2obj_expr(o->v.BinOp.left); 2647 value = ast2obj_expr(o->v.BinOp.left);
2569 if (!value) goto failed; 2648 if (!value) goto failed;
2570 if (PyObject_SetAttrString(result, "left", value) == -1) 2649 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
2571 goto failed; 2650 goto failed;
2572 Py_DECREF(value); 2651 Py_DECREF(value);
2573 value = ast2obj_operator(o->v.BinOp.op); 2652 value = ast2obj_operator(o->v.BinOp.op);
2574 if (!value) goto failed; 2653 if (!value) goto failed;
2575 if (PyObject_SetAttrString(result, "op", value) == -1) 2654 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2576 goto failed; 2655 goto failed;
2577 Py_DECREF(value); 2656 Py_DECREF(value);
2578 value = ast2obj_expr(o->v.BinOp.right); 2657 value = ast2obj_expr(o->v.BinOp.right);
2579 if (!value) goto failed; 2658 if (!value) goto failed;
2580 if (PyObject_SetAttrString(result, "right", value) == -1) 2659 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1)
2581 goto failed; 2660 goto failed;
2582 Py_DECREF(value); 2661 Py_DECREF(value);
2583 break; 2662 break;
2584 case UnaryOp_kind: 2663 case UnaryOp_kind:
2585 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); 2664 result = PyType_GenericNew(UnaryOp_type, NULL, NULL);
2586 if (!result) goto failed; 2665 if (!result) goto failed;
2587 value = ast2obj_unaryop(o->v.UnaryOp.op); 2666 value = ast2obj_unaryop(o->v.UnaryOp.op);
2588 if (!value) goto failed; 2667 if (!value) goto failed;
2589 if (PyObject_SetAttrString(result, "op", value) == -1) 2668 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2590 goto failed; 2669 goto failed;
2591 Py_DECREF(value); 2670 Py_DECREF(value);
2592 value = ast2obj_expr(o->v.UnaryOp.operand); 2671 value = ast2obj_expr(o->v.UnaryOp.operand);
2593 if (!value) goto failed; 2672 if (!value) goto failed;
2594 if (PyObject_SetAttrString(result, "operand", value) == -1) 2673 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1)
2595 goto failed; 2674 goto failed;
2596 Py_DECREF(value); 2675 Py_DECREF(value);
2597 break; 2676 break;
2598 case Lambda_kind: 2677 case Lambda_kind:
2599 result = PyType_GenericNew(Lambda_type, NULL, NULL); 2678 result = PyType_GenericNew(Lambda_type, NULL, NULL);
2600 if (!result) goto failed; 2679 if (!result) goto failed;
2601 value = ast2obj_arguments(o->v.Lambda.args); 2680 value = ast2obj_arguments(o->v.Lambda.args);
2602 if (!value) goto failed; 2681 if (!value) goto failed;
2603 if (PyObject_SetAttrString(result, "args", value) == -1) 2682 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
2604 goto failed; 2683 goto failed;
2605 Py_DECREF(value); 2684 Py_DECREF(value);
2606 value = ast2obj_expr(o->v.Lambda.body); 2685 value = ast2obj_expr(o->v.Lambda.body);
2607 if (!value) goto failed; 2686 if (!value) goto failed;
2608 if (PyObject_SetAttrString(result, "body", value) == -1) 2687 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2609 goto failed; 2688 goto failed;
2610 Py_DECREF(value); 2689 Py_DECREF(value);
2611 break; 2690 break;
2612 case IfExp_kind: 2691 case IfExp_kind:
2613 result = PyType_GenericNew(IfExp_type, NULL, NULL); 2692 result = PyType_GenericNew(IfExp_type, NULL, NULL);
2614 if (!result) goto failed; 2693 if (!result) goto failed;
2615 value = ast2obj_expr(o->v.IfExp.test); 2694 value = ast2obj_expr(o->v.IfExp.test);
2616 if (!value) goto failed; 2695 if (!value) goto failed;
2617 if (PyObject_SetAttrString(result, "test", value) == -1) 2696 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2618 goto failed; 2697 goto failed;
2619 Py_DECREF(value); 2698 Py_DECREF(value);
2620 value = ast2obj_expr(o->v.IfExp.body); 2699 value = ast2obj_expr(o->v.IfExp.body);
2621 if (!value) goto failed; 2700 if (!value) goto failed;
2622 if (PyObject_SetAttrString(result, "body", value) == -1) 2701 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2623 goto failed; 2702 goto failed;
2624 Py_DECREF(value); 2703 Py_DECREF(value);
2625 value = ast2obj_expr(o->v.IfExp.orelse); 2704 value = ast2obj_expr(o->v.IfExp.orelse);
2626 if (!value) goto failed; 2705 if (!value) goto failed;
2627 if (PyObject_SetAttrString(result, "orelse", value) == -1) 2706 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2628 goto failed; 2707 goto failed;
2629 Py_DECREF(value); 2708 Py_DECREF(value);
2630 break; 2709 break;
2631 case Dict_kind: 2710 case Dict_kind:
2632 result = PyType_GenericNew(Dict_type, NULL, NULL); 2711 result = PyType_GenericNew(Dict_type, NULL, NULL);
2633 if (!result) goto failed; 2712 if (!result) goto failed;
2634 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); 2713 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr);
2635 if (!value) goto failed; 2714 if (!value) goto failed;
2636 if (PyObject_SetAttrString(result, "keys", value) == -1) 2715 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1)
2637 goto failed; 2716 goto failed;
2638 Py_DECREF(value); 2717 Py_DECREF(value);
2639 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); 2718 value = ast2obj_list(o->v.Dict.values, ast2obj_expr);
2640 if (!value) goto failed; 2719 if (!value) goto failed;
2641 if (PyObject_SetAttrString(result, "values", value) == -1) 2720 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
2642 goto failed; 2721 goto failed;
2643 Py_DECREF(value); 2722 Py_DECREF(value);
2644 break; 2723 break;
2645 case Set_kind: 2724 case Set_kind:
2646 result = PyType_GenericNew(Set_type, NULL, NULL); 2725 result = PyType_GenericNew(Set_type, NULL, NULL);
2647 if (!result) goto failed; 2726 if (!result) goto failed;
2648 value = ast2obj_list(o->v.Set.elts, ast2obj_expr); 2727 value = ast2obj_list(o->v.Set.elts, ast2obj_expr);
2649 if (!value) goto failed; 2728 if (!value) goto failed;
2650 if (PyObject_SetAttrString(result, "elts", value) == -1) 2729 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
2651 goto failed; 2730 goto failed;
2652 Py_DECREF(value); 2731 Py_DECREF(value);
2653 break; 2732 break;
2654 case ListComp_kind: 2733 case ListComp_kind:
2655 result = PyType_GenericNew(ListComp_type, NULL, NULL); 2734 result = PyType_GenericNew(ListComp_type, NULL, NULL);
2656 if (!result) goto failed; 2735 if (!result) goto failed;
2657 value = ast2obj_expr(o->v.ListComp.elt); 2736 value = ast2obj_expr(o->v.ListComp.elt);
2658 if (!value) goto failed; 2737 if (!value) goto failed;
2659 if (PyObject_SetAttrString(result, "elt", value) == -1) 2738 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
2660 goto failed; 2739 goto failed;
2661 Py_DECREF(value); 2740 Py_DECREF(value);
2662 value = ast2obj_list(o->v.ListComp.generators, 2741 value = ast2obj_list(o->v.ListComp.generators,
2663 ast2obj_comprehension); 2742 ast2obj_comprehension);
2664 if (!value) goto failed; 2743 if (!value) goto failed;
2665 if (PyObject_SetAttrString(result, "generators", value) == -1) 2744 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2666 goto failed; 2745 goto failed;
2667 Py_DECREF(value); 2746 Py_DECREF(value);
2668 break; 2747 break;
2669 case SetComp_kind: 2748 case SetComp_kind:
2670 result = PyType_GenericNew(SetComp_type, NULL, NULL); 2749 result = PyType_GenericNew(SetComp_type, NULL, NULL);
2671 if (!result) goto failed; 2750 if (!result) goto failed;
2672 value = ast2obj_expr(o->v.SetComp.elt); 2751 value = ast2obj_expr(o->v.SetComp.elt);
2673 if (!value) goto failed; 2752 if (!value) goto failed;
2674 if (PyObject_SetAttrString(result, "elt", value) == -1) 2753 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
2675 goto failed; 2754 goto failed;
2676 Py_DECREF(value); 2755 Py_DECREF(value);
2677 value = ast2obj_list(o->v.SetComp.generators, 2756 value = ast2obj_list(o->v.SetComp.generators,
2678 ast2obj_comprehension); 2757 ast2obj_comprehension);
2679 if (!value) goto failed; 2758 if (!value) goto failed;
2680 if (PyObject_SetAttrString(result, "generators", value) == -1) 2759 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2681 goto failed; 2760 goto failed;
2682 Py_DECREF(value); 2761 Py_DECREF(value);
2683 break; 2762 break;
2684 case DictComp_kind: 2763 case DictComp_kind:
2685 result = PyType_GenericNew(DictComp_type, NULL, NULL); 2764 result = PyType_GenericNew(DictComp_type, NULL, NULL);
2686 if (!result) goto failed; 2765 if (!result) goto failed;
2687 value = ast2obj_expr(o->v.DictComp.key); 2766 value = ast2obj_expr(o->v.DictComp.key);
2688 if (!value) goto failed; 2767 if (!value) goto failed;
2689 if (PyObject_SetAttrString(result, "key", value) == -1) 2768 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1)
2690 goto failed; 2769 goto failed;
2691 Py_DECREF(value); 2770 Py_DECREF(value);
2692 value = ast2obj_expr(o->v.DictComp.value); 2771 value = ast2obj_expr(o->v.DictComp.value);
2693 if (!value) goto failed; 2772 if (!value) goto failed;
2694 if (PyObject_SetAttrString(result, "value", value) == -1) 2773 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2695 goto failed; 2774 goto failed;
2696 Py_DECREF(value); 2775 Py_DECREF(value);
2697 value = ast2obj_list(o->v.DictComp.generators, 2776 value = ast2obj_list(o->v.DictComp.generators,
2698 ast2obj_comprehension); 2777 ast2obj_comprehension);
2699 if (!value) goto failed; 2778 if (!value) goto failed;
2700 if (PyObject_SetAttrString(result, "generators", value) == -1) 2779 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2701 goto failed; 2780 goto failed;
2702 Py_DECREF(value); 2781 Py_DECREF(value);
2703 break; 2782 break;
2704 case GeneratorExp_kind: 2783 case GeneratorExp_kind:
2705 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); 2784 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL);
2706 if (!result) goto failed; 2785 if (!result) goto failed;
2707 value = ast2obj_expr(o->v.GeneratorExp.elt); 2786 value = ast2obj_expr(o->v.GeneratorExp.elt);
2708 if (!value) goto failed; 2787 if (!value) goto failed;
2709 if (PyObject_SetAttrString(result, "elt", value) == -1) 2788 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
2710 goto failed; 2789 goto failed;
2711 Py_DECREF(value); 2790 Py_DECREF(value);
2712 value = ast2obj_list(o->v.GeneratorExp.generators, 2791 value = ast2obj_list(o->v.GeneratorExp.generators,
2713 ast2obj_comprehension); 2792 ast2obj_comprehension);
2714 if (!value) goto failed; 2793 if (!value) goto failed;
2715 if (PyObject_SetAttrString(result, "generators", value) == -1) 2794 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2716 goto failed; 2795 goto failed;
2717 Py_DECREF(value); 2796 Py_DECREF(value);
2718 break; 2797 break;
2719 case Yield_kind: 2798 case Yield_kind:
2720 result = PyType_GenericNew(Yield_type, NULL, NULL); 2799 result = PyType_GenericNew(Yield_type, NULL, NULL);
2721 if (!result) goto failed; 2800 if (!result) goto failed;
2722 value = ast2obj_int(o->v.Yield.is_from); 2801 value = ast2obj_int(o->v.Yield.is_from);
2723 if (!value) goto failed; 2802 if (!value) goto failed;
2724 if (PyObject_SetAttrString(result, "is_from", value) == -1) 2803 if (PyObject_SetAttrString(result, "is_from", value) == -1)
2725 goto failed; 2804 goto failed;
2726 Py_DECREF(value); 2805 Py_DECREF(value);
2727 value = ast2obj_expr(o->v.Yield.value); 2806 value = ast2obj_expr(o->v.Yield.value);
2728 if (!value) goto failed; 2807 if (!value) goto failed;
2729 if (PyObject_SetAttrString(result, "value", value) == -1) 2808 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2730 goto failed; 2809 goto failed;
2731 Py_DECREF(value); 2810 Py_DECREF(value);
2732 break; 2811 break;
2733 case Compare_kind: 2812 case Compare_kind:
2734 result = PyType_GenericNew(Compare_type, NULL, NULL); 2813 result = PyType_GenericNew(Compare_type, NULL, NULL);
2735 if (!result) goto failed; 2814 if (!result) goto failed;
2736 value = ast2obj_expr(o->v.Compare.left); 2815 value = ast2obj_expr(o->v.Compare.left);
2737 if (!value) goto failed; 2816 if (!value) goto failed;
2738 if (PyObject_SetAttrString(result, "left", value) == -1) 2817 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
2739 goto failed; 2818 goto failed;
2740 Py_DECREF(value); 2819 Py_DECREF(value);
2741 { 2820 {
2742 int i, n = asdl_seq_LEN(o->v.Compare.ops); 2821 int i, n = asdl_seq_LEN(o->v.Compare.ops);
2743 value = PyList_New(n); 2822 value = PyList_New(n);
2744 if (!value) goto failed; 2823 if (!value) goto failed;
2745 for(i = 0; i < n; i++) 2824 for(i = 0; i < n; i++)
2746 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_t y)asdl_seq_GET(o->v.Compare.ops, i))); 2825 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_t y)asdl_seq_GET(o->v.Compare.ops, i)));
2747 } 2826 }
2748 if (!value) goto failed; 2827 if (!value) goto failed;
2749 if (PyObject_SetAttrString(result, "ops", value) == -1) 2828 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1)
2750 goto failed; 2829 goto failed;
2751 Py_DECREF(value); 2830 Py_DECREF(value);
2752 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); 2831 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr);
2753 if (!value) goto failed; 2832 if (!value) goto failed;
2754 if (PyObject_SetAttrString(result, "comparators", value) == -1) 2833 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1)
2755 goto failed; 2834 goto failed;
2756 Py_DECREF(value); 2835 Py_DECREF(value);
2757 break; 2836 break;
2758 case Call_kind: 2837 case Call_kind:
2759 result = PyType_GenericNew(Call_type, NULL, NULL); 2838 result = PyType_GenericNew(Call_type, NULL, NULL);
2760 if (!result) goto failed; 2839 if (!result) goto failed;
2761 value = ast2obj_expr(o->v.Call.func); 2840 value = ast2obj_expr(o->v.Call.func);
2762 if (!value) goto failed; 2841 if (!value) goto failed;
2763 if (PyObject_SetAttrString(result, "func", value) == -1) 2842 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1)
2764 goto failed; 2843 goto failed;
2765 Py_DECREF(value); 2844 Py_DECREF(value);
2766 value = ast2obj_list(o->v.Call.args, ast2obj_expr); 2845 value = ast2obj_list(o->v.Call.args, ast2obj_expr);
2767 if (!value) goto failed; 2846 if (!value) goto failed;
2768 if (PyObject_SetAttrString(result, "args", value) == -1) 2847 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
2769 goto failed; 2848 goto failed;
2770 Py_DECREF(value); 2849 Py_DECREF(value);
2771 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); 2850 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword);
2772 if (!value) goto failed; 2851 if (!value) goto failed;
2773 if (PyObject_SetAttrString(result, "keywords", value) == -1) 2852 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
2774 goto failed; 2853 goto failed;
2775 Py_DECREF(value); 2854 Py_DECREF(value);
2776 value = ast2obj_expr(o->v.Call.starargs); 2855 value = ast2obj_expr(o->v.Call.starargs);
2777 if (!value) goto failed; 2856 if (!value) goto failed;
2778 if (PyObject_SetAttrString(result, "starargs", value) == -1) 2857 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
2779 goto failed; 2858 goto failed;
2780 Py_DECREF(value); 2859 Py_DECREF(value);
2781 value = ast2obj_expr(o->v.Call.kwargs); 2860 value = ast2obj_expr(o->v.Call.kwargs);
2782 if (!value) goto failed; 2861 if (!value) goto failed;
2783 if (PyObject_SetAttrString(result, "kwargs", value) == -1) 2862 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
2784 goto failed; 2863 goto failed;
2785 Py_DECREF(value); 2864 Py_DECREF(value);
2786 break; 2865 break;
2787 case Num_kind: 2866 case Num_kind:
2788 result = PyType_GenericNew(Num_type, NULL, NULL); 2867 result = PyType_GenericNew(Num_type, NULL, NULL);
2789 if (!result) goto failed; 2868 if (!result) goto failed;
2790 value = ast2obj_object(o->v.Num.n); 2869 value = ast2obj_object(o->v.Num.n);
2791 if (!value) goto failed; 2870 if (!value) goto failed;
2792 if (PyObject_SetAttrString(result, "n", value) == -1) 2871 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1)
2793 goto failed; 2872 goto failed;
2794 Py_DECREF(value); 2873 Py_DECREF(value);
2795 break; 2874 break;
2796 case Str_kind: 2875 case Str_kind:
2797 result = PyType_GenericNew(Str_type, NULL, NULL); 2876 result = PyType_GenericNew(Str_type, NULL, NULL);
2798 if (!result) goto failed; 2877 if (!result) goto failed;
2799 value = ast2obj_string(o->v.Str.s); 2878 value = ast2obj_string(o->v.Str.s);
2800 if (!value) goto failed; 2879 if (!value) goto failed;
2801 if (PyObject_SetAttrString(result, "s", value) == -1) 2880 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
2802 goto failed; 2881 goto failed;
2803 Py_DECREF(value); 2882 Py_DECREF(value);
2804 break; 2883 break;
2805 case Bytes_kind: 2884 case Bytes_kind:
2806 result = PyType_GenericNew(Bytes_type, NULL, NULL); 2885 result = PyType_GenericNew(Bytes_type, NULL, NULL);
2807 if (!result) goto failed; 2886 if (!result) goto failed;
2808 value = ast2obj_string(o->v.Bytes.s); 2887 value = ast2obj_bytes(o->v.Bytes.s);
2809 if (!value) goto failed; 2888 if (!value) goto failed;
2810 if (PyObject_SetAttrString(result, "s", value) == -1) 2889 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
2811 goto failed; 2890 goto failed;
2812 Py_DECREF(value); 2891 Py_DECREF(value);
2813 break; 2892 break;
2814 case Ellipsis_kind: 2893 case Ellipsis_kind:
2815 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); 2894 result = PyType_GenericNew(Ellipsis_type, NULL, NULL);
2816 if (!result) goto failed; 2895 if (!result) goto failed;
2817 break; 2896 break;
2818 case Attribute_kind: 2897 case Attribute_kind:
2819 result = PyType_GenericNew(Attribute_type, NULL, NULL); 2898 result = PyType_GenericNew(Attribute_type, NULL, NULL);
2820 if (!result) goto failed; 2899 if (!result) goto failed;
2821 value = ast2obj_expr(o->v.Attribute.value); 2900 value = ast2obj_expr(o->v.Attribute.value);
2822 if (!value) goto failed; 2901 if (!value) goto failed;
2823 if (PyObject_SetAttrString(result, "value", value) == -1) 2902 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2824 goto failed; 2903 goto failed;
2825 Py_DECREF(value); 2904 Py_DECREF(value);
2826 value = ast2obj_identifier(o->v.Attribute.attr); 2905 value = ast2obj_identifier(o->v.Attribute.attr);
2827 if (!value) goto failed; 2906 if (!value) goto failed;
2828 if (PyObject_SetAttrString(result, "attr", value) == -1) 2907 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1)
2829 goto failed; 2908 goto failed;
2830 Py_DECREF(value); 2909 Py_DECREF(value);
2831 value = ast2obj_expr_context(o->v.Attribute.ctx); 2910 value = ast2obj_expr_context(o->v.Attribute.ctx);
2832 if (!value) goto failed; 2911 if (!value) goto failed;
2833 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2912 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2834 goto failed; 2913 goto failed;
2835 Py_DECREF(value); 2914 Py_DECREF(value);
2836 break; 2915 break;
2837 case Subscript_kind: 2916 case Subscript_kind:
2838 result = PyType_GenericNew(Subscript_type, NULL, NULL); 2917 result = PyType_GenericNew(Subscript_type, NULL, NULL);
2839 if (!result) goto failed; 2918 if (!result) goto failed;
2840 value = ast2obj_expr(o->v.Subscript.value); 2919 value = ast2obj_expr(o->v.Subscript.value);
2841 if (!value) goto failed; 2920 if (!value) goto failed;
2842 if (PyObject_SetAttrString(result, "value", value) == -1) 2921 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2843 goto failed; 2922 goto failed;
2844 Py_DECREF(value); 2923 Py_DECREF(value);
2845 value = ast2obj_slice(o->v.Subscript.slice); 2924 value = ast2obj_slice(o->v.Subscript.slice);
2846 if (!value) goto failed; 2925 if (!value) goto failed;
2847 if (PyObject_SetAttrString(result, "slice", value) == -1) 2926 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1)
2848 goto failed; 2927 goto failed;
2849 Py_DECREF(value); 2928 Py_DECREF(value);
2850 value = ast2obj_expr_context(o->v.Subscript.ctx); 2929 value = ast2obj_expr_context(o->v.Subscript.ctx);
2851 if (!value) goto failed; 2930 if (!value) goto failed;
2852 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2931 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2853 goto failed; 2932 goto failed;
2854 Py_DECREF(value); 2933 Py_DECREF(value);
2855 break; 2934 break;
2856 case Starred_kind: 2935 case Starred_kind:
2857 result = PyType_GenericNew(Starred_type, NULL, NULL); 2936 result = PyType_GenericNew(Starred_type, NULL, NULL);
2858 if (!result) goto failed; 2937 if (!result) goto failed;
2859 value = ast2obj_expr(o->v.Starred.value); 2938 value = ast2obj_expr(o->v.Starred.value);
2860 if (!value) goto failed; 2939 if (!value) goto failed;
2861 if (PyObject_SetAttrString(result, "value", value) == -1) 2940 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2862 goto failed; 2941 goto failed;
2863 Py_DECREF(value); 2942 Py_DECREF(value);
2864 value = ast2obj_expr_context(o->v.Starred.ctx); 2943 value = ast2obj_expr_context(o->v.Starred.ctx);
2865 if (!value) goto failed; 2944 if (!value) goto failed;
2866 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2945 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2867 goto failed; 2946 goto failed;
2868 Py_DECREF(value); 2947 Py_DECREF(value);
2869 break; 2948 break;
2870 case Name_kind: 2949 case Name_kind:
2871 result = PyType_GenericNew(Name_type, NULL, NULL); 2950 result = PyType_GenericNew(Name_type, NULL, NULL);
2872 if (!result) goto failed; 2951 if (!result) goto failed;
2873 value = ast2obj_identifier(o->v.Name.id); 2952 value = ast2obj_identifier(o->v.Name.id);
2874 if (!value) goto failed; 2953 if (!value) goto failed;
2875 if (PyObject_SetAttrString(result, "id", value) == -1) 2954 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1)
2876 goto failed; 2955 goto failed;
2877 Py_DECREF(value); 2956 Py_DECREF(value);
2878 value = ast2obj_expr_context(o->v.Name.ctx); 2957 value = ast2obj_expr_context(o->v.Name.ctx);
2879 if (!value) goto failed; 2958 if (!value) goto failed;
2880 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2959 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2881 goto failed; 2960 goto failed;
2882 Py_DECREF(value); 2961 Py_DECREF(value);
2883 break; 2962 break;
2884 case List_kind: 2963 case List_kind:
2885 result = PyType_GenericNew(List_type, NULL, NULL); 2964 result = PyType_GenericNew(List_type, NULL, NULL);
2886 if (!result) goto failed; 2965 if (!result) goto failed;
2887 value = ast2obj_list(o->v.List.elts, ast2obj_expr); 2966 value = ast2obj_list(o->v.List.elts, ast2obj_expr);
2888 if (!value) goto failed; 2967 if (!value) goto failed;
2889 if (PyObject_SetAttrString(result, "elts", value) == -1) 2968 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
2890 goto failed; 2969 goto failed;
2891 Py_DECREF(value); 2970 Py_DECREF(value);
2892 value = ast2obj_expr_context(o->v.List.ctx); 2971 value = ast2obj_expr_context(o->v.List.ctx);
2893 if (!value) goto failed; 2972 if (!value) goto failed;
2894 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2973 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2895 goto failed; 2974 goto failed;
2896 Py_DECREF(value); 2975 Py_DECREF(value);
2897 break; 2976 break;
2898 case Tuple_kind: 2977 case Tuple_kind:
2899 result = PyType_GenericNew(Tuple_type, NULL, NULL); 2978 result = PyType_GenericNew(Tuple_type, NULL, NULL);
2900 if (!result) goto failed; 2979 if (!result) goto failed;
2901 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); 2980 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr);
2902 if (!value) goto failed; 2981 if (!value) goto failed;
2903 if (PyObject_SetAttrString(result, "elts", value) == -1) 2982 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
2904 goto failed; 2983 goto failed;
2905 Py_DECREF(value); 2984 Py_DECREF(value);
2906 value = ast2obj_expr_context(o->v.Tuple.ctx); 2985 value = ast2obj_expr_context(o->v.Tuple.ctx);
2907 if (!value) goto failed; 2986 if (!value) goto failed;
2908 if (PyObject_SetAttrString(result, "ctx", value) == -1) 2987 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2909 goto failed; 2988 goto failed;
2910 Py_DECREF(value); 2989 Py_DECREF(value);
2911 break; 2990 break;
2912 } 2991 }
2913 value = ast2obj_int(o->lineno); 2992 value = ast2obj_int(o->lineno);
2914 if (!value) goto failed; 2993 if (!value) goto failed;
2915 if (PyObject_SetAttrString(result, "lineno", value) < 0) 2994 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
2916 goto failed; 2995 goto failed;
2917 Py_DECREF(value); 2996 Py_DECREF(value);
2918 value = ast2obj_int(o->col_offset); 2997 value = ast2obj_int(o->col_offset);
2919 if (!value) goto failed; 2998 if (!value) goto failed;
2920 if (PyObject_SetAttrString(result, "col_offset", value) < 0) 2999 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
2921 goto failed; 3000 goto failed;
2922 Py_DECREF(value); 3001 Py_DECREF(value);
2923 return result; 3002 return result;
2924 failed: 3003 failed:
2925 Py_XDECREF(value); 3004 Py_XDECREF(value);
2926 Py_XDECREF(result); 3005 Py_XDECREF(result);
2927 return NULL; 3006 return NULL;
2928 } 3007 }
2929 3008
2930 PyObject* ast2obj_expr_context(expr_context_ty o) 3009 PyObject* ast2obj_expr_context(expr_context_ty o)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2963 Py_INCREF(Py_None); 3042 Py_INCREF(Py_None);
2964 return Py_None; 3043 return Py_None;
2965 } 3044 }
2966 3045
2967 switch (o->kind) { 3046 switch (o->kind) {
2968 case Slice_kind: 3047 case Slice_kind:
2969 result = PyType_GenericNew(Slice_type, NULL, NULL); 3048 result = PyType_GenericNew(Slice_type, NULL, NULL);
2970 if (!result) goto failed; 3049 if (!result) goto failed;
2971 value = ast2obj_expr(o->v.Slice.lower); 3050 value = ast2obj_expr(o->v.Slice.lower);
2972 if (!value) goto failed; 3051 if (!value) goto failed;
2973 if (PyObject_SetAttrString(result, "lower", value) == -1) 3052 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1)
2974 goto failed; 3053 goto failed;
2975 Py_DECREF(value); 3054 Py_DECREF(value);
2976 value = ast2obj_expr(o->v.Slice.upper); 3055 value = ast2obj_expr(o->v.Slice.upper);
2977 if (!value) goto failed; 3056 if (!value) goto failed;
2978 if (PyObject_SetAttrString(result, "upper", value) == -1) 3057 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1)
2979 goto failed; 3058 goto failed;
2980 Py_DECREF(value); 3059 Py_DECREF(value);
2981 value = ast2obj_expr(o->v.Slice.step); 3060 value = ast2obj_expr(o->v.Slice.step);
2982 if (!value) goto failed; 3061 if (!value) goto failed;
2983 if (PyObject_SetAttrString(result, "step", value) == -1) 3062 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1)
2984 goto failed; 3063 goto failed;
2985 Py_DECREF(value); 3064 Py_DECREF(value);
2986 break; 3065 break;
2987 case ExtSlice_kind: 3066 case ExtSlice_kind:
2988 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); 3067 result = PyType_GenericNew(ExtSlice_type, NULL, NULL);
2989 if (!result) goto failed; 3068 if (!result) goto failed;
2990 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); 3069 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);
2991 if (!value) goto failed; 3070 if (!value) goto failed;
2992 if (PyObject_SetAttrString(result, "dims", value) == -1) 3071 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1)
2993 goto failed; 3072 goto failed;
2994 Py_DECREF(value); 3073 Py_DECREF(value);
2995 break; 3074 break;
2996 case Index_kind: 3075 case Index_kind:
2997 result = PyType_GenericNew(Index_type, NULL, NULL); 3076 result = PyType_GenericNew(Index_type, NULL, NULL);
2998 if (!result) goto failed; 3077 if (!result) goto failed;
2999 value = ast2obj_expr(o->v.Index.value); 3078 value = ast2obj_expr(o->v.Index.value);
3000 if (!value) goto failed; 3079 if (!value) goto failed;
3001 if (PyObject_SetAttrString(result, "value", value) == -1) 3080 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
3002 goto failed; 3081 goto failed;
3003 Py_DECREF(value); 3082 Py_DECREF(value);
3004 break; 3083 break;
3005 } 3084 }
3006 return result; 3085 return result;
3007 failed: 3086 failed:
3008 Py_XDECREF(value); 3087 Py_XDECREF(value);
3009 Py_XDECREF(result); 3088 Py_XDECREF(result);
3010 return NULL; 3089 return NULL;
3011 } 3090 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 PyObject *result = NULL, *value = NULL; 3216 PyObject *result = NULL, *value = NULL;
3138 if (!o) { 3217 if (!o) {
3139 Py_INCREF(Py_None); 3218 Py_INCREF(Py_None);
3140 return Py_None; 3219 return Py_None;
3141 } 3220 }
3142 3221
3143 result = PyType_GenericNew(comprehension_type, NULL, NULL); 3222 result = PyType_GenericNew(comprehension_type, NULL, NULL);
3144 if (!result) return NULL; 3223 if (!result) return NULL;
3145 value = ast2obj_expr(o->target); 3224 value = ast2obj_expr(o->target);
3146 if (!value) goto failed; 3225 if (!value) goto failed;
3147 if (PyObject_SetAttrString(result, "target", value) == -1) 3226 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
3148 goto failed; 3227 goto failed;
3149 Py_DECREF(value); 3228 Py_DECREF(value);
3150 value = ast2obj_expr(o->iter); 3229 value = ast2obj_expr(o->iter);
3151 if (!value) goto failed; 3230 if (!value) goto failed;
3152 if (PyObject_SetAttrString(result, "iter", value) == -1) 3231 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
3153 goto failed; 3232 goto failed;
3154 Py_DECREF(value); 3233 Py_DECREF(value);
3155 value = ast2obj_list(o->ifs, ast2obj_expr); 3234 value = ast2obj_list(o->ifs, ast2obj_expr);
3156 if (!value) goto failed; 3235 if (!value) goto failed;
3157 if (PyObject_SetAttrString(result, "ifs", value) == -1) 3236 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1)
3158 goto failed; 3237 goto failed;
3159 Py_DECREF(value); 3238 Py_DECREF(value);
3160 return result; 3239 return result;
3161 failed: 3240 failed:
3162 Py_XDECREF(value); 3241 Py_XDECREF(value);
3163 Py_XDECREF(result); 3242 Py_XDECREF(result);
3164 return NULL; 3243 return NULL;
3165 } 3244 }
3166 3245
3167 PyObject* 3246 PyObject*
3168 ast2obj_excepthandler(void* _o) 3247 ast2obj_excepthandler(void* _o)
3169 { 3248 {
3170 excepthandler_ty o = (excepthandler_ty)_o; 3249 excepthandler_ty o = (excepthandler_ty)_o;
3171 PyObject *result = NULL, *value = NULL; 3250 PyObject *result = NULL, *value = NULL;
3172 if (!o) { 3251 if (!o) {
3173 Py_INCREF(Py_None); 3252 Py_INCREF(Py_None);
3174 return Py_None; 3253 return Py_None;
3175 } 3254 }
3176 3255
3177 switch (o->kind) { 3256 switch (o->kind) {
3178 case ExceptHandler_kind: 3257 case ExceptHandler_kind:
3179 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL); 3258 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL);
3180 if (!result) goto failed; 3259 if (!result) goto failed;
3181 value = ast2obj_expr(o->v.ExceptHandler.type); 3260 value = ast2obj_expr(o->v.ExceptHandler.type);
3182 if (!value) goto failed; 3261 if (!value) goto failed;
3183 if (PyObject_SetAttrString(result, "type", value) == -1) 3262 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1)
3184 goto failed; 3263 goto failed;
3185 Py_DECREF(value); 3264 Py_DECREF(value);
3186 value = ast2obj_identifier(o->v.ExceptHandler.name); 3265 value = ast2obj_identifier(o->v.ExceptHandler.name);
3187 if (!value) goto failed; 3266 if (!value) goto failed;
3188 if (PyObject_SetAttrString(result, "name", value) == -1) 3267 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
3189 goto failed; 3268 goto failed;
3190 Py_DECREF(value); 3269 Py_DECREF(value);
3191 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt); 3270 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt);
3192 if (!value) goto failed; 3271 if (!value) goto failed;
3193 if (PyObject_SetAttrString(result, "body", value) == -1) 3272 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
3194 goto failed; 3273 goto failed;
3195 Py_DECREF(value); 3274 Py_DECREF(value);
3196 break; 3275 break;
3197 } 3276 }
3198 value = ast2obj_int(o->lineno); 3277 value = ast2obj_int(o->lineno);
3199 if (!value) goto failed; 3278 if (!value) goto failed;
3200 if (PyObject_SetAttrString(result, "lineno", value) < 0) 3279 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
3201 goto failed; 3280 goto failed;
3202 Py_DECREF(value); 3281 Py_DECREF(value);
3203 value = ast2obj_int(o->col_offset); 3282 value = ast2obj_int(o->col_offset);
3204 if (!value) goto failed; 3283 if (!value) goto failed;
3205 if (PyObject_SetAttrString(result, "col_offset", value) < 0) 3284 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
3206 goto failed; 3285 goto failed;
3207 Py_DECREF(value); 3286 Py_DECREF(value);
3208 return result; 3287 return result;
3209 failed: 3288 failed:
3210 Py_XDECREF(value); 3289 Py_XDECREF(value);
3211 Py_XDECREF(result); 3290 Py_XDECREF(result);
3212 return NULL; 3291 return NULL;
3213 } 3292 }
3214 3293
3215 PyObject* 3294 PyObject*
3216 ast2obj_arguments(void* _o) 3295 ast2obj_arguments(void* _o)
3217 { 3296 {
3218 arguments_ty o = (arguments_ty)_o; 3297 arguments_ty o = (arguments_ty)_o;
3219 PyObject *result = NULL, *value = NULL; 3298 PyObject *result = NULL, *value = NULL;
3220 if (!o) { 3299 if (!o) {
3221 Py_INCREF(Py_None); 3300 Py_INCREF(Py_None);
3222 return Py_None; 3301 return Py_None;
3223 } 3302 }
3224 3303
3225 result = PyType_GenericNew(arguments_type, NULL, NULL); 3304 result = PyType_GenericNew(arguments_type, NULL, NULL);
3226 if (!result) return NULL; 3305 if (!result) return NULL;
3227 value = ast2obj_list(o->args, ast2obj_arg); 3306 value = ast2obj_list(o->args, ast2obj_arg);
3228 if (!value) goto failed; 3307 if (!value) goto failed;
3229 if (PyObject_SetAttrString(result, "args", value) == -1) 3308 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
3230 goto failed; 3309 goto failed;
3231 Py_DECREF(value); 3310 Py_DECREF(value);
3232 value = ast2obj_identifier(o->vararg); 3311 value = ast2obj_identifier(o->vararg);
3233 if (!value) goto failed; 3312 if (!value) goto failed;
3234 if (PyObject_SetAttrString(result, "vararg", value) == -1) 3313 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1)
3235 goto failed; 3314 goto failed;
3236 Py_DECREF(value); 3315 Py_DECREF(value);
3237 value = ast2obj_expr(o->varargannotation); 3316 value = ast2obj_expr(o->varargannotation);
3238 if (!value) goto failed; 3317 if (!value) goto failed;
3239 if (PyObject_SetAttrString(result, "varargannotation", value) == -1) 3318 if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1)
3240 goto failed; 3319 goto failed;
3241 Py_DECREF(value); 3320 Py_DECREF(value);
3242 value = ast2obj_list(o->kwonlyargs, ast2obj_arg); 3321 value = ast2obj_list(o->kwonlyargs, ast2obj_arg);
3243 if (!value) goto failed; 3322 if (!value) goto failed;
3244 if (PyObject_SetAttrString(result, "kwonlyargs", value) == -1) 3323 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1)
3245 goto failed; 3324 goto failed;
3246 Py_DECREF(value); 3325 Py_DECREF(value);
3247 value = ast2obj_identifier(o->kwarg); 3326 value = ast2obj_identifier(o->kwarg);
3248 if (!value) goto failed; 3327 if (!value) goto failed;
3249 if (PyObject_SetAttrString(result, "kwarg", value) == -1) 3328 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1)
3250 goto failed; 3329 goto failed;
3251 Py_DECREF(value); 3330 Py_DECREF(value);
3252 value = ast2obj_expr(o->kwargannotation); 3331 value = ast2obj_expr(o->kwargannotation);
3253 if (!value) goto failed; 3332 if (!value) goto failed;
3254 if (PyObject_SetAttrString(result, "kwargannotation", value) == -1) 3333 if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1)
3255 goto failed; 3334 goto failed;
3256 Py_DECREF(value); 3335 Py_DECREF(value);
3257 value = ast2obj_list(o->defaults, ast2obj_expr); 3336 value = ast2obj_list(o->defaults, ast2obj_expr);
3258 if (!value) goto failed; 3337 if (!value) goto failed;
3259 if (PyObject_SetAttrString(result, "defaults", value) == -1) 3338 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1)
3260 goto failed; 3339 goto failed;
3261 Py_DECREF(value); 3340 Py_DECREF(value);
3262 value = ast2obj_list(o->kw_defaults, ast2obj_expr); 3341 value = ast2obj_list(o->kw_defaults, ast2obj_expr);
3263 if (!value) goto failed; 3342 if (!value) goto failed;
3264 if (PyObject_SetAttrString(result, "kw_defaults", value) == -1) 3343 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)
3265 goto failed; 3344 goto failed;
3266 Py_DECREF(value); 3345 Py_DECREF(value);
3267 return result; 3346 return result;
3268 failed: 3347 failed:
3269 Py_XDECREF(value); 3348 Py_XDECREF(value);
3270 Py_XDECREF(result); 3349 Py_XDECREF(result);
3271 return NULL; 3350 return NULL;
3272 } 3351 }
3273 3352
3274 PyObject* 3353 PyObject*
3275 ast2obj_arg(void* _o) 3354 ast2obj_arg(void* _o)
3276 { 3355 {
3277 arg_ty o = (arg_ty)_o; 3356 arg_ty o = (arg_ty)_o;
3278 PyObject *result = NULL, *value = NULL; 3357 PyObject *result = NULL, *value = NULL;
3279 if (!o) { 3358 if (!o) {
3280 Py_INCREF(Py_None); 3359 Py_INCREF(Py_None);
3281 return Py_None; 3360 return Py_None;
3282 } 3361 }
3283 3362
3284 result = PyType_GenericNew(arg_type, NULL, NULL); 3363 result = PyType_GenericNew(arg_type, NULL, NULL);
3285 if (!result) return NULL; 3364 if (!result) return NULL;
3286 value = ast2obj_identifier(o->arg); 3365 value = ast2obj_identifier(o->arg);
3287 if (!value) goto failed; 3366 if (!value) goto failed;
3288 if (PyObject_SetAttrString(result, "arg", value) == -1) 3367 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
3289 goto failed; 3368 goto failed;
3290 Py_DECREF(value); 3369 Py_DECREF(value);
3291 value = ast2obj_expr(o->annotation); 3370 value = ast2obj_expr(o->annotation);
3292 if (!value) goto failed; 3371 if (!value) goto failed;
3293 if (PyObject_SetAttrString(result, "annotation", value) == -1) 3372 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1)
3294 goto failed; 3373 goto failed;
3295 Py_DECREF(value); 3374 Py_DECREF(value);
3296 return result; 3375 return result;
3297 failed: 3376 failed:
3298 Py_XDECREF(value); 3377 Py_XDECREF(value);
3299 Py_XDECREF(result); 3378 Py_XDECREF(result);
3300 return NULL; 3379 return NULL;
3301 } 3380 }
3302 3381
3303 PyObject* 3382 PyObject*
3304 ast2obj_keyword(void* _o) 3383 ast2obj_keyword(void* _o)
3305 { 3384 {
3306 keyword_ty o = (keyword_ty)_o; 3385 keyword_ty o = (keyword_ty)_o;
3307 PyObject *result = NULL, *value = NULL; 3386 PyObject *result = NULL, *value = NULL;
3308 if (!o) { 3387 if (!o) {
3309 Py_INCREF(Py_None); 3388 Py_INCREF(Py_None);
3310 return Py_None; 3389 return Py_None;
3311 } 3390 }
3312 3391
3313 result = PyType_GenericNew(keyword_type, NULL, NULL); 3392 result = PyType_GenericNew(keyword_type, NULL, NULL);
3314 if (!result) return NULL; 3393 if (!result) return NULL;
3315 value = ast2obj_identifier(o->arg); 3394 value = ast2obj_identifier(o->arg);
3316 if (!value) goto failed; 3395 if (!value) goto failed;
3317 if (PyObject_SetAttrString(result, "arg", value) == -1) 3396 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
3318 goto failed; 3397 goto failed;
3319 Py_DECREF(value); 3398 Py_DECREF(value);
3320 value = ast2obj_expr(o->value); 3399 value = ast2obj_expr(o->value);
3321 if (!value) goto failed; 3400 if (!value) goto failed;
3322 if (PyObject_SetAttrString(result, "value", value) == -1) 3401 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
3323 goto failed; 3402 goto failed;
3324 Py_DECREF(value); 3403 Py_DECREF(value);
3325 return result; 3404 return result;
3326 failed: 3405 failed:
3327 Py_XDECREF(value); 3406 Py_XDECREF(value);
3328 Py_XDECREF(result); 3407 Py_XDECREF(result);
3329 return NULL; 3408 return NULL;
3330 } 3409 }
3331 3410
3332 PyObject* 3411 PyObject*
3333 ast2obj_alias(void* _o) 3412 ast2obj_alias(void* _o)
3334 { 3413 {
3335 alias_ty o = (alias_ty)_o; 3414 alias_ty o = (alias_ty)_o;
3336 PyObject *result = NULL, *value = NULL; 3415 PyObject *result = NULL, *value = NULL;
3337 if (!o) { 3416 if (!o) {
3338 Py_INCREF(Py_None); 3417 Py_INCREF(Py_None);
3339 return Py_None; 3418 return Py_None;
3340 } 3419 }
3341 3420
3342 result = PyType_GenericNew(alias_type, NULL, NULL); 3421 result = PyType_GenericNew(alias_type, NULL, NULL);
3343 if (!result) return NULL; 3422 if (!result) return NULL;
3344 value = ast2obj_identifier(o->name); 3423 value = ast2obj_identifier(o->name);
3345 if (!value) goto failed; 3424 if (!value) goto failed;
3346 if (PyObject_SetAttrString(result, "name", value) == -1) 3425 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
3347 goto failed; 3426 goto failed;
3348 Py_DECREF(value); 3427 Py_DECREF(value);
3349 value = ast2obj_identifier(o->asname); 3428 value = ast2obj_identifier(o->asname);
3350 if (!value) goto failed; 3429 if (!value) goto failed;
3351 if (PyObject_SetAttrString(result, "asname", value) == -1) 3430 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1)
3352 goto failed; 3431 goto failed;
3353 Py_DECREF(value); 3432 Py_DECREF(value);
3354 return result; 3433 return result;
3355 failed: 3434 failed:
3356 Py_XDECREF(value); 3435 Py_XDECREF(value);
3357 Py_XDECREF(result); 3436 Py_XDECREF(result);
3358 return NULL; 3437 return NULL;
3359 } 3438 }
3360 3439
3361 PyObject* 3440 PyObject*
3362 ast2obj_withitem(void* _o) 3441 ast2obj_withitem(void* _o)
3363 { 3442 {
3364 withitem_ty o = (withitem_ty)_o; 3443 withitem_ty o = (withitem_ty)_o;
3365 PyObject *result = NULL, *value = NULL; 3444 PyObject *result = NULL, *value = NULL;
3366 if (!o) { 3445 if (!o) {
3367 Py_INCREF(Py_None); 3446 Py_INCREF(Py_None);
3368 return Py_None; 3447 return Py_None;
3369 } 3448 }
3370 3449
3371 result = PyType_GenericNew(withitem_type, NULL, NULL); 3450 result = PyType_GenericNew(withitem_type, NULL, NULL);
3372 if (!result) return NULL; 3451 if (!result) return NULL;
3373 value = ast2obj_expr(o->context_expr); 3452 value = ast2obj_expr(o->context_expr);
3374 if (!value) goto failed; 3453 if (!value) goto failed;
3375 if (PyObject_SetAttrString(result, "context_expr", value) == -1) 3454 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)
3376 goto failed; 3455 goto failed;
3377 Py_DECREF(value); 3456 Py_DECREF(value);
3378 value = ast2obj_expr(o->optional_vars); 3457 value = ast2obj_expr(o->optional_vars);
3379 if (!value) goto failed; 3458 if (!value) goto failed;
3380 if (PyObject_SetAttrString(result, "optional_vars", value) == -1) 3459 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)
3381 goto failed; 3460 goto failed;
3382 Py_DECREF(value); 3461 Py_DECREF(value);
3383 return result; 3462 return result;
3384 failed: 3463 failed:
3385 Py_XDECREF(value); 3464 Py_XDECREF(value);
3386 Py_XDECREF(result); 3465 Py_XDECREF(result);
3387 return NULL; 3466 return NULL;
3388 } 3467 }
3389 3468
3390 3469
3391 int 3470 int
3392 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) 3471 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
3393 { 3472 {
3394 int isinstance; 3473 int isinstance;
3395 3474
3396 PyObject *tmp = NULL; 3475 PyObject *tmp = NULL;
3397 3476
3398 if (obj == Py_None) { 3477 if (obj == Py_None) {
3399 *out = NULL; 3478 *out = NULL;
3400 return 0; 3479 return 0;
3401 } 3480 }
3402 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); 3481 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);
3403 if (isinstance == -1) { 3482 if (isinstance == -1) {
3404 return 1; 3483 return 1;
3405 } 3484 }
3406 if (isinstance) { 3485 if (isinstance) {
3407 asdl_seq* body; 3486 asdl_seq* body;
3408 3487
3409 if (PyObject_HasAttrString(obj, "body")) { 3488 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3410 int res; 3489 int res;
3411 Py_ssize_t len; 3490 Py_ssize_t len;
3412 Py_ssize_t i; 3491 Py_ssize_t i;
3413 tmp = PyObject_GetAttrString(obj, "body"); 3492 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3414 if (tmp == NULL) goto failed; 3493 if (tmp == NULL) goto failed;
3415 if (!PyList_Check(tmp)) { 3494 if (!PyList_Check(tmp)) {
3416 PyErr_Format(PyExc_TypeError, "Module field \"bo dy\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3495 PyErr_Format(PyExc_TypeError, "Module field \"bo dy\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3417 goto failed; 3496 goto failed;
3418 } 3497 }
3419 len = PyList_GET_SIZE(tmp); 3498 len = PyList_GET_SIZE(tmp);
3420 body = asdl_seq_new(len, arena); 3499 body = asdl_seq_new(len, arena);
3421 if (body == NULL) goto failed; 3500 if (body == NULL) goto failed;
3422 for (i = 0; i < len; i++) { 3501 for (i = 0; i < len; i++) {
3423 stmt_ty value; 3502 stmt_ty value;
(...skipping 11 matching lines...) Expand all
3435 if (*out == NULL) goto failed; 3514 if (*out == NULL) goto failed;
3436 return 0; 3515 return 0;
3437 } 3516 }
3438 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); 3517 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);
3439 if (isinstance == -1) { 3518 if (isinstance == -1) {
3440 return 1; 3519 return 1;
3441 } 3520 }
3442 if (isinstance) { 3521 if (isinstance) {
3443 asdl_seq* body; 3522 asdl_seq* body;
3444 3523
3445 if (PyObject_HasAttrString(obj, "body")) { 3524 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3446 int res; 3525 int res;
3447 Py_ssize_t len; 3526 Py_ssize_t len;
3448 Py_ssize_t i; 3527 Py_ssize_t i;
3449 tmp = PyObject_GetAttrString(obj, "body"); 3528 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3450 if (tmp == NULL) goto failed; 3529 if (tmp == NULL) goto failed;
3451 if (!PyList_Check(tmp)) { 3530 if (!PyList_Check(tmp)) {
3452 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3531 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3453 goto failed; 3532 goto failed;
3454 } 3533 }
3455 len = PyList_GET_SIZE(tmp); 3534 len = PyList_GET_SIZE(tmp);
3456 body = asdl_seq_new(len, arena); 3535 body = asdl_seq_new(len, arena);
3457 if (body == NULL) goto failed; 3536 if (body == NULL) goto failed;
3458 for (i = 0; i < len; i++) { 3537 for (i = 0; i < len; i++) {
3459 stmt_ty value; 3538 stmt_ty value;
(...skipping 11 matching lines...) Expand all
3471 if (*out == NULL) goto failed; 3550 if (*out == NULL) goto failed;
3472 return 0; 3551 return 0;
3473 } 3552 }
3474 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); 3553 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);
3475 if (isinstance == -1) { 3554 if (isinstance == -1) {
3476 return 1; 3555 return 1;
3477 } 3556 }
3478 if (isinstance) { 3557 if (isinstance) {
3479 expr_ty body; 3558 expr_ty body;
3480 3559
3481 if (PyObject_HasAttrString(obj, "body")) { 3560 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3482 int res; 3561 int res;
3483 tmp = PyObject_GetAttrString(obj, "body"); 3562 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3484 if (tmp == NULL) goto failed; 3563 if (tmp == NULL) goto failed;
3485 res = obj2ast_expr(tmp, &body, arena); 3564 res = obj2ast_expr(tmp, &body, arena);
3486 if (res != 0) goto failed; 3565 if (res != 0) goto failed;
3487 Py_XDECREF(tmp); 3566 Py_XDECREF(tmp);
3488 tmp = NULL; 3567 tmp = NULL;
3489 } else { 3568 } else {
3490 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from Expression"); 3569 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from Expression");
3491 return 1; 3570 return 1;
3492 } 3571 }
3493 *out = Expression(body, arena); 3572 *out = Expression(body, arena);
3494 if (*out == NULL) goto failed; 3573 if (*out == NULL) goto failed;
3495 return 0; 3574 return 0;
3496 } 3575 }
3497 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); 3576 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);
3498 if (isinstance == -1) { 3577 if (isinstance == -1) {
3499 return 1; 3578 return 1;
3500 } 3579 }
3501 if (isinstance) { 3580 if (isinstance) {
3502 asdl_seq* body; 3581 asdl_seq* body;
3503 3582
3504 if (PyObject_HasAttrString(obj, "body")) { 3583 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3505 int res; 3584 int res;
3506 Py_ssize_t len; 3585 Py_ssize_t len;
3507 Py_ssize_t i; 3586 Py_ssize_t i;
3508 tmp = PyObject_GetAttrString(obj, "body"); 3587 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3509 if (tmp == NULL) goto failed; 3588 if (tmp == NULL) goto failed;
3510 if (!PyList_Check(tmp)) { 3589 if (!PyList_Check(tmp)) {
3511 PyErr_Format(PyExc_TypeError, "Suite field \"bod y\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3590 PyErr_Format(PyExc_TypeError, "Suite field \"bod y\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3512 goto failed; 3591 goto failed;
3513 } 3592 }
3514 len = PyList_GET_SIZE(tmp); 3593 len = PyList_GET_SIZE(tmp);
3515 body = asdl_seq_new(len, arena); 3594 body = asdl_seq_new(len, arena);
3516 if (body == NULL) goto failed; 3595 if (body == NULL) goto failed;
3517 for (i = 0; i < len; i++) { 3596 for (i = 0; i < len; i++) {
3518 stmt_ty value; 3597 stmt_ty value;
(...skipping 24 matching lines...) Expand all
3543 int isinstance; 3622 int isinstance;
3544 3623
3545 PyObject *tmp = NULL; 3624 PyObject *tmp = NULL;
3546 int lineno; 3625 int lineno;
3547 int col_offset; 3626 int col_offset;
3548 3627
3549 if (obj == Py_None) { 3628 if (obj == Py_None) {
3550 *out = NULL; 3629 *out = NULL;
3551 return 0; 3630 return 0;
3552 } 3631 }
3553 if (PyObject_HasAttrString(obj, "lineno")) { 3632 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
3554 int res; 3633 int res;
3555 tmp = PyObject_GetAttrString(obj, "lineno"); 3634 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
3556 if (tmp == NULL) goto failed; 3635 if (tmp == NULL) goto failed;
3557 res = obj2ast_int(tmp, &lineno, arena); 3636 res = obj2ast_int(tmp, &lineno, arena);
3558 if (res != 0) goto failed; 3637 if (res != 0) goto failed;
3559 Py_XDECREF(tmp); 3638 Py_XDECREF(tmp);
3560 tmp = NULL; 3639 tmp = NULL;
3561 } else { 3640 } else {
3562 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" miss ing from stmt"); 3641 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" miss ing from stmt");
3563 return 1; 3642 return 1;
3564 } 3643 }
3565 if (PyObject_HasAttrString(obj, "col_offset")) { 3644 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
3566 int res; 3645 int res;
3567 tmp = PyObject_GetAttrString(obj, "col_offset"); 3646 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
3568 if (tmp == NULL) goto failed; 3647 if (tmp == NULL) goto failed;
3569 res = obj2ast_int(tmp, &col_offset, arena); 3648 res = obj2ast_int(tmp, &col_offset, arena);
3570 if (res != 0) goto failed; 3649 if (res != 0) goto failed;
3571 Py_XDECREF(tmp); 3650 Py_XDECREF(tmp);
3572 tmp = NULL; 3651 tmp = NULL;
3573 } else { 3652 } else {
3574 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); 3653 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
3575 return 1; 3654 return 1;
3576 } 3655 }
3577 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); 3656 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type);
3578 if (isinstance == -1) { 3657 if (isinstance == -1) {
3579 return 1; 3658 return 1;
3580 } 3659 }
3581 if (isinstance) { 3660 if (isinstance) {
3582 identifier name; 3661 identifier name;
3583 arguments_ty args; 3662 arguments_ty args;
3584 asdl_seq* body; 3663 asdl_seq* body;
3585 asdl_seq* decorator_list; 3664 asdl_seq* decorator_list;
3586 expr_ty returns; 3665 expr_ty returns;
3587 3666
3588 if (PyObject_HasAttrString(obj, "name")) { 3667 if (_PyObject_HasAttrId(obj, &PyId_name)) {
3589 int res; 3668 int res;
3590 tmp = PyObject_GetAttrString(obj, "name"); 3669 tmp = _PyObject_GetAttrId(obj, &PyId_name);
3591 if (tmp == NULL) goto failed; 3670 if (tmp == NULL) goto failed;
3592 res = obj2ast_identifier(tmp, &name, arena); 3671 res = obj2ast_identifier(tmp, &name, arena);
3593 if (res != 0) goto failed; 3672 if (res != 0) goto failed;
3594 Py_XDECREF(tmp); 3673 Py_XDECREF(tmp);
3595 tmp = NULL; 3674 tmp = NULL;
3596 } else { 3675 } else {
3597 PyErr_SetString(PyExc_TypeError, "required field \"name\ " missing from FunctionDef"); 3676 PyErr_SetString(PyExc_TypeError, "required field \"name\ " missing from FunctionDef");
3598 return 1; 3677 return 1;
3599 } 3678 }
3600 if (PyObject_HasAttrString(obj, "args")) { 3679 if (_PyObject_HasAttrId(obj, &PyId_args)) {
3601 int res; 3680 int res;
3602 tmp = PyObject_GetAttrString(obj, "args"); 3681 tmp = _PyObject_GetAttrId(obj, &PyId_args);
3603 if (tmp == NULL) goto failed; 3682 if (tmp == NULL) goto failed;
3604 res = obj2ast_arguments(tmp, &args, arena); 3683 res = obj2ast_arguments(tmp, &args, arena);
3605 if (res != 0) goto failed; 3684 if (res != 0) goto failed;
3606 Py_XDECREF(tmp); 3685 Py_XDECREF(tmp);
3607 tmp = NULL; 3686 tmp = NULL;
3608 } else { 3687 } else {
3609 PyErr_SetString(PyExc_TypeError, "required field \"args\ " missing from FunctionDef"); 3688 PyErr_SetString(PyExc_TypeError, "required field \"args\ " missing from FunctionDef");
3610 return 1; 3689 return 1;
3611 } 3690 }
3612 if (PyObject_HasAttrString(obj, "body")) { 3691 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3613 int res; 3692 int res;
3614 Py_ssize_t len; 3693 Py_ssize_t len;
3615 Py_ssize_t i; 3694 Py_ssize_t i;
3616 tmp = PyObject_GetAttrString(obj, "body"); 3695 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3617 if (tmp == NULL) goto failed; 3696 if (tmp == NULL) goto failed;
3618 if (!PyList_Check(tmp)) { 3697 if (!PyList_Check(tmp)) {
3619 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3698 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3620 goto failed; 3699 goto failed;
3621 } 3700 }
3622 len = PyList_GET_SIZE(tmp); 3701 len = PyList_GET_SIZE(tmp);
3623 body = asdl_seq_new(len, arena); 3702 body = asdl_seq_new(len, arena);
3624 if (body == NULL) goto failed; 3703 if (body == NULL) goto failed;
3625 for (i = 0; i < len; i++) { 3704 for (i = 0; i < len; i++) {
3626 stmt_ty value; 3705 stmt_ty value;
3627 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 3706 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
3628 if (res != 0) goto failed; 3707 if (res != 0) goto failed;
3629 asdl_seq_SET(body, i, value); 3708 asdl_seq_SET(body, i, value);
3630 } 3709 }
3631 Py_XDECREF(tmp); 3710 Py_XDECREF(tmp);
3632 tmp = NULL; 3711 tmp = NULL;
3633 } else { 3712 } else {
3634 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from FunctionDef"); 3713 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from FunctionDef");
3635 return 1; 3714 return 1;
3636 } 3715 }
3637 if (PyObject_HasAttrString(obj, "decorator_list")) { 3716 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
3638 int res; 3717 int res;
3639 Py_ssize_t len; 3718 Py_ssize_t len;
3640 Py_ssize_t i; 3719 Py_ssize_t i;
3641 tmp = PyObject_GetAttrString(obj, "decorator_list"); 3720 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
3642 if (tmp == NULL) goto failed; 3721 if (tmp == NULL) goto failed;
3643 if (!PyList_Check(tmp)) { 3722 if (!PyList_Check(tmp)) {
3644 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3723 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3645 goto failed; 3724 goto failed;
3646 } 3725 }
3647 len = PyList_GET_SIZE(tmp); 3726 len = PyList_GET_SIZE(tmp);
3648 decorator_list = asdl_seq_new(len, arena); 3727 decorator_list = asdl_seq_new(len, arena);
3649 if (decorator_list == NULL) goto failed; 3728 if (decorator_list == NULL) goto failed;
3650 for (i = 0; i < len; i++) { 3729 for (i = 0; i < len; i++) {
3651 expr_ty value; 3730 expr_ty value;
3652 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val ue, arena); 3731 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val ue, arena);
3653 if (res != 0) goto failed; 3732 if (res != 0) goto failed;
3654 asdl_seq_SET(decorator_list, i, value); 3733 asdl_seq_SET(decorator_list, i, value);
3655 } 3734 }
3656 Py_XDECREF(tmp); 3735 Py_XDECREF(tmp);
3657 tmp = NULL; 3736 tmp = NULL;
3658 } else { 3737 } else {
3659 PyErr_SetString(PyExc_TypeError, "required field \"decor ator_list\" missing from FunctionDef"); 3738 PyErr_SetString(PyExc_TypeError, "required field \"decor ator_list\" missing from FunctionDef");
3660 return 1; 3739 return 1;
3661 } 3740 }
3662 if (PyObject_HasAttrString(obj, "returns")) { 3741 if (_PyObject_HasAttrId(obj, &PyId_returns)) {
3663 int res; 3742 int res;
3664 tmp = PyObject_GetAttrString(obj, "returns"); 3743 tmp = _PyObject_GetAttrId(obj, &PyId_returns);
3665 if (tmp == NULL) goto failed; 3744 if (tmp == NULL) goto failed;
3666 res = obj2ast_expr(tmp, &returns, arena); 3745 res = obj2ast_expr(tmp, &returns, arena);
3667 if (res != 0) goto failed; 3746 if (res != 0) goto failed;
3668 Py_XDECREF(tmp); 3747 Py_XDECREF(tmp);
3669 tmp = NULL; 3748 tmp = NULL;
3670 } else { 3749 } else {
3671 returns = NULL; 3750 returns = NULL;
3672 } 3751 }
3673 *out = FunctionDef(name, args, body, decorator_list, returns, 3752 *out = FunctionDef(name, args, body, decorator_list, returns,
3674 lineno, col_offset, arena); 3753 lineno, col_offset, arena);
3675 if (*out == NULL) goto failed; 3754 if (*out == NULL) goto failed;
3676 return 0; 3755 return 0;
3677 } 3756 }
3678 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); 3757 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type);
3679 if (isinstance == -1) { 3758 if (isinstance == -1) {
3680 return 1; 3759 return 1;
3681 } 3760 }
3682 if (isinstance) { 3761 if (isinstance) {
3683 identifier name; 3762 identifier name;
3684 asdl_seq* bases; 3763 asdl_seq* bases;
3685 asdl_seq* keywords; 3764 asdl_seq* keywords;
3686 expr_ty starargs; 3765 expr_ty starargs;
3687 expr_ty kwargs; 3766 expr_ty kwargs;
3688 asdl_seq* body; 3767 asdl_seq* body;
3689 asdl_seq* decorator_list; 3768 asdl_seq* decorator_list;
3690 3769
3691 if (PyObject_HasAttrString(obj, "name")) { 3770 if (_PyObject_HasAttrId(obj, &PyId_name)) {
3692 int res; 3771 int res;
3693 tmp = PyObject_GetAttrString(obj, "name"); 3772 tmp = _PyObject_GetAttrId(obj, &PyId_name);
3694 if (tmp == NULL) goto failed; 3773 if (tmp == NULL) goto failed;
3695 res = obj2ast_identifier(tmp, &name, arena); 3774 res = obj2ast_identifier(tmp, &name, arena);
3696 if (res != 0) goto failed; 3775 if (res != 0) goto failed;
3697 Py_XDECREF(tmp); 3776 Py_XDECREF(tmp);
3698 tmp = NULL; 3777 tmp = NULL;
3699 } else { 3778 } else {
3700 PyErr_SetString(PyExc_TypeError, "required field \"name\ " missing from ClassDef"); 3779 PyErr_SetString(PyExc_TypeError, "required field \"name\ " missing from ClassDef");
3701 return 1; 3780 return 1;
3702 } 3781 }
3703 if (PyObject_HasAttrString(obj, "bases")) { 3782 if (_PyObject_HasAttrId(obj, &PyId_bases)) {
3704 int res; 3783 int res;
3705 Py_ssize_t len; 3784 Py_ssize_t len;
3706 Py_ssize_t i; 3785 Py_ssize_t i;
3707 tmp = PyObject_GetAttrString(obj, "bases"); 3786 tmp = _PyObject_GetAttrId(obj, &PyId_bases);
3708 if (tmp == NULL) goto failed; 3787 if (tmp == NULL) goto failed;
3709 if (!PyList_Check(tmp)) { 3788 if (!PyList_Check(tmp)) {
3710 PyErr_Format(PyExc_TypeError, "ClassDef field \" bases\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3789 PyErr_Format(PyExc_TypeError, "ClassDef field \" bases\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3711 goto failed; 3790 goto failed;
3712 } 3791 }
3713 len = PyList_GET_SIZE(tmp); 3792 len = PyList_GET_SIZE(tmp);
3714 bases = asdl_seq_new(len, arena); 3793 bases = asdl_seq_new(len, arena);
3715 if (bases == NULL) goto failed; 3794 if (bases == NULL) goto failed;
3716 for (i = 0; i < len; i++) { 3795 for (i = 0; i < len; i++) {
3717 expr_ty value; 3796 expr_ty value;
3718 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val ue, arena); 3797 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val ue, arena);
3719 if (res != 0) goto failed; 3798 if (res != 0) goto failed;
3720 asdl_seq_SET(bases, i, value); 3799 asdl_seq_SET(bases, i, value);
3721 } 3800 }
3722 Py_XDECREF(tmp); 3801 Py_XDECREF(tmp);
3723 tmp = NULL; 3802 tmp = NULL;
3724 } else { 3803 } else {
3725 PyErr_SetString(PyExc_TypeError, "required field \"bases \" missing from ClassDef"); 3804 PyErr_SetString(PyExc_TypeError, "required field \"bases \" missing from ClassDef");
3726 return 1; 3805 return 1;
3727 } 3806 }
3728 if (PyObject_HasAttrString(obj, "keywords")) { 3807 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
3729 int res; 3808 int res;
3730 Py_ssize_t len; 3809 Py_ssize_t len;
3731 Py_ssize_t i; 3810 Py_ssize_t i;
3732 tmp = PyObject_GetAttrString(obj, "keywords"); 3811 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
3733 if (tmp == NULL) goto failed; 3812 if (tmp == NULL) goto failed;
3734 if (!PyList_Check(tmp)) { 3813 if (!PyList_Check(tmp)) {
3735 PyErr_Format(PyExc_TypeError, "ClassDef field \" keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3814 PyErr_Format(PyExc_TypeError, "ClassDef field \" keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3736 goto failed; 3815 goto failed;
3737 } 3816 }
3738 len = PyList_GET_SIZE(tmp); 3817 len = PyList_GET_SIZE(tmp);
3739 keywords = asdl_seq_new(len, arena); 3818 keywords = asdl_seq_new(len, arena);
3740 if (keywords == NULL) goto failed; 3819 if (keywords == NULL) goto failed;
3741 for (i = 0; i < len; i++) { 3820 for (i = 0; i < len; i++) {
3742 keyword_ty value; 3821 keyword_ty value;
3743 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), & value, arena); 3822 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), & value, arena);
3744 if (res != 0) goto failed; 3823 if (res != 0) goto failed;
3745 asdl_seq_SET(keywords, i, value); 3824 asdl_seq_SET(keywords, i, value);
3746 } 3825 }
3747 Py_XDECREF(tmp); 3826 Py_XDECREF(tmp);
3748 tmp = NULL; 3827 tmp = NULL;
3749 } else { 3828 } else {
3750 PyErr_SetString(PyExc_TypeError, "required field \"keywo rds\" missing from ClassDef"); 3829 PyErr_SetString(PyExc_TypeError, "required field \"keywo rds\" missing from ClassDef");
3751 return 1; 3830 return 1;
3752 } 3831 }
3753 if (PyObject_HasAttrString(obj, "starargs")) { 3832 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
3754 int res; 3833 int res;
3755 tmp = PyObject_GetAttrString(obj, "starargs"); 3834 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
3756 if (tmp == NULL) goto failed; 3835 if (tmp == NULL) goto failed;
3757 res = obj2ast_expr(tmp, &starargs, arena); 3836 res = obj2ast_expr(tmp, &starargs, arena);
3758 if (res != 0) goto failed; 3837 if (res != 0) goto failed;
3759 Py_XDECREF(tmp); 3838 Py_XDECREF(tmp);
3760 tmp = NULL; 3839 tmp = NULL;
3761 } else { 3840 } else {
3762 starargs = NULL; 3841 starargs = NULL;
3763 } 3842 }
3764 if (PyObject_HasAttrString(obj, "kwargs")) { 3843 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
3765 int res; 3844 int res;
3766 tmp = PyObject_GetAttrString(obj, "kwargs"); 3845 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
3767 if (tmp == NULL) goto failed; 3846 if (tmp == NULL) goto failed;
3768 res = obj2ast_expr(tmp, &kwargs, arena); 3847 res = obj2ast_expr(tmp, &kwargs, arena);
3769 if (res != 0) goto failed; 3848 if (res != 0) goto failed;
3770 Py_XDECREF(tmp); 3849 Py_XDECREF(tmp);
3771 tmp = NULL; 3850 tmp = NULL;
3772 } else { 3851 } else {
3773 kwargs = NULL; 3852 kwargs = NULL;
3774 } 3853 }
3775 if (PyObject_HasAttrString(obj, "body")) { 3854 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3776 int res; 3855 int res;
3777 Py_ssize_t len; 3856 Py_ssize_t len;
3778 Py_ssize_t i; 3857 Py_ssize_t i;
3779 tmp = PyObject_GetAttrString(obj, "body"); 3858 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3780 if (tmp == NULL) goto failed; 3859 if (tmp == NULL) goto failed;
3781 if (!PyList_Check(tmp)) { 3860 if (!PyList_Check(tmp)) {
3782 PyErr_Format(PyExc_TypeError, "ClassDef field \" body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3861 PyErr_Format(PyExc_TypeError, "ClassDef field \" body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3783 goto failed; 3862 goto failed;
3784 } 3863 }
3785 len = PyList_GET_SIZE(tmp); 3864 len = PyList_GET_SIZE(tmp);
3786 body = asdl_seq_new(len, arena); 3865 body = asdl_seq_new(len, arena);
3787 if (body == NULL) goto failed; 3866 if (body == NULL) goto failed;
3788 for (i = 0; i < len; i++) { 3867 for (i = 0; i < len; i++) {
3789 stmt_ty value; 3868 stmt_ty value;
3790 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 3869 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
3791 if (res != 0) goto failed; 3870 if (res != 0) goto failed;
3792 asdl_seq_SET(body, i, value); 3871 asdl_seq_SET(body, i, value);
3793 } 3872 }
3794 Py_XDECREF(tmp); 3873 Py_XDECREF(tmp);
3795 tmp = NULL; 3874 tmp = NULL;
3796 } else { 3875 } else {
3797 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from ClassDef"); 3876 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from ClassDef");
3798 return 1; 3877 return 1;
3799 } 3878 }
3800 if (PyObject_HasAttrString(obj, "decorator_list")) { 3879 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
3801 int res; 3880 int res;
3802 Py_ssize_t len; 3881 Py_ssize_t len;
3803 Py_ssize_t i; 3882 Py_ssize_t i;
3804 tmp = PyObject_GetAttrString(obj, "decorator_list"); 3883 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
3805 if (tmp == NULL) goto failed; 3884 if (tmp == NULL) goto failed;
3806 if (!PyList_Check(tmp)) { 3885 if (!PyList_Check(tmp)) {
3807 PyErr_Format(PyExc_TypeError, "ClassDef field \" decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3886 PyErr_Format(PyExc_TypeError, "ClassDef field \" decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3808 goto failed; 3887 goto failed;
3809 } 3888 }
3810 len = PyList_GET_SIZE(tmp); 3889 len = PyList_GET_SIZE(tmp);
3811 decorator_list = asdl_seq_new(len, arena); 3890 decorator_list = asdl_seq_new(len, arena);
3812 if (decorator_list == NULL) goto failed; 3891 if (decorator_list == NULL) goto failed;
3813 for (i = 0; i < len; i++) { 3892 for (i = 0; i < len; i++) {
3814 expr_ty value; 3893 expr_ty value;
(...skipping 12 matching lines...) Expand all
3827 if (*out == NULL) goto failed; 3906 if (*out == NULL) goto failed;
3828 return 0; 3907 return 0;
3829 } 3908 }
3830 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); 3909 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type);
3831 if (isinstance == -1) { 3910 if (isinstance == -1) {
3832 return 1; 3911 return 1;
3833 } 3912 }
3834 if (isinstance) { 3913 if (isinstance) {
3835 expr_ty value; 3914 expr_ty value;
3836 3915
3837 if (PyObject_HasAttrString(obj, "value")) { 3916 if (_PyObject_HasAttrId(obj, &PyId_value)) {
3838 int res; 3917 int res;
3839 tmp = PyObject_GetAttrString(obj, "value"); 3918 tmp = _PyObject_GetAttrId(obj, &PyId_value);
3840 if (tmp == NULL) goto failed; 3919 if (tmp == NULL) goto failed;
3841 res = obj2ast_expr(tmp, &value, arena); 3920 res = obj2ast_expr(tmp, &value, arena);
3842 if (res != 0) goto failed; 3921 if (res != 0) goto failed;
3843 Py_XDECREF(tmp); 3922 Py_XDECREF(tmp);
3844 tmp = NULL; 3923 tmp = NULL;
3845 } else { 3924 } else {
3846 value = NULL; 3925 value = NULL;
3847 } 3926 }
3848 *out = Return(value, lineno, col_offset, arena); 3927 *out = Return(value, lineno, col_offset, arena);
3849 if (*out == NULL) goto failed; 3928 if (*out == NULL) goto failed;
3850 return 0; 3929 return 0;
3851 } 3930 }
3852 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); 3931 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type);
3853 if (isinstance == -1) { 3932 if (isinstance == -1) {
3854 return 1; 3933 return 1;
3855 } 3934 }
3856 if (isinstance) { 3935 if (isinstance) {
3857 asdl_seq* targets; 3936 asdl_seq* targets;
3858 3937
3859 if (PyObject_HasAttrString(obj, "targets")) { 3938 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
3860 int res; 3939 int res;
3861 Py_ssize_t len; 3940 Py_ssize_t len;
3862 Py_ssize_t i; 3941 Py_ssize_t i;
3863 tmp = PyObject_GetAttrString(obj, "targets"); 3942 tmp = _PyObject_GetAttrId(obj, &PyId_targets);
3864 if (tmp == NULL) goto failed; 3943 if (tmp == NULL) goto failed;
3865 if (!PyList_Check(tmp)) { 3944 if (!PyList_Check(tmp)) {
3866 PyErr_Format(PyExc_TypeError, "Delete field \"ta rgets\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3945 PyErr_Format(PyExc_TypeError, "Delete field \"ta rgets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3867 goto failed; 3946 goto failed;
3868 } 3947 }
3869 len = PyList_GET_SIZE(tmp); 3948 len = PyList_GET_SIZE(tmp);
3870 targets = asdl_seq_new(len, arena); 3949 targets = asdl_seq_new(len, arena);
3871 if (targets == NULL) goto failed; 3950 if (targets == NULL) goto failed;
3872 for (i = 0; i < len; i++) { 3951 for (i = 0; i < len; i++) {
3873 expr_ty value; 3952 expr_ty value;
(...skipping 12 matching lines...) Expand all
3886 return 0; 3965 return 0;
3887 } 3966 }
3888 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); 3967 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type);
3889 if (isinstance == -1) { 3968 if (isinstance == -1) {
3890 return 1; 3969 return 1;
3891 } 3970 }
3892 if (isinstance) { 3971 if (isinstance) {
3893 asdl_seq* targets; 3972 asdl_seq* targets;
3894 expr_ty value; 3973 expr_ty value;
3895 3974
3896 if (PyObject_HasAttrString(obj, "targets")) { 3975 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
3897 int res; 3976 int res;
3898 Py_ssize_t len; 3977 Py_ssize_t len;
3899 Py_ssize_t i; 3978 Py_ssize_t i;
3900 tmp = PyObject_GetAttrString(obj, "targets"); 3979 tmp = _PyObject_GetAttrId(obj, &PyId_targets);
3901 if (tmp == NULL) goto failed; 3980 if (tmp == NULL) goto failed;
3902 if (!PyList_Check(tmp)) { 3981 if (!PyList_Check(tmp)) {
3903 PyErr_Format(PyExc_TypeError, "Assign field \"ta rgets\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3982 PyErr_Format(PyExc_TypeError, "Assign field \"ta rgets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3904 goto failed; 3983 goto failed;
3905 } 3984 }
3906 len = PyList_GET_SIZE(tmp); 3985 len = PyList_GET_SIZE(tmp);
3907 targets = asdl_seq_new(len, arena); 3986 targets = asdl_seq_new(len, arena);
3908 if (targets == NULL) goto failed; 3987 if (targets == NULL) goto failed;
3909 for (i = 0; i < len; i++) { 3988 for (i = 0; i < len; i++) {
3910 expr_ty value; 3989 expr_ty value;
3911 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val ue, arena); 3990 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &val ue, arena);
3912 if (res != 0) goto failed; 3991 if (res != 0) goto failed;
3913 asdl_seq_SET(targets, i, value); 3992 asdl_seq_SET(targets, i, value);
3914 } 3993 }
3915 Py_XDECREF(tmp); 3994 Py_XDECREF(tmp);
3916 tmp = NULL; 3995 tmp = NULL;
3917 } else { 3996 } else {
3918 PyErr_SetString(PyExc_TypeError, "required field \"targe ts\" missing from Assign"); 3997 PyErr_SetString(PyExc_TypeError, "required field \"targe ts\" missing from Assign");
3919 return 1; 3998 return 1;
3920 } 3999 }
3921 if (PyObject_HasAttrString(obj, "value")) { 4000 if (_PyObject_HasAttrId(obj, &PyId_value)) {
3922 int res; 4001 int res;
3923 tmp = PyObject_GetAttrString(obj, "value"); 4002 tmp = _PyObject_GetAttrId(obj, &PyId_value);
3924 if (tmp == NULL) goto failed; 4003 if (tmp == NULL) goto failed;
3925 res = obj2ast_expr(tmp, &value, arena); 4004 res = obj2ast_expr(tmp, &value, arena);
3926 if (res != 0) goto failed; 4005 if (res != 0) goto failed;
3927 Py_XDECREF(tmp); 4006 Py_XDECREF(tmp);
3928 tmp = NULL; 4007 tmp = NULL;
3929 } else { 4008 } else {
3930 PyErr_SetString(PyExc_TypeError, "required field \"value \" missing from Assign"); 4009 PyErr_SetString(PyExc_TypeError, "required field \"value \" missing from Assign");
3931 return 1; 4010 return 1;
3932 } 4011 }
3933 *out = Assign(targets, value, lineno, col_offset, arena); 4012 *out = Assign(targets, value, lineno, col_offset, arena);
3934 if (*out == NULL) goto failed; 4013 if (*out == NULL) goto failed;
3935 return 0; 4014 return 0;
3936 } 4015 }
3937 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); 4016 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type);
3938 if (isinstance == -1) { 4017 if (isinstance == -1) {
3939 return 1; 4018 return 1;
3940 } 4019 }
3941 if (isinstance) { 4020 if (isinstance) {
3942 expr_ty target; 4021 expr_ty target;
3943 operator_ty op; 4022 operator_ty op;
3944 expr_ty value; 4023 expr_ty value;
3945 4024
3946 if (PyObject_HasAttrString(obj, "target")) { 4025 if (_PyObject_HasAttrId(obj, &PyId_target)) {
3947 int res; 4026 int res;
3948 tmp = PyObject_GetAttrString(obj, "target"); 4027 tmp = _PyObject_GetAttrId(obj, &PyId_target);
3949 if (tmp == NULL) goto failed; 4028 if (tmp == NULL) goto failed;
3950 res = obj2ast_expr(tmp, &target, arena); 4029 res = obj2ast_expr(tmp, &target, arena);
3951 if (res != 0) goto failed; 4030 if (res != 0) goto failed;
3952 Py_XDECREF(tmp); 4031 Py_XDECREF(tmp);
3953 tmp = NULL; 4032 tmp = NULL;
3954 } else { 4033 } else {
3955 PyErr_SetString(PyExc_TypeError, "required field \"targe t\" missing from AugAssign"); 4034 PyErr_SetString(PyExc_TypeError, "required field \"targe t\" missing from AugAssign");
3956 return 1; 4035 return 1;
3957 } 4036 }
3958 if (PyObject_HasAttrString(obj, "op")) { 4037 if (_PyObject_HasAttrId(obj, &PyId_op)) {
3959 int res; 4038 int res;
3960 tmp = PyObject_GetAttrString(obj, "op"); 4039 tmp = _PyObject_GetAttrId(obj, &PyId_op);
3961 if (tmp == NULL) goto failed; 4040 if (tmp == NULL) goto failed;
3962 res = obj2ast_operator(tmp, &op, arena); 4041 res = obj2ast_operator(tmp, &op, arena);
3963 if (res != 0) goto failed; 4042 if (res != 0) goto failed;
3964 Py_XDECREF(tmp); 4043 Py_XDECREF(tmp);
3965 tmp = NULL; 4044 tmp = NULL;
3966 } else { 4045 } else {
3967 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); 4046 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
3968 return 1; 4047 return 1;
3969 } 4048 }
3970 if (PyObject_HasAttrString(obj, "value")) { 4049 if (_PyObject_HasAttrId(obj, &PyId_value)) {
3971 int res; 4050 int res;
3972 tmp = PyObject_GetAttrString(obj, "value"); 4051 tmp = _PyObject_GetAttrId(obj, &PyId_value);
3973 if (tmp == NULL) goto failed; 4052 if (tmp == NULL) goto failed;
3974 res = obj2ast_expr(tmp, &value, arena); 4053 res = obj2ast_expr(tmp, &value, arena);
3975 if (res != 0) goto failed; 4054 if (res != 0) goto failed;
3976 Py_XDECREF(tmp); 4055 Py_XDECREF(tmp);
3977 tmp = NULL; 4056 tmp = NULL;
3978 } else { 4057 } else {
3979 PyErr_SetString(PyExc_TypeError, "required field \"value \" missing from AugAssign"); 4058 PyErr_SetString(PyExc_TypeError, "required field \"value \" missing from AugAssign");
3980 return 1; 4059 return 1;
3981 } 4060 }
3982 *out = AugAssign(target, op, value, lineno, col_offset, arena); 4061 *out = AugAssign(target, op, value, lineno, col_offset, arena);
3983 if (*out == NULL) goto failed; 4062 if (*out == NULL) goto failed;
3984 return 0; 4063 return 0;
3985 } 4064 }
3986 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); 4065 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type);
3987 if (isinstance == -1) { 4066 if (isinstance == -1) {
3988 return 1; 4067 return 1;
3989 } 4068 }
3990 if (isinstance) { 4069 if (isinstance) {
3991 expr_ty target; 4070 expr_ty target;
3992 expr_ty iter; 4071 expr_ty iter;
3993 asdl_seq* body; 4072 asdl_seq* body;
3994 asdl_seq* orelse; 4073 asdl_seq* orelse;
3995 4074
3996 if (PyObject_HasAttrString(obj, "target")) { 4075 if (_PyObject_HasAttrId(obj, &PyId_target)) {
3997 int res; 4076 int res;
3998 tmp = PyObject_GetAttrString(obj, "target"); 4077 tmp = _PyObject_GetAttrId(obj, &PyId_target);
3999 if (tmp == NULL) goto failed; 4078 if (tmp == NULL) goto failed;
4000 res = obj2ast_expr(tmp, &target, arena); 4079 res = obj2ast_expr(tmp, &target, arena);
4001 if (res != 0) goto failed; 4080 if (res != 0) goto failed;
4002 Py_XDECREF(tmp); 4081 Py_XDECREF(tmp);
4003 tmp = NULL; 4082 tmp = NULL;
4004 } else { 4083 } else {
4005 PyErr_SetString(PyExc_TypeError, "required field \"targe t\" missing from For"); 4084 PyErr_SetString(PyExc_TypeError, "required field \"targe t\" missing from For");
4006 return 1; 4085 return 1;
4007 } 4086 }
4008 if (PyObject_HasAttrString(obj, "iter")) { 4087 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
4009 int res; 4088 int res;
4010 tmp = PyObject_GetAttrString(obj, "iter"); 4089 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
4011 if (tmp == NULL) goto failed; 4090 if (tmp == NULL) goto failed;
4012 res = obj2ast_expr(tmp, &iter, arena); 4091 res = obj2ast_expr(tmp, &iter, arena);
4013 if (res != 0) goto failed; 4092 if (res != 0) goto failed;
4014 Py_XDECREF(tmp); 4093 Py_XDECREF(tmp);
4015 tmp = NULL; 4094 tmp = NULL;
4016 } else { 4095 } else {
4017 PyErr_SetString(PyExc_TypeError, "required field \"iter\ " missing from For"); 4096 PyErr_SetString(PyExc_TypeError, "required field \"iter\ " missing from For");
4018 return 1; 4097 return 1;
4019 } 4098 }
4020 if (PyObject_HasAttrString(obj, "body")) { 4099 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4021 int res; 4100 int res;
4022 Py_ssize_t len; 4101 Py_ssize_t len;
4023 Py_ssize_t i; 4102 Py_ssize_t i;
4024 tmp = PyObject_GetAttrString(obj, "body"); 4103 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4025 if (tmp == NULL) goto failed; 4104 if (tmp == NULL) goto failed;
4026 if (!PyList_Check(tmp)) { 4105 if (!PyList_Check(tmp)) {
4027 PyErr_Format(PyExc_TypeError, "For field \"body\ " must be a list, not a %.200s", tmp->ob_type->tp_name); 4106 PyErr_Format(PyExc_TypeError, "For field \"body\ " must be a list, not a %.200s", tmp->ob_type->tp_name);
4028 goto failed; 4107 goto failed;
4029 } 4108 }
4030 len = PyList_GET_SIZE(tmp); 4109 len = PyList_GET_SIZE(tmp);
4031 body = asdl_seq_new(len, arena); 4110 body = asdl_seq_new(len, arena);
4032 if (body == NULL) goto failed; 4111 if (body == NULL) goto failed;
4033 for (i = 0; i < len; i++) { 4112 for (i = 0; i < len; i++) {
4034 stmt_ty value; 4113 stmt_ty value;
4035 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 4114 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
4036 if (res != 0) goto failed; 4115 if (res != 0) goto failed;
4037 asdl_seq_SET(body, i, value); 4116 asdl_seq_SET(body, i, value);
4038 } 4117 }
4039 Py_XDECREF(tmp); 4118 Py_XDECREF(tmp);
4040 tmp = NULL; 4119 tmp = NULL;
4041 } else { 4120 } else {
4042 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from For"); 4121 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from For");
4043 return 1; 4122 return 1;
4044 } 4123 }
4045 if (PyObject_HasAttrString(obj, "orelse")) { 4124 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4046 int res; 4125 int res;
4047 Py_ssize_t len; 4126 Py_ssize_t len;
4048 Py_ssize_t i; 4127 Py_ssize_t i;
4049 tmp = PyObject_GetAttrString(obj, "orelse"); 4128 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4050 if (tmp == NULL) goto failed; 4129 if (tmp == NULL) goto failed;
4051 if (!PyList_Check(tmp)) { 4130 if (!PyList_Check(tmp)) {
4052 PyErr_Format(PyExc_TypeError, "For field \"orels e\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4131 PyErr_Format(PyExc_TypeError, "For field \"orels e\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4053 goto failed; 4132 goto failed;
4054 } 4133 }
4055 len = PyList_GET_SIZE(tmp); 4134 len = PyList_GET_SIZE(tmp);
4056 orelse = asdl_seq_new(len, arena); 4135 orelse = asdl_seq_new(len, arena);
4057 if (orelse == NULL) goto failed; 4136 if (orelse == NULL) goto failed;
4058 for (i = 0; i < len; i++) { 4137 for (i = 0; i < len; i++) {
4059 stmt_ty value; 4138 stmt_ty value;
(...skipping 14 matching lines...) Expand all
4074 } 4153 }
4075 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); 4154 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type);
4076 if (isinstance == -1) { 4155 if (isinstance == -1) {
4077 return 1; 4156 return 1;
4078 } 4157 }
4079 if (isinstance) { 4158 if (isinstance) {
4080 expr_ty test; 4159 expr_ty test;
4081 asdl_seq* body; 4160 asdl_seq* body;
4082 asdl_seq* orelse; 4161 asdl_seq* orelse;
4083 4162
4084 if (PyObject_HasAttrString(obj, "test")) { 4163 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4085 int res; 4164 int res;
4086 tmp = PyObject_GetAttrString(obj, "test"); 4165 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4087 if (tmp == NULL) goto failed; 4166 if (tmp == NULL) goto failed;
4088 res = obj2ast_expr(tmp, &test, arena); 4167 res = obj2ast_expr(tmp, &test, arena);
4089 if (res != 0) goto failed; 4168 if (res != 0) goto failed;
4090 Py_XDECREF(tmp); 4169 Py_XDECREF(tmp);
4091 tmp = NULL; 4170 tmp = NULL;
4092 } else { 4171 } else {
4093 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from While"); 4172 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from While");
4094 return 1; 4173 return 1;
4095 } 4174 }
4096 if (PyObject_HasAttrString(obj, "body")) { 4175 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4097 int res; 4176 int res;
4098 Py_ssize_t len; 4177 Py_ssize_t len;
4099 Py_ssize_t i; 4178 Py_ssize_t i;
4100 tmp = PyObject_GetAttrString(obj, "body"); 4179 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4101 if (tmp == NULL) goto failed; 4180 if (tmp == NULL) goto failed;
4102 if (!PyList_Check(tmp)) { 4181 if (!PyList_Check(tmp)) {
4103 PyErr_Format(PyExc_TypeError, "While field \"bod y\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4182 PyErr_Format(PyExc_TypeError, "While field \"bod y\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4104 goto failed; 4183 goto failed;
4105 } 4184 }
4106 len = PyList_GET_SIZE(tmp); 4185 len = PyList_GET_SIZE(tmp);
4107 body = asdl_seq_new(len, arena); 4186 body = asdl_seq_new(len, arena);
4108 if (body == NULL) goto failed; 4187 if (body == NULL) goto failed;
4109 for (i = 0; i < len; i++) { 4188 for (i = 0; i < len; i++) {
4110 stmt_ty value; 4189 stmt_ty value;
4111 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 4190 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
4112 if (res != 0) goto failed; 4191 if (res != 0) goto failed;
4113 asdl_seq_SET(body, i, value); 4192 asdl_seq_SET(body, i, value);
4114 } 4193 }
4115 Py_XDECREF(tmp); 4194 Py_XDECREF(tmp);
4116 tmp = NULL; 4195 tmp = NULL;
4117 } else { 4196 } else {
4118 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from While"); 4197 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from While");
4119 return 1; 4198 return 1;
4120 } 4199 }
4121 if (PyObject_HasAttrString(obj, "orelse")) { 4200 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4122 int res; 4201 int res;
4123 Py_ssize_t len; 4202 Py_ssize_t len;
4124 Py_ssize_t i; 4203 Py_ssize_t i;
4125 tmp = PyObject_GetAttrString(obj, "orelse"); 4204 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4126 if (tmp == NULL) goto failed; 4205 if (tmp == NULL) goto failed;
4127 if (!PyList_Check(tmp)) { 4206 if (!PyList_Check(tmp)) {
4128 PyErr_Format(PyExc_TypeError, "While field \"ore lse\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4207 PyErr_Format(PyExc_TypeError, "While field \"ore lse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4129 goto failed; 4208 goto failed;
4130 } 4209 }
4131 len = PyList_GET_SIZE(tmp); 4210 len = PyList_GET_SIZE(tmp);
4132 orelse = asdl_seq_new(len, arena); 4211 orelse = asdl_seq_new(len, arena);
4133 if (orelse == NULL) goto failed; 4212 if (orelse == NULL) goto failed;
4134 for (i = 0; i < len; i++) { 4213 for (i = 0; i < len; i++) {
4135 stmt_ty value; 4214 stmt_ty value;
(...skipping 13 matching lines...) Expand all
4149 } 4228 }
4150 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); 4229 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type);
4151 if (isinstance == -1) { 4230 if (isinstance == -1) {
4152 return 1; 4231 return 1;
4153 } 4232 }
4154 if (isinstance) { 4233 if (isinstance) {
4155 expr_ty test; 4234 expr_ty test;
4156 asdl_seq* body; 4235 asdl_seq* body;
4157 asdl_seq* orelse; 4236 asdl_seq* orelse;
4158 4237
4159 if (PyObject_HasAttrString(obj, "test")) { 4238 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4160 int res; 4239 int res;
4161 tmp = PyObject_GetAttrString(obj, "test"); 4240 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4162 if (tmp == NULL) goto failed; 4241 if (tmp == NULL) goto failed;
4163 res = obj2ast_expr(tmp, &test, arena); 4242 res = obj2ast_expr(tmp, &test, arena);
4164 if (res != 0) goto failed; 4243 if (res != 0) goto failed;
4165 Py_XDECREF(tmp); 4244 Py_XDECREF(tmp);
4166 tmp = NULL; 4245 tmp = NULL;
4167 } else { 4246 } else {
4168 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from If"); 4247 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from If");
4169 return 1; 4248 return 1;
4170 } 4249 }
4171 if (PyObject_HasAttrString(obj, "body")) { 4250 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4172 int res; 4251 int res;
4173 Py_ssize_t len; 4252 Py_ssize_t len;
4174 Py_ssize_t i; 4253 Py_ssize_t i;
4175 tmp = PyObject_GetAttrString(obj, "body"); 4254 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4176 if (tmp == NULL) goto failed; 4255 if (tmp == NULL) goto failed;
4177 if (!PyList_Check(tmp)) { 4256 if (!PyList_Check(tmp)) {
4178 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4257 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4179 goto failed; 4258 goto failed;
4180 } 4259 }
4181 len = PyList_GET_SIZE(tmp); 4260 len = PyList_GET_SIZE(tmp);
4182 body = asdl_seq_new(len, arena); 4261 body = asdl_seq_new(len, arena);
4183 if (body == NULL) goto failed; 4262 if (body == NULL) goto failed;
4184 for (i = 0; i < len; i++) { 4263 for (i = 0; i < len; i++) {
4185 stmt_ty value; 4264 stmt_ty value;
4186 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 4265 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
4187 if (res != 0) goto failed; 4266 if (res != 0) goto failed;
4188 asdl_seq_SET(body, i, value); 4267 asdl_seq_SET(body, i, value);
4189 } 4268 }
4190 Py_XDECREF(tmp); 4269 Py_XDECREF(tmp);
4191 tmp = NULL; 4270 tmp = NULL;
4192 } else { 4271 } else {
4193 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from If"); 4272 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from If");
4194 return 1; 4273 return 1;
4195 } 4274 }
4196 if (PyObject_HasAttrString(obj, "orelse")) { 4275 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4197 int res; 4276 int res;
4198 Py_ssize_t len; 4277 Py_ssize_t len;
4199 Py_ssize_t i; 4278 Py_ssize_t i;
4200 tmp = PyObject_GetAttrString(obj, "orelse"); 4279 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4201 if (tmp == NULL) goto failed; 4280 if (tmp == NULL) goto failed;
4202 if (!PyList_Check(tmp)) { 4281 if (!PyList_Check(tmp)) {
4203 PyErr_Format(PyExc_TypeError, "If field \"orelse \" must be a list, not a %.200s", tmp->ob_type->tp_name); 4282 PyErr_Format(PyExc_TypeError, "If field \"orelse \" must be a list, not a %.200s", tmp->ob_type->tp_name);
4204 goto failed; 4283 goto failed;
4205 } 4284 }
4206 len = PyList_GET_SIZE(tmp); 4285 len = PyList_GET_SIZE(tmp);
4207 orelse = asdl_seq_new(len, arena); 4286 orelse = asdl_seq_new(len, arena);
4208 if (orelse == NULL) goto failed; 4287 if (orelse == NULL) goto failed;
4209 for (i = 0; i < len; i++) { 4288 for (i = 0; i < len; i++) {
4210 stmt_ty value; 4289 stmt_ty value;
(...skipping 12 matching lines...) Expand all
4223 return 0; 4302 return 0;
4224 } 4303 }
4225 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); 4304 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type);
4226 if (isinstance == -1) { 4305 if (isinstance == -1) {
4227 return 1; 4306 return 1;
4228 } 4307 }
4229 if (isinstance) { 4308 if (isinstance) {
4230 asdl_seq* items; 4309 asdl_seq* items;
4231 asdl_seq* body; 4310 asdl_seq* body;
4232 4311
4233 if (PyObject_HasAttrString(obj, "items")) { 4312 if (_PyObject_HasAttrId(obj, &PyId_items)) {
4234 int res; 4313 int res;
4235 Py_ssize_t len; 4314 Py_ssize_t len;
4236 Py_ssize_t i; 4315 Py_ssize_t i;
4237 tmp = PyObject_GetAttrString(obj, "items"); 4316 tmp = _PyObject_GetAttrId(obj, &PyId_items);
4238 if (tmp == NULL) goto failed; 4317 if (tmp == NULL) goto failed;
4239 if (!PyList_Check(tmp)) { 4318 if (!PyList_Check(tmp)) {
4240 PyErr_Format(PyExc_TypeError, "With field \"item s\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4319 PyErr_Format(PyExc_TypeError, "With field \"item s\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4241 goto failed; 4320 goto failed;
4242 } 4321 }
4243 len = PyList_GET_SIZE(tmp); 4322 len = PyList_GET_SIZE(tmp);
4244 items = asdl_seq_new(len, arena); 4323 items = asdl_seq_new(len, arena);
4245 if (items == NULL) goto failed; 4324 if (items == NULL) goto failed;
4246 for (i = 0; i < len; i++) { 4325 for (i = 0; i < len; i++) {
4247 withitem_ty value; 4326 withitem_ty value;
4248 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena); 4327 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
4249 if (res != 0) goto failed; 4328 if (res != 0) goto failed;
4250 asdl_seq_SET(items, i, value); 4329 asdl_seq_SET(items, i, value);
4251 } 4330 }
4252 Py_XDECREF(tmp); 4331 Py_XDECREF(tmp);
4253 tmp = NULL; 4332 tmp = NULL;
4254 } else { 4333 } else {
4255 PyErr_SetString(PyExc_TypeError, "required field \"items \" missing from With"); 4334 PyErr_SetString(PyExc_TypeError, "required field \"items \" missing from With");
4256 return 1; 4335 return 1;
4257 } 4336 }
4258 if (PyObject_HasAttrString(obj, "body")) { 4337 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4259 int res; 4338 int res;
4260 Py_ssize_t len; 4339 Py_ssize_t len;
4261 Py_ssize_t i; 4340 Py_ssize_t i;
4262 tmp = PyObject_GetAttrString(obj, "body"); 4341 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4263 if (tmp == NULL) goto failed; 4342 if (tmp == NULL) goto failed;
4264 if (!PyList_Check(tmp)) { 4343 if (!PyList_Check(tmp)) {
4265 PyErr_Format(PyExc_TypeError, "With field \"body \" must be a list, not a %.200s", tmp->ob_type->tp_name); 4344 PyErr_Format(PyExc_TypeError, "With field \"body \" must be a list, not a %.200s", tmp->ob_type->tp_name);
4266 goto failed; 4345 goto failed;
4267 } 4346 }
4268 len = PyList_GET_SIZE(tmp); 4347 len = PyList_GET_SIZE(tmp);
4269 body = asdl_seq_new(len, arena); 4348 body = asdl_seq_new(len, arena);
4270 if (body == NULL) goto failed; 4349 if (body == NULL) goto failed;
4271 for (i = 0; i < len; i++) { 4350 for (i = 0; i < len; i++) {
4272 stmt_ty value; 4351 stmt_ty value;
(...skipping 12 matching lines...) Expand all
4285 return 0; 4364 return 0;
4286 } 4365 }
4287 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); 4366 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type);
4288 if (isinstance == -1) { 4367 if (isinstance == -1) {
4289 return 1; 4368 return 1;
4290 } 4369 }
4291 if (isinstance) { 4370 if (isinstance) {
4292 expr_ty exc; 4371 expr_ty exc;
4293 expr_ty cause; 4372 expr_ty cause;
4294 4373
4295 if (PyObject_HasAttrString(obj, "exc")) { 4374 if (_PyObject_HasAttrId(obj, &PyId_exc)) {
4296 int res; 4375 int res;
4297 tmp = PyObject_GetAttrString(obj, "exc"); 4376 tmp = _PyObject_GetAttrId(obj, &PyId_exc);
4298 if (tmp == NULL) goto failed; 4377 if (tmp == NULL) goto failed;
4299 res = obj2ast_expr(tmp, &exc, arena); 4378 res = obj2ast_expr(tmp, &exc, arena);
4300 if (res != 0) goto failed; 4379 if (res != 0) goto failed;
4301 Py_XDECREF(tmp); 4380 Py_XDECREF(tmp);
4302 tmp = NULL; 4381 tmp = NULL;
4303 } else { 4382 } else {
4304 exc = NULL; 4383 exc = NULL;
4305 } 4384 }
4306 if (PyObject_HasAttrString(obj, "cause")) { 4385 if (_PyObject_HasAttrId(obj, &PyId_cause)) {
4307 int res; 4386 int res;
4308 tmp = PyObject_GetAttrString(obj, "cause"); 4387 tmp = _PyObject_GetAttrId(obj, &PyId_cause);
4309 if (tmp == NULL) goto failed; 4388 if (tmp == NULL) goto failed;
4310 res = obj2ast_expr(tmp, &cause, arena); 4389 res = obj2ast_expr(tmp, &cause, arena);
4311 if (res != 0) goto failed; 4390 if (res != 0) goto failed;
4312 Py_XDECREF(tmp); 4391 Py_XDECREF(tmp);
4313 tmp = NULL; 4392 tmp = NULL;
4314 } else { 4393 } else {
4315 cause = NULL; 4394 cause = NULL;
4316 } 4395 }
4317 *out = Raise(exc, cause, lineno, col_offset, arena); 4396 *out = Raise(exc, cause, lineno, col_offset, arena);
4318 if (*out == NULL) goto failed; 4397 if (*out == NULL) goto failed;
4319 return 0; 4398 return 0;
4320 } 4399 }
4321 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type); 4400 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type);
4322 if (isinstance == -1) { 4401 if (isinstance == -1) {
4323 return 1; 4402 return 1;
4324 } 4403 }
4325 if (isinstance) { 4404 if (isinstance) {
4326 asdl_seq* body; 4405 asdl_seq* body;
4327 asdl_seq* handlers; 4406 asdl_seq* handlers;
4328 asdl_seq* orelse; 4407 asdl_seq* orelse;
4329 asdl_seq* finalbody; 4408 asdl_seq* finalbody;
4330 4409
4331 if (PyObject_HasAttrString(obj, "body")) { 4410 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4332 int res; 4411 int res;
4333 Py_ssize_t len; 4412 Py_ssize_t len;
4334 Py_ssize_t i; 4413 Py_ssize_t i;
4335 tmp = PyObject_GetAttrString(obj, "body"); 4414 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4336 if (tmp == NULL) goto failed; 4415 if (tmp == NULL) goto failed;
4337 if (!PyList_Check(tmp)) { 4416 if (!PyList_Check(tmp)) {
4338 PyErr_Format(PyExc_TypeError, "Try field \"body\ " must be a list, not a %.200s", tmp->ob_type->tp_name); 4417 PyErr_Format(PyExc_TypeError, "Try field \"body\ " must be a list, not a %.200s", tmp->ob_type->tp_name);
4339 goto failed; 4418 goto failed;
4340 } 4419 }
4341 len = PyList_GET_SIZE(tmp); 4420 len = PyList_GET_SIZE(tmp);
4342 body = asdl_seq_new(len, arena); 4421 body = asdl_seq_new(len, arena);
4343 if (body == NULL) goto failed; 4422 if (body == NULL) goto failed;
4344 for (i = 0; i < len; i++) { 4423 for (i = 0; i < len; i++) {
4345 stmt_ty value; 4424 stmt_ty value;
4346 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 4425 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
4347 if (res != 0) goto failed; 4426 if (res != 0) goto failed;
4348 asdl_seq_SET(body, i, value); 4427 asdl_seq_SET(body, i, value);
4349 } 4428 }
4350 Py_XDECREF(tmp); 4429 Py_XDECREF(tmp);
4351 tmp = NULL; 4430 tmp = NULL;
4352 } else { 4431 } else {
4353 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from Try"); 4432 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from Try");
4354 return 1; 4433 return 1;
4355 } 4434 }
4356 if (PyObject_HasAttrString(obj, "handlers")) { 4435 if (_PyObject_HasAttrId(obj, &PyId_handlers)) {
4357 int res; 4436 int res;
4358 Py_ssize_t len; 4437 Py_ssize_t len;
4359 Py_ssize_t i; 4438 Py_ssize_t i;
4360 tmp = PyObject_GetAttrString(obj, "handlers"); 4439 tmp = _PyObject_GetAttrId(obj, &PyId_handlers);
4361 if (tmp == NULL) goto failed; 4440 if (tmp == NULL) goto failed;
4362 if (!PyList_Check(tmp)) { 4441 if (!PyList_Check(tmp)) {
4363 PyErr_Format(PyExc_TypeError, "Try field \"handl ers\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4442 PyErr_Format(PyExc_TypeError, "Try field \"handl ers\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4364 goto failed; 4443 goto failed;
4365 } 4444 }
4366 len = PyList_GET_SIZE(tmp); 4445 len = PyList_GET_SIZE(tmp);
4367 handlers = asdl_seq_new(len, arena); 4446 handlers = asdl_seq_new(len, arena);
4368 if (handlers == NULL) goto failed; 4447 if (handlers == NULL) goto failed;
4369 for (i = 0; i < len; i++) { 4448 for (i = 0; i < len; i++) {
4370 excepthandler_ty value; 4449 excepthandler_ty value;
4371 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena); 4450 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena);
4372 if (res != 0) goto failed; 4451 if (res != 0) goto failed;
4373 asdl_seq_SET(handlers, i, value); 4452 asdl_seq_SET(handlers, i, value);
4374 } 4453 }
4375 Py_XDECREF(tmp); 4454 Py_XDECREF(tmp);
4376 tmp = NULL; 4455 tmp = NULL;
4377 } else { 4456 } else {
4378 PyErr_SetString(PyExc_TypeError, "required field \"handl ers\" missing from Try"); 4457 PyErr_SetString(PyExc_TypeError, "required field \"handl ers\" missing from Try");
4379 return 1; 4458 return 1;
4380 } 4459 }
4381 if (PyObject_HasAttrString(obj, "orelse")) { 4460 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4382 int res; 4461 int res;
4383 Py_ssize_t len; 4462 Py_ssize_t len;
4384 Py_ssize_t i; 4463 Py_ssize_t i;
4385 tmp = PyObject_GetAttrString(obj, "orelse"); 4464 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4386 if (tmp == NULL) goto failed; 4465 if (tmp == NULL) goto failed;
4387 if (!PyList_Check(tmp)) { 4466 if (!PyList_Check(tmp)) {
4388 PyErr_Format(PyExc_TypeError, "Try field \"orels e\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4467 PyErr_Format(PyExc_TypeError, "Try field \"orels e\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4389 goto failed; 4468 goto failed;
4390 } 4469 }
4391 len = PyList_GET_SIZE(tmp); 4470 len = PyList_GET_SIZE(tmp);
4392 orelse = asdl_seq_new(len, arena); 4471 orelse = asdl_seq_new(len, arena);
4393 if (orelse == NULL) goto failed; 4472 if (orelse == NULL) goto failed;
4394 for (i = 0; i < len; i++) { 4473 for (i = 0; i < len; i++) {
4395 stmt_ty value; 4474 stmt_ty value;
4396 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena); 4475 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &val ue, arena);
4397 if (res != 0) goto failed; 4476 if (res != 0) goto failed;
4398 asdl_seq_SET(orelse, i, value); 4477 asdl_seq_SET(orelse, i, value);
4399 } 4478 }
4400 Py_XDECREF(tmp); 4479 Py_XDECREF(tmp);
4401 tmp = NULL; 4480 tmp = NULL;
4402 } else { 4481 } else {
4403 PyErr_SetString(PyExc_TypeError, "required field \"orels e\" missing from Try"); 4482 PyErr_SetString(PyExc_TypeError, "required field \"orels e\" missing from Try");
4404 return 1; 4483 return 1;
4405 } 4484 }
4406 if (PyObject_HasAttrString(obj, "finalbody")) { 4485 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) {
4407 int res; 4486 int res;
4408 Py_ssize_t len; 4487 Py_ssize_t len;
4409 Py_ssize_t i; 4488 Py_ssize_t i;
4410 tmp = PyObject_GetAttrString(obj, "finalbody"); 4489 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody);
4411 if (tmp == NULL) goto failed; 4490 if (tmp == NULL) goto failed;
4412 if (!PyList_Check(tmp)) { 4491 if (!PyList_Check(tmp)) {
4413 PyErr_Format(PyExc_TypeError, "Try field \"final body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4492 PyErr_Format(PyExc_TypeError, "Try field \"final body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4414 goto failed; 4493 goto failed;
4415 } 4494 }
4416 len = PyList_GET_SIZE(tmp); 4495 len = PyList_GET_SIZE(tmp);
4417 finalbody = asdl_seq_new(len, arena); 4496 finalbody = asdl_seq_new(len, arena);
4418 if (finalbody == NULL) goto failed; 4497 if (finalbody == NULL) goto failed;
4419 for (i = 0; i < len; i++) { 4498 for (i = 0; i < len; i++) {
4420 stmt_ty value; 4499 stmt_ty value;
(...skipping 13 matching lines...) Expand all
4434 return 0; 4513 return 0;
4435 } 4514 }
4436 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); 4515 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type);
4437 if (isinstance == -1) { 4516 if (isinstance == -1) {
4438 return 1; 4517 return 1;
4439 } 4518 }
4440 if (isinstance) { 4519 if (isinstance) {
4441 expr_ty test; 4520 expr_ty test;
4442 expr_ty msg; 4521 expr_ty msg;
4443 4522
4444 if (PyObject_HasAttrString(obj, "test")) { 4523 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4445 int res; 4524 int res;
4446 tmp = PyObject_GetAttrString(obj, "test"); 4525 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4447 if (tmp == NULL) goto failed; 4526 if (tmp == NULL) goto failed;
4448 res = obj2ast_expr(tmp, &test, arena); 4527 res = obj2ast_expr(tmp, &test, arena);
4449 if (res != 0) goto failed; 4528 if (res != 0) goto failed;
4450 Py_XDECREF(tmp); 4529 Py_XDECREF(tmp);
4451 tmp = NULL; 4530 tmp = NULL;
4452 } else { 4531 } else {
4453 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from Assert"); 4532 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from Assert");
4454 return 1; 4533 return 1;
4455 } 4534 }
4456 if (PyObject_HasAttrString(obj, "msg")) { 4535 if (_PyObject_HasAttrId(obj, &PyId_msg)) {
4457 int res; 4536 int res;
4458 tmp = PyObject_GetAttrString(obj, "msg"); 4537 tmp = _PyObject_GetAttrId(obj, &PyId_msg);
4459 if (tmp == NULL) goto failed; 4538 if (tmp == NULL) goto failed;
4460 res = obj2ast_expr(tmp, &msg, arena); 4539 res = obj2ast_expr(tmp, &msg, arena);
4461 if (res != 0) goto failed; 4540 if (res != 0) goto failed;
4462 Py_XDECREF(tmp); 4541 Py_XDECREF(tmp);
4463 tmp = NULL; 4542 tmp = NULL;
4464 } else { 4543 } else {
4465 msg = NULL; 4544 msg = NULL;
4466 } 4545 }
4467 *out = Assert(test, msg, lineno, col_offset, arena); 4546 *out = Assert(test, msg, lineno, col_offset, arena);
4468 if (*out == NULL) goto failed; 4547 if (*out == NULL) goto failed;
4469 return 0; 4548 return 0;
4470 } 4549 }
4471 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); 4550 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type);
4472 if (isinstance == -1) { 4551 if (isinstance == -1) {
4473 return 1; 4552 return 1;
4474 } 4553 }
4475 if (isinstance) { 4554 if (isinstance) {
4476 asdl_seq* names; 4555 asdl_seq* names;
4477 4556
4478 if (PyObject_HasAttrString(obj, "names")) { 4557 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4479 int res; 4558 int res;
4480 Py_ssize_t len; 4559 Py_ssize_t len;
4481 Py_ssize_t i; 4560 Py_ssize_t i;
4482 tmp = PyObject_GetAttrString(obj, "names"); 4561 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4483 if (tmp == NULL) goto failed; 4562 if (tmp == NULL) goto failed;
4484 if (!PyList_Check(tmp)) { 4563 if (!PyList_Check(tmp)) {
4485 PyErr_Format(PyExc_TypeError, "Import field \"na mes\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4564 PyErr_Format(PyExc_TypeError, "Import field \"na mes\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4486 goto failed; 4565 goto failed;
4487 } 4566 }
4488 len = PyList_GET_SIZE(tmp); 4567 len = PyList_GET_SIZE(tmp);
4489 names = asdl_seq_new(len, arena); 4568 names = asdl_seq_new(len, arena);
4490 if (names == NULL) goto failed; 4569 if (names == NULL) goto failed;
4491 for (i = 0; i < len; i++) { 4570 for (i = 0; i < len; i++) {
4492 alias_ty value; 4571 alias_ty value;
(...skipping 13 matching lines...) Expand all
4506 } 4585 }
4507 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); 4586 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type);
4508 if (isinstance == -1) { 4587 if (isinstance == -1) {
4509 return 1; 4588 return 1;
4510 } 4589 }
4511 if (isinstance) { 4590 if (isinstance) {
4512 identifier module; 4591 identifier module;
4513 asdl_seq* names; 4592 asdl_seq* names;
4514 int level; 4593 int level;
4515 4594
4516 if (PyObject_HasAttrString(obj, "module")) { 4595 if (_PyObject_HasAttrId(obj, &PyId_module)) {
4517 int res; 4596 int res;
4518 tmp = PyObject_GetAttrString(obj, "module"); 4597 tmp = _PyObject_GetAttrId(obj, &PyId_module);
4519 if (tmp == NULL) goto failed; 4598 if (tmp == NULL) goto failed;
4520 res = obj2ast_identifier(tmp, &module, arena); 4599 res = obj2ast_identifier(tmp, &module, arena);
4521 if (res != 0) goto failed; 4600 if (res != 0) goto failed;
4522 Py_XDECREF(tmp); 4601 Py_XDECREF(tmp);
4523 tmp = NULL; 4602 tmp = NULL;
4524 } else { 4603 } else {
4525 module = NULL; 4604 module = NULL;
4526 } 4605 }
4527 if (PyObject_HasAttrString(obj, "names")) { 4606 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4528 int res; 4607 int res;
4529 Py_ssize_t len; 4608 Py_ssize_t len;
4530 Py_ssize_t i; 4609 Py_ssize_t i;
4531 tmp = PyObject_GetAttrString(obj, "names"); 4610 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4532 if (tmp == NULL) goto failed; 4611 if (tmp == NULL) goto failed;
4533 if (!PyList_Check(tmp)) { 4612 if (!PyList_Check(tmp)) {
4534 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4613 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4535 goto failed; 4614 goto failed;
4536 } 4615 }
4537 len = PyList_GET_SIZE(tmp); 4616 len = PyList_GET_SIZE(tmp);
4538 names = asdl_seq_new(len, arena); 4617 names = asdl_seq_new(len, arena);
4539 if (names == NULL) goto failed; 4618 if (names == NULL) goto failed;
4540 for (i = 0; i < len; i++) { 4619 for (i = 0; i < len; i++) {
4541 alias_ty value; 4620 alias_ty value;
4542 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &va lue, arena); 4621 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &va lue, arena);
4543 if (res != 0) goto failed; 4622 if (res != 0) goto failed;
4544 asdl_seq_SET(names, i, value); 4623 asdl_seq_SET(names, i, value);
4545 } 4624 }
4546 Py_XDECREF(tmp); 4625 Py_XDECREF(tmp);
4547 tmp = NULL; 4626 tmp = NULL;
4548 } else { 4627 } else {
4549 PyErr_SetString(PyExc_TypeError, "required field \"names \" missing from ImportFrom"); 4628 PyErr_SetString(PyExc_TypeError, "required field \"names \" missing from ImportFrom");
4550 return 1; 4629 return 1;
4551 } 4630 }
4552 if (PyObject_HasAttrString(obj, "level")) { 4631 if (_PyObject_HasAttrId(obj, &PyId_level)) {
4553 int res; 4632 int res;
4554 tmp = PyObject_GetAttrString(obj, "level"); 4633 tmp = _PyObject_GetAttrId(obj, &PyId_level);
4555 if (tmp == NULL) goto failed; 4634 if (tmp == NULL) goto failed;
4556 res = obj2ast_int(tmp, &level, arena); 4635 res = obj2ast_int(tmp, &level, arena);
4557 if (res != 0) goto failed; 4636 if (res != 0) goto failed;
4558 Py_XDECREF(tmp); 4637 Py_XDECREF(tmp);
4559 tmp = NULL; 4638 tmp = NULL;
4560 } else { 4639 } else {
4561 level = 0; 4640 level = 0;
4562 } 4641 }
4563 *out = ImportFrom(module, names, level, lineno, col_offset, 4642 *out = ImportFrom(module, names, level, lineno, col_offset,
4564 arena); 4643 arena);
4565 if (*out == NULL) goto failed; 4644 if (*out == NULL) goto failed;
4566 return 0; 4645 return 0;
4567 } 4646 }
4568 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); 4647 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type);
4569 if (isinstance == -1) { 4648 if (isinstance == -1) {
4570 return 1; 4649 return 1;
4571 } 4650 }
4572 if (isinstance) { 4651 if (isinstance) {
4573 asdl_seq* names; 4652 asdl_seq* names;
4574 4653
4575 if (PyObject_HasAttrString(obj, "names")) { 4654 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4576 int res; 4655 int res;
4577 Py_ssize_t len; 4656 Py_ssize_t len;
4578 Py_ssize_t i; 4657 Py_ssize_t i;
4579 tmp = PyObject_GetAttrString(obj, "names"); 4658 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4580 if (tmp == NULL) goto failed; 4659 if (tmp == NULL) goto failed;
4581 if (!PyList_Check(tmp)) { 4660 if (!PyList_Check(tmp)) {
4582 PyErr_Format(PyExc_TypeError, "Global field \"na mes\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4661 PyErr_Format(PyExc_TypeError, "Global field \"na mes\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4583 goto failed; 4662 goto failed;
4584 } 4663 }
4585 len = PyList_GET_SIZE(tmp); 4664 len = PyList_GET_SIZE(tmp);
4586 names = asdl_seq_new(len, arena); 4665 names = asdl_seq_new(len, arena);
4587 if (names == NULL) goto failed; 4666 if (names == NULL) goto failed;
4588 for (i = 0; i < len; i++) { 4667 for (i = 0; i < len; i++) {
4589 identifier value; 4668 identifier value;
(...skipping 11 matching lines...) Expand all
4601 if (*out == NULL) goto failed; 4680 if (*out == NULL) goto failed;
4602 return 0; 4681 return 0;
4603 } 4682 }
4604 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type); 4683 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type);
4605 if (isinstance == -1) { 4684 if (isinstance == -1) {
4606 return 1; 4685 return 1;
4607 } 4686 }
4608 if (isinstance) { 4687 if (isinstance) {
4609 asdl_seq* names; 4688 asdl_seq* names;
4610 4689
4611 if (PyObject_HasAttrString(obj, "names")) { 4690 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4612 int res; 4691 int res;
4613 Py_ssize_t len; 4692 Py_ssize_t len;
4614 Py_ssize_t i; 4693 Py_ssize_t i;
4615 tmp = PyObject_GetAttrString(obj, "names"); 4694 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4616 if (tmp == NULL) goto failed; 4695 if (tmp == NULL) goto failed;
4617 if (!PyList_Check(tmp)) { 4696 if (!PyList_Check(tmp)) {
4618 PyErr_Format(PyExc_TypeError, "Nonlocal field \" names\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4697 PyErr_Format(PyExc_TypeError, "Nonlocal field \" names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4619 goto failed; 4698 goto failed;
4620 } 4699 }
4621 len = PyList_GET_SIZE(tmp); 4700 len = PyList_GET_SIZE(tmp);
4622 names = asdl_seq_new(len, arena); 4701 names = asdl_seq_new(len, arena);
4623 if (names == NULL) goto failed; 4702 if (names == NULL) goto failed;
4624 for (i = 0; i < len; i++) { 4703 for (i = 0; i < len; i++) {
4625 identifier value; 4704 identifier value;
(...skipping 11 matching lines...) Expand all
4637 if (*out == NULL) goto failed; 4716 if (*out == NULL) goto failed;
4638 return 0; 4717 return 0;
4639 } 4718 }
4640 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); 4719 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type);
4641 if (isinstance == -1) { 4720 if (isinstance == -1) {
4642 return 1; 4721 return 1;
4643 } 4722 }
4644 if (isinstance) { 4723 if (isinstance) {
4645 expr_ty value; 4724 expr_ty value;
4646 4725
4647 if (PyObject_HasAttrString(obj, "value")) { 4726 if (_PyObject_HasAttrId(obj, &PyId_value)) {
4648 int res; 4727 int res;
4649 tmp = PyObject_GetAttrString(obj, "value"); 4728 tmp = _PyObject_GetAttrId(obj, &PyId_value);
4650 if (tmp == NULL) goto failed; 4729 if (tmp == NULL) goto failed;
4651 res = obj2ast_expr(tmp, &value, arena); 4730 res = obj2ast_expr(tmp, &value, arena);
4652 if (res != 0) goto failed; 4731 if (res != 0) goto failed;
4653 Py_XDECREF(tmp); 4732 Py_XDECREF(tmp);
4654 tmp = NULL; 4733 tmp = NULL;
4655 } else { 4734 } else {
4656 PyErr_SetString(PyExc_TypeError, "required field \"value \" missing from Expr"); 4735 PyErr_SetString(PyExc_TypeError, "required field \"value \" missing from Expr");
4657 return 1; 4736 return 1;
4658 } 4737 }
4659 *out = Expr(value, lineno, col_offset, arena); 4738 *out = Expr(value, lineno, col_offset, arena);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 int isinstance; 4782 int isinstance;
4704 4783
4705 PyObject *tmp = NULL; 4784 PyObject *tmp = NULL;
4706 int lineno; 4785 int lineno;
4707 int col_offset; 4786 int col_offset;
4708 4787
4709 if (obj == Py_None) { 4788 if (obj == Py_None) {
4710 *out = NULL; 4789 *out = NULL;
4711 return 0; 4790 return 0;
4712 } 4791 }
4713 if (PyObject_HasAttrString(obj, "lineno")) { 4792 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
4714 int res; 4793 int res;
4715 tmp = PyObject_GetAttrString(obj, "lineno"); 4794 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
4716 if (tmp == NULL) goto failed; 4795 if (tmp == NULL) goto failed;
4717 res = obj2ast_int(tmp, &lineno, arena); 4796 res = obj2ast_int(tmp, &lineno, arena);
4718 if (res != 0) goto failed; 4797 if (res != 0) goto failed;
4719 Py_XDECREF(tmp); 4798 Py_XDECREF(tmp);
4720 tmp = NULL; 4799 tmp = NULL;
4721 } else { 4800 } else {
4722 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" miss ing from expr"); 4801 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" miss ing from expr");
4723 return 1; 4802 return 1;
4724 } 4803 }
4725 if (PyObject_HasAttrString(obj, "col_offset")) { 4804 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
4726 int res; 4805 int res;
4727 tmp = PyObject_GetAttrString(obj, "col_offset"); 4806 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
4728 if (tmp == NULL) goto failed; 4807 if (tmp == NULL) goto failed;
4729 res = obj2ast_int(tmp, &col_offset, arena); 4808 res = obj2ast_int(tmp, &col_offset, arena);
4730 if (res != 0) goto failed; 4809 if (res != 0) goto failed;
4731 Py_XDECREF(tmp); 4810 Py_XDECREF(tmp);
4732 tmp = NULL; 4811 tmp = NULL;
4733 } else { 4812 } else {
4734 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); 4813 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
4735 return 1; 4814 return 1;
4736 } 4815 }
4737 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); 4816 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type);
4738 if (isinstance == -1) { 4817 if (isinstance == -1) {
4739 return 1; 4818 return 1;
4740 } 4819 }
4741 if (isinstance) { 4820 if (isinstance) {
4742 boolop_ty op; 4821 boolop_ty op;
4743 asdl_seq* values; 4822 asdl_seq* values;
4744 4823
4745 if (PyObject_HasAttrString(obj, "op")) { 4824 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4746 int res; 4825 int res;
4747 tmp = PyObject_GetAttrString(obj, "op"); 4826 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4748 if (tmp == NULL) goto failed; 4827 if (tmp == NULL) goto failed;
4749 res = obj2ast_boolop(tmp, &op, arena); 4828 res = obj2ast_boolop(tmp, &op, arena);
4750 if (res != 0) goto failed; 4829 if (res != 0) goto failed;
4751 Py_XDECREF(tmp); 4830 Py_XDECREF(tmp);
4752 tmp = NULL; 4831 tmp = NULL;
4753 } else { 4832 } else {
4754 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp"); 4833 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
4755 return 1; 4834 return 1;
4756 } 4835 }
4757 if (PyObject_HasAttrString(obj, "values")) { 4836 if (_PyObject_HasAttrId(obj, &PyId_values)) {
4758 int res; 4837 int res;
4759 Py_ssize_t len; 4838 Py_ssize_t len;
4760 Py_ssize_t i; 4839 Py_ssize_t i;
4761 tmp = PyObject_GetAttrString(obj, "values"); 4840 tmp = _PyObject_GetAttrId(obj, &PyId_values);
4762 if (tmp == NULL) goto failed; 4841 if (tmp == NULL) goto failed;
4763 if (!PyList_Check(tmp)) { 4842 if (!PyList_Check(tmp)) {
4764 PyErr_Format(PyExc_TypeError, "BoolOp field \"va lues\" must be a list, not a %.200s", tmp->ob_type->tp_name); 4843 PyErr_Format(PyExc_TypeError, "BoolOp field \"va lues\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4765 goto failed; 4844 goto failed;
4766 } 4845 }
4767 len = PyList_GET_SIZE(tmp); 4846 len = PyList_GET_SIZE(tmp);
4768 values = asdl_seq_new(len, arena); 4847 values = asdl_seq_new(len, arena);
4769 if (values == NULL) goto failed; 4848 if (values == NULL) goto failed;
4770 for (i = 0; i < len; i++) { 4849 for (i = 0; i < len; i++) {
4771 expr_ty value; 4850 expr_ty value;
(...skipping 13 matching lines...) Expand all
4785 } 4864 }
4786 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); 4865 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type);
4787 if (isinstance == -1) { 4866 if (isinstance == -1) {
4788 return 1; 4867 return 1;
4789 } 4868 }
4790 if (isinstance) { 4869 if (isinstance) {
4791 expr_ty left; 4870 expr_ty left;
4792 operator_ty op; 4871 operator_ty op;
4793 expr_ty right; 4872 expr_ty right;
4794 4873
4795 if (PyObject_HasAttrString(obj, "left")) { 4874 if (_PyObject_HasAttrId(obj, &PyId_left)) {
4796 int res; 4875 int res;
4797 tmp = PyObject_GetAttrString(obj, "left"); 4876 tmp = _PyObject_GetAttrId(obj, &PyId_left);
4798 if (tmp == NULL) goto failed; 4877 if (tmp == NULL) goto failed;
4799 res = obj2ast_expr(tmp, &left, arena); 4878 res = obj2ast_expr(tmp, &left, arena);
4800 if (res != 0) goto failed; 4879 if (res != 0) goto failed;
4801 Py_XDECREF(tmp); 4880 Py_XDECREF(tmp);
4802 tmp = NULL; 4881 tmp = NULL;
4803 } else { 4882 } else {
4804 PyErr_SetString(PyExc_TypeError, "required field \"left\ " missing from BinOp"); 4883 PyErr_SetString(PyExc_TypeError, "required field \"left\ " missing from BinOp");
4805 return 1; 4884 return 1;
4806 } 4885 }
4807 if (PyObject_HasAttrString(obj, "op")) { 4886 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4808 int res; 4887 int res;
4809 tmp = PyObject_GetAttrString(obj, "op"); 4888 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4810 if (tmp == NULL) goto failed; 4889 if (tmp == NULL) goto failed;
4811 res = obj2ast_operator(tmp, &op, arena); 4890 res = obj2ast_operator(tmp, &op, arena);
4812 if (res != 0) goto failed; 4891 if (res != 0) goto failed;
4813 Py_XDECREF(tmp); 4892 Py_XDECREF(tmp);
4814 tmp = NULL; 4893 tmp = NULL;
4815 } else { 4894 } else {
4816 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp"); 4895 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
4817 return 1; 4896 return 1;
4818 } 4897 }
4819 if (PyObject_HasAttrString(obj, "right")) { 4898 if (_PyObject_HasAttrId(obj, &PyId_right)) {
4820 int res; 4899 int res;
4821 tmp = PyObject_GetAttrString(obj, "right"); 4900 tmp = _PyObject_GetAttrId(obj, &PyId_right);
4822 if (tmp == NULL) goto failed; 4901 if (tmp == NULL) goto failed;
4823 res = obj2ast_expr(tmp, &right, arena); 4902 res = obj2ast_expr(tmp, &right, arena);
4824 if (res != 0) goto failed; 4903 if (res != 0) goto failed;
4825 Py_XDECREF(tmp); 4904 Py_XDECREF(tmp);
4826 tmp = NULL; 4905 tmp = NULL;
4827 } else { 4906 } else {
4828 PyErr_SetString(PyExc_TypeError, "required field \"right \" missing from BinOp"); 4907 PyErr_SetString(PyExc_TypeError, "required field \"right \" missing from BinOp");
4829 return 1; 4908 return 1;
4830 } 4909 }
4831 *out = BinOp(left, op, right, lineno, col_offset, arena); 4910 *out = BinOp(left, op, right, lineno, col_offset, arena);
4832 if (*out == NULL) goto failed; 4911 if (*out == NULL) goto failed;
4833 return 0; 4912 return 0;
4834 } 4913 }
4835 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); 4914 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type);
4836 if (isinstance == -1) { 4915 if (isinstance == -1) {
4837 return 1; 4916 return 1;
4838 } 4917 }
4839 if (isinstance) { 4918 if (isinstance) {
4840 unaryop_ty op; 4919 unaryop_ty op;
4841 expr_ty operand; 4920 expr_ty operand;
4842 4921
4843 if (PyObject_HasAttrString(obj, "op")) { 4922 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4844 int res; 4923 int res;
4845 tmp = PyObject_GetAttrString(obj, "op"); 4924 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4846 if (tmp == NULL) goto failed; 4925 if (tmp == NULL) goto failed;
4847 res = obj2ast_unaryop(tmp, &op, arena); 4926 res = obj2ast_unaryop(tmp, &op, arena);
4848 if (res != 0) goto failed; 4927 if (res != 0) goto failed;
4849 Py_XDECREF(tmp); 4928 Py_XDECREF(tmp);
4850 tmp = NULL; 4929 tmp = NULL;
4851 } else { 4930 } else {
4852 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp"); 4931 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
4853 return 1; 4932 return 1;
4854 } 4933 }
4855 if (PyObject_HasAttrString(obj, "operand")) { 4934 if (_PyObject_HasAttrId(obj, &PyId_operand)) {
4856 int res; 4935 int res;
4857 tmp = PyObject_GetAttrString(obj, "operand"); 4936 tmp = _PyObject_GetAttrId(obj, &PyId_operand);
4858 if (tmp == NULL) goto failed; 4937 if (tmp == NULL) goto failed;
4859 res = obj2ast_expr(tmp, &operand, arena); 4938 res = obj2ast_expr(tmp, &operand, arena);
4860 if (res != 0) goto failed; 4939 if (res != 0) goto failed;
4861 Py_XDECREF(tmp); 4940 Py_XDECREF(tmp);
4862 tmp = NULL; 4941 tmp = NULL;
4863 } else { 4942 } else {
4864 PyErr_SetString(PyExc_TypeError, "required field \"opera nd\" missing from UnaryOp"); 4943 PyErr_SetString(PyExc_TypeError, "required field \"opera nd\" missing from UnaryOp");
4865 return 1; 4944 return 1;
4866 } 4945 }
4867 *out = UnaryOp(op, operand, lineno, col_offset, arena); 4946 *out = UnaryOp(op, operand, lineno, col_offset, arena);
4868 if (*out == NULL) goto failed; 4947 if (*out == NULL) goto failed;
4869 return 0; 4948 return 0;
4870 } 4949 }
4871 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); 4950 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type);
4872 if (isinstance == -1) { 4951 if (isinstance == -1) {
4873 return 1; 4952 return 1;
4874 } 4953 }
4875 if (isinstance) { 4954 if (isinstance) {
4876 arguments_ty args; 4955 arguments_ty args;
4877 expr_ty body; 4956 expr_ty body;
4878 4957
4879 if (PyObject_HasAttrString(obj, "args")) { 4958 if (_PyObject_HasAttrId(obj, &PyId_args)) {
4880 int res; 4959 int res;
4881 tmp = PyObject_GetAttrString(obj, "args"); 4960 tmp = _PyObject_GetAttrId(obj, &PyId_args);
4882 if (tmp == NULL) goto failed; 4961 if (tmp == NULL) goto failed;
4883 res = obj2ast_arguments(tmp, &args, arena); 4962 res = obj2ast_arguments(tmp, &args, arena);
4884 if (res != 0) goto failed; 4963 if (res != 0) goto failed;
4885 Py_XDECREF(tmp); 4964 Py_XDECREF(tmp);
4886 tmp = NULL; 4965 tmp = NULL;
4887 } else { 4966 } else {
4888 PyErr_SetString(PyExc_TypeError, "required field \"args\ " missing from Lambda"); 4967 PyErr_SetString(PyExc_TypeError, "required field \"args\ " missing from Lambda");
4889 return 1; 4968 return 1;
4890 } 4969 }
4891 if (PyObject_HasAttrString(obj, "body")) { 4970 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4892 int res; 4971 int res;
4893 tmp = PyObject_GetAttrString(obj, "body"); 4972 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4894 if (tmp == NULL) goto failed; 4973 if (tmp == NULL) goto failed;
4895 res = obj2ast_expr(tmp, &body, arena); 4974 res = obj2ast_expr(tmp, &body, arena);
4896 if (res != 0) goto failed; 4975 if (res != 0) goto failed;
4897 Py_XDECREF(tmp); 4976 Py_XDECREF(tmp);
4898 tmp = NULL; 4977 tmp = NULL;
4899 } else { 4978 } else {
4900 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from Lambda"); 4979 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from Lambda");
4901 return 1; 4980 return 1;
4902 } 4981 }
4903 *out = Lambda(args, body, lineno, col_offset, arena); 4982 *out = Lambda(args, body, lineno, col_offset, arena);
4904 if (*out == NULL) goto failed; 4983 if (*out == NULL) goto failed;
4905 return 0; 4984 return 0;
4906 } 4985 }
4907 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); 4986 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type);
4908 if (isinstance == -1) { 4987 if (isinstance == -1) {
4909 return 1; 4988 return 1;
4910 } 4989 }
4911 if (isinstance) { 4990 if (isinstance) {
4912 expr_ty test; 4991 expr_ty test;
4913 expr_ty body; 4992 expr_ty body;
4914 expr_ty orelse; 4993 expr_ty orelse;
4915 4994
4916 if (PyObject_HasAttrString(obj, "test")) { 4995 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4917 int res; 4996 int res;
4918 tmp = PyObject_GetAttrString(obj, "test"); 4997 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4919 if (tmp == NULL) goto failed; 4998 if (tmp == NULL) goto failed;
4920 res = obj2ast_expr(tmp, &test, arena); 4999 res = obj2ast_expr(tmp, &test, arena);
4921 if (res != 0) goto failed; 5000 if (res != 0) goto failed;
4922 Py_XDECREF(tmp); 5001 Py_XDECREF(tmp);
4923 tmp = NULL; 5002 tmp = NULL;
4924 } else { 5003 } else {
4925 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from IfExp"); 5004 PyErr_SetString(PyExc_TypeError, "required field \"test\ " missing from IfExp");
4926 return 1; 5005 return 1;
4927 } 5006 }
4928 if (PyObject_HasAttrString(obj, "body")) { 5007 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4929 int res; 5008 int res;
4930 tmp = PyObject_GetAttrString(obj, "body"); 5009 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4931 if (tmp == NULL) goto failed; 5010 if (tmp == NULL) goto failed;
4932 res = obj2ast_expr(tmp, &body, arena); 5011 res = obj2ast_expr(tmp, &body, arena);
4933 if (res != 0) goto failed; 5012 if (res != 0) goto failed;
4934 Py_XDECREF(tmp); 5013 Py_XDECREF(tmp);
4935 tmp = NULL; 5014 tmp = NULL;
4936 } else { 5015 } else {
4937 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from IfExp"); 5016 PyErr_SetString(PyExc_TypeError, "required field \"body\ " missing from IfExp");
4938 return 1; 5017 return 1;
4939 } 5018 }
4940 if (PyObject_HasAttrString(obj, "orelse")) { 5019 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4941 int res; 5020 int res;
4942 tmp = PyObject_GetAttrString(obj, "orelse"); 5021 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4943 if (tmp == NULL) goto failed; 5022 if (tmp == NULL) goto failed;
4944 res = obj2ast_expr(tmp, &orelse, arena); 5023 res = obj2ast_expr(tmp, &orelse, arena);
4945 if (res != 0) goto failed; 5024 if (res != 0) goto failed;
4946 Py_XDECREF(tmp); 5025 Py_XDECREF(tmp);
4947 tmp = NULL; 5026 tmp = NULL;
4948 } else { 5027 } else {
4949 PyErr_SetString(PyExc_TypeError, "required field \"orels e\" missing from IfExp"); 5028 PyErr_SetString(PyExc_TypeError, "required field \"orels e\" missing from IfExp");
4950 return 1; 5029 return 1;
4951 } 5030 }
4952 *out = IfExp(test, body, orelse, lineno, col_offset, arena); 5031 *out = IfExp(test, body, orelse, lineno, col_offset, arena);
4953 if (*out == NULL) goto failed; 5032 if (*out == NULL) goto failed;
4954 return 0; 5033 return 0;
4955 } 5034 }
4956 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); 5035 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type);
4957 if (isinstance == -1) { 5036 if (isinstance == -1) {
4958 return 1; 5037 return 1;
4959 } 5038 }
4960 if (isinstance) { 5039 if (isinstance) {
4961 asdl_seq* keys; 5040 asdl_seq* keys;
4962 asdl_seq* values; 5041 asdl_seq* values;
4963 5042
4964 if (PyObject_HasAttrString(obj, "keys")) { 5043 if (_PyObject_HasAttrId(obj, &PyId_keys)) {
4965 int res; 5044 int res;
4966 Py_ssize_t len; 5045 Py_ssize_t len;
4967 Py_ssize_t i; 5046 Py_ssize_t i;
4968 tmp = PyObject_GetAttrString(obj, "keys"); 5047 tmp = _PyObject_GetAttrId(obj, &PyId_keys);
4969 if (tmp == NULL) goto failed; 5048 if (tmp == NULL) goto failed;
4970 if (!PyList_Check(tmp)) { 5049 if (!PyList_Check(tmp)) {
4971 PyErr_Format(PyExc_TypeError, "Dict field \"keys \" must be a list, not a %.200s", tmp->ob_type->tp_name); 5050 PyErr_Format(PyExc_TypeError, "Dict field \"keys \" must be a list, not a %.200s", tmp->ob_type->tp_name);
4972 goto failed; 5051 goto failed;
4973 } 5052 }
4974 len = PyList_GET_SIZE(tmp); 5053 len = PyList_GET_SIZE(tmp);