File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1+ The ``BINARY_SUBSCR_LIST_INT `` and ``BINARY_SUBSCR_TUPLE_INT ``
2+ instructions are no longer used for negative integers because
3+ those instructions always miss when encountering negative integers.
Original file line number Diff line number Diff line change @@ -1302,17 +1302,25 @@ _Py_Specialize_BinarySubscr(
13021302 PyTypeObject * container_type = Py_TYPE (container );
13031303 if (container_type == & PyList_Type ) {
13041304 if (PyLong_CheckExact (sub )) {
1305- _py_set_opcode (instr , BINARY_SUBSCR_LIST_INT );
1306- goto success ;
1305+ if (Py_SIZE (sub ) == 0 || Py_SIZE (sub ) == 1 ) {
1306+ _py_set_opcode (instr , BINARY_SUBSCR_LIST_INT );
1307+ goto success ;
1308+ }
1309+ SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
1310+ goto fail ;
13071311 }
13081312 SPECIALIZATION_FAIL (BINARY_SUBSCR ,
13091313 PySlice_Check (sub ) ? SPEC_FAIL_SUBSCR_LIST_SLICE : SPEC_FAIL_OTHER );
13101314 goto fail ;
13111315 }
13121316 if (container_type == & PyTuple_Type ) {
13131317 if (PyLong_CheckExact (sub )) {
1314- _py_set_opcode (instr , BINARY_SUBSCR_TUPLE_INT );
1315- goto success ;
1318+ if (Py_SIZE (sub ) == 0 || Py_SIZE (sub ) == 1 ) {
1319+ _py_set_opcode (instr , BINARY_SUBSCR_TUPLE_INT );
1320+ goto success ;
1321+ }
1322+ SPECIALIZATION_FAIL (BINARY_SUBSCR , SPEC_FAIL_OUT_OF_RANGE );
1323+ goto fail ;
13161324 }
13171325 SPECIALIZATION_FAIL (BINARY_SUBSCR ,
13181326 PySlice_Check (sub ) ? SPEC_FAIL_SUBSCR_TUPLE_SLICE : SPEC_FAIL_OTHER );
You can’t perform that action at this time.
0 commit comments