summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c544
1 files changed, 455 insertions, 89 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index e03dac0..05fa541 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -3374,13 +3374,18 @@ int
obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
if (obj == Py_None) {
*out = NULL;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Module_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* body;
if (PyObject_HasAttrString(obj, "body")) {
@@ -3412,7 +3417,11 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Interactive_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* body;
if (PyObject_HasAttrString(obj, "body")) {
@@ -3444,7 +3453,11 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Expression_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty body;
if (PyObject_HasAttrString(obj, "body")) {
@@ -3463,7 +3476,11 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Suite_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* body;
if (PyObject_HasAttrString(obj, "body")) {
@@ -3508,6 +3525,7 @@ int
obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
int lineno;
int col_offset;
@@ -3540,7 +3558,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
return 1;
}
- if (PyObject_IsInstance(obj, (PyObject*)FunctionDef_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
identifier name;
arguments_ty args;
asdl_seq* body;
@@ -3637,7 +3659,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)ClassDef_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
identifier name;
asdl_seq* bases;
asdl_seq* keywords;
@@ -3785,7 +3811,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Return_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
if (PyObject_HasAttrString(obj, "value")) {
@@ -3803,7 +3833,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Delete_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* targets;
if (PyObject_HasAttrString(obj, "targets")) {
@@ -3835,7 +3869,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Assign_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* targets;
expr_ty value;
@@ -3880,7 +3918,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)AugAssign_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty target;
operator_ty op;
expr_ty value;
@@ -3925,7 +3967,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)For_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)For_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty target;
expr_ty iter;
asdl_seq* body;
@@ -4010,7 +4056,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)While_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)While_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty test;
asdl_seq* body;
asdl_seq* orelse;
@@ -4081,7 +4131,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)If_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)If_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty test;
asdl_seq* body;
asdl_seq* orelse;
@@ -4152,7 +4206,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)With_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)With_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty context_expr;
expr_ty optional_vars;
asdl_seq* body;
@@ -4210,7 +4268,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Raise_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty exc;
expr_ty cause;
@@ -4240,7 +4302,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)TryExcept_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)TryExcept_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* body;
asdl_seq* handlers;
asdl_seq* orelse;
@@ -4325,7 +4391,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)TryFinally_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)TryFinally_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* body;
asdl_seq* finalbody;
@@ -4383,7 +4453,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Assert_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty test;
expr_ty msg;
@@ -4414,7 +4488,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Import_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* names;
if (PyObject_HasAttrString(obj, "names")) {
@@ -4446,7 +4524,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)ImportFrom_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
identifier module;
asdl_seq* names;
int level;
@@ -4503,7 +4585,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Global_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* names;
if (PyObject_HasAttrString(obj, "names")) {
@@ -4535,7 +4621,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Nonlocal_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* names;
if (PyObject_HasAttrString(obj, "names")) {
@@ -4567,7 +4657,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Expr_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
if (PyObject_HasAttrString(obj, "value")) {
@@ -4586,19 +4680,31 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Pass_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Pass(lineno, col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Break_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Break(lineno, col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Continue_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Continue(lineno, col_offset, arena);
if (*out == NULL) goto failed;
@@ -4617,6 +4723,7 @@ int
obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
int lineno;
int col_offset;
@@ -4649,7 +4756,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
return 1;
}
- if (PyObject_IsInstance(obj, (PyObject*)BoolOp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
boolop_ty op;
asdl_seq* values;
@@ -4694,7 +4805,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)BinOp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty left;
operator_ty op;
expr_ty right;
@@ -4739,7 +4854,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)UnaryOp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
unaryop_ty op;
expr_ty operand;
@@ -4771,7 +4890,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Lambda_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
arguments_ty args;
expr_ty body;
@@ -4803,7 +4926,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)IfExp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty test;
expr_ty body;
expr_ty orelse;
@@ -4848,7 +4975,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Dict_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* keys;
asdl_seq* values;
@@ -4906,7 +5037,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Set_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* elts;
if (PyObject_HasAttrString(obj, "elts")) {
@@ -4938,7 +5073,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)ListComp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty elt;
asdl_seq* generators;
@@ -4983,7 +5122,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)SetComp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty elt;
asdl_seq* generators;
@@ -5028,7 +5171,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)DictComp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty key;
expr_ty value;
asdl_seq* generators;
@@ -5087,7 +5234,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty elt;
asdl_seq* generators;
@@ -5132,7 +5283,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Yield_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
if (PyObject_HasAttrString(obj, "value")) {
@@ -5150,7 +5305,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Compare_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty left;
asdl_int_seq* ops;
asdl_seq* comparators;
@@ -5222,7 +5381,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Call_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty func;
asdl_seq* args;
asdl_seq* keywords;
@@ -5318,7 +5481,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Num_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
object n;
if (PyObject_HasAttrString(obj, "n")) {
@@ -5337,7 +5504,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Str_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
string s;
if (PyObject_HasAttrString(obj, "s")) {
@@ -5356,7 +5527,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Bytes_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
string s;
if (PyObject_HasAttrString(obj, "s")) {
@@ -5375,13 +5550,21 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Ellipsis_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Ellipsis(lineno, col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Attribute_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
identifier attr;
expr_context_ty ctx;
@@ -5426,7 +5609,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Subscript_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
slice_ty slice;
expr_context_ty ctx;
@@ -5471,7 +5658,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Starred_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
expr_context_ty ctx;
@@ -5503,7 +5694,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Name_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
identifier id;
expr_context_ty ctx;
@@ -5535,7 +5730,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)List_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)List_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* elts;
expr_context_ty ctx;
@@ -5580,7 +5779,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Tuple_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* elts;
expr_context_ty ctx;
@@ -5638,28 +5841,53 @@ int
obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
- if (PyObject_IsInstance(obj, (PyObject*)Load_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Load;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Store_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Store;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Del_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Del;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)AugLoad_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = AugLoad;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)AugStore_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = AugStore;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Param_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Param;
return 0;
}
@@ -5676,13 +5904,18 @@ int
obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
if (obj == Py_None) {
*out = NULL;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Slice_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty lower;
expr_ty upper;
expr_ty step;
@@ -5724,7 +5957,11 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)ExtSlice_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
asdl_seq* dims;
if (PyObject_HasAttrString(obj, "dims")) {
@@ -5756,7 +5993,11 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
if (*out == NULL) goto failed;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Index_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty value;
if (PyObject_HasAttrString(obj, "value")) {
@@ -5788,12 +6029,21 @@ int
obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
- if (PyObject_IsInstance(obj, (PyObject*)And_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)And_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = And;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Or_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Or;
return 0;
}
@@ -5810,52 +6060,101 @@ int
obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
- if (PyObject_IsInstance(obj, (PyObject*)Add_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Add;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Sub_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Sub;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Mult_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Mult;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Div_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Div;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Mod_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Mod;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Pow_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Pow;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)LShift_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = LShift;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)RShift_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = RShift;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)BitOr_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = BitOr;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)BitXor_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = BitXor;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)BitAnd_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = BitAnd;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)FloorDiv_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = FloorDiv;
return 0;
}
@@ -5872,20 +6171,37 @@ int
obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
- if (PyObject_IsInstance(obj, (PyObject*)Invert_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Invert;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Not_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Not;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)UAdd_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = UAdd;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)USub_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = USub;
return 0;
}
@@ -5902,44 +6218,85 @@ int
obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
- if (PyObject_IsInstance(obj, (PyObject*)Eq_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Eq;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)NotEq_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = NotEq;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Lt_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Lt;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)LtE_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = LtE;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Gt_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Gt;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)GtE_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = GtE;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)Is_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = Is;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)IsNot_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = IsNot;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)In_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)In_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = In;
return 0;
}
- if (PyObject_IsInstance(obj, (PyObject*)NotIn_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
*out = NotIn;
return 0;
}
@@ -6020,6 +6377,7 @@ int
obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
+ int isinstance;
int lineno;
int col_offset;
@@ -6052,7 +6410,11 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
return 1;
}
- if (PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type)) {
+ isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
expr_ty type;
identifier name;
asdl_seq* body;
@@ -6629,11 +6991,15 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
(PyObject*)Interactive_type};
char *req_name[] = {"Module", "Expression", "Interactive"};
+ int isinstance;
assert(0 <= mode && mode <= 2);
init_types();
- if (!PyObject_IsInstance(ast, req_type[mode])) {
+ isinstance = PyObject_IsInstance(ast, req_type[mode]);
+ if (isinstance == -1)
+ return NULL;
+ if (!isinstance) {
PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
req_name[mode], Py_TYPE(ast)->tp_name);
return NULL;