@@ -503,14 +503,14 @@ def p_index(s, base):
503503 # s.sy == '['
504504 pos = s .position ()
505505 s .next ()
506- subscripts = p_subscript_list (s )
507- if len ( subscripts ) == 1 and len (subscripts [0 ]) == 2 :
506+ subscripts , is_single_value = p_subscript_list (s )
507+ if is_single_value and len (subscripts [0 ]) == 2 :
508508 start , stop = subscripts [0 ]
509509 result = ExprNodes .SliceIndexNode (pos ,
510510 base = base , start = start , stop = stop )
511511 else :
512512 indexes = make_slice_nodes (pos , subscripts )
513- if len ( indexes ) == 1 :
513+ if is_single_value :
514514 index = indexes [0 ]
515515 else :
516516 index = ExprNodes .TupleNode (pos , args = indexes )
@@ -520,13 +520,15 @@ def p_index(s, base):
520520 return result
521521
522522def p_subscript_list (s ):
523+ is_single_value = True
523524 items = [p_subscript (s )]
524525 while s .sy == ',' :
526+ is_single_value = False
525527 s .next ()
526528 if s .sy == ']' :
527529 break
528530 items .append (p_subscript (s ))
529- return items
531+ return items , is_single_value
530532
531533#subscript: '.' '.' '.' | test | [test] ':' [test] [':' [test]]
532534
@@ -2117,7 +2119,7 @@ def p_memoryviewslice_access(s, base_type_node):
21172119 # s.sy == '['
21182120 pos = s .position ()
21192121 s .next ()
2120- subscripts = p_subscript_list (s )
2122+ subscripts , _ = p_subscript_list (s )
21212123 # make sure each entry in subscripts is a slice
21222124 for subscript in subscripts :
21232125 if len (subscript ) < 2 :
0 commit comments