@@ -1372,7 +1372,7 @@ handle_keywordonly_args(struct compiling *c, const node *n, int start,
1372
1372
goto error ;
1373
1373
asdl_seq_SET (kwonlyargs , j ++ , arg );
1374
1374
i += 1 ; /* the name */
1375
- if (TYPE (CHILD (n , i )) == COMMA )
1375
+ if (i < NCH ( n ) && TYPE (CHILD (n , i )) == COMMA )
1376
1376
i += 1 ; /* the comma, if present */
1377
1377
break ;
1378
1378
case TYPE_COMMENT :
@@ -1514,7 +1514,7 @@ ast_for_arguments(struct compiling *c, const node *n)
1514
1514
return NULL ;
1515
1515
asdl_seq_SET (posargs , k ++ , arg );
1516
1516
i += 1 ; /* the name */
1517
- if (TYPE (CHILD (n , i )) == COMMA )
1517
+ if (i < NCH ( n ) && TYPE (CHILD (n , i )) == COMMA )
1518
1518
i += 1 ; /* the comma, if present */
1519
1519
break ;
1520
1520
case STAR :
@@ -1530,7 +1530,7 @@ ast_for_arguments(struct compiling *c, const node *n)
1530
1530
int res = 0 ;
1531
1531
i += 2 ; /* now follows keyword only arguments */
1532
1532
1533
- if (TYPE (CHILD (n , i )) == TYPE_COMMENT ) {
1533
+ if (i < NCH ( n ) && TYPE (CHILD (n , i )) == TYPE_COMMENT ) {
1534
1534
ast_error (c , CHILD (n , i ),
1535
1535
"bare * has associated type comment" );
1536
1536
return NULL ;
@@ -1546,11 +1546,11 @@ ast_for_arguments(struct compiling *c, const node *n)
1546
1546
if (!vararg )
1547
1547
return NULL ;
1548
1548
1549
- i += 2 ; /* the star and the name */
1550
- if (TYPE (CHILD (n , i )) == COMMA )
1551
- i += 1 ; /* the comma, if present */
1549
+ i += 2 ; /* the star and the name */
1550
+ if (i < NCH ( n ) && TYPE (CHILD (n , i )) == COMMA )
1551
+ i += 1 ; /* the comma, if present */
1552
1552
1553
- if (TYPE (CHILD (n , i )) == TYPE_COMMENT ) {
1553
+ if (i < NCH ( n ) && TYPE (CHILD (n , i )) == TYPE_COMMENT ) {
1554
1554
vararg -> type_comment = NEW_TYPE_COMMENT (CHILD (n , i ));
1555
1555
i += 1 ;
1556
1556
}
@@ -1572,7 +1572,7 @@ ast_for_arguments(struct compiling *c, const node *n)
1572
1572
if (!kwarg )
1573
1573
return NULL ;
1574
1574
i += 2 ; /* the double star and the name */
1575
- if (TYPE (CHILD (n , i )) == COMMA )
1575
+ if (i < NCH ( n ) && TYPE (CHILD (n , i )) == COMMA )
1576
1576
i += 1 ; /* the comma, if present */
1577
1577
break ;
1578
1578
case TYPE_COMMENT :
0 commit comments