~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Python/Python-ast.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
3180
3180
obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
3181
3181
{
3182
3182
        PyObject* tmp = NULL;
 
3183
        int isinstance;
3183
3184
 
3184
3185
 
3185
3186
        if (obj == Py_None) {
3186
3187
                *out = NULL;
3187
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
3195
                asdl_seq* body;
3191
3196
 
3192
3197
                if (PyObject_HasAttrString(obj, "body")) {
3218
3223
                if (*out == NULL) goto failed;
3219
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
3231
                asdl_seq* body;
3223
3232
 
3224
3233
                if (PyObject_HasAttrString(obj, "body")) {
3250
3259
                if (*out == NULL) goto failed;
3251
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
3267
                expr_ty body;
3255
3268
 
3256
3269
                if (PyObject_HasAttrString(obj, "body")) {
3269
3282
                if (*out == NULL) goto failed;
3270
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
3290
                asdl_seq* body;
3274
3291
 
3275
3292
                if (PyObject_HasAttrString(obj, "body")) {
3314
3331
obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
3315
3332
{
3316
3333
        PyObject* tmp = NULL;
 
3334
        int isinstance;
3317
3335
 
3318
3336
        int lineno;
3319
3337
        int col_offset;
3346
3364
                PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
3347
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
3372
                identifier name;
3351
3373
                arguments_ty args;
3352
3374
                asdl_seq* body;
3431
3453
                if (*out == NULL) goto failed;
3432
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
3461
                identifier name;
3436
3462
                asdl_seq* bases;
3437
3463
                asdl_seq* body;
3529
3555
                if (*out == NULL) goto failed;
3530
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
3563
                expr_ty value;
3534
3564
 
3535
3565
                if (PyObject_HasAttrString(obj, "value")) {
3547
3577
                if (*out == NULL) goto failed;
3548
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
3585
                asdl_seq* targets;
3552
3586
 
3553
3587
                if (PyObject_HasAttrString(obj, "targets")) {
3579
3613
                if (*out == NULL) goto failed;
3580
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
3621
                asdl_seq* targets;
3584
3622
                expr_ty value;
3585
3623
 
3624
3662
                if (*out == NULL) goto failed;
3625
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
3670
                expr_ty target;
3629
3671
                operator_ty op;
3630
3672
                expr_ty value;
3669
3711
                if (*out == NULL) goto failed;
3670
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
3719
                expr_ty dest;
3674
3720
                asdl_seq* values;
3675
3721
                bool nl;
3726
3772
                if (*out == NULL) goto failed;
3727
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
3780
                expr_ty target;
3731
3781
                expr_ty iter;
3732
3782
                asdl_seq* body;
3811
3861
                if (*out == NULL) goto failed;
3812
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
3869
                expr_ty test;
3816
3870
                asdl_seq* body;
3817
3871
                asdl_seq* orelse;
3882
3936
                if (*out == NULL) goto failed;
3883
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
3944
                expr_ty test;
3887
3945
                asdl_seq* body;
3888
3946
                asdl_seq* orelse;
3953
4011
                if (*out == NULL) goto failed;
3954
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
4019
                expr_ty context_expr;
3958
4020
                expr_ty optional_vars;
3959
4021
                asdl_seq* body;
4011
4073
                if (*out == NULL) goto failed;
4012
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
4081
                expr_ty type;
4016
4082
                expr_ty inst;
4017
4083
                expr_ty tback;
4053
4119
                if (*out == NULL) goto failed;
4054
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
4127
                asdl_seq* body;
4058
4128
                asdl_seq* handlers;
4059
4129
                asdl_seq* orelse;
4138
4208
                if (*out == NULL) goto failed;
4139
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
4216
                asdl_seq* body;
4143
4217
                asdl_seq* finalbody;
4144
4218
 
4196
4270
                if (*out == NULL) goto failed;
4197
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
4278
                expr_ty test;
4201
4279
                expr_ty msg;
4202
4280
 
4227
4305
                if (*out == NULL) goto failed;
4228
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
4313
                asdl_seq* names;
4232
4314
 
4233
4315
                if (PyObject_HasAttrString(obj, "names")) {
4259
4341
                if (*out == NULL) goto failed;
4260
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
4349
                identifier module;
4264
4350
                asdl_seq* names;
4265
4351
                int level;
4317
4403
                if (*out == NULL) goto failed;
4318
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
4411
                expr_ty body;
4322
4412
                expr_ty globals;
4323
4413
                expr_ty locals;
4360
4450
                if (*out == NULL) goto failed;
4361
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
4458
                asdl_seq* names;
4365
4459
 
4366
4460
                if (PyObject_HasAttrString(obj, "names")) {
4392
4486
                if (*out == NULL) goto failed;
4393
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
4494
                expr_ty value;
4397
4495
 
4398
4496
                if (PyObject_HasAttrString(obj, "value")) {
4411
4509
                if (*out == NULL) goto failed;
4412
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
4518
                *out = Pass(lineno, col_offset, arena);
4417
4519
                if (*out == NULL) goto failed;
4418
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
4528
                *out = Break(lineno, col_offset, arena);
4423
4529
                if (*out == NULL) goto failed;
4424
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
4538
                *out = Continue(lineno, col_offset, arena);
4429
4539
                if (*out == NULL) goto failed;
4442
4552
obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
4443
4553
{
4444
4554
        PyObject* tmp = NULL;
 
4555
        int isinstance;
4445
4556
 
4446
4557
        int lineno;
4447
4558
        int col_offset;
4474
4585
                PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
4475
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
4593
                boolop_ty op;
4479
4594
                asdl_seq* values;
4480
4595
 
4519
4634
                if (*out == NULL) goto failed;
4520
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
4642
                expr_ty left;
4524
4643
                operator_ty op;
4525
4644
                expr_ty right;
4564
4683
                if (*out == NULL) goto failed;
4565
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
4691
                unaryop_ty op;
4569
4692
                expr_ty operand;
4570
4693
 
4596
4719
                if (*out == NULL) goto failed;
4597
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
4727
                arguments_ty args;
4601
4728
                expr_ty body;
4602
4729
 
4628
4755
                if (*out == NULL) goto failed;
4629
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
4763
                expr_ty test;
4633
4764
                expr_ty body;
4634
4765
                expr_ty orelse;
4673
4804
                if (*out == NULL) goto failed;
4674
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
4812
                asdl_seq* keys;
4678
4813
                asdl_seq* values;
4679
4814
 
4731
4866
                if (*out == NULL) goto failed;
4732
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
4874
                expr_ty elt;
4736
4875
                asdl_seq* generators;
4737
4876
 
4776
4915
                if (*out == NULL) goto failed;
4777
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
4923
                expr_ty elt;
4781
4924
                asdl_seq* generators;
4782
4925
 
4821
4964
                if (*out == NULL) goto failed;
4822
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
4972
                expr_ty value;
4826
4973
 
4827
4974
                if (PyObject_HasAttrString(obj, "value")) {
4839
4986
                if (*out == NULL) goto failed;
4840
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
4994
                expr_ty left;
4844
4995
                asdl_int_seq* ops;
4845
4996
                asdl_seq* comparators;
4911
5062
                if (*out == NULL) goto failed;
4912
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
5070
                expr_ty func;
4916
5071
                asdl_seq* args;
4917
5072
                asdl_seq* keywords;
5007
5162
                if (*out == NULL) goto failed;
5008
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
5170
                expr_ty value;
5012
5171
 
5013
5172
                if (PyObject_HasAttrString(obj, "value")) {
5026
5185
                if (*out == NULL) goto failed;
5027
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
5193
                object n;
5031
5194
 
5032
5195
                if (PyObject_HasAttrString(obj, "n")) {
5045
5208
                if (*out == NULL) goto failed;
5046
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
5216
                string s;
5050
5217
 
5051
5218
                if (PyObject_HasAttrString(obj, "s")) {
5064
5231
                if (*out == NULL) goto failed;
5065
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
5239
                expr_ty value;
5069
5240
                identifier attr;
5070
5241
                expr_context_ty ctx;
5109
5280
                if (*out == NULL) goto failed;
5110
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
5288
                expr_ty value;
5114
5289
                slice_ty slice;
5115
5290
                expr_context_ty ctx;
5154
5329
                if (*out == NULL) goto failed;
5155
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
5337
                identifier id;
5159
5338
                expr_context_ty ctx;
5160
5339
 
5186
5365
                if (*out == NULL) goto failed;
5187
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
5373
                asdl_seq* elts;
5191
5374
                expr_context_ty ctx;
5192
5375
 
5231
5414
                if (*out == NULL) goto failed;
5232
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
5422
                asdl_seq* elts;
5236
5423
                expr_context_ty ctx;
5237
5424
 
5289
5476
obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
5290
5477
{
5291
5478
        PyObject* tmp = NULL;
 
5479
        int isinstance;
5292
5480
 
5293
 
        if (PyObject_IsInstance(obj, (PyObject*)Load_type)) {
 
5481
        isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type);
 
5482
        if (isinstance == -1) {
 
5483
                return 1;
 
5484
        }
 
5485
        if (isinstance) {
5294
5486
                *out = Load;
5295
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
5494
                *out = Store;
5299
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
5502
                *out = Del;
5303
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
5510
                *out = AugLoad;
5307
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
5518
                *out = AugStore;
5311
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
5526
                *out = Param;
5315
5527
                return 0;
5316
5528
        }
5327
5539
obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
5328
5540
{
5329
5541
        PyObject* tmp = NULL;
 
5542
        int isinstance;
5330
5543
 
5331
5544
 
5332
5545
        if (obj == Py_None) {
5333
5546
                *out = NULL;
5334
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
5555
                *out = Ellipsis(arena);
5339
5556
                if (*out == NULL) goto failed;
5340
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
5564
                expr_ty lower;
5344
5565
                expr_ty upper;
5345
5566
                expr_ty step;
5381
5602
                if (*out == NULL) goto failed;
5382
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
5610
                asdl_seq* dims;
5386
5611
 
5387
5612
                if (PyObject_HasAttrString(obj, "dims")) {
5413
5638
                if (*out == NULL) goto failed;
5414
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
5646
                expr_ty value;
5418
5647
 
5419
5648
                if (PyObject_HasAttrString(obj, "value")) {
5445
5674
obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
5446
5675
{
5447
5676
        PyObject* tmp = NULL;
 
5677
        int isinstance;
5448
5678
 
5449
 
        if (PyObject_IsInstance(obj, (PyObject*)And_type)) {
 
5679
        isinstance = PyObject_IsInstance(obj, (PyObject *)And_type);
 
5680
        if (isinstance == -1) {
 
5681
                return 1;
 
5682
        }
 
5683
        if (isinstance) {
5450
5684
                *out = And;
5451
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
5692
                *out = Or;
5455
5693
                return 0;
5456
5694
        }
5467
5705
obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
5468
5706
{
5469
5707
        PyObject* tmp = NULL;
 
5708
        int isinstance;
5470
5709
 
5471
 
        if (PyObject_IsInstance(obj, (PyObject*)Add_type)) {
 
5710
        isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type);
 
5711
        if (isinstance == -1) {
 
5712
                return 1;
 
5713
        }
 
5714
        if (isinstance) {
5472
5715
                *out = Add;
5473
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
5723
                *out = Sub;
5477
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
5731
                *out = Mult;
5481
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
5739
                *out = Div;
5485
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
5747
                *out = Mod;
5489
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
5755
                *out = Pow;
5493
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
5763
                *out = LShift;
5497
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
5771
                *out = RShift;
5501
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
5779
                *out = BitOr;
5505
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
5787
                *out = BitXor;
5509
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
5795
                *out = BitAnd;
5513
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
5803
                *out = FloorDiv;
5517
5804
                return 0;
5518
5805
        }
5529
5816
obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
5530
5817
{
5531
5818
        PyObject* tmp = NULL;
 
5819
        int isinstance;
5532
5820
 
5533
 
        if (PyObject_IsInstance(obj, (PyObject*)Invert_type)) {
 
5821
        isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type);
 
5822
        if (isinstance == -1) {
 
5823
                return 1;
 
5824
        }
 
5825
        if (isinstance) {
5534
5826
                *out = Invert;
5535
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
5834
                *out = Not;
5539
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
5842
                *out = UAdd;
5543
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
5850
                *out = USub;
5547
5851
                return 0;
5548
5852
        }
5559
5863
obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
5560
5864
{
5561
5865
        PyObject* tmp = NULL;
 
5866
        int isinstance;
5562
5867
 
5563
 
        if (PyObject_IsInstance(obj, (PyObject*)Eq_type)) {
 
5868
        isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type);
 
5869
        if (isinstance == -1) {
 
5870
                return 1;
 
5871
        }
 
5872
        if (isinstance) {
5564
5873
                *out = Eq;
5565
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
5881
                *out = NotEq;
5569
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
5889
                *out = Lt;
5573
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
5897
                *out = LtE;
5577
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
5905
                *out = Gt;
5581
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
5913
                *out = GtE;
5585
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
5921
                *out = Is;
5589
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
5929
                *out = IsNot;
5593
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
5937
                *out = In;
5597
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
5945
                *out = NotIn;
5601
5946
                return 0;
5602
5947
        }
5677
6022
obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
5678
6023
{
5679
6024
        PyObject* tmp = NULL;
 
6025
        int isinstance;
5680
6026
 
5681
6027
        int lineno;
5682
6028
        int col_offset;
5709
6055
                PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
5710
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
6063
                expr_ty type;
5714
6064
                expr_ty name;
5715
6065
                asdl_seq* body;
6110
6460
    PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
6111
6461
                            (PyObject*)Interactive_type};
6112
6462
    char *req_name[] = {"Module", "Expression", "Interactive"};
 
6463
    int isinstance;
6113
6464
    assert(0 <= mode && mode <= 2);
6114
6465
 
6115
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
6472
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
6119
6473
                     req_name[mode], Py_TYPE(ast)->tp_name);
6120
6474
        return NULL;