Skip to content

Commit 5de39f4

Browse files
authored
bpo-45510: Check both types when specializing subtraction (GH-29995)
1 parent 9fe0de2 commit 5de39f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Python/specialize.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,10 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
14901490
break;
14911491
case NB_SUBTRACT:
14921492
case NB_INPLACE_SUBTRACT:
1493+
if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) {
1494+
SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES);
1495+
goto failure;
1496+
}
14931497
if (PyLong_CheckExact(lhs)) {
14941498
*instr = _Py_MAKECODEUNIT(BINARY_OP_SUBTRACT_INT,
14951499
_Py_OPARG(*instr));

0 commit comments

Comments
 (0)