mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45510: Check both types when specializing subtraction (GH-29995)
This commit is contained in:
parent
9fe0de28bc
commit
5de39f4b41
1 changed files with 4 additions and 0 deletions
|
@ -1490,6 +1490,10 @@ _Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
|
|||
break;
|
||||
case NB_SUBTRACT:
|
||||
case NB_INPLACE_SUBTRACT:
|
||||
if (!Py_IS_TYPE(lhs, Py_TYPE(rhs))) {
|
||||
SPECIALIZATION_FAIL(BINARY_OP, SPEC_FAIL_DIFFERENT_TYPES);
|
||||
goto failure;
|
||||
}
|
||||
if (PyLong_CheckExact(lhs)) {
|
||||
*instr = _Py_MAKECODEUNIT(BINARY_OP_SUBTRACT_INT,
|
||||
_Py_OPARG(*instr));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue