@@ -1384,14 +1384,6 @@ def check_op_count(func, op, expected):
13841384 actual += 1
13851385 self .assertEqual (actual , expected )
13861386
1387- def check_num_consts (func , typ , expected ):
1388- num_consts = 0
1389- consts = func .__code__ .co_consts
1390- for instr in dis .Bytecode (func ):
1391- if instr .opname == "LOAD_CONST" and isinstance (consts [instr .oparg ], typ ):
1392- num_consts += 1
1393- self .assertEqual (num_consts , expected )
1394-
13951387 def check_consts (func , typ , expected ):
13961388 all_consts = set ()
13971389 consts = func .__code__ .co_consts
@@ -1406,51 +1398,60 @@ def load():
14061398 check_op_count (load , "BINARY_SLICE" , 3 )
14071399 check_op_count (load , "BUILD_SLICE" , 0 )
14081400 check_consts (load , slice , {slice (None , None , None )})
1401+ check_op_count (load , "BINARY_SUBSCR" , 1 )
14091402
14101403 def store ():
14111404 x [a :b ] = y
1412- x [a :] = y
1405+ x [a :] = y
14131406 x [:b ] = y
14141407 x [:] = y
14151408
14161409 check_op_count (store , "STORE_SLICE" , 3 )
14171410 check_op_count (store , "BUILD_SLICE" , 0 )
1411+ check_op_count (store , "STORE_SUBSCR" , 1 )
14181412 check_consts (store , slice , {slice (None , None , None )})
14191413
14201414 def long_slice ():
14211415 return x [a :b :c ]
14221416
14231417 check_op_count (long_slice , "BUILD_SLICE" , 1 )
14241418 check_op_count (long_slice , "BINARY_SLICE" , 0 )
1425- check_num_consts (long_slice , slice , 0 )
1419+ check_consts (long_slice , slice , set ())
1420+ check_op_count (long_slice , "BINARY_SUBSCR" , 1 )
14261421
14271422 def aug ():
14281423 x [a :b ] += y
14291424
14301425 check_op_count (aug , "BINARY_SLICE" , 1 )
14311426 check_op_count (aug , "STORE_SLICE" , 1 )
14321427 check_op_count (aug , "BUILD_SLICE" , 0 )
1433- check_num_consts (long_slice , slice , 0 )
1428+ check_op_count (aug , "BINARY_SUBSCR" , 0 )
1429+ check_op_count (aug , "STORE_SUBSCR" , 0 )
1430+ check_consts (aug , slice , set ())
14341431
14351432 def aug_const ():
14361433 x [1 :2 ] += y
14371434
14381435 check_op_count (aug_const , "BINARY_SLICE" , 0 )
14391436 check_op_count (aug_const , "STORE_SLICE" , 0 )
1437+ check_op_count (aug_const , "BINARY_SUBSCR" , 1 )
1438+ check_op_count (aug_const , "STORE_SUBSCR" , 1 )
14401439 check_consts (aug_const , slice , {slice (1 , 2 )})
14411440
14421441 def compound_const_slice ():
14431442 x [1 :2 :3 , 4 :5 :6 ] = y
14441443
14451444 check_op_count (compound_const_slice , "BINARY_SLICE" , 0 )
14461445 check_op_count (compound_const_slice , "BUILD_SLICE" , 0 )
1447- check_num_consts (compound_const_slice , slice , 0 )
1446+ check_op_count (compound_const_slice , "STORE_SLICE" , 0 )
1447+ check_op_count (compound_const_slice , "BINARY_SUBSCR" , 1 )
1448+ check_consts (compound_const_slice , slice , {})
14481449 check_consts (compound_const_slice , tuple , {(slice (1 , 2 , 3 ), slice (4 , 5 , 6 ))})
14491450
14501451 def mutable_slice ():
14511452 x [[]:] = y
14521453
1453- check_num_consts (mutable_slice , slice , 0 )
1454+ check_consts (mutable_slice , slice , {} )
14541455
14551456 def different_but_equal ():
14561457 x [:0 ] = y
0 commit comments