Merged revisions 76774 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76774 | benjamin.peterson | 2009-12-12 18:54:15 -0600 (Sat, 12 Dec 2009) | 1 line account for PyObject_IsInstance's new ability to fail ........
This commit is contained in:
parent
e2d6700d4a
commit
011e9f1726
|
@ -367,6 +367,7 @@ class Obj2ModVisitor(PickleVisitor):
|
|||
self.emit("obj2ast_%s(PyObject* obj, %s* out, PyArena* arena)" % (name, ctype), 0)
|
||||
self.emit("{", 0)
|
||||
self.emit("PyObject* tmp = NULL;", 1)
|
||||
self.emit("int isinstance;", 1)
|
||||
self.emit("", 0)
|
||||
|
||||
def sumTrailer(self, name):
|
||||
|
@ -386,7 +387,13 @@ class Obj2ModVisitor(PickleVisitor):
|
|||
def simpleSum(self, sum, name):
|
||||
self.funcHeader(name)
|
||||
for t in sum.types:
|
||||
self.emit("if (PyObject_IsInstance(obj, (PyObject*)%s_type)) {" % t.name, 1)
|
||||
line = ("isinstance = PyObject_IsInstance(obj, "
|
||||
"(PyObject *)%s_type);")
|
||||
self.emit(line % (t.name,), 1)
|
||||
self.emit("if (isinstance == -1) {", 1)
|
||||
self.emit("return 1;", 2)
|
||||
self.emit("}", 1)
|
||||
self.emit("if (isinstance) {", 1)
|
||||
self.emit("*out = %s;" % t.name, 2)
|
||||
self.emit("return 0;", 2)
|
||||
self.emit("}", 1)
|
||||
|
@ -408,7 +415,12 @@ class Obj2ModVisitor(PickleVisitor):
|
|||
for a in sum.attributes:
|
||||
self.visitField(a, name, sum=sum, depth=1)
|
||||
for t in sum.types:
|
||||
self.emit("if (PyObject_IsInstance(obj, (PyObject*)%s_type)) {" % t.name, 1)
|
||||
line = "isinstance = PyObject_IsInstance(obj, (PyObject*)%s_type);"
|
||||
self.emit(line % (t.name,), 1)
|
||||
self.emit("if (isinstance == -1) {", 1)
|
||||
self.emit("return 1;", 2)
|
||||
self.emit("}", 1)
|
||||
self.emit("if (isinstance) {", 1)
|
||||
for f in t.fields:
|
||||
self.visitFieldDeclaration(f, t.name, sum=sum, depth=2)
|
||||
self.emit("", 0)
|
||||
|
@ -1093,11 +1105,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;
|
||||
|
|
|
@ -3180,13 +3180,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")) {
|
||||
|
@ -3218,7 +3223,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")) {
|
||||
|
@ -3250,7 +3259,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")) {
|
||||
|
@ -3269,7 +3282,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")) {
|
||||
|
@ -3314,6 +3331,7 @@ int
|
|||
obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
|
||||
{
|
||||
PyObject* tmp = NULL;
|
||||
int isinstance;
|
||||
|
||||
int lineno;
|
||||
int col_offset;
|
||||
|
@ -3346,7 +3364,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;
|
||||
|
@ -3431,7 +3453,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* body;
|
||||
|
@ -3529,7 +3555,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")) {
|
||||
|
@ -3547,7 +3577,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")) {
|
||||
|
@ -3579,7 +3613,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;
|
||||
|
||||
|
@ -3624,7 +3662,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;
|
||||
|
@ -3669,7 +3711,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
|
|||
if (*out == NULL) goto failed;
|
||||
return 0;
|
||||
}
|
||||
if (PyObject_IsInstance(obj, (PyObject*)Print_type)) {
|
||||
isinstance = PyObject_IsInstance(obj, (PyObject*)Print_type);
|
||||
if (isinstance == -1) {
|
||||
return 1;
|
||||
}
|
||||
if (isinstance) {
|
||||
expr_ty dest;
|
||||
asdl_seq* values;
|
||||
bool nl;
|
||||
|
@ -3726,7 +3772,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;
|
||||
|
@ -3811,7 +3861,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;
|
||||
|
@ -3882,7 +3936,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;
|
||||
|
@ -3953,7 +4011,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;
|
||||
|
@ -4011,7 +4073,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 type;
|
||||
expr_ty inst;
|
||||
expr_ty tback;
|
||||
|
@ -4053,7 +4119,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;
|
||||
|
@ -4138,7 +4208,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;
|
||||
|
||||
|
@ -4196,7 +4270,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;
|
||||
|
||||
|
@ -4227,7 +4305,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")) {
|
||||
|
@ -4259,7 +4341,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;
|
||||
|
@ -4317,7 +4403,11 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
|
|||
if (*out == NULL) goto failed;
|
||||
return 0;
|
||||
}
|
||||
if (PyObject_IsInstance(obj, (PyObject*)Exec_type)) {
|
||||
isinstance = PyObject_IsInstance(obj, (PyObject*)Exec_type);
|
||||
if (isinstance == -1) {
|
||||
return 1;
|
||||
}
|
||||
if (isinstance) {
|
||||
expr_ty body;
|
||||
expr_ty globals;
|
||||
expr_ty locals;
|
||||
|
@ -4360,7 +4450,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")) {
|
||||
|
@ -4392,7 +4486,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")) {
|
||||
|
@ -4411,19 +4509,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;
|
||||
|
@ -4442,6 +4552,7 @@ int
|
|||
obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
|
||||
{
|
||||
PyObject* tmp = NULL;
|
||||
int isinstance;
|
||||
|
||||
int lineno;
|
||||
int col_offset;
|
||||
|
@ -4474,7 +4585,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;
|
||||
|
||||
|
@ -4519,7 +4634,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;
|
||||
|
@ -4564,7 +4683,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;
|
||||
|
||||
|
@ -4596,7 +4719,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;
|
||||
|
||||
|
@ -4628,7 +4755,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;
|
||||
|
@ -4673,7 +4804,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;
|
||||
|
||||
|
@ -4731,7 +4866,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;
|
||||
|
||||
|
@ -4776,7 +4915,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;
|
||||
|
||||
|
@ -4821,7 +4964,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")) {
|
||||
|
@ -4839,7 +4986,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;
|
||||
|
@ -4911,7 +5062,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;
|
||||
|
@ -5007,7 +5162,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
|
|||
if (*out == NULL) goto failed;
|
||||
return 0;
|
||||
}
|
||||
if (PyObject_IsInstance(obj, (PyObject*)Repr_type)) {
|
||||
isinstance = PyObject_IsInstance(obj, (PyObject*)Repr_type);
|
||||
if (isinstance == -1) {
|
||||
return 1;
|
||||
}
|
||||
if (isinstance) {
|
||||
expr_ty value;
|
||||
|
||||
if (PyObject_HasAttrString(obj, "value")) {
|
||||
|
@ -5026,7 +5185,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")) {
|
||||
|
@ -5045,7 +5208,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")) {
|
||||
|
@ -5064,7 +5231,11 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* 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;
|
||||
|
@ -5109,7 +5280,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;
|
||||
|
@ -5154,7 +5329,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;
|
||||
|
||||
|
@ -5186,7 +5365,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;
|
||||
|
||||
|
@ -5231,7 +5414,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;
|
||||
|
||||
|
@ -5289,28 +5476,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;
|
||||
}
|
||||
|
@ -5327,19 +5539,28 @@ 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*)Ellipsis_type)) {
|
||||
isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type);
|
||||
if (isinstance == -1) {
|
||||
return 1;
|
||||
}
|
||||
if (isinstance) {
|
||||
|
||||
*out = Ellipsis(arena);
|
||||
if (*out == NULL) goto failed;
|
||||
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;
|
||||
|
@ -5381,7 +5602,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")) {
|
||||
|
@ -5413,7 +5638,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")) {
|
||||
|
@ -5445,12 +5674,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;
|
||||
}
|
||||
|
@ -5467,52 +5705,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;
|
||||
}
|
||||
|
@ -5529,20 +5816,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;
|
||||
}
|
||||
|
@ -5559,44 +5863,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;
|
||||
}
|
||||
|
@ -5677,6 +6022,7 @@ int
|
|||
obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
|
||||
{
|
||||
PyObject* tmp = NULL;
|
||||
int isinstance;
|
||||
|
||||
int lineno;
|
||||
int col_offset;
|
||||
|
@ -5709,7 +6055,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;
|
||||
expr_ty name;
|
||||
asdl_seq* body;
|
||||
|
@ -6110,11 +6460,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;
|
||||
|
|
|
@ -465,6 +465,7 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
int mode = -1;
|
||||
int dont_inherit = 0;
|
||||
int supplied_flags = 0;
|
||||
int is_ast;
|
||||
PyCompilerFlags cf;
|
||||
PyObject *result = NULL, *cmd, *tmp = NULL;
|
||||
Py_ssize_t length;
|
||||
|
@ -504,7 +505,10 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (PyAST_Check(cmd)) {
|
||||
is_ast = PyAST_Check(cmd);
|
||||
if (is_ast == -1)
|
||||
return NULL;
|
||||
if (is_ast) {
|
||||
if (supplied_flags & PyCF_ONLY_AST) {
|
||||
Py_INCREF(cmd);
|
||||
result = cmd;
|
||||
|
|
Loading…
Reference in New Issue