comparison Python/Python-ast.c @ 43102:981ecc526703

Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
author Collin Winter <collinw@gmail.com>
date Fri, 31 Aug 2007 00:04:24 +0000
parents 6e7359106718
children 88aaa380f091
comparison
equal deleted inserted replaced
43101:3c4329431bbc 43102:981ecc526703
1 /* File automatically generated by Parser/asdl_c.py. */ 1 /* File automatically generated by Parser/asdl_c.py. */
2 2
3 3
4 /* 4 /*
5 __version__ 56266. 5 __version__ 465.
6 6
7 This module must be committed separately after each AST grammar change; 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 8 The __version__ number is set to the revision number of the commit
9 containing the grammar change. 9 containing the grammar change.
10 */ 10 */
99 "optional_vars", 99 "optional_vars",
100 "body", 100 "body",
101 }; 101 };
102 static PyTypeObject *Raise_type; 102 static PyTypeObject *Raise_type;
103 static char *Raise_fields[]={ 103 static char *Raise_fields[]={
104 "type", 104 "exc",
105 "inst", 105 "cause",
106 "tback",
107 }; 106 };
108 static PyTypeObject *TryExcept_type; 107 static PyTypeObject *TryExcept_type;
109 static char *TryExcept_fields[]={ 108 static char *TryExcept_fields[]={
110 "body", 109 "body",
111 "handlers", 110 "handlers",
508 if (!While_type) return 0; 507 if (!While_type) return 0;
509 If_type = make_type("If", stmt_type, If_fields, 3); 508 If_type = make_type("If", stmt_type, If_fields, 3);
510 if (!If_type) return 0; 509 if (!If_type) return 0;
511 With_type = make_type("With", stmt_type, With_fields, 3); 510 With_type = make_type("With", stmt_type, With_fields, 3);
512 if (!With_type) return 0; 511 if (!With_type) return 0;
513 Raise_type = make_type("Raise", stmt_type, Raise_fields, 3); 512 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2);
514 if (!Raise_type) return 0; 513 if (!Raise_type) return 0;
515 TryExcept_type = make_type("TryExcept", stmt_type, TryExcept_fields, 3); 514 TryExcept_type = make_type("TryExcept", stmt_type, TryExcept_fields, 3);
516 if (!TryExcept_type) return 0; 515 if (!TryExcept_type) return 0;
517 TryFinally_type = make_type("TryFinally", stmt_type, TryFinally_fields, 516 TryFinally_type = make_type("TryFinally", stmt_type, TryFinally_fields,
518 2); 517 2);
1050 p->col_offset = col_offset; 1049 p->col_offset = col_offset;
1051 return p; 1050 return p;
1052 } 1051 }
1053 1052
1054 stmt_ty 1053 stmt_ty
1055 Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int col_offset, 1054 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena)
1056 PyArena *arena)
1057 { 1055 {
1058 stmt_ty p; 1056 stmt_ty p;
1059 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1057 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1060 if (!p) 1058 if (!p)
1061 return NULL; 1059 return NULL;
1062 p->kind = Raise_kind; 1060 p->kind = Raise_kind;
1063 p->v.Raise.type = type; 1061 p->v.Raise.exc = exc;
1064 p->v.Raise.inst = inst; 1062 p->v.Raise.cause = cause;
1065 p->v.Raise.tback = tback;
1066 p->lineno = lineno; 1063 p->lineno = lineno;
1067 p->col_offset = col_offset; 1064 p->col_offset = col_offset;
1068 return p; 1065 return p;
1069 } 1066 }
1070 1067
2219 Py_DECREF(value); 2216 Py_DECREF(value);
2220 break; 2217 break;
2221 case Raise_kind: 2218 case Raise_kind:
2222 result = PyType_GenericNew(Raise_type, NULL, NULL); 2219 result = PyType_GenericNew(Raise_type, NULL, NULL);
2223 if (!result) goto failed; 2220 if (!result) goto failed;
2224 value = ast2obj_expr(o->v.Raise.type); 2221 value = ast2obj_expr(o->v.Raise.exc);
2225 if (!value) goto failed; 2222 if (!value) goto failed;
2226 if (PyObject_SetAttrString(result, "type", value) == -1) 2223 if (PyObject_SetAttrString(result, "exc", value) == -1)
2227 goto failed; 2224 goto failed;
2228 Py_DECREF(value); 2225 Py_DECREF(value);
2229 value = ast2obj_expr(o->v.Raise.inst); 2226 value = ast2obj_expr(o->v.Raise.cause);
2230 if (!value) goto failed; 2227 if (!value) goto failed;
2231 if (PyObject_SetAttrString(result, "inst", value) == -1) 2228 if (PyObject_SetAttrString(result, "cause", value) == -1)
2232 goto failed;
2233 Py_DECREF(value);
2234 value = ast2obj_expr(o->v.Raise.tback);
2235 if (!value) goto failed;
2236 if (PyObject_SetAttrString(result, "tback", value) == -1)
2237 goto failed; 2229 goto failed;
2238 Py_DECREF(value); 2230 Py_DECREF(value);
2239 break; 2231 break;
2240 case TryExcept_kind: 2232 case TryExcept_kind:
2241 result = PyType_GenericNew(TryExcept_type, NULL, NULL); 2233 result = PyType_GenericNew(TryExcept_type, NULL, NULL);
3177 if (!m) return; 3169 if (!m) return;
3178 d = PyModule_GetDict(m); 3170 d = PyModule_GetDict(m);
3179 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; 3171 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
3180 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) 3172 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
3181 return; 3173 return;
3182 if (PyModule_AddStringConstant(m, "__version__", "56266") < 0) 3174 if (PyModule_AddStringConstant(m, "__version__", "465") < 0)
3183 return; 3175 return;
3184 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; 3176 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
3185 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) 3177 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
3186 return; 3178 return;
3187 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) 3179 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type)