Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 57674:2b934d466993 2.6
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
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sun, 13 Dec 2009 00:59:01 +0000 |
| parents | 82ccc7e77ec5 |
| children | 86fa95c560a6 b36cb4602e21 |
comparison
equal
deleted
inserted
replaced
| 57668:8690a7eff82a | 57674:2b934d466993 |
|---|---|
| 3178 | 3178 |
| 3179 int | 3179 int |
| 3180 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) | 3180 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) |
| 3181 { | 3181 { |
| 3182 PyObject* tmp = NULL; | 3182 PyObject* tmp = NULL; |
| 3183 int isinstance; | |
| 3183 | 3184 |
| 3184 | 3185 |
| 3185 if (obj == Py_None) { | 3186 if (obj == Py_None) { |
| 3186 *out = NULL; | 3187 *out = NULL; |
| 3187 return 0; | 3188 return 0; |
| 3188 } | 3189 } |
| 3189 if (PyObject_IsInstance(obj, (PyObject*)Module_type)) { | 3190 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); |
| 3191 if (isinstance == -1) { | |
| 3192 return 1; | |
| 3193 } | |
| 3194 if (isinstance) { | |
| 3190 asdl_seq* body; | 3195 asdl_seq* body; |
| 3191 | 3196 |
| 3192 if (PyObject_HasAttrString(obj, "body")) { | 3197 if (PyObject_HasAttrString(obj, "body")) { |
| 3193 int res; | 3198 int res; |
| 3194 Py_ssize_t len; | 3199 Py_ssize_t len; |
| 3216 } | 3221 } |
| 3217 *out = Module(body, arena); | 3222 *out = Module(body, arena); |
| 3218 if (*out == NULL) goto failed; | 3223 if (*out == NULL) goto failed; |
| 3219 return 0; | 3224 return 0; |
| 3220 } | 3225 } |
| 3221 if (PyObject_IsInstance(obj, (PyObject*)Interactive_type)) { | 3226 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); |
| 3227 if (isinstance == -1) { | |
| 3228 return 1; | |
| 3229 } | |
| 3230 if (isinstance) { | |
| 3222 asdl_seq* body; | 3231 asdl_seq* body; |
| 3223 | 3232 |
| 3224 if (PyObject_HasAttrString(obj, "body")) { | 3233 if (PyObject_HasAttrString(obj, "body")) { |
| 3225 int res; | 3234 int res; |
| 3226 Py_ssize_t len; | 3235 Py_ssize_t len; |
| 3248 } | 3257 } |
| 3249 *out = Interactive(body, arena); | 3258 *out = Interactive(body, arena); |
| 3250 if (*out == NULL) goto failed; | 3259 if (*out == NULL) goto failed; |
| 3251 return 0; | 3260 return 0; |
| 3252 } | 3261 } |
| 3253 if (PyObject_IsInstance(obj, (PyObject*)Expression_type)) { | 3262 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); |
| 3263 if (isinstance == -1) { | |
| 3264 return 1; | |
| 3265 } | |
| 3266 if (isinstance) { | |
| 3254 expr_ty body; | 3267 expr_ty body; |
| 3255 | 3268 |
| 3256 if (PyObject_HasAttrString(obj, "body")) { | 3269 if (PyObject_HasAttrString(obj, "body")) { |
| 3257 int res; | 3270 int res; |
| 3258 tmp = PyObject_GetAttrString(obj, "body"); | 3271 tmp = PyObject_GetAttrString(obj, "body"); |
| 3267 } | 3280 } |
| 3268 *out = Expression(body, arena); | 3281 *out = Expression(body, arena); |
| 3269 if (*out == NULL) goto failed; | 3282 if (*out == NULL) goto failed; |
| 3270 return 0; | 3283 return 0; |
| 3271 } | 3284 } |
| 3272 if (PyObject_IsInstance(obj, (PyObject*)Suite_type)) { | 3285 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); |
| 3286 if (isinstance == -1) { | |
| 3287 return 1; | |
| 3288 } | |
| 3289 if (isinstance) { | |
| 3273 asdl_seq* body; | 3290 asdl_seq* body; |
| 3274 | 3291 |
| 3275 if (PyObject_HasAttrString(obj, "body")) { | 3292 if (PyObject_HasAttrString(obj, "body")) { |
| 3276 int res; | 3293 int res; |
| 3277 Py_ssize_t len; | 3294 Py_ssize_t len; |
| 3312 | 3329 |
| 3313 int | 3330 int |
| 3314 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) | 3331 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) |
| 3315 { | 3332 { |
| 3316 PyObject* tmp = NULL; | 3333 PyObject* tmp = NULL; |
| 3334 int isinstance; | |
| 3317 | 3335 |
| 3318 int lineno; | 3336 int lineno; |
| 3319 int col_offset; | 3337 int col_offset; |
| 3320 | 3338 |
| 3321 if (obj == Py_None) { | 3339 if (obj == Py_None) { |
| 3344 tmp = NULL; | 3362 tmp = NULL; |
| 3345 } else { | 3363 } else { |
| 3346 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); | 3364 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); |
| 3347 return 1; | 3365 return 1; |
| 3348 } | 3366 } |
| 3349 if (PyObject_IsInstance(obj, (PyObject*)FunctionDef_type)) { | 3367 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); |
| 3368 if (isinstance == -1) { | |
| 3369 return 1; | |
| 3370 } | |
| 3371 if (isinstance) { | |
| 3350 identifier name; | 3372 identifier name; |
| 3351 arguments_ty args; | 3373 arguments_ty args; |
| 3352 asdl_seq* body; | 3374 asdl_seq* body; |
| 3353 asdl_seq* decorator_list; | 3375 asdl_seq* decorator_list; |
| 3354 | 3376 |
| 3429 *out = FunctionDef(name, args, body, decorator_list, lineno, | 3451 *out = FunctionDef(name, args, body, decorator_list, lineno, |
| 3430 col_offset, arena); | 3452 col_offset, arena); |
| 3431 if (*out == NULL) goto failed; | 3453 if (*out == NULL) goto failed; |
| 3432 return 0; | 3454 return 0; |
| 3433 } | 3455 } |
| 3434 if (PyObject_IsInstance(obj, (PyObject*)ClassDef_type)) { | 3456 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); |
| 3457 if (isinstance == -1) { | |
| 3458 return 1; | |
| 3459 } | |
| 3460 if (isinstance) { | |
| 3435 identifier name; | 3461 identifier name; |
| 3436 asdl_seq* bases; | 3462 asdl_seq* bases; |
| 3437 asdl_seq* body; | 3463 asdl_seq* body; |
| 3438 asdl_seq* decorator_list; | 3464 asdl_seq* decorator_list; |
| 3439 | 3465 |
| 3527 *out = ClassDef(name, bases, body, decorator_list, lineno, | 3553 *out = ClassDef(name, bases, body, decorator_list, lineno, |
| 3528 col_offset, arena); | 3554 col_offset, arena); |
| 3529 if (*out == NULL) goto failed; | 3555 if (*out == NULL) goto failed; |
| 3530 return 0; | 3556 return 0; |
| 3531 } | 3557 } |
| 3532 if (PyObject_IsInstance(obj, (PyObject*)Return_type)) { | 3558 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); |
| 3559 if (isinstance == -1) { | |
| 3560 return 1; | |
| 3561 } | |
| 3562 if (isinstance) { | |
| 3533 expr_ty value; | 3563 expr_ty value; |
| 3534 | 3564 |
| 3535 if (PyObject_HasAttrString(obj, "value")) { | 3565 if (PyObject_HasAttrString(obj, "value")) { |
| 3536 int res; | 3566 int res; |
| 3537 tmp = PyObject_GetAttrString(obj, "value"); | 3567 tmp = PyObject_GetAttrString(obj, "value"); |
| 3545 } | 3575 } |
| 3546 *out = Return(value, lineno, col_offset, arena); | 3576 *out = Return(value, lineno, col_offset, arena); |
| 3547 if (*out == NULL) goto failed; | 3577 if (*out == NULL) goto failed; |
| 3548 return 0; | 3578 return 0; |
| 3549 } | 3579 } |
| 3550 if (PyObject_IsInstance(obj, (PyObject*)Delete_type)) { | 3580 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); |
| 3581 if (isinstance == -1) { | |
| 3582 return 1; | |
| 3583 } | |
| 3584 if (isinstance) { | |
| 3551 asdl_seq* targets; | 3585 asdl_seq* targets; |
| 3552 | 3586 |
| 3553 if (PyObject_HasAttrString(obj, "targets")) { | 3587 if (PyObject_HasAttrString(obj, "targets")) { |
| 3554 int res; | 3588 int res; |
| 3555 Py_ssize_t len; | 3589 Py_ssize_t len; |
| 3577 } | 3611 } |
| 3578 *out = Delete(targets, lineno, col_offset, arena); | 3612 *out = Delete(targets, lineno, col_offset, arena); |
| 3579 if (*out == NULL) goto failed; | 3613 if (*out == NULL) goto failed; |
| 3580 return 0; | 3614 return 0; |
| 3581 } | 3615 } |
| 3582 if (PyObject_IsInstance(obj, (PyObject*)Assign_type)) { | 3616 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); |
| 3617 if (isinstance == -1) { | |
| 3618 return 1; | |
| 3619 } | |
| 3620 if (isinstance) { | |
| 3583 asdl_seq* targets; | 3621 asdl_seq* targets; |
| 3584 expr_ty value; | 3622 expr_ty value; |
| 3585 | 3623 |
| 3586 if (PyObject_HasAttrString(obj, "targets")) { | 3624 if (PyObject_HasAttrString(obj, "targets")) { |
| 3587 int res; | 3625 int res; |
| 3622 } | 3660 } |
| 3623 *out = Assign(targets, value, lineno, col_offset, arena); | 3661 *out = Assign(targets, value, lineno, col_offset, arena); |
| 3624 if (*out == NULL) goto failed; | 3662 if (*out == NULL) goto failed; |
| 3625 return 0; | 3663 return 0; |
| 3626 } | 3664 } |
| 3627 if (PyObject_IsInstance(obj, (PyObject*)AugAssign_type)) { | 3665 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); |
| 3666 if (isinstance == -1) { | |
| 3667 return 1; | |
| 3668 } | |
| 3669 if (isinstance) { | |
| 3628 expr_ty target; | 3670 expr_ty target; |
| 3629 operator_ty op; | 3671 operator_ty op; |
| 3630 expr_ty value; | 3672 expr_ty value; |
| 3631 | 3673 |
| 3632 if (PyObject_HasAttrString(obj, "target")) { | 3674 if (PyObject_HasAttrString(obj, "target")) { |
| 3667 } | 3709 } |
| 3668 *out = AugAssign(target, op, value, lineno, col_offset, arena); | 3710 *out = AugAssign(target, op, value, lineno, col_offset, arena); |
| 3669 if (*out == NULL) goto failed; | 3711 if (*out == NULL) goto failed; |
| 3670 return 0; | 3712 return 0; |
| 3671 } | 3713 } |
| 3672 if (PyObject_IsInstance(obj, (PyObject*)Print_type)) { | 3714 isinstance = PyObject_IsInstance(obj, (PyObject*)Print_type); |
| 3715 if (isinstance == -1) { | |
| 3716 return 1; | |
| 3717 } | |
| 3718 if (isinstance) { | |
| 3673 expr_ty dest; | 3719 expr_ty dest; |
| 3674 asdl_seq* values; | 3720 asdl_seq* values; |
| 3675 bool nl; | 3721 bool nl; |
| 3676 | 3722 |
| 3677 if (PyObject_HasAttrString(obj, "dest")) { | 3723 if (PyObject_HasAttrString(obj, "dest")) { |
| 3724 } | 3770 } |
| 3725 *out = Print(dest, values, nl, lineno, col_offset, arena); | 3771 *out = Print(dest, values, nl, lineno, col_offset, arena); |
| 3726 if (*out == NULL) goto failed; | 3772 if (*out == NULL) goto failed; |
| 3727 return 0; | 3773 return 0; |
| 3728 } | 3774 } |
| 3729 if (PyObject_IsInstance(obj, (PyObject*)For_type)) { | 3775 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); |
| 3776 if (isinstance == -1) { | |
| 3777 return 1; | |
| 3778 } | |
| 3779 if (isinstance) { | |
| 3730 expr_ty target; | 3780 expr_ty target; |
| 3731 expr_ty iter; | 3781 expr_ty iter; |
| 3732 asdl_seq* body; | 3782 asdl_seq* body; |
| 3733 asdl_seq* orelse; | 3783 asdl_seq* orelse; |
| 3734 | 3784 |
| 3809 *out = For(target, iter, body, orelse, lineno, col_offset, | 3859 *out = For(target, iter, body, orelse, lineno, col_offset, |
| 3810 arena); | 3860 arena); |
| 3811 if (*out == NULL) goto failed; | 3861 if (*out == NULL) goto failed; |
| 3812 return 0; | 3862 return 0; |
| 3813 } | 3863 } |
| 3814 if (PyObject_IsInstance(obj, (PyObject*)While_type)) { | 3864 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); |
| 3865 if (isinstance == -1) { | |
| 3866 return 1; | |
| 3867 } | |
| 3868 if (isinstance) { | |
| 3815 expr_ty test; | 3869 expr_ty test; |
| 3816 asdl_seq* body; | 3870 asdl_seq* body; |
| 3817 asdl_seq* orelse; | 3871 asdl_seq* orelse; |
| 3818 | 3872 |
| 3819 if (PyObject_HasAttrString(obj, "test")) { | 3873 if (PyObject_HasAttrString(obj, "test")) { |
| 3880 } | 3934 } |
| 3881 *out = While(test, body, orelse, lineno, col_offset, arena); | 3935 *out = While(test, body, orelse, lineno, col_offset, arena); |
| 3882 if (*out == NULL) goto failed; | 3936 if (*out == NULL) goto failed; |
| 3883 return 0; | 3937 return 0; |
| 3884 } | 3938 } |
| 3885 if (PyObject_IsInstance(obj, (PyObject*)If_type)) { | 3939 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); |
| 3940 if (isinstance == -1) { | |
| 3941 return 1; | |
| 3942 } | |
| 3943 if (isinstance) { | |
| 3886 expr_ty test; | 3944 expr_ty test; |
| 3887 asdl_seq* body; | 3945 asdl_seq* body; |
| 3888 asdl_seq* orelse; | 3946 asdl_seq* orelse; |
| 3889 | 3947 |
| 3890 if (PyObject_HasAttrString(obj, "test")) { | 3948 if (PyObject_HasAttrString(obj, "test")) { |
| 3951 } | 4009 } |
| 3952 *out = If(test, body, orelse, lineno, col_offset, arena); | 4010 *out = If(test, body, orelse, lineno, col_offset, arena); |
| 3953 if (*out == NULL) goto failed; | 4011 if (*out == NULL) goto failed; |
| 3954 return 0; | 4012 return 0; |
| 3955 } | 4013 } |
| 3956 if (PyObject_IsInstance(obj, (PyObject*)With_type)) { | 4014 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); |
| 4015 if (isinstance == -1) { | |
| 4016 return 1; | |
| 4017 } | |
| 4018 if (isinstance) { | |
| 3957 expr_ty context_expr; | 4019 expr_ty context_expr; |
| 3958 expr_ty optional_vars; | 4020 expr_ty optional_vars; |
| 3959 asdl_seq* body; | 4021 asdl_seq* body; |
| 3960 | 4022 |
| 3961 if (PyObject_HasAttrString(obj, "context_expr")) { | 4023 if (PyObject_HasAttrString(obj, "context_expr")) { |
| 4009 *out = With(context_expr, optional_vars, body, lineno, | 4071 *out = With(context_expr, optional_vars, body, lineno, |
| 4010 col_offset, arena); | 4072 col_offset, arena); |
| 4011 if (*out == NULL) goto failed; | 4073 if (*out == NULL) goto failed; |
| 4012 return 0; | 4074 return 0; |
| 4013 } | 4075 } |
| 4014 if (PyObject_IsInstance(obj, (PyObject*)Raise_type)) { | 4076 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); |
| 4077 if (isinstance == -1) { | |
| 4078 return 1; | |
| 4079 } | |
| 4080 if (isinstance) { | |
| 4015 expr_ty type; | 4081 expr_ty type; |
| 4016 expr_ty inst; | 4082 expr_ty inst; |
| 4017 expr_ty tback; | 4083 expr_ty tback; |
| 4018 | 4084 |
| 4019 if (PyObject_HasAttrString(obj, "type")) { | 4085 if (PyObject_HasAttrString(obj, "type")) { |
| 4051 } | 4117 } |
| 4052 *out = Raise(type, inst, tback, lineno, col_offset, arena); | 4118 *out = Raise(type, inst, tback, lineno, col_offset, arena); |
| 4053 if (*out == NULL) goto failed; | 4119 if (*out == NULL) goto failed; |
| 4054 return 0; | 4120 return 0; |
| 4055 } | 4121 } |
| 4056 if (PyObject_IsInstance(obj, (PyObject*)TryExcept_type)) { | 4122 isinstance = PyObject_IsInstance(obj, (PyObject*)TryExcept_type); |
| 4123 if (isinstance == -1) { | |
| 4124 return 1; | |
| 4125 } | |
| 4126 if (isinstance) { | |
| 4057 asdl_seq* body; | 4127 asdl_seq* body; |
| 4058 asdl_seq* handlers; | 4128 asdl_seq* handlers; |
| 4059 asdl_seq* orelse; | 4129 asdl_seq* orelse; |
| 4060 | 4130 |
| 4061 if (PyObject_HasAttrString(obj, "body")) { | 4131 if (PyObject_HasAttrString(obj, "body")) { |
| 4136 *out = TryExcept(body, handlers, orelse, lineno, col_offset, | 4206 *out = TryExcept(body, handlers, orelse, lineno, col_offset, |
| 4137 arena); | 4207 arena); |
| 4138 if (*out == NULL) goto failed; | 4208 if (*out == NULL) goto failed; |
| 4139 return 0; | 4209 return 0; |
| 4140 } | 4210 } |
| 4141 if (PyObject_IsInstance(obj, (PyObject*)TryFinally_type)) { | 4211 isinstance = PyObject_IsInstance(obj, (PyObject*)TryFinally_type); |
| 4212 if (isinstance == -1) { | |
| 4213 return 1; | |
| 4214 } | |
| 4215 if (isinstance) { | |
| 4142 asdl_seq* body; | 4216 asdl_seq* body; |
| 4143 asdl_seq* finalbody; | 4217 asdl_seq* finalbody; |
| 4144 | 4218 |
| 4145 if (PyObject_HasAttrString(obj, "body")) { | 4219 if (PyObject_HasAttrString(obj, "body")) { |
| 4146 int res; | 4220 int res; |
| 4194 } | 4268 } |
| 4195 *out = TryFinally(body, finalbody, lineno, col_offset, arena); | 4269 *out = TryFinally(body, finalbody, lineno, col_offset, arena); |
| 4196 if (*out == NULL) goto failed; | 4270 if (*out == NULL) goto failed; |
| 4197 return 0; | 4271 return 0; |
| 4198 } | 4272 } |
| 4199 if (PyObject_IsInstance(obj, (PyObject*)Assert_type)) { | 4273 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); |
| 4274 if (isinstance == -1) { | |
| 4275 return 1; | |
| 4276 } | |
| 4277 if (isinstance) { | |
| 4200 expr_ty test; | 4278 expr_ty test; |
| 4201 expr_ty msg; | 4279 expr_ty msg; |
| 4202 | 4280 |
| 4203 if (PyObject_HasAttrString(obj, "test")) { | 4281 if (PyObject_HasAttrString(obj, "test")) { |
| 4204 int res; | 4282 int res; |
| 4225 } | 4303 } |
| 4226 *out = Assert(test, msg, lineno, col_offset, arena); | 4304 *out = Assert(test, msg, lineno, col_offset, arena); |
| 4227 if (*out == NULL) goto failed; | 4305 if (*out == NULL) goto failed; |
| 4228 return 0; | 4306 return 0; |
| 4229 } | 4307 } |
| 4230 if (PyObject_IsInstance(obj, (PyObject*)Import_type)) { | 4308 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); |
| 4309 if (isinstance == -1) { | |
| 4310 return 1; | |
| 4311 } | |
| 4312 if (isinstance) { | |
| 4231 asdl_seq* names; | 4313 asdl_seq* names; |
| 4232 | 4314 |
| 4233 if (PyObject_HasAttrString(obj, "names")) { | 4315 if (PyObject_HasAttrString(obj, "names")) { |
| 4234 int res; | 4316 int res; |
| 4235 Py_ssize_t len; | 4317 Py_ssize_t len; |
| 4257 } | 4339 } |
| 4258 *out = Import(names, lineno, col_offset, arena); | 4340 *out = Import(names, lineno, col_offset, arena); |
| 4259 if (*out == NULL) goto failed; | 4341 if (*out == NULL) goto failed; |
| 4260 return 0; | 4342 return 0; |
| 4261 } | 4343 } |
| 4262 if (PyObject_IsInstance(obj, (PyObject*)ImportFrom_type)) { | 4344 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); |
| 4345 if (isinstance == -1) { | |
| 4346 return 1; | |
| 4347 } | |
| 4348 if (isinstance) { | |
| 4263 identifier module; | 4349 identifier module; |
| 4264 asdl_seq* names; | 4350 asdl_seq* names; |
| 4265 int level; | 4351 int level; |
| 4266 | 4352 |
| 4267 if (PyObject_HasAttrString(obj, "module")) { | 4353 if (PyObject_HasAttrString(obj, "module")) { |
| 4315 *out = ImportFrom(module, names, level, lineno, col_offset, | 4401 *out = ImportFrom(module, names, level, lineno, col_offset, |
| 4316 arena); | 4402 arena); |
| 4317 if (*out == NULL) goto failed; | 4403 if (*out == NULL) goto failed; |
| 4318 return 0; | 4404 return 0; |
| 4319 } | 4405 } |
| 4320 if (PyObject_IsInstance(obj, (PyObject*)Exec_type)) { | 4406 isinstance = PyObject_IsInstance(obj, (PyObject*)Exec_type); |
| 4407 if (isinstance == -1) { | |
| 4408 return 1; | |
| 4409 } | |
| 4410 if (isinstance) { | |
| 4321 expr_ty body; | 4411 expr_ty body; |
| 4322 expr_ty globals; | 4412 expr_ty globals; |
| 4323 expr_ty locals; | 4413 expr_ty locals; |
| 4324 | 4414 |
| 4325 if (PyObject_HasAttrString(obj, "body")) { | 4415 if (PyObject_HasAttrString(obj, "body")) { |
| 4358 } | 4448 } |
| 4359 *out = Exec(body, globals, locals, lineno, col_offset, arena); | 4449 *out = Exec(body, globals, locals, lineno, col_offset, arena); |
| 4360 if (*out == NULL) goto failed; | 4450 if (*out == NULL) goto failed; |
| 4361 return 0; | 4451 return 0; |
| 4362 } | 4452 } |
| 4363 if (PyObject_IsInstance(obj, (PyObject*)Global_type)) { | 4453 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); |
| 4454 if (isinstance == -1) { | |
| 4455 return 1; | |
| 4456 } | |
| 4457 if (isinstance) { | |
| 4364 asdl_seq* names; | 4458 asdl_seq* names; |
| 4365 | 4459 |
| 4366 if (PyObject_HasAttrString(obj, "names")) { | 4460 if (PyObject_HasAttrString(obj, "names")) { |
| 4367 int res; | 4461 int res; |
| 4368 Py_ssize_t len; | 4462 Py_ssize_t len; |
| 4390 } | 4484 } |
| 4391 *out = Global(names, lineno, col_offset, arena); | 4485 *out = Global(names, lineno, col_offset, arena); |
| 4392 if (*out == NULL) goto failed; | 4486 if (*out == NULL) goto failed; |
| 4393 return 0; | 4487 return 0; |
| 4394 } | 4488 } |
| 4395 if (PyObject_IsInstance(obj, (PyObject*)Expr_type)) { | 4489 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); |
| 4490 if (isinstance == -1) { | |
| 4491 return 1; | |
| 4492 } | |
| 4493 if (isinstance) { | |
| 4396 expr_ty value; | 4494 expr_ty value; |
| 4397 | 4495 |
| 4398 if (PyObject_HasAttrString(obj, "value")) { | 4496 if (PyObject_HasAttrString(obj, "value")) { |
| 4399 int res; | 4497 int res; |
| 4400 tmp = PyObject_GetAttrString(obj, "value"); | 4498 tmp = PyObject_GetAttrString(obj, "value"); |
| 4409 } | 4507 } |
| 4410 *out = Expr(value, lineno, col_offset, arena); | 4508 *out = Expr(value, lineno, col_offset, arena); |
| 4411 if (*out == NULL) goto failed; | 4509 if (*out == NULL) goto failed; |
| 4412 return 0; | 4510 return 0; |
| 4413 } | 4511 } |
| 4414 if (PyObject_IsInstance(obj, (PyObject*)Pass_type)) { | 4512 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); |
| 4513 if (isinstance == -1) { | |
| 4514 return 1; | |
| 4515 } | |
| 4516 if (isinstance) { | |
| 4415 | 4517 |
| 4416 *out = Pass(lineno, col_offset, arena); | 4518 *out = Pass(lineno, col_offset, arena); |
| 4417 if (*out == NULL) goto failed; | 4519 if (*out == NULL) goto failed; |
| 4418 return 0; | 4520 return 0; |
| 4419 } | 4521 } |
| 4420 if (PyObject_IsInstance(obj, (PyObject*)Break_type)) { | 4522 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); |
| 4523 if (isinstance == -1) { | |
| 4524 return 1; | |
| 4525 } | |
| 4526 if (isinstance) { | |
| 4421 | 4527 |
| 4422 *out = Break(lineno, col_offset, arena); | 4528 *out = Break(lineno, col_offset, arena); |
| 4423 if (*out == NULL) goto failed; | 4529 if (*out == NULL) goto failed; |
| 4424 return 0; | 4530 return 0; |
| 4425 } | 4531 } |
| 4426 if (PyObject_IsInstance(obj, (PyObject*)Continue_type)) { | 4532 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); |
| 4533 if (isinstance == -1) { | |
| 4534 return 1; | |
| 4535 } | |
| 4536 if (isinstance) { | |
| 4427 | 4537 |
| 4428 *out = Continue(lineno, col_offset, arena); | 4538 *out = Continue(lineno, col_offset, arena); |
| 4429 if (*out == NULL) goto failed; | 4539 if (*out == NULL) goto failed; |
| 4430 return 0; | 4540 return 0; |
| 4431 } | 4541 } |
| 4440 | 4550 |
| 4441 int | 4551 int |
| 4442 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) | 4552 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) |
| 4443 { | 4553 { |
| 4444 PyObject* tmp = NULL; | 4554 PyObject* tmp = NULL; |
| 4555 int isinstance; | |
| 4445 | 4556 |
| 4446 int lineno; | 4557 int lineno; |
| 4447 int col_offset; | 4558 int col_offset; |
| 4448 | 4559 |
| 4449 if (obj == Py_None) { | 4560 if (obj == Py_None) { |
| 4472 tmp = NULL; | 4583 tmp = NULL; |
| 4473 } else { | 4584 } else { |
| 4474 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); | 4585 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); |
| 4475 return 1; | 4586 return 1; |
| 4476 } | 4587 } |
| 4477 if (PyObject_IsInstance(obj, (PyObject*)BoolOp_type)) { | 4588 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); |
| 4589 if (isinstance == -1) { | |
| 4590 return 1; | |
| 4591 } | |
| 4592 if (isinstance) { | |
| 4478 boolop_ty op; | 4593 boolop_ty op; |
| 4479 asdl_seq* values; | 4594 asdl_seq* values; |
| 4480 | 4595 |
| 4481 if (PyObject_HasAttrString(obj, "op")) { | 4596 if (PyObject_HasAttrString(obj, "op")) { |
| 4482 int res; | 4597 int res; |
| 4517 } | 4632 } |
| 4518 *out = BoolOp(op, values, lineno, col_offset, arena); | 4633 *out = BoolOp(op, values, lineno, col_offset, arena); |
| 4519 if (*out == NULL) goto failed; | 4634 if (*out == NULL) goto failed; |
| 4520 return 0; | 4635 return 0; |
| 4521 } | 4636 } |
| 4522 if (PyObject_IsInstance(obj, (PyObject*)BinOp_type)) { | 4637 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); |
| 4638 if (isinstance == -1) { | |
| 4639 return 1; | |
| 4640 } | |
| 4641 if (isinstance) { | |
| 4523 expr_ty left; | 4642 expr_ty left; |
| 4524 operator_ty op; | 4643 operator_ty op; |
| 4525 expr_ty right; | 4644 expr_ty right; |
| 4526 | 4645 |
| 4527 if (PyObject_HasAttrString(obj, "left")) { | 4646 if (PyObject_HasAttrString(obj, "left")) { |
| 4562 } | 4681 } |
| 4563 *out = BinOp(left, op, right, lineno, col_offset, arena); | 4682 *out = BinOp(left, op, right, lineno, col_offset, arena); |
| 4564 if (*out == NULL) goto failed; | 4683 if (*out == NULL) goto failed; |
| 4565 return 0; | 4684 return 0; |
| 4566 } | 4685 } |
| 4567 if (PyObject_IsInstance(obj, (PyObject*)UnaryOp_type)) { | 4686 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); |
| 4687 if (isinstance == -1) { | |
| 4688 return 1; | |
| 4689 } | |
| 4690 if (isinstance) { | |
| 4568 unaryop_ty op; | 4691 unaryop_ty op; |
| 4569 expr_ty operand; | 4692 expr_ty operand; |
| 4570 | 4693 |
| 4571 if (PyObject_HasAttrString(obj, "op")) { | 4694 if (PyObject_HasAttrString(obj, "op")) { |
| 4572 int res; | 4695 int res; |
| 4594 } | 4717 } |
| 4595 *out = UnaryOp(op, operand, lineno, col_offset, arena); | 4718 *out = UnaryOp(op, operand, lineno, col_offset, arena); |
| 4596 if (*out == NULL) goto failed; | 4719 if (*out == NULL) goto failed; |
| 4597 return 0; | 4720 return 0; |
| 4598 } | 4721 } |
| 4599 if (PyObject_IsInstance(obj, (PyObject*)Lambda_type)) { | 4722 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); |
| 4723 if (isinstance == -1) { | |
| 4724 return 1; | |
| 4725 } | |
| 4726 if (isinstance) { | |
| 4600 arguments_ty args; | 4727 arguments_ty args; |
| 4601 expr_ty body; | 4728 expr_ty body; |
| 4602 | 4729 |
| 4603 if (PyObject_HasAttrString(obj, "args")) { | 4730 if (PyObject_HasAttrString(obj, "args")) { |
| 4604 int res; | 4731 int res; |
| 4626 } | 4753 } |
| 4627 *out = Lambda(args, body, lineno, col_offset, arena); | 4754 *out = Lambda(args, body, lineno, col_offset, arena); |
| 4628 if (*out == NULL) goto failed; | 4755 if (*out == NULL) goto failed; |
| 4629 return 0; | 4756 return 0; |
| 4630 } | 4757 } |
| 4631 if (PyObject_IsInstance(obj, (PyObject*)IfExp_type)) { | 4758 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); |
| 4759 if (isinstance == -1) { | |
| 4760 return 1; | |
| 4761 } | |
| 4762 if (isinstance) { | |
| 4632 expr_ty test; | 4763 expr_ty test; |
| 4633 expr_ty body; | 4764 expr_ty body; |
| 4634 expr_ty orelse; | 4765 expr_ty orelse; |
| 4635 | 4766 |
| 4636 if (PyObject_HasAttrString(obj, "test")) { | 4767 if (PyObject_HasAttrString(obj, "test")) { |
| 4671 } | 4802 } |
| 4672 *out = IfExp(test, body, orelse, lineno, col_offset, arena); | 4803 *out = IfExp(test, body, orelse, lineno, col_offset, arena); |
| 4673 if (*out == NULL) goto failed; | 4804 if (*out == NULL) goto failed; |
| 4674 return 0; | 4805 return 0; |
| 4675 } | 4806 } |
| 4676 if (PyObject_IsInstance(obj, (PyObject*)Dict_type)) { | 4807 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); |
| 4808 if (isinstance == -1) { | |
| 4809 return 1; | |
| 4810 } | |
| 4811 if (isinstance) { | |
| 4677 asdl_seq* keys; | 4812 asdl_seq* keys; |
| 4678 asdl_seq* values; | 4813 asdl_seq* values; |
| 4679 | 4814 |
| 4680 if (PyObject_HasAttrString(obj, "keys")) { | 4815 if (PyObject_HasAttrString(obj, "keys")) { |
| 4681 int res; | 4816 int res; |
| 4729 } | 4864 } |
| 4730 *out = Dict(keys, values, lineno, col_offset, arena); | 4865 *out = Dict(keys, values, lineno, col_offset, arena); |
| 4731 if (*out == NULL) goto failed; | 4866 if (*out == NULL) goto failed; |
| 4732 return 0; | 4867 return 0; |
| 4733 } | 4868 } |
| 4734 if (PyObject_IsInstance(obj, (PyObject*)ListComp_type)) { | 4869 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type); |
| 4870 if (isinstance == -1) { | |
| 4871 return 1; | |
| 4872 } | |
| 4873 if (isinstance) { | |
| 4735 expr_ty elt; | 4874 expr_ty elt; |
| 4736 asdl_seq* generators; | 4875 asdl_seq* generators; |
| 4737 | 4876 |
| 4738 if (PyObject_HasAttrString(obj, "elt")) { | 4877 if (PyObject_HasAttrString(obj, "elt")) { |
| 4739 int res; | 4878 int res; |
| 4774 } | 4913 } |
| 4775 *out = ListComp(elt, generators, lineno, col_offset, arena); | 4914 *out = ListComp(elt, generators, lineno, col_offset, arena); |
| 4776 if (*out == NULL) goto failed; | 4915 if (*out == NULL) goto failed; |
| 4777 return 0; | 4916 return 0; |
| 4778 } | 4917 } |
| 4779 if (PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type)) { | 4918 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type); |
| 4919 if (isinstance == -1) { | |
| 4920 return 1; | |
| 4921 } | |
| 4922 if (isinstance) { | |
| 4780 expr_ty elt; | 4923 expr_ty elt; |
| 4781 asdl_seq* generators; | 4924 asdl_seq* generators; |
| 4782 | 4925 |
| 4783 if (PyObject_HasAttrString(obj, "elt")) { | 4926 if (PyObject_HasAttrString(obj, "elt")) { |
| 4784 int res; | 4927 int res; |
| 4819 } | 4962 } |
| 4820 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); | 4963 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); |
| 4821 if (*out == NULL) goto failed; | 4964 if (*out == NULL) goto failed; |
| 4822 return 0; | 4965 return 0; |
| 4823 } | 4966 } |
| 4824 if (PyObject_IsInstance(obj, (PyObject*)Yield_type)) { | 4967 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type); |
| 4968 if (isinstance == -1) { | |
| 4969 return 1; | |
| 4970 } | |
| 4971 if (isinstance) { | |
| 4825 expr_ty value; | 4972 expr_ty value; |
| 4826 | 4973 |
| 4827 if (PyObject_HasAttrString(obj, "value")) { | 4974 if (PyObject_HasAttrString(obj, "value")) { |
| 4828 int res; | 4975 int res; |
| 4829 tmp = PyObject_GetAttrString(obj, "value"); | 4976 tmp = PyObject_GetAttrString(obj, "value"); |
| 4837 } | 4984 } |
| 4838 *out = Yield(value, lineno, col_offset, arena); | 4985 *out = Yield(value, lineno, col_offset, arena); |
| 4839 if (*out == NULL) goto failed; | 4986 if (*out == NULL) goto failed; |
| 4840 return 0; | 4987 return 0; |
| 4841 } | 4988 } |
| 4842 if (PyObject_IsInstance(obj, (PyObject*)Compare_type)) { | 4989 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); |
| 4990 if (isinstance == -1) { | |
| 4991 return 1; | |
| 4992 } | |
| 4993 if (isinstance) { | |
| 4843 expr_ty left; | 4994 expr_ty left; |
| 4844 asdl_int_seq* ops; | 4995 asdl_int_seq* ops; |
| 4845 asdl_seq* comparators; | 4996 asdl_seq* comparators; |
| 4846 | 4997 |
| 4847 if (PyObject_HasAttrString(obj, "left")) { | 4998 if (PyObject_HasAttrString(obj, "left")) { |
| 4909 *out = Compare(left, ops, comparators, lineno, col_offset, | 5060 *out = Compare(left, ops, comparators, lineno, col_offset, |
| 4910 arena); | 5061 arena); |
| 4911 if (*out == NULL) goto failed; | 5062 if (*out == NULL) goto failed; |
| 4912 return 0; | 5063 return 0; |
| 4913 } | 5064 } |
| 4914 if (PyObject_IsInstance(obj, (PyObject*)Call_type)) { | 5065 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type); |
| 5066 if (isinstance == -1) { | |
| 5067 return 1; | |
| 5068 } | |
| 5069 if (isinstance) { | |
| 4915 expr_ty func; | 5070 expr_ty func; |
| 4916 asdl_seq* args; | 5071 asdl_seq* args; |
| 4917 asdl_seq* keywords; | 5072 asdl_seq* keywords; |
| 4918 expr_ty starargs; | 5073 expr_ty starargs; |
| 4919 expr_ty kwargs; | 5074 expr_ty kwargs; |
| 5005 *out = Call(func, args, keywords, starargs, kwargs, lineno, | 5160 *out = Call(func, args, keywords, starargs, kwargs, lineno, |
| 5006 col_offset, arena); | 5161 col_offset, arena); |
| 5007 if (*out == NULL) goto failed; | 5162 if (*out == NULL) goto failed; |
| 5008 return 0; | 5163 return 0; |
| 5009 } | 5164 } |
| 5010 if (PyObject_IsInstance(obj, (PyObject*)Repr_type)) { | 5165 isinstance = PyObject_IsInstance(obj, (PyObject*)Repr_type); |
| 5166 if (isinstance == -1) { | |
| 5167 return 1; | |
| 5168 } | |
| 5169 if (isinstance) { | |
| 5011 expr_ty value; | 5170 expr_ty value; |
| 5012 | 5171 |
| 5013 if (PyObject_HasAttrString(obj, "value")) { | 5172 if (PyObject_HasAttrString(obj, "value")) { |
| 5014 int res; | 5173 int res; |
| 5015 tmp = PyObject_GetAttrString(obj, "value"); | 5174 tmp = PyObject_GetAttrString(obj, "value"); |
| 5024 } | 5183 } |
| 5025 *out = Repr(value, lineno, col_offset, arena); | 5184 *out = Repr(value, lineno, col_offset, arena); |
| 5026 if (*out == NULL) goto failed; | 5185 if (*out == NULL) goto failed; |
| 5027 return 0; | 5186 return 0; |
| 5028 } | 5187 } |
| 5029 if (PyObject_IsInstance(obj, (PyObject*)Num_type)) { | 5188 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type); |
| 5189 if (isinstance == -1) { | |
| 5190 return 1; | |
| 5191 } | |
| 5192 if (isinstance) { | |
| 5030 object n; | 5193 object n; |
| 5031 | 5194 |
| 5032 if (PyObject_HasAttrString(obj, "n")) { | 5195 if (PyObject_HasAttrString(obj, "n")) { |
| 5033 int res; | 5196 int res; |
| 5034 tmp = PyObject_GetAttrString(obj, "n"); | 5197 tmp = PyObject_GetAttrString(obj, "n"); |
| 5043 } | 5206 } |
| 5044 *out = Num(n, lineno, col_offset, arena); | 5207 *out = Num(n, lineno, col_offset, arena); |
| 5045 if (*out == NULL) goto failed; | 5208 if (*out == NULL) goto failed; |
| 5046 return 0; | 5209 return 0; |
| 5047 } | 5210 } |
| 5048 if (PyObject_IsInstance(obj, (PyObject*)Str_type)) { | 5211 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type); |
| 5212 if (isinstance == -1) { | |
| 5213 return 1; | |
| 5214 } | |
| 5215 if (isinstance) { | |
| 5049 string s; | 5216 string s; |
| 5050 | 5217 |
| 5051 if (PyObject_HasAttrString(obj, "s")) { | 5218 if (PyObject_HasAttrString(obj, "s")) { |
| 5052 int res; | 5219 int res; |
| 5053 tmp = PyObject_GetAttrString(obj, "s"); | 5220 tmp = PyObject_GetAttrString(obj, "s"); |
| 5062 } | 5229 } |
| 5063 *out = Str(s, lineno, col_offset, arena); | 5230 *out = Str(s, lineno, col_offset, arena); |
| 5064 if (*out == NULL) goto failed; | 5231 if (*out == NULL) goto failed; |
| 5065 return 0; | 5232 return 0; |
| 5066 } | 5233 } |
| 5067 if (PyObject_IsInstance(obj, (PyObject*)Attribute_type)) { | 5234 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type); |
| 5235 if (isinstance == -1) { | |
| 5236 return 1; | |
| 5237 } | |
| 5238 if (isinstance) { | |
| 5068 expr_ty value; | 5239 expr_ty value; |
| 5069 identifier attr; | 5240 identifier attr; |
| 5070 expr_context_ty ctx; | 5241 expr_context_ty ctx; |
| 5071 | 5242 |
| 5072 if (PyObject_HasAttrString(obj, "value")) { | 5243 if (PyObject_HasAttrString(obj, "value")) { |
| 5107 } | 5278 } |
| 5108 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); | 5279 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); |
| 5109 if (*out == NULL) goto failed; | 5280 if (*out == NULL) goto failed; |
| 5110 return 0; | 5281 return 0; |
| 5111 } | 5282 } |
| 5112 if (PyObject_IsInstance(obj, (PyObject*)Subscript_type)) { | 5283 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); |
| 5284 if (isinstance == -1) { | |
| 5285 return 1; | |
| 5286 } | |
| 5287 if (isinstance) { | |
| 5113 expr_ty value; | 5288 expr_ty value; |
| 5114 slice_ty slice; | 5289 slice_ty slice; |
| 5115 expr_context_ty ctx; | 5290 expr_context_ty ctx; |
| 5116 | 5291 |
| 5117 if (PyObject_HasAttrString(obj, "value")) { | 5292 if (PyObject_HasAttrString(obj, "value")) { |
| 5152 } | 5327 } |
| 5153 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); | 5328 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); |
| 5154 if (*out == NULL) goto failed; | 5329 if (*out == NULL) goto failed; |
| 5155 return 0; | 5330 return 0; |
| 5156 } | 5331 } |
| 5157 if (PyObject_IsInstance(obj, (PyObject*)Name_type)) { | 5332 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); |
| 5333 if (isinstance == -1) { | |
| 5334 return 1; | |
| 5335 } | |
| 5336 if (isinstance) { | |
| 5158 identifier id; | 5337 identifier id; |
| 5159 expr_context_ty ctx; | 5338 expr_context_ty ctx; |
| 5160 | 5339 |
| 5161 if (PyObject_HasAttrString(obj, "id")) { | 5340 if (PyObject_HasAttrString(obj, "id")) { |
| 5162 int res; | 5341 int res; |
| 5184 } | 5363 } |
| 5185 *out = Name(id, ctx, lineno, col_offset, arena); | 5364 *out = Name(id, ctx, lineno, col_offset, arena); |
| 5186 if (*out == NULL) goto failed; | 5365 if (*out == NULL) goto failed; |
| 5187 return 0; | 5366 return 0; |
| 5188 } | 5367 } |
| 5189 if (PyObject_IsInstance(obj, (PyObject*)List_type)) { | 5368 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type); |
| 5369 if (isinstance == -1) { | |
| 5370 return 1; | |
| 5371 } | |
| 5372 if (isinstance) { | |
| 5190 asdl_seq* elts; | 5373 asdl_seq* elts; |
| 5191 expr_context_ty ctx; | 5374 expr_context_ty ctx; |
| 5192 | 5375 |
| 5193 if (PyObject_HasAttrString(obj, "elts")) { | 5376 if (PyObject_HasAttrString(obj, "elts")) { |
| 5194 int res; | 5377 int res; |
| 5229 } | 5412 } |
| 5230 *out = List(elts, ctx, lineno, col_offset, arena); | 5413 *out = List(elts, ctx, lineno, col_offset, arena); |
| 5231 if (*out == NULL) goto failed; | 5414 if (*out == NULL) goto failed; |
| 5232 return 0; | 5415 return 0; |
| 5233 } | 5416 } |
| 5234 if (PyObject_IsInstance(obj, (PyObject*)Tuple_type)) { | 5417 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type); |
| 5418 if (isinstance == -1) { | |
| 5419 return 1; | |
| 5420 } | |
| 5421 if (isinstance) { | |
| 5235 asdl_seq* elts; | 5422 asdl_seq* elts; |
| 5236 expr_context_ty ctx; | 5423 expr_context_ty ctx; |
| 5237 | 5424 |
| 5238 if (PyObject_HasAttrString(obj, "elts")) { | 5425 if (PyObject_HasAttrString(obj, "elts")) { |
| 5239 int res; | 5426 int res; |
| 5287 | 5474 |
| 5288 int | 5475 int |
| 5289 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) | 5476 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) |
| 5290 { | 5477 { |
| 5291 PyObject* tmp = NULL; | 5478 PyObject* tmp = NULL; |
| 5292 | 5479 int isinstance; |
| 5293 if (PyObject_IsInstance(obj, (PyObject*)Load_type)) { | 5480 |
| 5481 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); | |
| 5482 if (isinstance == -1) { | |
| 5483 return 1; | |
| 5484 } | |
| 5485 if (isinstance) { | |
| 5294 *out = Load; | 5486 *out = Load; |
| 5295 return 0; | 5487 return 0; |
| 5296 } | 5488 } |
| 5297 if (PyObject_IsInstance(obj, (PyObject*)Store_type)) { | 5489 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); |
| 5490 if (isinstance == -1) { | |
| 5491 return 1; | |
| 5492 } | |
| 5493 if (isinstance) { | |
| 5298 *out = Store; | 5494 *out = Store; |
| 5299 return 0; | 5495 return 0; |
| 5300 } | 5496 } |
| 5301 if (PyObject_IsInstance(obj, (PyObject*)Del_type)) { | 5497 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); |
| 5498 if (isinstance == -1) { | |
| 5499 return 1; | |
| 5500 } | |
| 5501 if (isinstance) { | |
| 5302 *out = Del; | 5502 *out = Del; |
| 5303 return 0; | 5503 return 0; |
| 5304 } | 5504 } |
| 5305 if (PyObject_IsInstance(obj, (PyObject*)AugLoad_type)) { | 5505 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); |
| 5506 if (isinstance == -1) { | |
| 5507 return 1; | |
| 5508 } | |
| 5509 if (isinstance) { | |
| 5306 *out = AugLoad; | 5510 *out = AugLoad; |
| 5307 return 0; | 5511 return 0; |
| 5308 } | 5512 } |
| 5309 if (PyObject_IsInstance(obj, (PyObject*)AugStore_type)) { | 5513 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); |
| 5514 if (isinstance == -1) { | |
| 5515 return 1; | |
| 5516 } | |
| 5517 if (isinstance) { | |
| 5310 *out = AugStore; | 5518 *out = AugStore; |
| 5311 return 0; | 5519 return 0; |
| 5312 } | 5520 } |
| 5313 if (PyObject_IsInstance(obj, (PyObject*)Param_type)) { | 5521 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); |
| 5522 if (isinstance == -1) { | |
| 5523 return 1; | |
| 5524 } | |
| 5525 if (isinstance) { | |
| 5314 *out = Param; | 5526 *out = Param; |
| 5315 return 0; | 5527 return 0; |
| 5316 } | 5528 } |
| 5317 | 5529 |
| 5318 tmp = PyObject_Repr(obj); | 5530 tmp = PyObject_Repr(obj); |
| 5325 | 5537 |
| 5326 int | 5538 int |
| 5327 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) | 5539 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) |
| 5328 { | 5540 { |
| 5329 PyObject* tmp = NULL; | 5541 PyObject* tmp = NULL; |
| 5542 int isinstance; | |
| 5330 | 5543 |
| 5331 | 5544 |
| 5332 if (obj == Py_None) { | 5545 if (obj == Py_None) { |
| 5333 *out = NULL; | 5546 *out = NULL; |
| 5334 return 0; | 5547 return 0; |
| 5335 } | 5548 } |
| 5336 if (PyObject_IsInstance(obj, (PyObject*)Ellipsis_type)) { | 5549 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type); |
| 5550 if (isinstance == -1) { | |
| 5551 return 1; | |
| 5552 } | |
| 5553 if (isinstance) { | |
| 5337 | 5554 |
| 5338 *out = Ellipsis(arena); | 5555 *out = Ellipsis(arena); |
| 5339 if (*out == NULL) goto failed; | 5556 if (*out == NULL) goto failed; |
| 5340 return 0; | 5557 return 0; |
| 5341 } | 5558 } |
| 5342 if (PyObject_IsInstance(obj, (PyObject*)Slice_type)) { | 5559 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); |
| 5560 if (isinstance == -1) { | |
| 5561 return 1; | |
| 5562 } | |
| 5563 if (isinstance) { | |
| 5343 expr_ty lower; | 5564 expr_ty lower; |
| 5344 expr_ty upper; | 5565 expr_ty upper; |
| 5345 expr_ty step; | 5566 expr_ty step; |
| 5346 | 5567 |
| 5347 if (PyObject_HasAttrString(obj, "lower")) { | 5568 if (PyObject_HasAttrString(obj, "lower")) { |
| 5379 } | 5600 } |
| 5380 *out = Slice(lower, upper, step, arena); | 5601 *out = Slice(lower, upper, step, arena); |
| 5381 if (*out == NULL) goto failed; | 5602 if (*out == NULL) goto failed; |
| 5382 return 0; | 5603 return 0; |
| 5383 } | 5604 } |
| 5384 if (PyObject_IsInstance(obj, (PyObject*)ExtSlice_type)) { | 5605 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); |
| 5606 if (isinstance == -1) { | |
| 5607 return 1; | |
| 5608 } | |
| 5609 if (isinstance) { | |
| 5385 asdl_seq* dims; | 5610 asdl_seq* dims; |
| 5386 | 5611 |
| 5387 if (PyObject_HasAttrString(obj, "dims")) { | 5612 if (PyObject_HasAttrString(obj, "dims")) { |
| 5388 int res; | 5613 int res; |
| 5389 Py_ssize_t len; | 5614 Py_ssize_t len; |
| 5411 } | 5636 } |
| 5412 *out = ExtSlice(dims, arena); | 5637 *out = ExtSlice(dims, arena); |
| 5413 if (*out == NULL) goto failed; | 5638 if (*out == NULL) goto failed; |
| 5414 return 0; | 5639 return 0; |
| 5415 } | 5640 } |
| 5416 if (PyObject_IsInstance(obj, (PyObject*)Index_type)) { | 5641 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); |
| 5642 if (isinstance == -1) { | |
| 5643 return 1; | |
| 5644 } | |
| 5645 if (isinstance) { | |
| 5417 expr_ty value; | 5646 expr_ty value; |
| 5418 | 5647 |
| 5419 if (PyObject_HasAttrString(obj, "value")) { | 5648 if (PyObject_HasAttrString(obj, "value")) { |
| 5420 int res; | 5649 int res; |
| 5421 tmp = PyObject_GetAttrString(obj, "value"); | 5650 tmp = PyObject_GetAttrString(obj, "value"); |
| 5443 | 5672 |
| 5444 int | 5673 int |
| 5445 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) | 5674 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) |
| 5446 { | 5675 { |
| 5447 PyObject* tmp = NULL; | 5676 PyObject* tmp = NULL; |
| 5448 | 5677 int isinstance; |
| 5449 if (PyObject_IsInstance(obj, (PyObject*)And_type)) { | 5678 |
| 5679 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); | |
| 5680 if (isinstance == -1) { | |
| 5681 return 1; | |
| 5682 } | |
| 5683 if (isinstance) { | |
| 5450 *out = And; | 5684 *out = And; |
| 5451 return 0; | 5685 return 0; |
| 5452 } | 5686 } |
| 5453 if (PyObject_IsInstance(obj, (PyObject*)Or_type)) { | 5687 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); |
| 5688 if (isinstance == -1) { | |
| 5689 return 1; | |
| 5690 } | |
| 5691 if (isinstance) { | |
| 5454 *out = Or; | 5692 *out = Or; |
| 5455 return 0; | 5693 return 0; |
| 5456 } | 5694 } |
| 5457 | 5695 |
| 5458 tmp = PyObject_Repr(obj); | 5696 tmp = PyObject_Repr(obj); |
| 5465 | 5703 |
| 5466 int | 5704 int |
| 5467 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) | 5705 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) |
| 5468 { | 5706 { |
| 5469 PyObject* tmp = NULL; | 5707 PyObject* tmp = NULL; |
| 5470 | 5708 int isinstance; |
| 5471 if (PyObject_IsInstance(obj, (PyObject*)Add_type)) { | 5709 |
| 5710 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); | |
| 5711 if (isinstance == -1) { | |
| 5712 return 1; | |
| 5713 } | |
| 5714 if (isinstance) { | |
| 5472 *out = Add; | 5715 *out = Add; |
| 5473 return 0; | 5716 return 0; |
| 5474 } | 5717 } |
| 5475 if (PyObject_IsInstance(obj, (PyObject*)Sub_type)) { | 5718 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); |
| 5719 if (isinstance == -1) { | |
| 5720 return 1; | |
| 5721 } | |
| 5722 if (isinstance) { | |
| 5476 *out = Sub; | 5723 *out = Sub; |
| 5477 return 0; | 5724 return 0; |
| 5478 } | 5725 } |
| 5479 if (PyObject_IsInstance(obj, (PyObject*)Mult_type)) { | 5726 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); |
| 5727 if (isinstance == -1) { | |
| 5728 return 1; | |
| 5729 } | |
| 5730 if (isinstance) { | |
| 5480 *out = Mult; | 5731 *out = Mult; |
| 5481 return 0; | 5732 return 0; |
| 5482 } | 5733 } |
| 5483 if (PyObject_IsInstance(obj, (PyObject*)Div_type)) { | 5734 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); |
| 5735 if (isinstance == -1) { | |
| 5736 return 1; | |
| 5737 } | |
| 5738 if (isinstance) { | |
| 5484 *out = Div; | 5739 *out = Div; |
| 5485 return 0; | 5740 return 0; |
| 5486 } | 5741 } |
| 5487 if (PyObject_IsInstance(obj, (PyObject*)Mod_type)) { | 5742 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); |
| 5743 if (isinstance == -1) { | |
| 5744 return 1; | |
| 5745 } | |
| 5746 if (isinstance) { | |
| 5488 *out = Mod; | 5747 *out = Mod; |
| 5489 return 0; | 5748 return 0; |
| 5490 } | 5749 } |
| 5491 if (PyObject_IsInstance(obj, (PyObject*)Pow_type)) { | 5750 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); |
| 5751 if (isinstance == -1) { | |
| 5752 return 1; | |
| 5753 } | |
| 5754 if (isinstance) { | |
| 5492 *out = Pow; | 5755 *out = Pow; |
| 5493 return 0; | 5756 return 0; |
| 5494 } | 5757 } |
| 5495 if (PyObject_IsInstance(obj, (PyObject*)LShift_type)) { | 5758 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); |
| 5759 if (isinstance == -1) { | |
| 5760 return 1; | |
| 5761 } | |
| 5762 if (isinstance) { | |
| 5496 *out = LShift; | 5763 *out = LShift; |
| 5497 return 0; | 5764 return 0; |
| 5498 } | 5765 } |
| 5499 if (PyObject_IsInstance(obj, (PyObject*)RShift_type)) { | 5766 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); |
| 5767 if (isinstance == -1) { | |
| 5768 return 1; | |
| 5769 } | |
| 5770 if (isinstance) { | |
| 5500 *out = RShift; | 5771 *out = RShift; |
| 5501 return 0; | 5772 return 0; |
| 5502 } | 5773 } |
| 5503 if (PyObject_IsInstance(obj, (PyObject*)BitOr_type)) { | 5774 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); |
| 5775 if (isinstance == -1) { | |
| 5776 return 1; | |
| 5777 } | |
| 5778 if (isinstance) { | |
| 5504 *out = BitOr; | 5779 *out = BitOr; |
| 5505 return 0; | 5780 return 0; |
| 5506 } | 5781 } |
| 5507 if (PyObject_IsInstance(obj, (PyObject*)BitXor_type)) { | 5782 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); |
| 5783 if (isinstance == -1) { | |
| 5784 return 1; | |
| 5785 } | |
| 5786 if (isinstance) { | |
| 5508 *out = BitXor; | 5787 *out = BitXor; |
| 5509 return 0; | 5788 return 0; |
| 5510 } | 5789 } |
| 5511 if (PyObject_IsInstance(obj, (PyObject*)BitAnd_type)) { | 5790 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); |
| 5791 if (isinstance == -1) { | |
| 5792 return 1; | |
| 5793 } | |
| 5794 if (isinstance) { | |
| 5512 *out = BitAnd; | 5795 *out = BitAnd; |
| 5513 return 0; | 5796 return 0; |
| 5514 } | 5797 } |
| 5515 if (PyObject_IsInstance(obj, (PyObject*)FloorDiv_type)) { | 5798 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); |
| 5799 if (isinstance == -1) { | |
| 5800 return 1; | |
| 5801 } | |
| 5802 if (isinstance) { | |
| 5516 *out = FloorDiv; | 5803 *out = FloorDiv; |
| 5517 return 0; | 5804 return 0; |
| 5518 } | 5805 } |
| 5519 | 5806 |
| 5520 tmp = PyObject_Repr(obj); | 5807 tmp = PyObject_Repr(obj); |
| 5527 | 5814 |
| 5528 int | 5815 int |
| 5529 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) | 5816 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) |
| 5530 { | 5817 { |
| 5531 PyObject* tmp = NULL; | 5818 PyObject* tmp = NULL; |
| 5532 | 5819 int isinstance; |
| 5533 if (PyObject_IsInstance(obj, (PyObject*)Invert_type)) { | 5820 |
| 5821 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); | |
| 5822 if (isinstance == -1) { | |
| 5823 return 1; | |
| 5824 } | |
| 5825 if (isinstance) { | |
| 5534 *out = Invert; | 5826 *out = Invert; |
| 5535 return 0; | 5827 return 0; |
| 5536 } | 5828 } |
| 5537 if (PyObject_IsInstance(obj, (PyObject*)Not_type)) { | 5829 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); |
| 5830 if (isinstance == -1) { | |
| 5831 return 1; | |
| 5832 } | |
| 5833 if (isinstance) { | |
| 5538 *out = Not; | 5834 *out = Not; |
| 5539 return 0; | 5835 return 0; |
| 5540 } | 5836 } |
| 5541 if (PyObject_IsInstance(obj, (PyObject*)UAdd_type)) { | 5837 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); |
| 5838 if (isinstance == -1) { | |
| 5839 return 1; | |
| 5840 } | |
| 5841 if (isinstance) { | |
| 5542 *out = UAdd; | 5842 *out = UAdd; |
| 5543 return 0; | 5843 return 0; |
| 5544 } | 5844 } |
| 5545 if (PyObject_IsInstance(obj, (PyObject*)USub_type)) { | 5845 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); |
| 5846 if (isinstance == -1) { | |
| 5847 return 1; | |
| 5848 } | |
| 5849 if (isinstance) { | |
| 5546 *out = USub; | 5850 *out = USub; |
| 5547 return 0; | 5851 return 0; |
| 5548 } | 5852 } |
| 5549 | 5853 |
| 5550 tmp = PyObject_Repr(obj); | 5854 tmp = PyObject_Repr(obj); |
| 5557 | 5861 |
| 5558 int | 5862 int |
| 5559 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) | 5863 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) |
| 5560 { | 5864 { |
| 5561 PyObject* tmp = NULL; | 5865 PyObject* tmp = NULL; |
| 5562 | 5866 int isinstance; |
| 5563 if (PyObject_IsInstance(obj, (PyObject*)Eq_type)) { | 5867 |
| 5868 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); | |
| 5869 if (isinstance == -1) { | |
| 5870 return 1; | |
| 5871 } | |
| 5872 if (isinstance) { | |
| 5564 *out = Eq; | 5873 *out = Eq; |
| 5565 return 0; | 5874 return 0; |
| 5566 } | 5875 } |
| 5567 if (PyObject_IsInstance(obj, (PyObject*)NotEq_type)) { | 5876 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); |
| 5877 if (isinstance == -1) { | |
| 5878 return 1; | |
| 5879 } | |
| 5880 if (isinstance) { | |
| 5568 *out = NotEq; | 5881 *out = NotEq; |
| 5569 return 0; | 5882 return 0; |
| 5570 } | 5883 } |
| 5571 if (PyObject_IsInstance(obj, (PyObject*)Lt_type)) { | 5884 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); |
| 5885 if (isinstance == -1) { | |
| 5886 return 1; | |
| 5887 } | |
| 5888 if (isinstance) { | |
| 5572 *out = Lt; | 5889 *out = Lt; |
| 5573 return 0; | 5890 return 0; |
| 5574 } | 5891 } |
| 5575 if (PyObject_IsInstance(obj, (PyObject*)LtE_type)) { | 5892 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); |
| 5893 if (isinstance == -1) { | |
| 5894 return 1; | |
| 5895 } | |
| 5896 if (isinstance) { | |
| 5576 *out = LtE; | 5897 *out = LtE; |
| 5577 return 0; | 5898 return 0; |
| 5578 } | 5899 } |
| 5579 if (PyObject_IsInstance(obj, (PyObject*)Gt_type)) { | 5900 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); |
| 5901 if (isinstance == -1) { | |
| 5902 return 1; | |
| 5903 } | |
| 5904 if (isinstance) { | |
| 5580 *out = Gt; | 5905 *out = Gt; |
| 5581 return 0; | 5906 return 0; |
| 5582 } | 5907 } |
| 5583 if (PyObject_IsInstance(obj, (PyObject*)GtE_type)) { | 5908 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); |
| 5909 if (isinstance == -1) { | |
| 5910 return 1; | |
| 5911 } | |
| 5912 if (isinstance) { | |
| 5584 *out = GtE; | 5913 *out = GtE; |
| 5585 return 0; | 5914 return 0; |
| 5586 } | 5915 } |
| 5587 if (PyObject_IsInstance(obj, (PyObject*)Is_type)) { | 5916 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); |
| 5917 if (isinstance == -1) { | |
| 5918 return 1; | |
| 5919 } | |
| 5920 if (isinstance) { | |
| 5588 *out = Is; | 5921 *out = Is; |
| 5589 return 0; | 5922 return 0; |
| 5590 } | 5923 } |
| 5591 if (PyObject_IsInstance(obj, (PyObject*)IsNot_type)) { | 5924 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); |
| 5925 if (isinstance == -1) { | |
| 5926 return 1; | |
| 5927 } | |
| 5928 if (isinstance) { | |
| 5592 *out = IsNot; | 5929 *out = IsNot; |
| 5593 return 0; | 5930 return 0; |
| 5594 } | 5931 } |
| 5595 if (PyObject_IsInstance(obj, (PyObject*)In_type)) { | 5932 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); |
| 5933 if (isinstance == -1) { | |
| 5934 return 1; | |
| 5935 } | |
| 5936 if (isinstance) { | |
| 5596 *out = In; | 5937 *out = In; |
| 5597 return 0; | 5938 return 0; |
| 5598 } | 5939 } |
| 5599 if (PyObject_IsInstance(obj, (PyObject*)NotIn_type)) { | 5940 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); |
| 5941 if (isinstance == -1) { | |
| 5942 return 1; | |
| 5943 } | |
| 5944 if (isinstance) { | |
| 5600 *out = NotIn; | 5945 *out = NotIn; |
| 5601 return 0; | 5946 return 0; |
| 5602 } | 5947 } |
| 5603 | 5948 |
| 5604 tmp = PyObject_Repr(obj); | 5949 tmp = PyObject_Repr(obj); |
| 5675 | 6020 |
| 5676 int | 6021 int |
| 5677 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) | 6022 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) |
| 5678 { | 6023 { |
| 5679 PyObject* tmp = NULL; | 6024 PyObject* tmp = NULL; |
| 6025 int isinstance; | |
| 5680 | 6026 |
| 5681 int lineno; | 6027 int lineno; |
| 5682 int col_offset; | 6028 int col_offset; |
| 5683 | 6029 |
| 5684 if (obj == Py_None) { | 6030 if (obj == Py_None) { |
| 5707 tmp = NULL; | 6053 tmp = NULL; |
| 5708 } else { | 6054 } else { |
| 5709 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); | 6055 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); |
| 5710 return 1; | 6056 return 1; |
| 5711 } | 6057 } |
| 5712 if (PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type)) { | 6058 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type); |
| 6059 if (isinstance == -1) { | |
| 6060 return 1; | |
| 6061 } | |
| 6062 if (isinstance) { | |
| 5713 expr_ty type; | 6063 expr_ty type; |
| 5714 expr_ty name; | 6064 expr_ty name; |
| 5715 asdl_seq* body; | 6065 asdl_seq* body; |
| 5716 | 6066 |
| 5717 if (PyObject_HasAttrString(obj, "type")) { | 6067 if (PyObject_HasAttrString(obj, "type")) { |
| 6108 { | 6458 { |
| 6109 mod_ty res; | 6459 mod_ty res; |
| 6110 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, | 6460 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, |
| 6111 (PyObject*)Interactive_type}; | 6461 (PyObject*)Interactive_type}; |
| 6112 char *req_name[] = {"Module", "Expression", "Interactive"}; | 6462 char *req_name[] = {"Module", "Expression", "Interactive"}; |
| 6463 int isinstance; | |
| 6113 assert(0 <= mode && mode <= 2); | 6464 assert(0 <= mode && mode <= 2); |
| 6114 | 6465 |
| 6115 init_types(); | 6466 init_types(); |
| 6116 | 6467 |
| 6117 if (!PyObject_IsInstance(ast, req_type[mode])) { | 6468 isinstance = PyObject_IsInstance(ast, req_type[mode]); |
| 6469 if (isinstance == -1) | |
| 6470 return NULL; | |
| 6471 if (!isinstance) { | |
| 6118 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", | 6472 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", |
| 6119 req_name[mode], Py_TYPE(ast)->tp_name); | 6473 req_name[mode], Py_TYPE(ast)->tp_name); |
| 6120 return NULL; | 6474 return NULL; |
| 6121 } | 6475 } |
| 6122 if (obj2ast_mod(ast, &res, arena) != 0) | 6476 if (obj2ast_mod(ast, &res, arena) != 0) |
