Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/cpython/pystats.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#define PYSTATS_MAX_UOP_ID 512

#define SPECIALIZATION_FAILURE_KINDS 44
#define SPECIALIZATION_FAILURE_KINDS 50

/* Stats for determining who is calling PyEval_EvalFrame */
#define EVAL_CALL_TOTAL 0
Expand Down
31 changes: 31 additions & 0 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,12 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
#define SPEC_FAIL_BINARY_OP_SUBSCR_DEQUE 42
#define SPEC_FAIL_BINARY_OP_SUBSCR_ENUMDICT 43
#define SPEC_FAIL_BINARY_OP_SUBSCR_STACKSUMMARY 44
#define SPEC_FAIL_BINARY_OP_SUBSCR_DEFAULTDICT 45
#define SPEC_FAIL_BINARY_OP_SUBSCR_COUNTER 46
#define SPEC_FAIL_BINARY_OP_SUBSCR_ORDEREDDICT 47
#define SPEC_FAIL_BINARY_OP_SUBSCR_BYTES 48
#define SPEC_FAIL_BINARY_OP_SUBSCR_STRUCTTIME 49
#define SPEC_FAIL_BINARY_OP_SUBSCR_RANGE 50

/* Calls */

Expand Down Expand Up @@ -2370,6 +2376,14 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
return SPEC_FAIL_BINARY_OP_SUBSCR_MAPPINGPROXY;
}

if (PyObject_TypeCheck(lhs, &PyBytes_Type)) {
return SPEC_FAIL_BINARY_OP_SUBSCR_BYTES;
}

if (PyObject_TypeCheck(lhs, &PyRange_Type)) {
return SPEC_FAIL_BINARY_OP_SUBSCR_RANGE;
}

if (strcmp(container_type->tp_name, "array.array") == 0) {
return SPEC_FAIL_BINARY_OP_SUBSCR_ARRAY;
}
Expand All @@ -2390,9 +2404,26 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
return SPEC_FAIL_BINARY_OP_SUBSCR_STACKSUMMARY;
}

if (strcmp(container_type->tp_name, "collections.defaultdict") == 0) {
return SPEC_FAIL_BINARY_OP_SUBSCR_DEFAULTDICT;
}

if (strcmp(container_type->tp_name, "Counter") == 0) {
return SPEC_FAIL_BINARY_OP_SUBSCR_COUNTER;
}

if (strcmp(container_type->tp_name, "collections.OrderedDict") == 0) {
return SPEC_FAIL_BINARY_OP_SUBSCR_ORDEREDDICT;
}

if (strcmp(container_type->tp_name, "time.struct_time") == 0) {
return SPEC_FAIL_BINARY_OP_SUBSCR_STRUCTTIME;
}

if (PySlice_Check(rhs)) {
return SPEC_FAIL_BINARY_OP_SUBSCR_OTHER_SLICE;
}

return SPEC_FAIL_BINARY_OP_SUBSCR;
}
Py_UNREACHABLE();
Expand Down
Loading