Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 57673:20b7deb53d4e legacy-trunk
account for PyObject_IsInstance's new ability to fail
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 13 Dec 2009 00:54:15 +0000 |
| parents | 247f8d268d58 |
| children | c2fdf25329ff |
comparison
equal
deleted
inserted
replaced
| 57665:2ffd19a224d4 | 57673:20b7deb53d4e |
|---|---|
| 3173 | 3173 |
| 3174 int | 3174 int |
| 3175 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) | 3175 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) |
| 3176 { | 3176 { |
| 3177 PyObject* tmp = NULL; | 3177 PyObject* tmp = NULL; |
| 3178 int isinstance; | |
| 3178 | 3179 |
| 3179 | 3180 |
| 3180 if (obj == Py_None) { | 3181 if (obj == Py_None) { |
| 3181 *out = NULL; | 3182 *out = NULL; |
| 3182 return 0; | 3183 return 0; |
| 3183 } | 3184 } |
| 3184 if (PyObject_IsInstance(obj, (PyObject*)Module_type)) { | 3185 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); |
| 3186 if (isinstance == -1) { | |
| 3187 return 1; | |
| 3188 } | |
| 3189 if (isinstance) { | |
| 3185 asdl_seq* body; | 3190 asdl_seq* body; |
| 3186 | 3191 |
| 3187 if (PyObject_HasAttrString(obj, "body")) { | 3192 if (PyObject_HasAttrString(obj, "body")) { |
| 3188 int res; | 3193 int res; |
| 3189 Py_ssize_t len; | 3194 Py_ssize_t len; |
| 3211 } | 3216 } |
| 3212 *out = Module(body, arena); | 3217 *out = Module(body, arena); |
| 3213 if (*out == NULL) goto failed; | 3218 if (*out == NULL) goto failed; |
| 3214 return 0; | 3219 return 0; |
| 3215 } | 3220 } |
| 3216 if (PyObject_IsInstance(obj, (PyObject*)Interactive_type)) { | 3221 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); |
| 3222 if (isinstance == -1) { | |
| 3223 return 1; | |
| 3224 } | |
| 3225 if (isinstance) { | |
| 3217 asdl_seq* body; | 3226 asdl_seq* body; |
| 3218 | 3227 |
| 3219 if (PyObject_HasAttrString(obj, "body")) { | 3228 if (PyObject_HasAttrString(obj, "body")) { |
| 3220 int res; | 3229 int res; |
| 3221 Py_ssize_t len; | 3230 Py_ssize_t len; |
| 3243 } | 3252 } |
| 3244 *out = Interactive(body, arena); | 3253 *out = Interactive(body, arena); |
| 3245 if (*out == NULL) goto failed; | 3254 if (*out == NULL) goto failed; |
| 3246 return 0; | 3255 return 0; |
| 3247 } | 3256 } |
| 3248 if (PyObject_IsInstance(obj, (PyObject*)Expression_type)) { | 3257 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); |
| 3258 if (isinstance == -1) { | |
| 3259 return 1; | |
| 3260 } | |
| 3261 if (isinstance) { | |
| 3249 expr_ty body; | 3262 expr_ty body; |
| 3250 | 3263 |
| 3251 if (PyObject_HasAttrString(obj, "body")) { | 3264 if (PyObject_HasAttrString(obj, "body")) { |
| 3252 int res; | 3265 int res; |
| 3253 tmp = PyObject_GetAttrString(obj, "body"); | 3266 tmp = PyObject_GetAttrString(obj, "body"); |
| 3262 } | 3275 } |
| 3263 *out = Expression(body, arena); | 3276 *out = Expression(body, arena); |
| 3264 if (*out == NULL) goto failed; | 3277 if (*out == NULL) goto failed; |
| 3265 return 0; | 3278 return 0; |
| 3266 } | 3279 } |
| 3267 if (PyObject_IsInstance(obj, (PyObject*)Suite_type)) { | 3280 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); |
| 3281 if (isinstance == -1) { | |
| 3282 return 1; | |
| 3283 } | |
| 3284 if (isinstance) { | |
| 3268 asdl_seq* body; | 3285 asdl_seq* body; |
| 3269 | 3286 |
| 3270 if (PyObject_HasAttrString(obj, "body")) { | 3287 if (PyObject_HasAttrString(obj, "body")) { |
| 3271 int res; | 3288 int res; |
| 3272 Py_ssize_t len; | 3289 Py_ssize_t len; |
| 3307 | 3324 |
| 3308 int | 3325 int |
| 3309 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) | 3326 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) |
| 3310 { | 3327 { |
| 3311 PyObject* tmp = NULL; | 3328 PyObject* tmp = NULL; |
| 3329 int isinstance; | |
| 3312 | 3330 |
| 3313 int lineno; | 3331 int lineno; |
| 3314 int col_offset; | 3332 int col_offset; |
| 3315 | 3333 |
| 3316 if (obj == Py_None) { | 3334 if (obj == Py_None) { |
| 3339 tmp = NULL; | 3357 tmp = NULL; |
| 3340 } else { | 3358 } else { |
| 3341 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); | 3359 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); |
| 3342 return 1; | 3360 return 1; |
| 3343 } | 3361 } |
| 3344 if (PyObject_IsInstance(obj, (PyObject*)FunctionDef_type)) { | 3362 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); |
| 3363 if (isinstance == -1) { | |
| 3364 return 1; | |
| 3365 } | |
| 3366 if (isinstance) { | |
| 3345 identifier name; | 3367 identifier name; |
| 3346 arguments_ty args; | 3368 arguments_ty args; |
| 3347 asdl_seq* body; | 3369 asdl_seq* body; |
| 3348 asdl_seq* decorator_list; | 3370 asdl_seq* decorator_list; |
| 3349 | 3371 |
| 3424 *out = FunctionDef(name, args, body, decorator_list, lineno, | 3446 *out = FunctionDef(name, args, body, decorator_list, lineno, |
| 3425 col_offset, arena); | 3447 col_offset, arena); |
| 3426 if (*out == NULL) goto failed; | 3448 if (*out == NULL) goto failed; |
| 3427 return 0; | 3449 return 0; |
| 3428 } | 3450 } |
| 3429 if (PyObject_IsInstance(obj, (PyObject*)ClassDef_type)) { | 3451 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); |
| 3452 if (isinstance == -1) { | |
| 3453 return 1; | |
| 3454 } | |
| 3455 if (isinstance) { | |
| 3430 identifier name; | 3456 identifier name; |
| 3431 asdl_seq* bases; | 3457 asdl_seq* bases; |
| 3432 asdl_seq* body; | 3458 asdl_seq* body; |
| 3433 asdl_seq* decorator_list; | 3459 asdl_seq* decorator_list; |
| 3434 | 3460 |
| 3522 *out = ClassDef(name, bases, body, decorator_list, lineno, | 3548 *out = ClassDef(name, bases, body, decorator_list, lineno, |
| 3523 col_offset, arena); | 3549 col_offset, arena); |
| 3524 if (*out == NULL) goto failed; | 3550 if (*out == NULL) goto failed; |
| 3525 return 0; | 3551 return 0; |
| 3526 } | 3552 } |
| 3527 if (PyObject_IsInstance(obj, (PyObject*)Return_type)) { | 3553 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); |
| 3554 if (isinstance == -1) { | |
| 3555 return 1; | |
| 3556 } | |
| 3557 if (isinstance) { | |
| 3528 expr_ty value; | 3558 expr_ty value; |
| 3529 | 3559 |
| 3530 if (PyObject_HasAttrString(obj, "value")) { | 3560 if (PyObject_HasAttrString(obj, "value")) { |
| 3531 int res; | 3561 int res; |
| 3532 tmp = PyObject_GetAttrString(obj, "value"); | 3562 tmp = PyObject_GetAttrString(obj, "value"); |
| 3540 } | 3570 } |
| 3541 *out = Return(value, lineno, col_offset, arena); | 3571 *out = Return(value, lineno, col_offset, arena); |
| 3542 if (*out == NULL) goto failed; | 3572 if (*out == NULL) goto failed; |
| 3543 return 0; | 3573 return 0; |
| 3544 } | 3574 } |
| 3545 if (PyObject_IsInstance(obj, (PyObject*)Delete_type)) { | 3575 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); |
| 3576 if (isinstance == -1) { | |
| 3577 return 1; | |
| 3578 } | |
| 3579 if (isinstance) { | |
| 3546 asdl_seq* targets; | 3580 asdl_seq* targets; |
| 3547 | 3581 |
| 3548 if (PyObject_HasAttrString(obj, "targets")) { | 3582 if (PyObject_HasAttrString(obj, "targets")) { |
| 3549 int res; | 3583 int res; |
| 3550 Py_ssize_t len; | 3584 Py_ssize_t len; |
| 3572 } | 3606 } |
| 3573 *out = Delete(targets, lineno, col_offset, arena); | 3607 *out = Delete(targets, lineno, col_offset, arena); |
| 3574 if (*out == NULL) goto failed; | 3608 if (*out == NULL) goto failed; |
| 3575 return 0; | 3609 return 0; |
| 3576 } | 3610 } |
| 3577 if (PyObject_IsInstance(obj, (PyObject*)Assign_type)) { | 3611 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); |
| 3612 if (isinstance == -1) { | |
| 3613 return 1; | |
| 3614 } | |
| 3615 if (isinstance) { | |
| 3578 asdl_seq* targets; | 3616 asdl_seq* targets; |
| 3579 expr_ty value; | 3617 expr_ty value; |
| 3580 | 3618 |
| 3581 if (PyObject_HasAttrString(obj, "targets")) { | 3619 if (PyObject_HasAttrString(obj, "targets")) { |
| 3582 int res; | 3620 int res; |
| 3617 } | 3655 } |
| 3618 *out = Assign(targets, value, lineno, col_offset, arena); | 3656 *out = Assign(targets, value, lineno, col_offset, arena); |
| 3619 if (*out == NULL) goto failed; | 3657 if (*out == NULL) goto failed; |
| 3620 return 0; | 3658 return 0; |
| 3621 } | 3659 } |
| 3622 if (PyObject_IsInstance(obj, (PyObject*)AugAssign_type)) { | 3660 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); |
| 3661 if (isinstance == -1) { | |
| 3662 return 1; | |
| 3663 } | |
| 3664 if (isinstance) { | |
| 3623 expr_ty target; | 3665 expr_ty target; |
| 3624 operator_ty op; | 3666 operator_ty op; |
| 3625 expr_ty value; | 3667 expr_ty value; |
| 3626 | 3668 |
| 3627 if (PyObject_HasAttrString(obj, "target")) { | 3669 if (PyObject_HasAttrString(obj, "target")) { |
| 3662 } | 3704 } |
| 3663 *out = AugAssign(target, op, value, lineno, col_offset, arena); | 3705 *out = AugAssign(target, op, value, lineno, col_offset, arena); |
| 3664 if (*out == NULL) goto failed; | 3706 if (*out == NULL) goto failed; |
| 3665 return 0; | 3707 return 0; |
| 3666 } | 3708 } |
| 3667 if (PyObject_IsInstance(obj, (PyObject*)Print_type)) { | 3709 isinstance = PyObject_IsInstance(obj, (PyObject*)Print_type); |
| 3710 if (isinstance == -1) { | |
| 3711 return 1; | |
| 3712 } | |
| 3713 if (isinstance) { | |
| 3668 expr_ty dest; | 3714 expr_ty dest; |
| 3669 asdl_seq* values; | 3715 asdl_seq* values; |
| 3670 bool nl; | 3716 bool nl; |
| 3671 | 3717 |
| 3672 if (PyObject_HasAttrString(obj, "dest")) { | 3718 if (PyObject_HasAttrString(obj, "dest")) { |
| 3719 } | 3765 } |
| 3720 *out = Print(dest, values, nl, lineno, col_offset, arena); | 3766 *out = Print(dest, values, nl, lineno, col_offset, arena); |
| 3721 if (*out == NULL) goto failed; | 3767 if (*out == NULL) goto failed; |
| 3722 return 0; | 3768 return 0; |
| 3723 } | 3769 } |
| 3724 if (PyObject_IsInstance(obj, (PyObject*)For_type)) { | 3770 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); |
| 3771 if (isinstance == -1) { | |
| 3772 return 1; | |
| 3773 } | |
| 3774 if (isinstance) { | |
| 3725 expr_ty target; | 3775 expr_ty target; |
| 3726 expr_ty iter; | 3776 expr_ty iter; |
| 3727 asdl_seq* body; | 3777 asdl_seq* body; |
| 3728 asdl_seq* orelse; | 3778 asdl_seq* orelse; |
| 3729 | 3779 |
| 3804 *out = For(target, iter, body, orelse, lineno, col_offset, | 3854 *out = For(target, iter, body, orelse, lineno, col_offset, |
| 3805 arena); | 3855 arena); |
| 3806 if (*out == NULL) goto failed; | 3856 if (*out == NULL) goto failed; |
| 3807 return 0; | 3857 return 0; |
| 3808 } | 3858 } |
| 3809 if (PyObject_IsInstance(obj, (PyObject*)While_type)) { | 3859 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); |
| 3860 if (isinstance == -1) { | |
| 3861 return 1; | |
| 3862 } | |
| 3863 if (isinstance) { | |
| 3810 expr_ty test; | 3864 expr_ty test; |
| 3811 asdl_seq* body; | 3865 asdl_seq* body; |
| 3812 asdl_seq* orelse; | 3866 asdl_seq* orelse; |
| 3813 | 3867 |
| 3814 if (PyObject_HasAttrString(obj, "test")) { | 3868 if (PyObject_HasAttrString(obj, "test")) { |
| 3875 } | 3929 } |
| 3876 *out = While(test, body, orelse, lineno, col_offset, arena); | 3930 *out = While(test, body, orelse, lineno, col_offset, arena); |
| 3877 if (*out == NULL) goto failed; | 3931 if (*out == NULL) goto failed; |
| 3878 return 0; | 3932 return 0; |
| 3879 } | 3933 } |
| 3880 if (PyObject_IsInstance(obj, (PyObject*)If_type)) { | 3934 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); |
| 3935 if (isinstance == -1) { | |
| 3936 return 1; | |
| 3937 } | |
| 3938 if (isinstance) { | |
| 3881 expr_ty test; | 3939 expr_ty test; |
| 3882 asdl_seq* body; | 3940 asdl_seq* body; |
| 3883 asdl_seq* orelse; | 3941 asdl_seq* orelse; |
| 3884 | 3942 |
| 3885 if (PyObject_HasAttrString(obj, "test")) { | 3943 if (PyObject_HasAttrString(obj, "test")) { |
| 3946 } | 4004 } |
| 3947 *out = If(test, body, orelse, lineno, col_offset, arena); | 4005 *out = If(test, body, orelse, lineno, col_offset, arena); |
| 3948 if (*out == NULL) goto failed; | 4006 if (*out == NULL) goto failed; |
| 3949 return 0; | 4007 return 0; |
| 3950 } | 4008 } |
| 3951 if (PyObject_IsInstance(obj, (PyObject*)With_type)) { | 4009 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); |
| 4010 if (isinstance == -1) { | |
| 4011 return 1; | |
| 4012 } | |
| 4013 if (isinstance) { | |
| 3952 expr_ty context_expr; | 4014 expr_ty context_expr; |
| 3953 expr_ty optional_vars; | 4015 expr_ty optional_vars; |
| 3954 asdl_seq* body; | 4016 asdl_seq* body; |
| 3955 | 4017 |
| 3956 if (PyObject_HasAttrString(obj, "context_expr")) { | 4018 if (PyObject_HasAttrString(obj, "context_expr")) { |
| 4004 *out = With(context_expr, optional_vars, body, lineno, | 4066 *out = With(context_expr, optional_vars, body, lineno, |
| 4005 col_offset, arena); | 4067 col_offset, arena); |
| 4006 if (*out == NULL) goto failed; | 4068 if (*out == NULL) goto failed; |
| 4007 return 0; | 4069 return 0; |
| 4008 } | 4070 } |
| 4009 if (PyObject_IsInstance(obj, (PyObject*)Raise_type)) { | 4071 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); |
| 4072 if (isinstance == -1) { | |
| 4073 return 1; | |
| 4074 } | |
| 4075 if (isinstance) { | |
| 4010 expr_ty type; | 4076 expr_ty type; |
| 4011 expr_ty inst; | 4077 expr_ty inst; |
| 4012 expr_ty tback; | 4078 expr_ty tback; |
| 4013 | 4079 |
| 4014 if (PyObject_HasAttrString(obj, "type")) { | 4080 if (PyObject_HasAttrString(obj, "type")) { |
| 4046 } | 4112 } |
| 4047 *out = Raise(type, inst, tback, lineno, col_offset, arena); | 4113 *out = Raise(type, inst, tback, lineno, col_offset, arena); |
| 4048 if (*out == NULL) goto failed; | 4114 if (*out == NULL) goto failed; |
| 4049 return 0; | 4115 return 0; |
| 4050 } | 4116 } |
| 4051 if (PyObject_IsInstance(obj, (PyObject*)TryExcept_type)) { | 4117 isinstance = PyObject_IsInstance(obj, (PyObject*)TryExcept_type); |
| 4118 if (isinstance == -1) { | |
| 4119 return 1; | |
| 4120 } | |
| 4121 if (isinstance) { | |
| 4052 asdl_seq* body; | 4122 asdl_seq* body; |
| 4053 asdl_seq* handlers; | 4123 asdl_seq* handlers; |
| 4054 asdl_seq* orelse; | 4124 asdl_seq* orelse; |
| 4055 | 4125 |
| 4056 if (PyObject_HasAttrString(obj, "body")) { | 4126 if (PyObject_HasAttrString(obj, "body")) { |
| 4131 *out = TryExcept(body, handlers, orelse, lineno, col_offset, | 4201 *out = TryExcept(body, handlers, orelse, lineno, col_offset, |
| 4132 arena); | 4202 arena); |
| 4133 if (*out == NULL) goto failed; | 4203 if (*out == NULL) goto failed; |
| 4134 return 0; | 4204 return 0; |
| 4135 } | 4205 } |
| 4136 if (PyObject_IsInstance(obj, (PyObject*)TryFinally_type)) { | 4206 isinstance = PyObject_IsInstance(obj, (PyObject*)TryFinally_type); |
| 4207 if (isinstance == -1) { | |
| 4208 return 1; | |
| 4209 } | |
| 4210 if (isinstance) { | |
| 4137 asdl_seq* body; | 4211 asdl_seq* body; |
| 4138 asdl_seq* finalbody; | 4212 asdl_seq* finalbody; |
| 4139 | 4213 |
| 4140 if (PyObject_HasAttrString(obj, "body")) { | 4214 if (PyObject_HasAttrString(obj, "body")) { |
| 4141 int res; | 4215 int res; |
| 4189 } | 4263 } |
| 4190 *out = TryFinally(body, finalbody, lineno, col_offset, arena); | 4264 *out = TryFinally(body, finalbody, lineno, col_offset, arena); |
| 4191 if (*out == NULL) goto failed; | 4265 if (*out == NULL) goto failed; |
| 4192 return 0; | 4266 return 0; |
| 4193 } | 4267 } |
| 4194 if (PyObject_IsInstance(obj, (PyObject*)Assert_type)) { | 4268 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); |
| 4269 if (isinstance == -1) { | |
| 4270 return 1; | |
| 4271 } | |
| 4272 if (isinstance) { | |
| 4195 expr_ty test; | 4273 expr_ty test; |
| 4196 expr_ty msg; | 4274 expr_ty msg; |
| 4197 | 4275 |
| 4198 if (PyObject_HasAttrString(obj, "test")) { | 4276 if (PyObject_HasAttrString(obj, "test")) { |
| 4199 int res; | 4277 int res; |
| 4220 } | 4298 } |
| 4221 *out = Assert(test, msg, lineno, col_offset, arena); | 4299 *out = Assert(test, msg, lineno, col_offset, arena); |
| 4222 if (*out == NULL) goto failed; | 4300 if (*out == NULL) goto failed; |
| 4223 return 0; | 4301 return 0; |
| 4224 } | 4302 } |
| 4225 if (PyObject_IsInstance(obj, (PyObject*)Import_type)) { | 4303 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); |
| 4304 if (isinstance == -1) { | |
| 4305 return 1; | |
| 4306 } | |
| 4307 if (isinstance) { | |
| 4226 asdl_seq* names; | 4308 asdl_seq* names; |
| 4227 | 4309 |
| 4228 if (PyObject_HasAttrString(obj, "names")) { | 4310 if (PyObject_HasAttrString(obj, "names")) { |
| 4229 int res; | 4311 int res; |
| 4230 Py_ssize_t len; | 4312 Py_ssize_t len; |
| 4252 } | 4334 } |
| 4253 *out = Import(names, lineno, col_offset, arena); | 4335 *out = Import(names, lineno, col_offset, arena); |
| 4254 if (*out == NULL) goto failed; | 4336 if (*out == NULL) goto failed; |
| 4255 return 0; | 4337 return 0; |
| 4256 } | 4338 } |
| 4257 if (PyObject_IsInstance(obj, (PyObject*)ImportFrom_type)) { | 4339 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); |
| 4340 if (isinstance == -1) { | |
| 4341 return 1; | |
| 4342 } | |
| 4343 if (isinstance) { | |
| 4258 identifier module; | 4344 identifier module; |
| 4259 asdl_seq* names; | 4345 asdl_seq* names; |
| 4260 int level; | 4346 int level; |
| 4261 | 4347 |
| 4262 if (PyObject_HasAttrString(obj, "module")) { | 4348 if (PyObject_HasAttrString(obj, "module")) { |
| 4309 *out = ImportFrom(module, names, level, lineno, col_offset, | 4395 *out = ImportFrom(module, names, level, lineno, col_offset, |
| 4310 arena); | 4396 arena); |
| 4311 if (*out == NULL) goto failed; | 4397 if (*out == NULL) goto failed; |
| 4312 return 0; | 4398 return 0; |
| 4313 } | 4399 } |
| 4314 if (PyObject_IsInstance(obj, (PyObject*)Exec_type)) { | 4400 isinstance = PyObject_IsInstance(obj, (PyObject*)Exec_type); |
| 4401 if (isinstance == -1) { | |
| 4402 return 1; | |
| 4403 } | |
| 4404 if (isinstance) { | |
| 4315 expr_ty body; | 4405 expr_ty body; |
| 4316 expr_ty globals; | 4406 expr_ty globals; |
| 4317 expr_ty locals; | 4407 expr_ty locals; |
| 4318 | 4408 |
| 4319 if (PyObject_HasAttrString(obj, "body")) { | 4409 if (PyObject_HasAttrString(obj, "body")) { |
| 4352 } | 4442 } |
| 4353 *out = Exec(body, globals, locals, lineno, col_offset, arena); | 4443 *out = Exec(body, globals, locals, lineno, col_offset, arena); |
| 4354 if (*out == NULL) goto failed; | 4444 if (*out == NULL) goto failed; |
| 4355 return 0; | 4445 return 0; |
| 4356 } | 4446 } |
| 4357 if (PyObject_IsInstance(obj, (PyObject*)Global_type)) { | 4447 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); |
| 4448 if (isinstance == -1) { | |
| 4449 return 1; | |
| 4450 } | |
| 4451 if (isinstance) { | |
| 4358 asdl_seq* names; | 4452 asdl_seq* names; |
| 4359 | 4453 |
| 4360 if (PyObject_HasAttrString(obj, "names")) { | 4454 if (PyObject_HasAttrString(obj, "names")) { |
| 4361 int res; | 4455 int res; |
| 4362 Py_ssize_t len; | 4456 Py_ssize_t len; |
| 4384 } | 4478 } |
| 4385 *out = Global(names, lineno, col_offset, arena); | 4479 *out = Global(names, lineno, col_offset, arena); |
| 4386 if (*out == NULL) goto failed; | 4480 if (*out == NULL) goto failed; |
| 4387 return 0; | 4481 return 0; |
| 4388 } | 4482 } |
| 4389 if (PyObject_IsInstance(obj, (PyObject*)Expr_type)) { | 4483 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); |
| 4484 if (isinstance == -1) { | |
| 4485 return 1; | |
| 4486 } | |
| 4487 if (isinstance) { | |
| 4390 expr_ty value; | 4488 expr_ty value; |
| 4391 | 4489 |
| 4392 if (PyObject_HasAttrString(obj, "value")) { | 4490 if (PyObject_HasAttrString(obj, "value")) { |
| 4393 int res; | 4491 int res; |
| 4394 tmp = PyObject_GetAttrString(obj, "value"); | 4492 tmp = PyObject_GetAttrString(obj, "value"); |
| 4403 } | 4501 } |
| 4404 *out = Expr(value, lineno, col_offset, arena); | 4502 *out = Expr(value, lineno, col_offset, arena); |
| 4405 if (*out == NULL) goto failed; | 4503 if (*out == NULL) goto failed; |
| 4406 return 0; | 4504 return 0; |
| 4407 } | 4505 } |
| 4408 if (PyObject_IsInstance(obj, (PyObject*)Pass_type)) { | 4506 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); |
| 4507 if (isinstance == -1) { | |
| 4508 return 1; | |
| 4509 } | |
| 4510 if (isinstance) { | |
| 4409 | 4511 |
| 4410 *out = Pass(lineno, col_offset, arena); | 4512 *out = Pass(lineno, col_offset, arena); |
| 4411 if (*out == NULL) goto failed; | 4513 if (*out == NULL) goto failed; |
| 4412 return 0; | 4514 return 0; |
| 4413 } | 4515 } |
| 4414 if (PyObject_IsInstance(obj, (PyObject*)Break_type)) { | 4516 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); |
| 4517 if (isinstance == -1) { | |
| 4518 return 1; | |
| 4519 } | |
| 4520 if (isinstance) { | |
| 4415 | 4521 |
| 4416 *out = Break(lineno, col_offset, arena); | 4522 *out = Break(lineno, col_offset, arena); |
| 4417 if (*out == NULL) goto failed; | 4523 if (*out == NULL) goto failed; |
| 4418 return 0; | 4524 return 0; |
| 4419 } | 4525 } |
| 4420 if (PyObject_IsInstance(obj, (PyObject*)Continue_type)) { | 4526 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); |
| 4527 if (isinstance == -1) { | |
| 4528 return 1; | |
| 4529 } | |
| 4530 if (isinstance) { | |
| 4421 | 4531 |
| 4422 *out = Continue(lineno, col_offset, arena); | 4532 *out = Continue(lineno, col_offset, arena); |
| 4423 if (*out == NULL) goto failed; | 4533 if (*out == NULL) goto failed; |
| 4424 return 0; | 4534 return 0; |
| 4425 } | 4535 } |
| 4434 | 4544 |
| 4435 int | 4545 int |
| 4436 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) | 4546 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) |
| 4437 { | 4547 { |
| 4438 PyObject* tmp = NULL; | 4548 PyObject* tmp = NULL; |
| 4549 int isinstance; | |
| 4439 | 4550 |
| 4440 int lineno; | 4551 int lineno; |
| 4441 int col_offset; | 4552 int col_offset; |
| 4442 | 4553 |
| 4443 if (obj == Py_None) { | 4554 if (obj == Py_None) { |
| 4466 tmp = NULL; | 4577 tmp = NULL; |
| 4467 } else { | 4578 } else { |
| 4468 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); | 4579 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); |
| 4469 return 1; | 4580 return 1; |
| 4470 } | 4581 } |
| 4471 if (PyObject_IsInstance(obj, (PyObject*)BoolOp_type)) { | 4582 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); |
| 4583 if (isinstance == -1) { | |
| 4584 return 1; | |
| 4585 } | |
| 4586 if (isinstance) { | |
| 4472 boolop_ty op; | 4587 boolop_ty op; |
| 4473 asdl_seq* values; | 4588 asdl_seq* values; |
| 4474 | 4589 |
| 4475 if (PyObject_HasAttrString(obj, "op")) { | 4590 if (PyObject_HasAttrString(obj, "op")) { |
| 4476 int res; | 4591 int res; |
| 4511 } | 4626 } |
| 4512 *out = BoolOp(op, values, lineno, col_offset, arena); | 4627 *out = BoolOp(op, values, lineno, col_offset, arena); |
| 4513 if (*out == NULL) goto failed; | 4628 if (*out == NULL) goto failed; |
| 4514 return 0; | 4629 return 0; |
| 4515 } | 4630 } |
| 4516 if (PyObject_IsInstance(obj, (PyObject*)BinOp_type)) { | 4631 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); |
| 4632 if (isinstance == -1) { | |
| 4633 return 1; | |
| 4634 } | |
| 4635 if (isinstance) { | |
| 4517 expr_ty left; | 4636 expr_ty left; |
| 4518 operator_ty op; | 4637 operator_ty op; |
| 4519 expr_ty right; | 4638 expr_ty right; |
| 4520 | 4639 |
| 4521 if (PyObject_HasAttrString(obj, "left")) { | 4640 if (PyObject_HasAttrString(obj, "left")) { |
| 4556 } | 4675 } |
| 4557 *out = BinOp(left, op, right, lineno, col_offset, arena); | 4676 *out = BinOp(left, op, right, lineno, col_offset, arena); |
| 4558 if (*out == NULL) goto failed; | 4677 if (*out == NULL) goto failed; |
| 4559 return 0; | 4678 return 0; |
| 4560 } | 4679 } |
| 4561 if (PyObject_IsInstance(obj, (PyObject*)UnaryOp_type)) { | 4680 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); |
| 4681 if (isinstance == -1) { | |
| 4682 return 1; | |
| 4683 } | |
| 4684 if (isinstance) { | |
| 4562 unaryop_ty op; | 4685 unaryop_ty op; |
| 4563 expr_ty operand; | 4686 expr_ty operand; |
| 4564 | 4687 |
| 4565 if (PyObject_HasAttrString(obj, "op")) { | 4688 if (PyObject_HasAttrString(obj, "op")) { |
| 4566 int res; | 4689 int res; |
| 4588 } | 4711 } |
| 4589 *out = UnaryOp(op, operand, lineno, col_offset, arena); | 4712 *out = UnaryOp(op, operand, lineno, col_offset, arena); |
| 4590 if (*out == NULL) goto failed; | 4713 if (*out == NULL) goto failed; |
| 4591 return 0; | 4714 return 0; |
| 4592 } | 4715 } |
| 4593 if (PyObject_IsInstance(obj, (PyObject*)Lambda_type)) { | 4716 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); |
| 4717 if (isinstance == -1) { | |
| 4718 return 1; | |
| 4719 } | |
| 4720 if (isinstance) { | |
| 4594 arguments_ty args; | 4721 arguments_ty args; |
| 4595 expr_ty body; | 4722 expr_ty body; |
| 4596 | 4723 |
| 4597 if (PyObject_HasAttrString(obj, "args")) { | 4724 if (PyObject_HasAttrString(obj, "args")) { |
| 4598 int res; | 4725 int res; |
| 4620 } | 4747 } |
| 4621 *out = Lambda(args, body, lineno, col_offset, arena); | 4748 *out = Lambda(args, body, lineno, col_offset, arena); |
| 4622 if (*out == NULL) goto failed; | 4749 if (*out == NULL) goto failed; |
| 4623 return 0; | 4750 return 0; |
| 4624 } | 4751 } |
| 4625 if (PyObject_IsInstance(obj, (PyObject*)IfExp_type)) { | 4752 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); |
| 4753 if (isinstance == -1) { | |
| 4754 return 1; | |
| 4755 } | |
| 4756 if (isinstance) { | |
| 4626 expr_ty test; | 4757 expr_ty test; |
| 4627 expr_ty body; | 4758 expr_ty body; |
| 4628 expr_ty orelse; | 4759 expr_ty orelse; |
| 4629 | 4760 |
| 4630 if (PyObject_HasAttrString(obj, "test")) { | 4761 if (PyObject_HasAttrString(obj, "test")) { |
| 4665 } | 4796 } |
| 4666 *out = IfExp(test, body, orelse, lineno, col_offset, arena); | 4797 *out = IfExp(test, body, orelse, lineno, col_offset, arena); |
| 4667 if (*out == NULL) goto failed; | 4798 if (*out == NULL) goto failed; |
| 4668 return 0; | 4799 return 0; |
| 4669 } | 4800 } |
| 4670 if (PyObject_IsInstance(obj, (PyObject*)Dict_type)) { | 4801 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); |
| 4802 if (isinstance == -1) { | |
| 4803 return 1; | |
| 4804 } | |
| 4805 if (isinstance) { | |
| 4671 asdl_seq* keys; | 4806 asdl_seq* keys; |
| 4672 asdl_seq* values; | 4807 asdl_seq* values; |
| 4673 | 4808 |
| 4674 if (PyObject_HasAttrString(obj, "keys")) { | 4809 if (PyObject_HasAttrString(obj, "keys")) { |
| 4675 int res; | 4810 int res; |
| 4723 } | 4858 } |
| 4724 *out = Dict(keys, values, lineno, col_offset, arena); | 4859 *out = Dict(keys, values, lineno, col_offset, arena); |
| 4725 if (*out == NULL) goto failed; | 4860 if (*out == NULL) goto failed; |
| 4726 return 0; | 4861 return 0; |
| 4727 } | 4862 } |
| 4728 if (PyObject_IsInstance(obj, (PyObject*)ListComp_type)) { | 4863 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type); |
| 4864 if (isinstance == -1) { | |
| 4865 return 1; | |
| 4866 } | |
| 4867 if (isinstance) { | |
| 4729 expr_ty elt; | 4868 expr_ty elt; |
| 4730 asdl_seq* generators; | 4869 asdl_seq* generators; |
| 4731 | 4870 |
| 4732 if (PyObject_HasAttrString(obj, "elt")) { | 4871 if (PyObject_HasAttrString(obj, "elt")) { |
| 4733 int res; | 4872 int res; |
| 4768 } | 4907 } |
| 4769 *out = ListComp(elt, generators, lineno, col_offset, arena); | 4908 *out = ListComp(elt, generators, lineno, col_offset, arena); |
| 4770 if (*out == NULL) goto failed; | 4909 if (*out == NULL) goto failed; |
| 4771 return 0; | 4910 return 0; |
| 4772 } | 4911 } |
| 4773 if (PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type)) { | 4912 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type); |
| 4913 if (isinstance == -1) { | |
| 4914 return 1; | |
| 4915 } | |
| 4916 if (isinstance) { | |
| 4774 expr_ty elt; | 4917 expr_ty elt; |
| 4775 asdl_seq* generators; | 4918 asdl_seq* generators; |
| 4776 | 4919 |
| 4777 if (PyObject_HasAttrString(obj, "elt")) { | 4920 if (PyObject_HasAttrString(obj, "elt")) { |
| 4778 int res; | 4921 int res; |
| 4813 } | 4956 } |
| 4814 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); | 4957 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); |
| 4815 if (*out == NULL) goto failed; | 4958 if (*out == NULL) goto failed; |
| 4816 return 0; | 4959 return 0; |
| 4817 } | 4960 } |
| 4818 if (PyObject_IsInstance(obj, (PyObject*)Yield_type)) { | 4961 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type); |
| 4962 if (isinstance == -1) { | |
| 4963 return 1; | |
| 4964 } | |
| 4965 if (isinstance) { | |
| 4819 expr_ty value; | 4966 expr_ty value; |
| 4820 | 4967 |
| 4821 if (PyObject_HasAttrString(obj, "value")) { | 4968 if (PyObject_HasAttrString(obj, "value")) { |
| 4822 int res; | 4969 int res; |
| 4823 tmp = PyObject_GetAttrString(obj, "value"); | 4970 tmp = PyObject_GetAttrString(obj, "value"); |
| 4831 } | 4978 } |
| 4832 *out = Yield(value, lineno, col_offset, arena); | 4979 *out = Yield(value, lineno, col_offset, arena); |
| 4833 if (*out == NULL) goto failed; | 4980 if (*out == NULL) goto failed; |
| 4834 return 0; | 4981 return 0; |
| 4835 } | 4982 } |
| 4836 if (PyObject_IsInstance(obj, (PyObject*)Compare_type)) { | 4983 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); |
| 4984 if (isinstance == -1) { | |
| 4985 return 1; | |
| 4986 } | |
| 4987 if (isinstance) { | |
| 4837 expr_ty left; | 4988 expr_ty left; |
| 4838 asdl_int_seq* ops; | 4989 asdl_int_seq* ops; |
| 4839 asdl_seq* comparators; | 4990 asdl_seq* comparators; |
| 4840 | 4991 |
| 4841 if (PyObject_HasAttrString(obj, "left")) { | 4992 if (PyObject_HasAttrString(obj, "left")) { |
| 4903 *out = Compare(left, ops, comparators, lineno, col_offset, | 5054 *out = Compare(left, ops, comparators, lineno, col_offset, |
| 4904 arena); | 5055 arena); |
| 4905 if (*out == NULL) goto failed; | 5056 if (*out == NULL) goto failed; |
| 4906 return 0; | 5057 return 0; |
| 4907 } | 5058 } |
| 4908 if (PyObject_IsInstance(obj, (PyObject*)Call_type)) { | 5059 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type); |
| 5060 if (isinstance == -1) { | |
| 5061 return 1; | |
| 5062 } | |
| 5063 if (isinstance) { | |
| 4909 expr_ty func; | 5064 expr_ty func; |
| 4910 asdl_seq* args; | 5065 asdl_seq* args; |
| 4911 asdl_seq* keywords; | 5066 asdl_seq* keywords; |
| 4912 expr_ty starargs; | 5067 expr_ty starargs; |
| 4913 expr_ty kwargs; | 5068 expr_ty kwargs; |
| 4999 *out = Call(func, args, keywords, starargs, kwargs, lineno, | 5154 *out = Call(func, args, keywords, starargs, kwargs, lineno, |
| 5000 col_offset, arena); | 5155 col_offset, arena); |
| 5001 if (*out == NULL) goto failed; | 5156 if (*out == NULL) goto failed; |
| 5002 return 0; | 5157 return 0; |
| 5003 } | 5158 } |
| 5004 if (PyObject_IsInstance(obj, (PyObject*)Repr_type)) { | 5159 isinstance = PyObject_IsInstance(obj, (PyObject*)Repr_type); |
| 5160 if (isinstance == -1) { | |
| 5161 return 1; | |
| 5162 } | |
| 5163 if (isinstance) { | |
| 5005 expr_ty value; | 5164 expr_ty value; |
| 5006 | 5165 |
| 5007 if (PyObject_HasAttrString(obj, "value")) { | 5166 if (PyObject_HasAttrString(obj, "value")) { |
| 5008 int res; | 5167 int res; |
| 5009 tmp = PyObject_GetAttrString(obj, "value"); | 5168 tmp = PyObject_GetAttrString(obj, "value"); |
| 5018 } | 5177 } |
| 5019 *out = Repr(value, lineno, col_offset, arena); | 5178 *out = Repr(value, lineno, col_offset, arena); |
| 5020 if (*out == NULL) goto failed; | 5179 if (*out == NULL) goto failed; |
| 5021 return 0; | 5180 return 0; |
| 5022 } | 5181 } |
| 5023 if (PyObject_IsInstance(obj, (PyObject*)Num_type)) { | 5182 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type); |
| 5183 if (isinstance == -1) { | |
| 5184 return 1; | |
| 5185 } | |
| 5186 if (isinstance) { | |
| 5024 object n; | 5187 object n; |
| 5025 | 5188 |
| 5026 if (PyObject_HasAttrString(obj, "n")) { | 5189 if (PyObject_HasAttrString(obj, "n")) { |
| 5027 int res; | 5190 int res; |
| 5028 tmp = PyObject_GetAttrString(obj, "n"); | 5191 tmp = PyObject_GetAttrString(obj, "n"); |
| 5037 } | 5200 } |
| 5038 *out = Num(n, lineno, col_offset, arena); | 5201 *out = Num(n, lineno, col_offset, arena); |
| 5039 if (*out == NULL) goto failed; | 5202 if (*out == NULL) goto failed; |
| 5040 return 0; | 5203 return 0; |
| 5041 } | 5204 } |
| 5042 if (PyObject_IsInstance(obj, (PyObject*)Str_type)) { | 5205 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type); |
| 5206 if (isinstance == -1) { | |
| 5207 return 1; | |
| 5208 } | |
| 5209 if (isinstance) { | |
| 5043 string s; | 5210 string s; |
| 5044 | 5211 |
| 5045 if (PyObject_HasAttrString(obj, "s")) { | 5212 if (PyObject_HasAttrString(obj, "s")) { |
| 5046 int res; | 5213 int res; |
| 5047 tmp = PyObject_GetAttrString(obj, "s"); | 5214 tmp = PyObject_GetAttrString(obj, "s"); |
| 5056 } | 5223 } |
| 5057 *out = Str(s, lineno, col_offset, arena); | 5224 *out = Str(s, lineno, col_offset, arena); |
| 5058 if (*out == NULL) goto failed; | 5225 if (*out == NULL) goto failed; |
| 5059 return 0; | 5226 return 0; |
| 5060 } | 5227 } |
| 5061 if (PyObject_IsInstance(obj, (PyObject*)Attribute_type)) { | 5228 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type); |
| 5229 if (isinstance == -1) { | |
| 5230 return 1; | |
| 5231 } | |
| 5232 if (isinstance) { | |
| 5062 expr_ty value; | 5233 expr_ty value; |
| 5063 identifier attr; | 5234 identifier attr; |
| 5064 expr_context_ty ctx; | 5235 expr_context_ty ctx; |
| 5065 | 5236 |
| 5066 if (PyObject_HasAttrString(obj, "value")) { | 5237 if (PyObject_HasAttrString(obj, "value")) { |
| 5101 } | 5272 } |
| 5102 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); | 5273 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); |
| 5103 if (*out == NULL) goto failed; | 5274 if (*out == NULL) goto failed; |
| 5104 return 0; | 5275 return 0; |
| 5105 } | 5276 } |
| 5106 if (PyObject_IsInstance(obj, (PyObject*)Subscript_type)) { | 5277 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); |
| 5278 if (isinstance == -1) { | |
| 5279 return 1; | |
| 5280 } | |
| 5281 if (isinstance) { | |
| 5107 expr_ty value; | 5282 expr_ty value; |
| 5108 slice_ty slice; | 5283 slice_ty slice; |
| 5109 expr_context_ty ctx; | 5284 expr_context_ty ctx; |
| 5110 | 5285 |
| 5111 if (PyObject_HasAttrString(obj, "value")) { | 5286 if (PyObject_HasAttrString(obj, "value")) { |
| 5146 } | 5321 } |
| 5147 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); | 5322 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); |
| 5148 if (*out == NULL) goto failed; | 5323 if (*out == NULL) goto failed; |
| 5149 return 0; | 5324 return 0; |
| 5150 } | 5325 } |
| 5151 if (PyObject_IsInstance(obj, (PyObject*)Name_type)) { | 5326 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); |
| 5327 if (isinstance == -1) { | |
| 5328 return 1; | |
| 5329 } | |
| 5330 if (isinstance) { | |
| 5152 identifier id; | 5331 identifier id; |
| 5153 expr_context_ty ctx; | 5332 expr_context_ty ctx; |
| 5154 | 5333 |
| 5155 if (PyObject_HasAttrString(obj, "id")) { | 5334 if (PyObject_HasAttrString(obj, "id")) { |
| 5156 int res; | 5335 int res; |
| 5178 } | 5357 } |
| 5179 *out = Name(id, ctx, lineno, col_offset, arena); | 5358 *out = Name(id, ctx, lineno, col_offset, arena); |
| 5180 if (*out == NULL) goto failed; | 5359 if (*out == NULL) goto failed; |
| 5181 return 0; | 5360 return 0; |
| 5182 } | 5361 } |
| 5183 if (PyObject_IsInstance(obj, (PyObject*)List_type)) { | 5362 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type); |
| 5363 if (isinstance == -1) { | |
| 5364 return 1; | |
| 5365 } | |
| 5366 if (isinstance) { | |
| 5184 asdl_seq* elts; | 5367 asdl_seq* elts; |
| 5185 expr_context_ty ctx; | 5368 expr_context_ty ctx; |
| 5186 | 5369 |
| 5187 if (PyObject_HasAttrString(obj, "elts")) { | 5370 if (PyObject_HasAttrString(obj, "elts")) { |
| 5188 int res; | 5371 int res; |
| 5223 } | 5406 } |
| 5224 *out = List(elts, ctx, lineno, col_offset, arena); | 5407 *out = List(elts, ctx, lineno, col_offset, arena); |
| 5225 if (*out == NULL) goto failed; | 5408 if (*out == NULL) goto failed; |
| 5226 return 0; | 5409 return 0; |
| 5227 } | 5410 } |
| 5228 if (PyObject_IsInstance(obj, (PyObject*)Tuple_type)) { | 5411 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type); |
| 5412 if (isinstance == -1) { | |
| 5413 return 1; | |
| 5414 } | |
| 5415 if (isinstance) { | |
| 5229 asdl_seq* elts; | 5416 asdl_seq* elts; |
| 5230 expr_context_ty ctx; | 5417 expr_context_ty ctx; |
| 5231 | 5418 |
| 5232 if (PyObject_HasAttrString(obj, "elts")) { | 5419 if (PyObject_HasAttrString(obj, "elts")) { |
| 5233 int res; | 5420 int res; |
| 5281 | 5468 |
| 5282 int | 5469 int |
| 5283 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) | 5470 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) |
| 5284 { | 5471 { |
| 5285 PyObject* tmp = NULL; | 5472 PyObject* tmp = NULL; |
| 5286 | 5473 int isinstance; |
| 5287 if (PyObject_IsInstance(obj, (PyObject*)Load_type)) { | 5474 |
| 5475 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); | |
| 5476 if (isinstance == -1) { | |
| 5477 return 1; | |
| 5478 } | |
| 5479 if (isinstance) { | |
| 5288 *out = Load; | 5480 *out = Load; |
| 5289 return 0; | 5481 return 0; |
| 5290 } | 5482 } |
| 5291 if (PyObject_IsInstance(obj, (PyObject*)Store_type)) { | 5483 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); |
| 5484 if (isinstance == -1) { | |
| 5485 return 1; | |
| 5486 } | |
| 5487 if (isinstance) { | |
| 5292 *out = Store; | 5488 *out = Store; |
| 5293 return 0; | 5489 return 0; |
| 5294 } | 5490 } |
| 5295 if (PyObject_IsInstance(obj, (PyObject*)Del_type)) { | 5491 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); |
| 5492 if (isinstance == -1) { | |
| 5493 return 1; | |
| 5494 } | |
| 5495 if (isinstance) { | |
| 5296 *out = Del; | 5496 *out = Del; |
| 5297 return 0; | 5497 return 0; |
| 5298 } | 5498 } |
| 5299 if (PyObject_IsInstance(obj, (PyObject*)AugLoad_type)) { | 5499 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); |
| 5500 if (isinstance == -1) { | |
| 5501 return 1; | |
| 5502 } | |
| 5503 if (isinstance) { | |
| 5300 *out = AugLoad; | 5504 *out = AugLoad; |
| 5301 return 0; | 5505 return 0; |
| 5302 } | 5506 } |
| 5303 if (PyObject_IsInstance(obj, (PyObject*)AugStore_type)) { | 5507 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); |
| 5508 if (isinstance == -1) { | |
| 5509 return 1; | |
| 5510 } | |
| 5511 if (isinstance) { | |
| 5304 *out = AugStore; | 5512 *out = AugStore; |
| 5305 return 0; | 5513 return 0; |
| 5306 } | 5514 } |
| 5307 if (PyObject_IsInstance(obj, (PyObject*)Param_type)) { | 5515 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); |
| 5516 if (isinstance == -1) { | |
| 5517 return 1; | |
| 5518 } | |
| 5519 if (isinstance) { | |
| 5308 *out = Param; | 5520 *out = Param; |
| 5309 return 0; | 5521 return 0; |
| 5310 } | 5522 } |
| 5311 | 5523 |
| 5312 tmp = PyObject_Repr(obj); | 5524 tmp = PyObject_Repr(obj); |
| 5319 | 5531 |
| 5320 int | 5532 int |
| 5321 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) | 5533 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) |
| 5322 { | 5534 { |
| 5323 PyObject* tmp = NULL; | 5535 PyObject* tmp = NULL; |
| 5536 int isinstance; | |
| 5324 | 5537 |
| 5325 | 5538 |
| 5326 if (obj == Py_None) { | 5539 if (obj == Py_None) { |
| 5327 *out = NULL; | 5540 *out = NULL; |
| 5328 return 0; | 5541 return 0; |
| 5329 } | 5542 } |
| 5330 if (PyObject_IsInstance(obj, (PyObject*)Ellipsis_type)) { | 5543 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type); |
| 5544 if (isinstance == -1) { | |
| 5545 return 1; | |
| 5546 } | |
| 5547 if (isinstance) { | |
| 5331 | 5548 |
| 5332 *out = Ellipsis(arena); | 5549 *out = Ellipsis(arena); |
| 5333 if (*out == NULL) goto failed; | 5550 if (*out == NULL) goto failed; |
| 5334 return 0; | 5551 return 0; |
| 5335 } | 5552 } |
| 5336 if (PyObject_IsInstance(obj, (PyObject*)Slice_type)) { | 5553 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); |
| 5554 if (isinstance == -1) { | |
| 5555 return 1; | |
| 5556 } | |
| 5557 if (isinstance) { | |
| 5337 expr_ty lower; | 5558 expr_ty lower; |
| 5338 expr_ty upper; | 5559 expr_ty upper; |
| 5339 expr_ty step; | 5560 expr_ty step; |
| 5340 | 5561 |
| 5341 if (PyObject_HasAttrString(obj, "lower")) { | 5562 if (PyObject_HasAttrString(obj, "lower")) { |
| 5373 } | 5594 } |
| 5374 *out = Slice(lower, upper, step, arena); | 5595 *out = Slice(lower, upper, step, arena); |
| 5375 if (*out == NULL) goto failed; | 5596 if (*out == NULL) goto failed; |
| 5376 return 0; | 5597 return 0; |
| 5377 } | 5598 } |
| 5378 if (PyObject_IsInstance(obj, (PyObject*)ExtSlice_type)) { | 5599 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); |
| 5600 if (isinstance == -1) { | |
| 5601 return 1; | |
| 5602 } | |
| 5603 if (isinstance) { | |
| 5379 asdl_seq* dims; | 5604 asdl_seq* dims; |
| 5380 | 5605 |
| 5381 if (PyObject_HasAttrString(obj, "dims")) { | 5606 if (PyObject_HasAttrString(obj, "dims")) { |
| 5382 int res; | 5607 int res; |
| 5383 Py_ssize_t len; | 5608 Py_ssize_t len; |
| 5405 } | 5630 } |
| 5406 *out = ExtSlice(dims, arena); | 5631 *out = ExtSlice(dims, arena); |
| 5407 if (*out == NULL) goto failed; | 5632 if (*out == NULL) goto failed; |
| 5408 return 0; | 5633 return 0; |
| 5409 } | 5634 } |
| 5410 if (PyObject_IsInstance(obj, (PyObject*)Index_type)) { | 5635 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); |
| 5636 if (isinstance == -1) { | |
| 5637 return 1; | |
| 5638 } | |
| 5639 if (isinstance) { | |
| 5411 expr_ty value; | 5640 expr_ty value; |
| 5412 | 5641 |
| 5413 if (PyObject_HasAttrString(obj, "value")) { | 5642 if (PyObject_HasAttrString(obj, "value")) { |
| 5414 int res; | 5643 int res; |
| 5415 tmp = PyObject_GetAttrString(obj, "value"); | 5644 tmp = PyObject_GetAttrString(obj, "value"); |
| 5437 | 5666 |
| 5438 int | 5667 int |
| 5439 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) | 5668 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) |
| 5440 { | 5669 { |
| 5441 PyObject* tmp = NULL; | 5670 PyObject* tmp = NULL; |
| 5442 | 5671 int isinstance; |
| 5443 if (PyObject_IsInstance(obj, (PyObject*)And_type)) { | 5672 |
| 5673 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); | |
| 5674 if (isinstance == -1) { | |
| 5675 return 1; | |
| 5676 } | |
| 5677 if (isinstance) { | |
| 5444 *out = And; | 5678 *out = And; |
| 5445 return 0; | 5679 return 0; |
| 5446 } | 5680 } |
| 5447 if (PyObject_IsInstance(obj, (PyObject*)Or_type)) { | 5681 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); |
| 5682 if (isinstance == -1) { | |
| 5683 return 1; | |
| 5684 } | |
| 5685 if (isinstance) { | |
| 5448 *out = Or; | 5686 *out = Or; |
| 5449 return 0; | 5687 return 0; |
| 5450 } | 5688 } |
| 5451 | 5689 |
| 5452 tmp = PyObject_Repr(obj); | 5690 tmp = PyObject_Repr(obj); |
| 5459 | 5697 |
| 5460 int | 5698 int |
| 5461 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) | 5699 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) |
| 5462 { | 5700 { |
| 5463 PyObject* tmp = NULL; | 5701 PyObject* tmp = NULL; |
| 5464 | 5702 int isinstance; |
| 5465 if (PyObject_IsInstance(obj, (PyObject*)Add_type)) { | 5703 |
| 5704 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); | |
| 5705 if (isinstance == -1) { | |
| 5706 return 1; | |
| 5707 } | |
| 5708 if (isinstance) { | |
| 5466 *out = Add; | 5709 *out = Add; |
| 5467 return 0; | 5710 return 0; |
| 5468 } | 5711 } |
| 5469 if (PyObject_IsInstance(obj, (PyObject*)Sub_type)) { | 5712 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); |
| 5713 if (isinstance == -1) { | |
| 5714 return 1; | |
| 5715 } | |
| 5716 if (isinstance) { | |
| 5470 *out = Sub; | 5717 *out = Sub; |
| 5471 return 0; | 5718 return 0; |
| 5472 } | 5719 } |
| 5473 if (PyObject_IsInstance(obj, (PyObject*)Mult_type)) { | 5720 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); |
| 5721 if (isinstance == -1) { | |
| 5722 return 1; | |
| 5723 } | |
| 5724 if (isinstance) { | |
| 5474 *out = Mult; | 5725 *out = Mult; |
| 5475 return 0; | 5726 return 0; |
| 5476 } | 5727 } |
| 5477 if (PyObject_IsInstance(obj, (PyObject*)Div_type)) { | 5728 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); |
| 5729 if (isinstance == -1) { | |
| 5730 return 1; | |
| 5731 } | |
| 5732 if (isinstance) { | |
| 5478 *out = Div; | 5733 *out = Div; |
| 5479 return 0; | 5734 return 0; |
| 5480 } | 5735 } |
| 5481 if (PyObject_IsInstance(obj, (PyObject*)Mod_type)) { | 5736 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); |
| 5737 if (isinstance == -1) { | |
| 5738 return 1; | |
| 5739 } | |
| 5740 if (isinstance) { | |
| 5482 *out = Mod; | 5741 *out = Mod; |
| 5483 return 0; | 5742 return 0; |
| 5484 } | 5743 } |
| 5485 if (PyObject_IsInstance(obj, (PyObject*)Pow_type)) { | 5744 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); |
| 5745 if (isinstance == -1) { | |
| 5746 return 1; | |
| 5747 } | |
| 5748 if (isinstance) { | |
| 5486 *out = Pow; | 5749 *out = Pow; |
| 5487 return 0; | 5750 return 0; |
| 5488 } | 5751 } |
| 5489 if (PyObject_IsInstance(obj, (PyObject*)LShift_type)) { | 5752 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); |
| 5753 if (isinstance == -1) { | |
| 5754 return 1; | |
| 5755 } | |
| 5756 if (isinstance) { | |
| 5490 *out = LShift; | 5757 *out = LShift; |
| 5491 return 0; | 5758 return 0; |
| 5492 } | 5759 } |
| 5493 if (PyObject_IsInstance(obj, (PyObject*)RShift_type)) { | 5760 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); |
| 5761 if (isinstance == -1) { | |
| 5762 return 1; | |
| 5763 } | |
| 5764 if (isinstance) { | |
| 5494 *out = RShift; | 5765 *out = RShift; |
| 5495 return 0; | 5766 return 0; |
| 5496 } | 5767 } |
| 5497 if (PyObject_IsInstance(obj, (PyObject*)BitOr_type)) { | 5768 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); |
| 5769 if (isinstance == -1) { | |
| 5770 return 1; | |
| 5771 } | |
| 5772 if (isinstance) { | |
| 5498 *out = BitOr; | 5773 *out = BitOr; |
| 5499 return 0; | 5774 return 0; |
| 5500 } | 5775 } |
| 5501 if (PyObject_IsInstance(obj, (PyObject*)BitXor_type)) { | 5776 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); |
| 5777 if (isinstance == -1) { | |
| 5778 return 1; | |
| 5779 } | |
| 5780 if (isinstance) { | |
| 5502 *out = BitXor; | 5781 *out = BitXor; |
| 5503 return 0; | 5782 return 0; |
| 5504 } | 5783 } |
| 5505 if (PyObject_IsInstance(obj, (PyObject*)BitAnd_type)) { | 5784 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); |
| 5785 if (isinstance == -1) { | |
| 5786 return 1; | |
| 5787 } | |
| 5788 if (isinstance) { | |
| 5506 *out = BitAnd; | 5789 *out = BitAnd; |
| 5507 return 0; | 5790 return 0; |
| 5508 } | 5791 } |
| 5509 if (PyObject_IsInstance(obj, (PyObject*)FloorDiv_type)) { | 5792 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); |
| 5793 if (isinstance == -1) { | |
| 5794 return 1; | |
| 5795 } | |
| 5796 if (isinstance) { | |
| 5510 *out = FloorDiv; | 5797 *out = FloorDiv; |
| 5511 return 0; | 5798 return 0; |
| 5512 } | 5799 } |
| 5513 | 5800 |
| 5514 tmp = PyObject_Repr(obj); | 5801 tmp = PyObject_Repr(obj); |
| 5521 | 5808 |
| 5522 int | 5809 int |
| 5523 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) | 5810 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) |
| 5524 { | 5811 { |
| 5525 PyObject* tmp = NULL; | 5812 PyObject* tmp = NULL; |
| 5526 | 5813 int isinstance; |
| 5527 if (PyObject_IsInstance(obj, (PyObject*)Invert_type)) { | 5814 |
| 5815 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); | |
| 5816 if (isinstance == -1) { | |
| 5817 return 1; | |
| 5818 } | |
| 5819 if (isinstance) { | |
| 5528 *out = Invert; | 5820 *out = Invert; |
| 5529 return 0; | 5821 return 0; |
| 5530 } | 5822 } |
| 5531 if (PyObject_IsInstance(obj, (PyObject*)Not_type)) { | 5823 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); |
| 5824 if (isinstance == -1) { | |
| 5825 return 1; | |
| 5826 } | |
| 5827 if (isinstance) { | |
| 5532 *out = Not; | 5828 *out = Not; |
| 5533 return 0; | 5829 return 0; |
| 5534 } | 5830 } |
| 5535 if (PyObject_IsInstance(obj, (PyObject*)UAdd_type)) { | 5831 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); |
| 5832 if (isinstance == -1) { | |
| 5833 return 1; | |
| 5834 } | |
| 5835 if (isinstance) { | |
| 5536 *out = UAdd; | 5836 *out = UAdd; |
| 5537 return 0; | 5837 return 0; |
| 5538 } | 5838 } |
| 5539 if (PyObject_IsInstance(obj, (PyObject*)USub_type)) { | 5839 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); |
| 5840 if (isinstance == -1) { | |
| 5841 return 1; | |
| 5842 } | |
| 5843 if (isinstance) { | |
| 5540 *out = USub; | 5844 *out = USub; |
| 5541 return 0; | 5845 return 0; |
| 5542 } | 5846 } |
| 5543 | 5847 |
| 5544 tmp = PyObject_Repr(obj); | 5848 tmp = PyObject_Repr(obj); |
| 5551 | 5855 |
| 5552 int | 5856 int |
| 5553 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) | 5857 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) |
| 5554 { | 5858 { |
| 5555 PyObject* tmp = NULL; | 5859 PyObject* tmp = NULL; |
| 5556 | 5860 int isinstance; |
| 5557 if (PyObject_IsInstance(obj, (PyObject*)Eq_type)) { | 5861 |
| 5862 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); | |
| 5863 if (isinstance == -1) { | |
| 5864 return 1; | |
| 5865 } | |
| 5866 if (isinstance) { | |
| 5558 *out = Eq; | 5867 *out = Eq; |
| 5559 return 0; | 5868 return 0; |
| 5560 } | 5869 } |
| 5561 if (PyObject_IsInstance(obj, (PyObject*)NotEq_type)) { | 5870 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); |
| 5871 if (isinstance == -1) { | |
| 5872 return 1; | |
| 5873 } | |
| 5874 if (isinstance) { | |
| 5562 *out = NotEq; | 5875 *out = NotEq; |
| 5563 return 0; | 5876 return 0; |
| 5564 } | 5877 } |
| 5565 if (PyObject_IsInstance(obj, (PyObject*)Lt_type)) { | 5878 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); |
| 5879 if (isinstance == -1) { | |
| 5880 return 1; | |
| 5881 } | |
| 5882 if (isinstance) { | |
| 5566 *out = Lt; | 5883 *out = Lt; |
| 5567 return 0; | 5884 return 0; |
| 5568 } | 5885 } |
| 5569 if (PyObject_IsInstance(obj, (PyObject*)LtE_type)) { | 5886 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); |
| 5887 if (isinstance == -1) { | |
| 5888 return 1; | |
| 5889 } | |
| 5890 if (isinstance) { | |
| 5570 *out = LtE; | 5891 *out = LtE; |
| 5571 return 0; | 5892 return 0; |
| 5572 } | 5893 } |
| 5573 if (PyObject_IsInstance(obj, (PyObject*)Gt_type)) { | 5894 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); |
| 5895 if (isinstance == -1) { | |
| 5896 return 1; | |
| 5897 } | |
| 5898 if (isinstance) { | |
| 5574 *out = Gt; | 5899 *out = Gt; |
| 5575 return 0; | 5900 return 0; |
| 5576 } | 5901 } |
| 5577 if (PyObject_IsInstance(obj, (PyObject*)GtE_type)) { | 5902 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); |
| 5903 if (isinstance == -1) { | |
| 5904 return 1; | |
| 5905 } | |
| 5906 if (isinstance) { | |
| 5578 *out = GtE; | 5907 *out = GtE; |
| 5579 return 0; | 5908 return 0; |
| 5580 } | 5909 } |
| 5581 if (PyObject_IsInstance(obj, (PyObject*)Is_type)) { | 5910 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); |
| 5911 if (isinstance == -1) { | |
| 5912 return 1; | |
| 5913 } | |
| 5914 if (isinstance) { | |
| 5582 *out = Is; | 5915 *out = Is; |
| 5583 return 0; | 5916 return 0; |
| 5584 } | 5917 } |
| 5585 if (PyObject_IsInstance(obj, (PyObject*)IsNot_type)) { | 5918 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); |
| 5919 if (isinstance == -1) { | |
| 5920 return 1; | |
| 5921 } | |
| 5922 if (isinstance) { | |
| 5586 *out = IsNot; | 5923 *out = IsNot; |
| 5587 return 0; | 5924 return 0; |
| 5588 } | 5925 } |
| 5589 if (PyObject_IsInstance(obj, (PyObject*)In_type)) { | 5926 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); |
| 5927 if (isinstance == -1) { | |
| 5928 return 1; | |
| 5929 } | |
| 5930 if (isinstance) { | |
| 5590 *out = In; | 5931 *out = In; |
| 5591 return 0; | 5932 return 0; |
| 5592 } | 5933 } |
| 5593 if (PyObject_IsInstance(obj, (PyObject*)NotIn_type)) { | 5934 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); |
| 5935 if (isinstance == -1) { | |
| 5936 return 1; | |
| 5937 } | |
| 5938 if (isinstance) { | |
| 5594 *out = NotIn; | 5939 *out = NotIn; |
| 5595 return 0; | 5940 return 0; |
| 5596 } | 5941 } |
| 5597 | 5942 |
| 5598 tmp = PyObject_Repr(obj); | 5943 tmp = PyObject_Repr(obj); |
| 5669 | 6014 |
| 5670 int | 6015 int |
| 5671 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) | 6016 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) |
| 5672 { | 6017 { |
| 5673 PyObject* tmp = NULL; | 6018 PyObject* tmp = NULL; |
| 6019 int isinstance; | |
| 5674 | 6020 |
| 5675 int lineno; | 6021 int lineno; |
| 5676 int col_offset; | 6022 int col_offset; |
| 5677 | 6023 |
| 5678 if (obj == Py_None) { | 6024 if (obj == Py_None) { |
| 5701 tmp = NULL; | 6047 tmp = NULL; |
| 5702 } else { | 6048 } else { |
| 5703 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); | 6049 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); |
| 5704 return 1; | 6050 return 1; |
| 5705 } | 6051 } |
| 5706 if (PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type)) { | 6052 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type); |
| 6053 if (isinstance == -1) { | |
| 6054 return 1; | |
| 6055 } | |
| 6056 if (isinstance) { | |
| 5707 expr_ty type; | 6057 expr_ty type; |
| 5708 expr_ty name; | 6058 expr_ty name; |
| 5709 asdl_seq* body; | 6059 asdl_seq* body; |
| 5710 | 6060 |
| 5711 if (PyObject_HasAttrString(obj, "type")) { | 6061 if (PyObject_HasAttrString(obj, "type")) { |
| 6102 { | 6452 { |
| 6103 mod_ty res; | 6453 mod_ty res; |
| 6104 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, | 6454 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, |
| 6105 (PyObject*)Interactive_type}; | 6455 (PyObject*)Interactive_type}; |
| 6106 char *req_name[] = {"Module", "Expression", "Interactive"}; | 6456 char *req_name[] = {"Module", "Expression", "Interactive"}; |
| 6457 int isinstance; | |
| 6107 assert(0 <= mode && mode <= 2); | 6458 assert(0 <= mode && mode <= 2); |
| 6108 | 6459 |
| 6109 init_types(); | 6460 init_types(); |
| 6110 | 6461 |
| 6111 if (!PyObject_IsInstance(ast, req_type[mode])) { | 6462 isinstance = PyObject_IsInstance(ast, req_type[mode]); |
| 6463 if (isinstance == -1) | |
| 6464 return NULL; | |
| 6465 if (!isinstance) { | |
| 6112 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", | 6466 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", |
| 6113 req_name[mode], Py_TYPE(ast)->tp_name); | 6467 req_name[mode], Py_TYPE(ast)->tp_name); |
| 6114 return NULL; | 6468 return NULL; |
| 6115 } | 6469 } |
| 6116 if (obj2ast_mod(ast, &res, arena) != 0) | 6470 if (obj2ast_mod(ast, &res, arena) != 0) |
