Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 57677:1558dc69aacf 3.1
Merged revisions 76776 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r76776 | benjamin.peterson | 2009-12-12 19:23:39 -0600 (Sat, 12 Dec 2009) | 25 lines
Merged revisions 76534,76538,76628,76701,76774 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r76534 | martin.v.loewis | 2009-11-26 02:42:05 -0600 (Thu, 26 Nov 2009) | 2 lines
Fix typo.
........
r76538 | georg.brandl | 2009-11-26 14:48:25 -0600 (Thu, 26 Nov 2009) | 1 line
#7400: typo.
........
r76628 | andrew.kuchling | 2009-12-02 08:27:11 -0600 (Wed, 02 Dec 2009) | 1 line
Markup fixes
........
r76701 | andrew.kuchling | 2009-12-07 20:37:05 -0600 (Mon, 07 Dec 2009) | 1 line
Typo fix; grammar fix
........
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 01:29:00 +0000 |
| parents | debd14c489b9 |
| children | 350898e095aa |
comparison
equal
deleted
inserted
replaced
| 57671:73a6b9b0543f | 57677:1558dc69aacf |
|---|---|
| 3377 | 3377 |
| 3378 int | 3378 int |
| 3379 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) | 3379 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) |
| 3380 { | 3380 { |
| 3381 PyObject* tmp = NULL; | 3381 PyObject* tmp = NULL; |
| 3382 int isinstance; | |
| 3382 | 3383 |
| 3383 | 3384 |
| 3384 if (obj == Py_None) { | 3385 if (obj == Py_None) { |
| 3385 *out = NULL; | 3386 *out = NULL; |
| 3386 return 0; | 3387 return 0; |
| 3387 } | 3388 } |
| 3388 if (PyObject_IsInstance(obj, (PyObject*)Module_type)) { | 3389 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); |
| 3390 if (isinstance == -1) { | |
| 3391 return 1; | |
| 3392 } | |
| 3393 if (isinstance) { | |
| 3389 asdl_seq* body; | 3394 asdl_seq* body; |
| 3390 | 3395 |
| 3391 if (PyObject_HasAttrString(obj, "body")) { | 3396 if (PyObject_HasAttrString(obj, "body")) { |
| 3392 int res; | 3397 int res; |
| 3393 Py_ssize_t len; | 3398 Py_ssize_t len; |
| 3415 } | 3420 } |
| 3416 *out = Module(body, arena); | 3421 *out = Module(body, arena); |
| 3417 if (*out == NULL) goto failed; | 3422 if (*out == NULL) goto failed; |
| 3418 return 0; | 3423 return 0; |
| 3419 } | 3424 } |
| 3420 if (PyObject_IsInstance(obj, (PyObject*)Interactive_type)) { | 3425 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); |
| 3426 if (isinstance == -1) { | |
| 3427 return 1; | |
| 3428 } | |
| 3429 if (isinstance) { | |
| 3421 asdl_seq* body; | 3430 asdl_seq* body; |
| 3422 | 3431 |
| 3423 if (PyObject_HasAttrString(obj, "body")) { | 3432 if (PyObject_HasAttrString(obj, "body")) { |
| 3424 int res; | 3433 int res; |
| 3425 Py_ssize_t len; | 3434 Py_ssize_t len; |
| 3447 } | 3456 } |
| 3448 *out = Interactive(body, arena); | 3457 *out = Interactive(body, arena); |
| 3449 if (*out == NULL) goto failed; | 3458 if (*out == NULL) goto failed; |
| 3450 return 0; | 3459 return 0; |
| 3451 } | 3460 } |
| 3452 if (PyObject_IsInstance(obj, (PyObject*)Expression_type)) { | 3461 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); |
| 3462 if (isinstance == -1) { | |
| 3463 return 1; | |
| 3464 } | |
| 3465 if (isinstance) { | |
| 3453 expr_ty body; | 3466 expr_ty body; |
| 3454 | 3467 |
| 3455 if (PyObject_HasAttrString(obj, "body")) { | 3468 if (PyObject_HasAttrString(obj, "body")) { |
| 3456 int res; | 3469 int res; |
| 3457 tmp = PyObject_GetAttrString(obj, "body"); | 3470 tmp = PyObject_GetAttrString(obj, "body"); |
| 3466 } | 3479 } |
| 3467 *out = Expression(body, arena); | 3480 *out = Expression(body, arena); |
| 3468 if (*out == NULL) goto failed; | 3481 if (*out == NULL) goto failed; |
| 3469 return 0; | 3482 return 0; |
| 3470 } | 3483 } |
| 3471 if (PyObject_IsInstance(obj, (PyObject*)Suite_type)) { | 3484 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); |
| 3485 if (isinstance == -1) { | |
| 3486 return 1; | |
| 3487 } | |
| 3488 if (isinstance) { | |
| 3472 asdl_seq* body; | 3489 asdl_seq* body; |
| 3473 | 3490 |
| 3474 if (PyObject_HasAttrString(obj, "body")) { | 3491 if (PyObject_HasAttrString(obj, "body")) { |
| 3475 int res; | 3492 int res; |
| 3476 Py_ssize_t len; | 3493 Py_ssize_t len; |
| 3511 | 3528 |
| 3512 int | 3529 int |
| 3513 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) | 3530 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) |
| 3514 { | 3531 { |
| 3515 PyObject* tmp = NULL; | 3532 PyObject* tmp = NULL; |
| 3533 int isinstance; | |
| 3516 | 3534 |
| 3517 int lineno; | 3535 int lineno; |
| 3518 int col_offset; | 3536 int col_offset; |
| 3519 | 3537 |
| 3520 if (obj == Py_None) { | 3538 if (obj == Py_None) { |
| 3543 tmp = NULL; | 3561 tmp = NULL; |
| 3544 } else { | 3562 } else { |
| 3545 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); | 3563 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); |
| 3546 return 1; | 3564 return 1; |
| 3547 } | 3565 } |
| 3548 if (PyObject_IsInstance(obj, (PyObject*)FunctionDef_type)) { | 3566 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); |
| 3567 if (isinstance == -1) { | |
| 3568 return 1; | |
| 3569 } | |
| 3570 if (isinstance) { | |
| 3549 identifier name; | 3571 identifier name; |
| 3550 arguments_ty args; | 3572 arguments_ty args; |
| 3551 asdl_seq* body; | 3573 asdl_seq* body; |
| 3552 asdl_seq* decorator_list; | 3574 asdl_seq* decorator_list; |
| 3553 expr_ty returns; | 3575 expr_ty returns; |
| 3640 *out = FunctionDef(name, args, body, decorator_list, returns, | 3662 *out = FunctionDef(name, args, body, decorator_list, returns, |
| 3641 lineno, col_offset, arena); | 3663 lineno, col_offset, arena); |
| 3642 if (*out == NULL) goto failed; | 3664 if (*out == NULL) goto failed; |
| 3643 return 0; | 3665 return 0; |
| 3644 } | 3666 } |
| 3645 if (PyObject_IsInstance(obj, (PyObject*)ClassDef_type)) { | 3667 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); |
| 3668 if (isinstance == -1) { | |
| 3669 return 1; | |
| 3670 } | |
| 3671 if (isinstance) { | |
| 3646 identifier name; | 3672 identifier name; |
| 3647 asdl_seq* bases; | 3673 asdl_seq* bases; |
| 3648 asdl_seq* keywords; | 3674 asdl_seq* keywords; |
| 3649 expr_ty starargs; | 3675 expr_ty starargs; |
| 3650 expr_ty kwargs; | 3676 expr_ty kwargs; |
| 3788 *out = ClassDef(name, bases, keywords, starargs, kwargs, body, | 3814 *out = ClassDef(name, bases, keywords, starargs, kwargs, body, |
| 3789 decorator_list, lineno, col_offset, arena); | 3815 decorator_list, lineno, col_offset, arena); |
| 3790 if (*out == NULL) goto failed; | 3816 if (*out == NULL) goto failed; |
| 3791 return 0; | 3817 return 0; |
| 3792 } | 3818 } |
| 3793 if (PyObject_IsInstance(obj, (PyObject*)Return_type)) { | 3819 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); |
| 3820 if (isinstance == -1) { | |
| 3821 return 1; | |
| 3822 } | |
| 3823 if (isinstance) { | |
| 3794 expr_ty value; | 3824 expr_ty value; |
| 3795 | 3825 |
| 3796 if (PyObject_HasAttrString(obj, "value")) { | 3826 if (PyObject_HasAttrString(obj, "value")) { |
| 3797 int res; | 3827 int res; |
| 3798 tmp = PyObject_GetAttrString(obj, "value"); | 3828 tmp = PyObject_GetAttrString(obj, "value"); |
| 3806 } | 3836 } |
| 3807 *out = Return(value, lineno, col_offset, arena); | 3837 *out = Return(value, lineno, col_offset, arena); |
| 3808 if (*out == NULL) goto failed; | 3838 if (*out == NULL) goto failed; |
| 3809 return 0; | 3839 return 0; |
| 3810 } | 3840 } |
| 3811 if (PyObject_IsInstance(obj, (PyObject*)Delete_type)) { | 3841 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); |
| 3842 if (isinstance == -1) { | |
| 3843 return 1; | |
| 3844 } | |
| 3845 if (isinstance) { | |
| 3812 asdl_seq* targets; | 3846 asdl_seq* targets; |
| 3813 | 3847 |
| 3814 if (PyObject_HasAttrString(obj, "targets")) { | 3848 if (PyObject_HasAttrString(obj, "targets")) { |
| 3815 int res; | 3849 int res; |
| 3816 Py_ssize_t len; | 3850 Py_ssize_t len; |
| 3838 } | 3872 } |
| 3839 *out = Delete(targets, lineno, col_offset, arena); | 3873 *out = Delete(targets, lineno, col_offset, arena); |
| 3840 if (*out == NULL) goto failed; | 3874 if (*out == NULL) goto failed; |
| 3841 return 0; | 3875 return 0; |
| 3842 } | 3876 } |
| 3843 if (PyObject_IsInstance(obj, (PyObject*)Assign_type)) { | 3877 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); |
| 3878 if (isinstance == -1) { | |
| 3879 return 1; | |
| 3880 } | |
| 3881 if (isinstance) { | |
| 3844 asdl_seq* targets; | 3882 asdl_seq* targets; |
| 3845 expr_ty value; | 3883 expr_ty value; |
| 3846 | 3884 |
| 3847 if (PyObject_HasAttrString(obj, "targets")) { | 3885 if (PyObject_HasAttrString(obj, "targets")) { |
| 3848 int res; | 3886 int res; |
| 3883 } | 3921 } |
| 3884 *out = Assign(targets, value, lineno, col_offset, arena); | 3922 *out = Assign(targets, value, lineno, col_offset, arena); |
| 3885 if (*out == NULL) goto failed; | 3923 if (*out == NULL) goto failed; |
| 3886 return 0; | 3924 return 0; |
| 3887 } | 3925 } |
| 3888 if (PyObject_IsInstance(obj, (PyObject*)AugAssign_type)) { | 3926 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); |
| 3927 if (isinstance == -1) { | |
| 3928 return 1; | |
| 3929 } | |
| 3930 if (isinstance) { | |
| 3889 expr_ty target; | 3931 expr_ty target; |
| 3890 operator_ty op; | 3932 operator_ty op; |
| 3891 expr_ty value; | 3933 expr_ty value; |
| 3892 | 3934 |
| 3893 if (PyObject_HasAttrString(obj, "target")) { | 3935 if (PyObject_HasAttrString(obj, "target")) { |
| 3928 } | 3970 } |
| 3929 *out = AugAssign(target, op, value, lineno, col_offset, arena); | 3971 *out = AugAssign(target, op, value, lineno, col_offset, arena); |
| 3930 if (*out == NULL) goto failed; | 3972 if (*out == NULL) goto failed; |
| 3931 return 0; | 3973 return 0; |
| 3932 } | 3974 } |
| 3933 if (PyObject_IsInstance(obj, (PyObject*)For_type)) { | 3975 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); |
| 3976 if (isinstance == -1) { | |
| 3977 return 1; | |
| 3978 } | |
| 3979 if (isinstance) { | |
| 3934 expr_ty target; | 3980 expr_ty target; |
| 3935 expr_ty iter; | 3981 expr_ty iter; |
| 3936 asdl_seq* body; | 3982 asdl_seq* body; |
| 3937 asdl_seq* orelse; | 3983 asdl_seq* orelse; |
| 3938 | 3984 |
| 4013 *out = For(target, iter, body, orelse, lineno, col_offset, | 4059 *out = For(target, iter, body, orelse, lineno, col_offset, |
| 4014 arena); | 4060 arena); |
| 4015 if (*out == NULL) goto failed; | 4061 if (*out == NULL) goto failed; |
| 4016 return 0; | 4062 return 0; |
| 4017 } | 4063 } |
| 4018 if (PyObject_IsInstance(obj, (PyObject*)While_type)) { | 4064 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); |
| 4065 if (isinstance == -1) { | |
| 4066 return 1; | |
| 4067 } | |
| 4068 if (isinstance) { | |
| 4019 expr_ty test; | 4069 expr_ty test; |
| 4020 asdl_seq* body; | 4070 asdl_seq* body; |
| 4021 asdl_seq* orelse; | 4071 asdl_seq* orelse; |
| 4022 | 4072 |
| 4023 if (PyObject_HasAttrString(obj, "test")) { | 4073 if (PyObject_HasAttrString(obj, "test")) { |
| 4084 } | 4134 } |
| 4085 *out = While(test, body, orelse, lineno, col_offset, arena); | 4135 *out = While(test, body, orelse, lineno, col_offset, arena); |
| 4086 if (*out == NULL) goto failed; | 4136 if (*out == NULL) goto failed; |
| 4087 return 0; | 4137 return 0; |
| 4088 } | 4138 } |
| 4089 if (PyObject_IsInstance(obj, (PyObject*)If_type)) { | 4139 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); |
| 4140 if (isinstance == -1) { | |
| 4141 return 1; | |
| 4142 } | |
| 4143 if (isinstance) { | |
| 4090 expr_ty test; | 4144 expr_ty test; |
| 4091 asdl_seq* body; | 4145 asdl_seq* body; |
| 4092 asdl_seq* orelse; | 4146 asdl_seq* orelse; |
| 4093 | 4147 |
| 4094 if (PyObject_HasAttrString(obj, "test")) { | 4148 if (PyObject_HasAttrString(obj, "test")) { |
| 4155 } | 4209 } |
| 4156 *out = If(test, body, orelse, lineno, col_offset, arena); | 4210 *out = If(test, body, orelse, lineno, col_offset, arena); |
| 4157 if (*out == NULL) goto failed; | 4211 if (*out == NULL) goto failed; |
| 4158 return 0; | 4212 return 0; |
| 4159 } | 4213 } |
| 4160 if (PyObject_IsInstance(obj, (PyObject*)With_type)) { | 4214 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); |
| 4215 if (isinstance == -1) { | |
| 4216 return 1; | |
| 4217 } | |
| 4218 if (isinstance) { | |
| 4161 expr_ty context_expr; | 4219 expr_ty context_expr; |
| 4162 expr_ty optional_vars; | 4220 expr_ty optional_vars; |
| 4163 asdl_seq* body; | 4221 asdl_seq* body; |
| 4164 | 4222 |
| 4165 if (PyObject_HasAttrString(obj, "context_expr")) { | 4223 if (PyObject_HasAttrString(obj, "context_expr")) { |
| 4213 *out = With(context_expr, optional_vars, body, lineno, | 4271 *out = With(context_expr, optional_vars, body, lineno, |
| 4214 col_offset, arena); | 4272 col_offset, arena); |
| 4215 if (*out == NULL) goto failed; | 4273 if (*out == NULL) goto failed; |
| 4216 return 0; | 4274 return 0; |
| 4217 } | 4275 } |
| 4218 if (PyObject_IsInstance(obj, (PyObject*)Raise_type)) { | 4276 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); |
| 4277 if (isinstance == -1) { | |
| 4278 return 1; | |
| 4279 } | |
| 4280 if (isinstance) { | |
| 4219 expr_ty exc; | 4281 expr_ty exc; |
| 4220 expr_ty cause; | 4282 expr_ty cause; |
| 4221 | 4283 |
| 4222 if (PyObject_HasAttrString(obj, "exc")) { | 4284 if (PyObject_HasAttrString(obj, "exc")) { |
| 4223 int res; | 4285 int res; |
| 4243 } | 4305 } |
| 4244 *out = Raise(exc, cause, lineno, col_offset, arena); | 4306 *out = Raise(exc, cause, lineno, col_offset, arena); |
| 4245 if (*out == NULL) goto failed; | 4307 if (*out == NULL) goto failed; |
| 4246 return 0; | 4308 return 0; |
| 4247 } | 4309 } |
| 4248 if (PyObject_IsInstance(obj, (PyObject*)TryExcept_type)) { | 4310 isinstance = PyObject_IsInstance(obj, (PyObject*)TryExcept_type); |
| 4311 if (isinstance == -1) { | |
| 4312 return 1; | |
| 4313 } | |
| 4314 if (isinstance) { | |
| 4249 asdl_seq* body; | 4315 asdl_seq* body; |
| 4250 asdl_seq* handlers; | 4316 asdl_seq* handlers; |
| 4251 asdl_seq* orelse; | 4317 asdl_seq* orelse; |
| 4252 | 4318 |
| 4253 if (PyObject_HasAttrString(obj, "body")) { | 4319 if (PyObject_HasAttrString(obj, "body")) { |
| 4328 *out = TryExcept(body, handlers, orelse, lineno, col_offset, | 4394 *out = TryExcept(body, handlers, orelse, lineno, col_offset, |
| 4329 arena); | 4395 arena); |
| 4330 if (*out == NULL) goto failed; | 4396 if (*out == NULL) goto failed; |
| 4331 return 0; | 4397 return 0; |
| 4332 } | 4398 } |
| 4333 if (PyObject_IsInstance(obj, (PyObject*)TryFinally_type)) { | 4399 isinstance = PyObject_IsInstance(obj, (PyObject*)TryFinally_type); |
| 4400 if (isinstance == -1) { | |
| 4401 return 1; | |
| 4402 } | |
| 4403 if (isinstance) { | |
| 4334 asdl_seq* body; | 4404 asdl_seq* body; |
| 4335 asdl_seq* finalbody; | 4405 asdl_seq* finalbody; |
| 4336 | 4406 |
| 4337 if (PyObject_HasAttrString(obj, "body")) { | 4407 if (PyObject_HasAttrString(obj, "body")) { |
| 4338 int res; | 4408 int res; |
| 4386 } | 4456 } |
| 4387 *out = TryFinally(body, finalbody, lineno, col_offset, arena); | 4457 *out = TryFinally(body, finalbody, lineno, col_offset, arena); |
| 4388 if (*out == NULL) goto failed; | 4458 if (*out == NULL) goto failed; |
| 4389 return 0; | 4459 return 0; |
| 4390 } | 4460 } |
| 4391 if (PyObject_IsInstance(obj, (PyObject*)Assert_type)) { | 4461 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); |
| 4462 if (isinstance == -1) { | |
| 4463 return 1; | |
| 4464 } | |
| 4465 if (isinstance) { | |
| 4392 expr_ty test; | 4466 expr_ty test; |
| 4393 expr_ty msg; | 4467 expr_ty msg; |
| 4394 | 4468 |
| 4395 if (PyObject_HasAttrString(obj, "test")) { | 4469 if (PyObject_HasAttrString(obj, "test")) { |
| 4396 int res; | 4470 int res; |
| 4417 } | 4491 } |
| 4418 *out = Assert(test, msg, lineno, col_offset, arena); | 4492 *out = Assert(test, msg, lineno, col_offset, arena); |
| 4419 if (*out == NULL) goto failed; | 4493 if (*out == NULL) goto failed; |
| 4420 return 0; | 4494 return 0; |
| 4421 } | 4495 } |
| 4422 if (PyObject_IsInstance(obj, (PyObject*)Import_type)) { | 4496 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); |
| 4497 if (isinstance == -1) { | |
| 4498 return 1; | |
| 4499 } | |
| 4500 if (isinstance) { | |
| 4423 asdl_seq* names; | 4501 asdl_seq* names; |
| 4424 | 4502 |
| 4425 if (PyObject_HasAttrString(obj, "names")) { | 4503 if (PyObject_HasAttrString(obj, "names")) { |
| 4426 int res; | 4504 int res; |
| 4427 Py_ssize_t len; | 4505 Py_ssize_t len; |
| 4449 } | 4527 } |
| 4450 *out = Import(names, lineno, col_offset, arena); | 4528 *out = Import(names, lineno, col_offset, arena); |
| 4451 if (*out == NULL) goto failed; | 4529 if (*out == NULL) goto failed; |
| 4452 return 0; | 4530 return 0; |
| 4453 } | 4531 } |
| 4454 if (PyObject_IsInstance(obj, (PyObject*)ImportFrom_type)) { | 4532 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); |
| 4533 if (isinstance == -1) { | |
| 4534 return 1; | |
| 4535 } | |
| 4536 if (isinstance) { | |
| 4455 identifier module; | 4537 identifier module; |
| 4456 asdl_seq* names; | 4538 asdl_seq* names; |
| 4457 int level; | 4539 int level; |
| 4458 | 4540 |
| 4459 if (PyObject_HasAttrString(obj, "module")) { | 4541 if (PyObject_HasAttrString(obj, "module")) { |
| 4507 *out = ImportFrom(module, names, level, lineno, col_offset, | 4589 *out = ImportFrom(module, names, level, lineno, col_offset, |
| 4508 arena); | 4590 arena); |
| 4509 if (*out == NULL) goto failed; | 4591 if (*out == NULL) goto failed; |
| 4510 return 0; | 4592 return 0; |
| 4511 } | 4593 } |
| 4512 if (PyObject_IsInstance(obj, (PyObject*)Global_type)) { | 4594 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); |
| 4595 if (isinstance == -1) { | |
| 4596 return 1; | |
| 4597 } | |
| 4598 if (isinstance) { | |
| 4513 asdl_seq* names; | 4599 asdl_seq* names; |
| 4514 | 4600 |
| 4515 if (PyObject_HasAttrString(obj, "names")) { | 4601 if (PyObject_HasAttrString(obj, "names")) { |
| 4516 int res; | 4602 int res; |
| 4517 Py_ssize_t len; | 4603 Py_ssize_t len; |
| 4539 } | 4625 } |
| 4540 *out = Global(names, lineno, col_offset, arena); | 4626 *out = Global(names, lineno, col_offset, arena); |
| 4541 if (*out == NULL) goto failed; | 4627 if (*out == NULL) goto failed; |
| 4542 return 0; | 4628 return 0; |
| 4543 } | 4629 } |
| 4544 if (PyObject_IsInstance(obj, (PyObject*)Nonlocal_type)) { | 4630 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type); |
| 4631 if (isinstance == -1) { | |
| 4632 return 1; | |
| 4633 } | |
| 4634 if (isinstance) { | |
| 4545 asdl_seq* names; | 4635 asdl_seq* names; |
| 4546 | 4636 |
| 4547 if (PyObject_HasAttrString(obj, "names")) { | 4637 if (PyObject_HasAttrString(obj, "names")) { |
| 4548 int res; | 4638 int res; |
| 4549 Py_ssize_t len; | 4639 Py_ssize_t len; |
| 4571 } | 4661 } |
| 4572 *out = Nonlocal(names, lineno, col_offset, arena); | 4662 *out = Nonlocal(names, lineno, col_offset, arena); |
| 4573 if (*out == NULL) goto failed; | 4663 if (*out == NULL) goto failed; |
| 4574 return 0; | 4664 return 0; |
| 4575 } | 4665 } |
| 4576 if (PyObject_IsInstance(obj, (PyObject*)Expr_type)) { | 4666 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); |
| 4667 if (isinstance == -1) { | |
| 4668 return 1; | |
| 4669 } | |
| 4670 if (isinstance) { | |
| 4577 expr_ty value; | 4671 expr_ty value; |
| 4578 | 4672 |
| 4579 if (PyObject_HasAttrString(obj, "value")) { | 4673 if (PyObject_HasAttrString(obj, "value")) { |
| 4580 int res; | 4674 int res; |
| 4581 tmp = PyObject_GetAttrString(obj, "value"); | 4675 tmp = PyObject_GetAttrString(obj, "value"); |
| 4590 } | 4684 } |
| 4591 *out = Expr(value, lineno, col_offset, arena); | 4685 *out = Expr(value, lineno, col_offset, arena); |
| 4592 if (*out == NULL) goto failed; | 4686 if (*out == NULL) goto failed; |
| 4593 return 0; | 4687 return 0; |
| 4594 } | 4688 } |
| 4595 if (PyObject_IsInstance(obj, (PyObject*)Pass_type)) { | 4689 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); |
| 4690 if (isinstance == -1) { | |
| 4691 return 1; | |
| 4692 } | |
| 4693 if (isinstance) { | |
| 4596 | 4694 |
| 4597 *out = Pass(lineno, col_offset, arena); | 4695 *out = Pass(lineno, col_offset, arena); |
| 4598 if (*out == NULL) goto failed; | 4696 if (*out == NULL) goto failed; |
| 4599 return 0; | 4697 return 0; |
| 4600 } | 4698 } |
| 4601 if (PyObject_IsInstance(obj, (PyObject*)Break_type)) { | 4699 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); |
| 4700 if (isinstance == -1) { | |
| 4701 return 1; | |
| 4702 } | |
| 4703 if (isinstance) { | |
| 4602 | 4704 |
| 4603 *out = Break(lineno, col_offset, arena); | 4705 *out = Break(lineno, col_offset, arena); |
| 4604 if (*out == NULL) goto failed; | 4706 if (*out == NULL) goto failed; |
| 4605 return 0; | 4707 return 0; |
| 4606 } | 4708 } |
| 4607 if (PyObject_IsInstance(obj, (PyObject*)Continue_type)) { | 4709 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); |
| 4710 if (isinstance == -1) { | |
| 4711 return 1; | |
| 4712 } | |
| 4713 if (isinstance) { | |
| 4608 | 4714 |
| 4609 *out = Continue(lineno, col_offset, arena); | 4715 *out = Continue(lineno, col_offset, arena); |
| 4610 if (*out == NULL) goto failed; | 4716 if (*out == NULL) goto failed; |
| 4611 return 0; | 4717 return 0; |
| 4612 } | 4718 } |
| 4621 | 4727 |
| 4622 int | 4728 int |
| 4623 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) | 4729 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) |
| 4624 { | 4730 { |
| 4625 PyObject* tmp = NULL; | 4731 PyObject* tmp = NULL; |
| 4732 int isinstance; | |
| 4626 | 4733 |
| 4627 int lineno; | 4734 int lineno; |
| 4628 int col_offset; | 4735 int col_offset; |
| 4629 | 4736 |
| 4630 if (obj == Py_None) { | 4737 if (obj == Py_None) { |
| 4653 tmp = NULL; | 4760 tmp = NULL; |
| 4654 } else { | 4761 } else { |
| 4655 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); | 4762 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); |
| 4656 return 1; | 4763 return 1; |
| 4657 } | 4764 } |
| 4658 if (PyObject_IsInstance(obj, (PyObject*)BoolOp_type)) { | 4765 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); |
| 4766 if (isinstance == -1) { | |
| 4767 return 1; | |
| 4768 } | |
| 4769 if (isinstance) { | |
| 4659 boolop_ty op; | 4770 boolop_ty op; |
| 4660 asdl_seq* values; | 4771 asdl_seq* values; |
| 4661 | 4772 |
| 4662 if (PyObject_HasAttrString(obj, "op")) { | 4773 if (PyObject_HasAttrString(obj, "op")) { |
| 4663 int res; | 4774 int res; |
| 4698 } | 4809 } |
| 4699 *out = BoolOp(op, values, lineno, col_offset, arena); | 4810 *out = BoolOp(op, values, lineno, col_offset, arena); |
| 4700 if (*out == NULL) goto failed; | 4811 if (*out == NULL) goto failed; |
| 4701 return 0; | 4812 return 0; |
| 4702 } | 4813 } |
| 4703 if (PyObject_IsInstance(obj, (PyObject*)BinOp_type)) { | 4814 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); |
| 4815 if (isinstance == -1) { | |
| 4816 return 1; | |
| 4817 } | |
| 4818 if (isinstance) { | |
| 4704 expr_ty left; | 4819 expr_ty left; |
| 4705 operator_ty op; | 4820 operator_ty op; |
| 4706 expr_ty right; | 4821 expr_ty right; |
| 4707 | 4822 |
| 4708 if (PyObject_HasAttrString(obj, "left")) { | 4823 if (PyObject_HasAttrString(obj, "left")) { |
| 4743 } | 4858 } |
| 4744 *out = BinOp(left, op, right, lineno, col_offset, arena); | 4859 *out = BinOp(left, op, right, lineno, col_offset, arena); |
| 4745 if (*out == NULL) goto failed; | 4860 if (*out == NULL) goto failed; |
| 4746 return 0; | 4861 return 0; |
| 4747 } | 4862 } |
| 4748 if (PyObject_IsInstance(obj, (PyObject*)UnaryOp_type)) { | 4863 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); |
| 4864 if (isinstance == -1) { | |
| 4865 return 1; | |
| 4866 } | |
| 4867 if (isinstance) { | |
| 4749 unaryop_ty op; | 4868 unaryop_ty op; |
| 4750 expr_ty operand; | 4869 expr_ty operand; |
| 4751 | 4870 |
| 4752 if (PyObject_HasAttrString(obj, "op")) { | 4871 if (PyObject_HasAttrString(obj, "op")) { |
| 4753 int res; | 4872 int res; |
| 4775 } | 4894 } |
| 4776 *out = UnaryOp(op, operand, lineno, col_offset, arena); | 4895 *out = UnaryOp(op, operand, lineno, col_offset, arena); |
| 4777 if (*out == NULL) goto failed; | 4896 if (*out == NULL) goto failed; |
| 4778 return 0; | 4897 return 0; |
| 4779 } | 4898 } |
| 4780 if (PyObject_IsInstance(obj, (PyObject*)Lambda_type)) { | 4899 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); |
| 4900 if (isinstance == -1) { | |
| 4901 return 1; | |
| 4902 } | |
| 4903 if (isinstance) { | |
| 4781 arguments_ty args; | 4904 arguments_ty args; |
| 4782 expr_ty body; | 4905 expr_ty body; |
| 4783 | 4906 |
| 4784 if (PyObject_HasAttrString(obj, "args")) { | 4907 if (PyObject_HasAttrString(obj, "args")) { |
| 4785 int res; | 4908 int res; |
| 4807 } | 4930 } |
| 4808 *out = Lambda(args, body, lineno, col_offset, arena); | 4931 *out = Lambda(args, body, lineno, col_offset, arena); |
| 4809 if (*out == NULL) goto failed; | 4932 if (*out == NULL) goto failed; |
| 4810 return 0; | 4933 return 0; |
| 4811 } | 4934 } |
| 4812 if (PyObject_IsInstance(obj, (PyObject*)IfExp_type)) { | 4935 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); |
| 4936 if (isinstance == -1) { | |
| 4937 return 1; | |
| 4938 } | |
| 4939 if (isinstance) { | |
| 4813 expr_ty test; | 4940 expr_ty test; |
| 4814 expr_ty body; | 4941 expr_ty body; |
| 4815 expr_ty orelse; | 4942 expr_ty orelse; |
| 4816 | 4943 |
| 4817 if (PyObject_HasAttrString(obj, "test")) { | 4944 if (PyObject_HasAttrString(obj, "test")) { |
| 4852 } | 4979 } |
| 4853 *out = IfExp(test, body, orelse, lineno, col_offset, arena); | 4980 *out = IfExp(test, body, orelse, lineno, col_offset, arena); |
| 4854 if (*out == NULL) goto failed; | 4981 if (*out == NULL) goto failed; |
| 4855 return 0; | 4982 return 0; |
| 4856 } | 4983 } |
| 4857 if (PyObject_IsInstance(obj, (PyObject*)Dict_type)) { | 4984 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); |
| 4985 if (isinstance == -1) { | |
| 4986 return 1; | |
| 4987 } | |
| 4988 if (isinstance) { | |
| 4858 asdl_seq* keys; | 4989 asdl_seq* keys; |
| 4859 asdl_seq* values; | 4990 asdl_seq* values; |
| 4860 | 4991 |
| 4861 if (PyObject_HasAttrString(obj, "keys")) { | 4992 if (PyObject_HasAttrString(obj, "keys")) { |
| 4862 int res; | 4993 int res; |
| 4910 } | 5041 } |
| 4911 *out = Dict(keys, values, lineno, col_offset, arena); | 5042 *out = Dict(keys, values, lineno, col_offset, arena); |
| 4912 if (*out == NULL) goto failed; | 5043 if (*out == NULL) goto failed; |
| 4913 return 0; | 5044 return 0; |
| 4914 } | 5045 } |
| 4915 if (PyObject_IsInstance(obj, (PyObject*)Set_type)) { | 5046 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type); |
| 5047 if (isinstance == -1) { | |
| 5048 return 1; | |
| 5049 } | |
| 5050 if (isinstance) { | |
| 4916 asdl_seq* elts; | 5051 asdl_seq* elts; |
| 4917 | 5052 |
| 4918 if (PyObject_HasAttrString(obj, "elts")) { | 5053 if (PyObject_HasAttrString(obj, "elts")) { |
| 4919 int res; | 5054 int res; |
| 4920 Py_ssize_t len; | 5055 Py_ssize_t len; |
| 4942 } | 5077 } |
| 4943 *out = Set(elts, lineno, col_offset, arena); | 5078 *out = Set(elts, lineno, col_offset, arena); |
| 4944 if (*out == NULL) goto failed; | 5079 if (*out == NULL) goto failed; |
| 4945 return 0; | 5080 return 0; |
| 4946 } | 5081 } |
| 4947 if (PyObject_IsInstance(obj, (PyObject*)ListComp_type)) { | 5082 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type); |
| 5083 if (isinstance == -1) { | |
| 5084 return 1; | |
| 5085 } | |
| 5086 if (isinstance) { | |
| 4948 expr_ty elt; | 5087 expr_ty elt; |
| 4949 asdl_seq* generators; | 5088 asdl_seq* generators; |
| 4950 | 5089 |
| 4951 if (PyObject_HasAttrString(obj, "elt")) { | 5090 if (PyObject_HasAttrString(obj, "elt")) { |
| 4952 int res; | 5091 int res; |
| 4987 } | 5126 } |
| 4988 *out = ListComp(elt, generators, lineno, col_offset, arena); | 5127 *out = ListComp(elt, generators, lineno, col_offset, arena); |
| 4989 if (*out == NULL) goto failed; | 5128 if (*out == NULL) goto failed; |
| 4990 return 0; | 5129 return 0; |
| 4991 } | 5130 } |
| 4992 if (PyObject_IsInstance(obj, (PyObject*)SetComp_type)) { | 5131 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type); |
| 5132 if (isinstance == -1) { | |
| 5133 return 1; | |
| 5134 } | |
| 5135 if (isinstance) { | |
| 4993 expr_ty elt; | 5136 expr_ty elt; |
| 4994 asdl_seq* generators; | 5137 asdl_seq* generators; |
| 4995 | 5138 |
| 4996 if (PyObject_HasAttrString(obj, "elt")) { | 5139 if (PyObject_HasAttrString(obj, "elt")) { |
| 4997 int res; | 5140 int res; |
| 5032 } | 5175 } |
| 5033 *out = SetComp(elt, generators, lineno, col_offset, arena); | 5176 *out = SetComp(elt, generators, lineno, col_offset, arena); |
| 5034 if (*out == NULL) goto failed; | 5177 if (*out == NULL) goto failed; |
| 5035 return 0; | 5178 return 0; |
| 5036 } | 5179 } |
| 5037 if (PyObject_IsInstance(obj, (PyObject*)DictComp_type)) { | 5180 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type); |
| 5181 if (isinstance == -1) { | |
| 5182 return 1; | |
| 5183 } | |
| 5184 if (isinstance) { | |
| 5038 expr_ty key; | 5185 expr_ty key; |
| 5039 expr_ty value; | 5186 expr_ty value; |
| 5040 asdl_seq* generators; | 5187 asdl_seq* generators; |
| 5041 | 5188 |
| 5042 if (PyObject_HasAttrString(obj, "key")) { | 5189 if (PyObject_HasAttrString(obj, "key")) { |
| 5091 *out = DictComp(key, value, generators, lineno, col_offset, | 5238 *out = DictComp(key, value, generators, lineno, col_offset, |
| 5092 arena); | 5239 arena); |
| 5093 if (*out == NULL) goto failed; | 5240 if (*out == NULL) goto failed; |
| 5094 return 0; | 5241 return 0; |
| 5095 } | 5242 } |
| 5096 if (PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type)) { | 5243 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type); |
| 5244 if (isinstance == -1) { | |
| 5245 return 1; | |
| 5246 } | |
| 5247 if (isinstance) { | |
| 5097 expr_ty elt; | 5248 expr_ty elt; |
| 5098 asdl_seq* generators; | 5249 asdl_seq* generators; |
| 5099 | 5250 |
| 5100 if (PyObject_HasAttrString(obj, "elt")) { | 5251 if (PyObject_HasAttrString(obj, "elt")) { |
| 5101 int res; | 5252 int res; |
| 5136 } | 5287 } |
| 5137 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); | 5288 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); |
| 5138 if (*out == NULL) goto failed; | 5289 if (*out == NULL) goto failed; |
| 5139 return 0; | 5290 return 0; |
| 5140 } | 5291 } |
| 5141 if (PyObject_IsInstance(obj, (PyObject*)Yield_type)) { | 5292 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type); |
| 5293 if (isinstance == -1) { | |
| 5294 return 1; | |
| 5295 } | |
| 5296 if (isinstance) { | |
| 5142 expr_ty value; | 5297 expr_ty value; |
| 5143 | 5298 |
| 5144 if (PyObject_HasAttrString(obj, "value")) { | 5299 if (PyObject_HasAttrString(obj, "value")) { |
| 5145 int res; | 5300 int res; |
| 5146 tmp = PyObject_GetAttrString(obj, "value"); | 5301 tmp = PyObject_GetAttrString(obj, "value"); |
| 5154 } | 5309 } |
| 5155 *out = Yield(value, lineno, col_offset, arena); | 5310 *out = Yield(value, lineno, col_offset, arena); |
| 5156 if (*out == NULL) goto failed; | 5311 if (*out == NULL) goto failed; |
| 5157 return 0; | 5312 return 0; |
| 5158 } | 5313 } |
| 5159 if (PyObject_IsInstance(obj, (PyObject*)Compare_type)) { | 5314 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); |
| 5315 if (isinstance == -1) { | |
| 5316 return 1; | |
| 5317 } | |
| 5318 if (isinstance) { | |
| 5160 expr_ty left; | 5319 expr_ty left; |
| 5161 asdl_int_seq* ops; | 5320 asdl_int_seq* ops; |
| 5162 asdl_seq* comparators; | 5321 asdl_seq* comparators; |
| 5163 | 5322 |
| 5164 if (PyObject_HasAttrString(obj, "left")) { | 5323 if (PyObject_HasAttrString(obj, "left")) { |
| 5226 *out = Compare(left, ops, comparators, lineno, col_offset, | 5385 *out = Compare(left, ops, comparators, lineno, col_offset, |
| 5227 arena); | 5386 arena); |
| 5228 if (*out == NULL) goto failed; | 5387 if (*out == NULL) goto failed; |
| 5229 return 0; | 5388 return 0; |
| 5230 } | 5389 } |
| 5231 if (PyObject_IsInstance(obj, (PyObject*)Call_type)) { | 5390 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type); |
| 5391 if (isinstance == -1) { | |
| 5392 return 1; | |
| 5393 } | |
| 5394 if (isinstance) { | |
| 5232 expr_ty func; | 5395 expr_ty func; |
| 5233 asdl_seq* args; | 5396 asdl_seq* args; |
| 5234 asdl_seq* keywords; | 5397 asdl_seq* keywords; |
| 5235 expr_ty starargs; | 5398 expr_ty starargs; |
| 5236 expr_ty kwargs; | 5399 expr_ty kwargs; |
| 5322 *out = Call(func, args, keywords, starargs, kwargs, lineno, | 5485 *out = Call(func, args, keywords, starargs, kwargs, lineno, |
| 5323 col_offset, arena); | 5486 col_offset, arena); |
| 5324 if (*out == NULL) goto failed; | 5487 if (*out == NULL) goto failed; |
| 5325 return 0; | 5488 return 0; |
| 5326 } | 5489 } |
| 5327 if (PyObject_IsInstance(obj, (PyObject*)Num_type)) { | 5490 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type); |
| 5491 if (isinstance == -1) { | |
| 5492 return 1; | |
| 5493 } | |
| 5494 if (isinstance) { | |
| 5328 object n; | 5495 object n; |
| 5329 | 5496 |
| 5330 if (PyObject_HasAttrString(obj, "n")) { | 5497 if (PyObject_HasAttrString(obj, "n")) { |
| 5331 int res; | 5498 int res; |
| 5332 tmp = PyObject_GetAttrString(obj, "n"); | 5499 tmp = PyObject_GetAttrString(obj, "n"); |
| 5341 } | 5508 } |
| 5342 *out = Num(n, lineno, col_offset, arena); | 5509 *out = Num(n, lineno, col_offset, arena); |
| 5343 if (*out == NULL) goto failed; | 5510 if (*out == NULL) goto failed; |
| 5344 return 0; | 5511 return 0; |
| 5345 } | 5512 } |
| 5346 if (PyObject_IsInstance(obj, (PyObject*)Str_type)) { | 5513 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type); |
| 5514 if (isinstance == -1) { | |
| 5515 return 1; | |
| 5516 } | |
| 5517 if (isinstance) { | |
| 5347 string s; | 5518 string s; |
| 5348 | 5519 |
| 5349 if (PyObject_HasAttrString(obj, "s")) { | 5520 if (PyObject_HasAttrString(obj, "s")) { |
| 5350 int res; | 5521 int res; |
| 5351 tmp = PyObject_GetAttrString(obj, "s"); | 5522 tmp = PyObject_GetAttrString(obj, "s"); |
| 5360 } | 5531 } |
| 5361 *out = Str(s, lineno, col_offset, arena); | 5532 *out = Str(s, lineno, col_offset, arena); |
| 5362 if (*out == NULL) goto failed; | 5533 if (*out == NULL) goto failed; |
| 5363 return 0; | 5534 return 0; |
| 5364 } | 5535 } |
| 5365 if (PyObject_IsInstance(obj, (PyObject*)Bytes_type)) { | 5536 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type); |
| 5537 if (isinstance == -1) { | |
| 5538 return 1; | |
| 5539 } | |
| 5540 if (isinstance) { | |
| 5366 string s; | 5541 string s; |
| 5367 | 5542 |
| 5368 if (PyObject_HasAttrString(obj, "s")) { | 5543 if (PyObject_HasAttrString(obj, "s")) { |
| 5369 int res; | 5544 int res; |
| 5370 tmp = PyObject_GetAttrString(obj, "s"); | 5545 tmp = PyObject_GetAttrString(obj, "s"); |
| 5379 } | 5554 } |
| 5380 *out = Bytes(s, lineno, col_offset, arena); | 5555 *out = Bytes(s, lineno, col_offset, arena); |
| 5381 if (*out == NULL) goto failed; | 5556 if (*out == NULL) goto failed; |
| 5382 return 0; | 5557 return 0; |
| 5383 } | 5558 } |
| 5384 if (PyObject_IsInstance(obj, (PyObject*)Ellipsis_type)) { | 5559 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type); |
| 5560 if (isinstance == -1) { | |
| 5561 return 1; | |
| 5562 } | |
| 5563 if (isinstance) { | |
| 5385 | 5564 |
| 5386 *out = Ellipsis(lineno, col_offset, arena); | 5565 *out = Ellipsis(lineno, col_offset, arena); |
| 5387 if (*out == NULL) goto failed; | 5566 if (*out == NULL) goto failed; |
| 5388 return 0; | 5567 return 0; |
| 5389 } | 5568 } |
| 5390 if (PyObject_IsInstance(obj, (PyObject*)Attribute_type)) { | 5569 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type); |
| 5570 if (isinstance == -1) { | |
| 5571 return 1; | |
| 5572 } | |
| 5573 if (isinstance) { | |
| 5391 expr_ty value; | 5574 expr_ty value; |
| 5392 identifier attr; | 5575 identifier attr; |
| 5393 expr_context_ty ctx; | 5576 expr_context_ty ctx; |
| 5394 | 5577 |
| 5395 if (PyObject_HasAttrString(obj, "value")) { | 5578 if (PyObject_HasAttrString(obj, "value")) { |
| 5430 } | 5613 } |
| 5431 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); | 5614 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); |
| 5432 if (*out == NULL) goto failed; | 5615 if (*out == NULL) goto failed; |
| 5433 return 0; | 5616 return 0; |
| 5434 } | 5617 } |
| 5435 if (PyObject_IsInstance(obj, (PyObject*)Subscript_type)) { | 5618 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); |
| 5619 if (isinstance == -1) { | |
| 5620 return 1; | |
| 5621 } | |
| 5622 if (isinstance) { | |
| 5436 expr_ty value; | 5623 expr_ty value; |
| 5437 slice_ty slice; | 5624 slice_ty slice; |
| 5438 expr_context_ty ctx; | 5625 expr_context_ty ctx; |
| 5439 | 5626 |
| 5440 if (PyObject_HasAttrString(obj, "value")) { | 5627 if (PyObject_HasAttrString(obj, "value")) { |
| 5475 } | 5662 } |
| 5476 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); | 5663 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); |
| 5477 if (*out == NULL) goto failed; | 5664 if (*out == NULL) goto failed; |
| 5478 return 0; | 5665 return 0; |
| 5479 } | 5666 } |
| 5480 if (PyObject_IsInstance(obj, (PyObject*)Starred_type)) { | 5667 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type); |
| 5668 if (isinstance == -1) { | |
| 5669 return 1; | |
| 5670 } | |
| 5671 if (isinstance) { | |
| 5481 expr_ty value; | 5672 expr_ty value; |
| 5482 expr_context_ty ctx; | 5673 expr_context_ty ctx; |
| 5483 | 5674 |
| 5484 if (PyObject_HasAttrString(obj, "value")) { | 5675 if (PyObject_HasAttrString(obj, "value")) { |
| 5485 int res; | 5676 int res; |
| 5507 } | 5698 } |
| 5508 *out = Starred(value, ctx, lineno, col_offset, arena); | 5699 *out = Starred(value, ctx, lineno, col_offset, arena); |
| 5509 if (*out == NULL) goto failed; | 5700 if (*out == NULL) goto failed; |
| 5510 return 0; | 5701 return 0; |
| 5511 } | 5702 } |
| 5512 if (PyObject_IsInstance(obj, (PyObject*)Name_type)) { | 5703 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); |
| 5704 if (isinstance == -1) { | |
| 5705 return 1; | |
| 5706 } | |
| 5707 if (isinstance) { | |
| 5513 identifier id; | 5708 identifier id; |
| 5514 expr_context_ty ctx; | 5709 expr_context_ty ctx; |
| 5515 | 5710 |
| 5516 if (PyObject_HasAttrString(obj, "id")) { | 5711 if (PyObject_HasAttrString(obj, "id")) { |
| 5517 int res; | 5712 int res; |
| 5539 } | 5734 } |
| 5540 *out = Name(id, ctx, lineno, col_offset, arena); | 5735 *out = Name(id, ctx, lineno, col_offset, arena); |
| 5541 if (*out == NULL) goto failed; | 5736 if (*out == NULL) goto failed; |
| 5542 return 0; | 5737 return 0; |
| 5543 } | 5738 } |
| 5544 if (PyObject_IsInstance(obj, (PyObject*)List_type)) { | 5739 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type); |
| 5740 if (isinstance == -1) { | |
| 5741 return 1; | |
| 5742 } | |
| 5743 if (isinstance) { | |
| 5545 asdl_seq* elts; | 5744 asdl_seq* elts; |
| 5546 expr_context_ty ctx; | 5745 expr_context_ty ctx; |
| 5547 | 5746 |
| 5548 if (PyObject_HasAttrString(obj, "elts")) { | 5747 if (PyObject_HasAttrString(obj, "elts")) { |
| 5549 int res; | 5748 int res; |
| 5584 } | 5783 } |
| 5585 *out = List(elts, ctx, lineno, col_offset, arena); | 5784 *out = List(elts, ctx, lineno, col_offset, arena); |
| 5586 if (*out == NULL) goto failed; | 5785 if (*out == NULL) goto failed; |
| 5587 return 0; | 5786 return 0; |
| 5588 } | 5787 } |
| 5589 if (PyObject_IsInstance(obj, (PyObject*)Tuple_type)) { | 5788 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type); |
| 5789 if (isinstance == -1) { | |
| 5790 return 1; | |
| 5791 } | |
| 5792 if (isinstance) { | |
| 5590 asdl_seq* elts; | 5793 asdl_seq* elts; |
| 5591 expr_context_ty ctx; | 5794 expr_context_ty ctx; |
| 5592 | 5795 |
| 5593 if (PyObject_HasAttrString(obj, "elts")) { | 5796 if (PyObject_HasAttrString(obj, "elts")) { |
| 5594 int res; | 5797 int res; |
| 5642 | 5845 |
| 5643 int | 5846 int |
| 5644 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) | 5847 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) |
| 5645 { | 5848 { |
| 5646 PyObject* tmp = NULL; | 5849 PyObject* tmp = NULL; |
| 5647 | 5850 int isinstance; |
| 5648 if (PyObject_IsInstance(obj, (PyObject*)Load_type)) { | 5851 |
| 5852 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); | |
| 5853 if (isinstance == -1) { | |
| 5854 return 1; | |
| 5855 } | |
| 5856 if (isinstance) { | |
| 5649 *out = Load; | 5857 *out = Load; |
| 5650 return 0; | 5858 return 0; |
| 5651 } | 5859 } |
| 5652 if (PyObject_IsInstance(obj, (PyObject*)Store_type)) { | 5860 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); |
| 5861 if (isinstance == -1) { | |
| 5862 return 1; | |
| 5863 } | |
| 5864 if (isinstance) { | |
| 5653 *out = Store; | 5865 *out = Store; |
| 5654 return 0; | 5866 return 0; |
| 5655 } | 5867 } |
| 5656 if (PyObject_IsInstance(obj, (PyObject*)Del_type)) { | 5868 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); |
| 5869 if (isinstance == -1) { | |
| 5870 return 1; | |
| 5871 } | |
| 5872 if (isinstance) { | |
| 5657 *out = Del; | 5873 *out = Del; |
| 5658 return 0; | 5874 return 0; |
| 5659 } | 5875 } |
| 5660 if (PyObject_IsInstance(obj, (PyObject*)AugLoad_type)) { | 5876 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); |
| 5877 if (isinstance == -1) { | |
| 5878 return 1; | |
| 5879 } | |
| 5880 if (isinstance) { | |
| 5661 *out = AugLoad; | 5881 *out = AugLoad; |
| 5662 return 0; | 5882 return 0; |
| 5663 } | 5883 } |
| 5664 if (PyObject_IsInstance(obj, (PyObject*)AugStore_type)) { | 5884 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); |
| 5885 if (isinstance == -1) { | |
| 5886 return 1; | |
| 5887 } | |
| 5888 if (isinstance) { | |
| 5665 *out = AugStore; | 5889 *out = AugStore; |
| 5666 return 0; | 5890 return 0; |
| 5667 } | 5891 } |
| 5668 if (PyObject_IsInstance(obj, (PyObject*)Param_type)) { | 5892 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); |
| 5893 if (isinstance == -1) { | |
| 5894 return 1; | |
| 5895 } | |
| 5896 if (isinstance) { | |
| 5669 *out = Param; | 5897 *out = Param; |
| 5670 return 0; | 5898 return 0; |
| 5671 } | 5899 } |
| 5672 | 5900 |
| 5673 tmp = PyObject_Repr(obj); | 5901 tmp = PyObject_Repr(obj); |
| 5680 | 5908 |
| 5681 int | 5909 int |
| 5682 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) | 5910 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) |
| 5683 { | 5911 { |
| 5684 PyObject* tmp = NULL; | 5912 PyObject* tmp = NULL; |
| 5913 int isinstance; | |
| 5685 | 5914 |
| 5686 | 5915 |
| 5687 if (obj == Py_None) { | 5916 if (obj == Py_None) { |
| 5688 *out = NULL; | 5917 *out = NULL; |
| 5689 return 0; | 5918 return 0; |
| 5690 } | 5919 } |
| 5691 if (PyObject_IsInstance(obj, (PyObject*)Slice_type)) { | 5920 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); |
| 5921 if (isinstance == -1) { | |
| 5922 return 1; | |
| 5923 } | |
| 5924 if (isinstance) { | |
| 5692 expr_ty lower; | 5925 expr_ty lower; |
| 5693 expr_ty upper; | 5926 expr_ty upper; |
| 5694 expr_ty step; | 5927 expr_ty step; |
| 5695 | 5928 |
| 5696 if (PyObject_HasAttrString(obj, "lower")) { | 5929 if (PyObject_HasAttrString(obj, "lower")) { |
| 5728 } | 5961 } |
| 5729 *out = Slice(lower, upper, step, arena); | 5962 *out = Slice(lower, upper, step, arena); |
| 5730 if (*out == NULL) goto failed; | 5963 if (*out == NULL) goto failed; |
| 5731 return 0; | 5964 return 0; |
| 5732 } | 5965 } |
| 5733 if (PyObject_IsInstance(obj, (PyObject*)ExtSlice_type)) { | 5966 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); |
| 5967 if (isinstance == -1) { | |
| 5968 return 1; | |
| 5969 } | |
| 5970 if (isinstance) { | |
| 5734 asdl_seq* dims; | 5971 asdl_seq* dims; |
| 5735 | 5972 |
| 5736 if (PyObject_HasAttrString(obj, "dims")) { | 5973 if (PyObject_HasAttrString(obj, "dims")) { |
| 5737 int res; | 5974 int res; |
| 5738 Py_ssize_t len; | 5975 Py_ssize_t len; |
| 5760 } | 5997 } |
| 5761 *out = ExtSlice(dims, arena); | 5998 *out = ExtSlice(dims, arena); |
| 5762 if (*out == NULL) goto failed; | 5999 if (*out == NULL) goto failed; |
| 5763 return 0; | 6000 return 0; |
| 5764 } | 6001 } |
| 5765 if (PyObject_IsInstance(obj, (PyObject*)Index_type)) { | 6002 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); |
| 6003 if (isinstance == -1) { | |
| 6004 return 1; | |
| 6005 } | |
| 6006 if (isinstance) { | |
| 5766 expr_ty value; | 6007 expr_ty value; |
| 5767 | 6008 |
| 5768 if (PyObject_HasAttrString(obj, "value")) { | 6009 if (PyObject_HasAttrString(obj, "value")) { |
| 5769 int res; | 6010 int res; |
| 5770 tmp = PyObject_GetAttrString(obj, "value"); | 6011 tmp = PyObject_GetAttrString(obj, "value"); |
| 5792 | 6033 |
| 5793 int | 6034 int |
| 5794 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) | 6035 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) |
| 5795 { | 6036 { |
| 5796 PyObject* tmp = NULL; | 6037 PyObject* tmp = NULL; |
| 5797 | 6038 int isinstance; |
| 5798 if (PyObject_IsInstance(obj, (PyObject*)And_type)) { | 6039 |
| 6040 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); | |
| 6041 if (isinstance == -1) { | |
| 6042 return 1; | |
| 6043 } | |
| 6044 if (isinstance) { | |
| 5799 *out = And; | 6045 *out = And; |
| 5800 return 0; | 6046 return 0; |
| 5801 } | 6047 } |
| 5802 if (PyObject_IsInstance(obj, (PyObject*)Or_type)) { | 6048 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); |
| 6049 if (isinstance == -1) { | |
| 6050 return 1; | |
| 6051 } | |
| 6052 if (isinstance) { | |
| 5803 *out = Or; | 6053 *out = Or; |
| 5804 return 0; | 6054 return 0; |
| 5805 } | 6055 } |
| 5806 | 6056 |
| 5807 tmp = PyObject_Repr(obj); | 6057 tmp = PyObject_Repr(obj); |
| 5814 | 6064 |
| 5815 int | 6065 int |
| 5816 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) | 6066 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) |
| 5817 { | 6067 { |
| 5818 PyObject* tmp = NULL; | 6068 PyObject* tmp = NULL; |
| 5819 | 6069 int isinstance; |
| 5820 if (PyObject_IsInstance(obj, (PyObject*)Add_type)) { | 6070 |
| 6071 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); | |
| 6072 if (isinstance == -1) { | |
| 6073 return 1; | |
| 6074 } | |
| 6075 if (isinstance) { | |
| 5821 *out = Add; | 6076 *out = Add; |
| 5822 return 0; | 6077 return 0; |
| 5823 } | 6078 } |
| 5824 if (PyObject_IsInstance(obj, (PyObject*)Sub_type)) { | 6079 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); |
| 6080 if (isinstance == -1) { | |
| 6081 return 1; | |
| 6082 } | |
| 6083 if (isinstance) { | |
| 5825 *out = Sub; | 6084 *out = Sub; |
| 5826 return 0; | 6085 return 0; |
| 5827 } | 6086 } |
| 5828 if (PyObject_IsInstance(obj, (PyObject*)Mult_type)) { | 6087 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); |
| 6088 if (isinstance == -1) { | |
| 6089 return 1; | |
| 6090 } | |
| 6091 if (isinstance) { | |
| 5829 *out = Mult; | 6092 *out = Mult; |
| 5830 return 0; | 6093 return 0; |
| 5831 } | 6094 } |
| 5832 if (PyObject_IsInstance(obj, (PyObject*)Div_type)) { | 6095 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); |
| 6096 if (isinstance == -1) { | |
| 6097 return 1; | |
| 6098 } | |
| 6099 if (isinstance) { | |
| 5833 *out = Div; | 6100 *out = Div; |
| 5834 return 0; | 6101 return 0; |
| 5835 } | 6102 } |
| 5836 if (PyObject_IsInstance(obj, (PyObject*)Mod_type)) { | 6103 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); |
| 6104 if (isinstance == -1) { | |
| 6105 return 1; | |
| 6106 } | |
| 6107 if (isinstance) { | |
| 5837 *out = Mod; | 6108 *out = Mod; |
| 5838 return 0; | 6109 return 0; |
| 5839 } | 6110 } |
| 5840 if (PyObject_IsInstance(obj, (PyObject*)Pow_type)) { | 6111 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); |
| 6112 if (isinstance == -1) { | |
| 6113 return 1; | |
| 6114 } | |
| 6115 if (isinstance) { | |
| 5841 *out = Pow; | 6116 *out = Pow; |
| 5842 return 0; | 6117 return 0; |
| 5843 } | 6118 } |
| 5844 if (PyObject_IsInstance(obj, (PyObject*)LShift_type)) { | 6119 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); |
| 6120 if (isinstance == -1) { | |
| 6121 return 1; | |
| 6122 } | |
| 6123 if (isinstance) { | |
| 5845 *out = LShift; | 6124 *out = LShift; |
| 5846 return 0; | 6125 return 0; |
| 5847 } | 6126 } |
| 5848 if (PyObject_IsInstance(obj, (PyObject*)RShift_type)) { | 6127 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); |
| 6128 if (isinstance == -1) { | |
| 6129 return 1; | |
| 6130 } | |
| 6131 if (isinstance) { | |
| 5849 *out = RShift; | 6132 *out = RShift; |
| 5850 return 0; | 6133 return 0; |
| 5851 } | 6134 } |
| 5852 if (PyObject_IsInstance(obj, (PyObject*)BitOr_type)) { | 6135 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); |
| 6136 if (isinstance == -1) { | |
| 6137 return 1; | |
| 6138 } | |
| 6139 if (isinstance) { | |
| 5853 *out = BitOr; | 6140 *out = BitOr; |
| 5854 return 0; | 6141 return 0; |
| 5855 } | 6142 } |
| 5856 if (PyObject_IsInstance(obj, (PyObject*)BitXor_type)) { | 6143 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); |
| 6144 if (isinstance == -1) { | |
| 6145 return 1; | |
| 6146 } | |
| 6147 if (isinstance) { | |
| 5857 *out = BitXor; | 6148 *out = BitXor; |
| 5858 return 0; | 6149 return 0; |
| 5859 } | 6150 } |
| 5860 if (PyObject_IsInstance(obj, (PyObject*)BitAnd_type)) { | 6151 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); |
| 6152 if (isinstance == -1) { | |
| 6153 return 1; | |
| 6154 } | |
| 6155 if (isinstance) { | |
| 5861 *out = BitAnd; | 6156 *out = BitAnd; |
| 5862 return 0; | 6157 return 0; |
| 5863 } | 6158 } |
| 5864 if (PyObject_IsInstance(obj, (PyObject*)FloorDiv_type)) { | 6159 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); |
| 6160 if (isinstance == -1) { | |
| 6161 return 1; | |
| 6162 } | |
| 6163 if (isinstance) { | |
| 5865 *out = FloorDiv; | 6164 *out = FloorDiv; |
| 5866 return 0; | 6165 return 0; |
| 5867 } | 6166 } |
| 5868 | 6167 |
| 5869 tmp = PyObject_Repr(obj); | 6168 tmp = PyObject_Repr(obj); |
| 5876 | 6175 |
| 5877 int | 6176 int |
| 5878 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) | 6177 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) |
| 5879 { | 6178 { |
| 5880 PyObject* tmp = NULL; | 6179 PyObject* tmp = NULL; |
| 5881 | 6180 int isinstance; |
| 5882 if (PyObject_IsInstance(obj, (PyObject*)Invert_type)) { | 6181 |
| 6182 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); | |
| 6183 if (isinstance == -1) { | |
| 6184 return 1; | |
| 6185 } | |
| 6186 if (isinstance) { | |
| 5883 *out = Invert; | 6187 *out = Invert; |
| 5884 return 0; | 6188 return 0; |
| 5885 } | 6189 } |
| 5886 if (PyObject_IsInstance(obj, (PyObject*)Not_type)) { | 6190 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); |
| 6191 if (isinstance == -1) { | |
| 6192 return 1; | |
| 6193 } | |
| 6194 if (isinstance) { | |
| 5887 *out = Not; | 6195 *out = Not; |
| 5888 return 0; | 6196 return 0; |
| 5889 } | 6197 } |
| 5890 if (PyObject_IsInstance(obj, (PyObject*)UAdd_type)) { | 6198 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); |
| 6199 if (isinstance == -1) { | |
| 6200 return 1; | |
| 6201 } | |
| 6202 if (isinstance) { | |
| 5891 *out = UAdd; | 6203 *out = UAdd; |
| 5892 return 0; | 6204 return 0; |
| 5893 } | 6205 } |
| 5894 if (PyObject_IsInstance(obj, (PyObject*)USub_type)) { | 6206 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); |
| 6207 if (isinstance == -1) { | |
| 6208 return 1; | |
| 6209 } | |
| 6210 if (isinstance) { | |
| 5895 *out = USub; | 6211 *out = USub; |
| 5896 return 0; | 6212 return 0; |
| 5897 } | 6213 } |
| 5898 | 6214 |
| 5899 tmp = PyObject_Repr(obj); | 6215 tmp = PyObject_Repr(obj); |
| 5906 | 6222 |
| 5907 int | 6223 int |
| 5908 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) | 6224 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) |
| 5909 { | 6225 { |
| 5910 PyObject* tmp = NULL; | 6226 PyObject* tmp = NULL; |
| 5911 | 6227 int isinstance; |
| 5912 if (PyObject_IsInstance(obj, (PyObject*)Eq_type)) { | 6228 |
| 6229 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); | |
| 6230 if (isinstance == -1) { | |
| 6231 return 1; | |
| 6232 } | |
| 6233 if (isinstance) { | |
| 5913 *out = Eq; | 6234 *out = Eq; |
| 5914 return 0; | 6235 return 0; |
| 5915 } | 6236 } |
| 5916 if (PyObject_IsInstance(obj, (PyObject*)NotEq_type)) { | 6237 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); |
| 6238 if (isinstance == -1) { | |
| 6239 return 1; | |
| 6240 } | |
| 6241 if (isinstance) { | |
| 5917 *out = NotEq; | 6242 *out = NotEq; |
| 5918 return 0; | 6243 return 0; |
| 5919 } | 6244 } |
| 5920 if (PyObject_IsInstance(obj, (PyObject*)Lt_type)) { | 6245 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); |
| 6246 if (isinstance == -1) { | |
| 6247 return 1; | |
| 6248 } | |
| 6249 if (isinstance) { | |
| 5921 *out = Lt; | 6250 *out = Lt; |
| 5922 return 0; | 6251 return 0; |
| 5923 } | 6252 } |
| 5924 if (PyObject_IsInstance(obj, (PyObject*)LtE_type)) { | 6253 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); |
| 6254 if (isinstance == -1) { | |
| 6255 return 1; | |
| 6256 } | |
| 6257 if (isinstance) { | |
| 5925 *out = LtE; | 6258 *out = LtE; |
| 5926 return 0; | 6259 return 0; |
| 5927 } | 6260 } |
| 5928 if (PyObject_IsInstance(obj, (PyObject*)Gt_type)) { | 6261 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); |
| 6262 if (isinstance == -1) { | |
| 6263 return 1; | |
| 6264 } | |
| 6265 if (isinstance) { | |
| 5929 *out = Gt; | 6266 *out = Gt; |
| 5930 return 0; | 6267 return 0; |
| 5931 } | 6268 } |
| 5932 if (PyObject_IsInstance(obj, (PyObject*)GtE_type)) { | 6269 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); |
| 6270 if (isinstance == -1) { | |
| 6271 return 1; | |
| 6272 } | |
| 6273 if (isinstance) { | |
| 5933 *out = GtE; | 6274 *out = GtE; |
| 5934 return 0; | 6275 return 0; |
| 5935 } | 6276 } |
| 5936 if (PyObject_IsInstance(obj, (PyObject*)Is_type)) { | 6277 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); |
| 6278 if (isinstance == -1) { | |
| 6279 return 1; | |
| 6280 } | |
| 6281 if (isinstance) { | |
| 5937 *out = Is; | 6282 *out = Is; |
| 5938 return 0; | 6283 return 0; |
| 5939 } | 6284 } |
| 5940 if (PyObject_IsInstance(obj, (PyObject*)IsNot_type)) { | 6285 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); |
| 6286 if (isinstance == -1) { | |
| 6287 return 1; | |
| 6288 } | |
| 6289 if (isinstance) { | |
| 5941 *out = IsNot; | 6290 *out = IsNot; |
| 5942 return 0; | 6291 return 0; |
| 5943 } | 6292 } |
| 5944 if (PyObject_IsInstance(obj, (PyObject*)In_type)) { | 6293 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); |
| 6294 if (isinstance == -1) { | |
| 6295 return 1; | |
| 6296 } | |
| 6297 if (isinstance) { | |
| 5945 *out = In; | 6298 *out = In; |
| 5946 return 0; | 6299 return 0; |
| 5947 } | 6300 } |
| 5948 if (PyObject_IsInstance(obj, (PyObject*)NotIn_type)) { | 6301 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); |
| 6302 if (isinstance == -1) { | |
| 6303 return 1; | |
| 6304 } | |
| 6305 if (isinstance) { | |
| 5949 *out = NotIn; | 6306 *out = NotIn; |
| 5950 return 0; | 6307 return 0; |
| 5951 } | 6308 } |
| 5952 | 6309 |
| 5953 tmp = PyObject_Repr(obj); | 6310 tmp = PyObject_Repr(obj); |
| 6024 | 6381 |
| 6025 int | 6382 int |
| 6026 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) | 6383 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) |
| 6027 { | 6384 { |
| 6028 PyObject* tmp = NULL; | 6385 PyObject* tmp = NULL; |
| 6386 int isinstance; | |
| 6029 | 6387 |
| 6030 int lineno; | 6388 int lineno; |
| 6031 int col_offset; | 6389 int col_offset; |
| 6032 | 6390 |
| 6033 if (obj == Py_None) { | 6391 if (obj == Py_None) { |
| 6056 tmp = NULL; | 6414 tmp = NULL; |
| 6057 } else { | 6415 } else { |
| 6058 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); | 6416 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); |
| 6059 return 1; | 6417 return 1; |
| 6060 } | 6418 } |
| 6061 if (PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type)) { | 6419 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type); |
| 6420 if (isinstance == -1) { | |
| 6421 return 1; | |
| 6422 } | |
| 6423 if (isinstance) { | |
| 6062 expr_ty type; | 6424 expr_ty type; |
| 6063 identifier name; | 6425 identifier name; |
| 6064 asdl_seq* body; | 6426 asdl_seq* body; |
| 6065 | 6427 |
| 6066 if (PyObject_HasAttrString(obj, "type")) { | 6428 if (PyObject_HasAttrString(obj, "type")) { |
| 6633 { | 6995 { |
| 6634 mod_ty res; | 6996 mod_ty res; |
| 6635 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, | 6997 PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type, |
| 6636 (PyObject*)Interactive_type}; | 6998 (PyObject*)Interactive_type}; |
| 6637 char *req_name[] = {"Module", "Expression", "Interactive"}; | 6999 char *req_name[] = {"Module", "Expression", "Interactive"}; |
| 7000 int isinstance; | |
| 6638 assert(0 <= mode && mode <= 2); | 7001 assert(0 <= mode && mode <= 2); |
| 6639 | 7002 |
| 6640 init_types(); | 7003 init_types(); |
| 6641 | 7004 |
| 6642 if (!PyObject_IsInstance(ast, req_type[mode])) { | 7005 isinstance = PyObject_IsInstance(ast, req_type[mode]); |
| 7006 if (isinstance == -1) | |
| 7007 return NULL; | |
| 7008 if (!isinstance) { | |
| 6643 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", | 7009 PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s", |
| 6644 req_name[mode], Py_TYPE(ast)->tp_name); | 7010 req_name[mode], Py_TYPE(ast)->tp_name); |
| 6645 return NULL; | 7011 return NULL; |
| 6646 } | 7012 } |
| 6647 if (obj2ast_mod(ast, &res, arena) != 0) | 7013 if (obj2ast_mod(ast, &res, arena) != 0) |
