diff options
author | Brandt Bucher <brandt@python.org> | 2021-12-09 01:17:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-09 01:17:16 (GMT) |
commit | 5de39f4b412ed5b0f3ed0140c83b2c1f8c707603 (patch) | |
tree | fd486f46ef8831b20ec55a0817c5fa6382743f14 /Python | |
parent | 9fe0de28bcc8d6b4077d9c3994648049730ee721 (diff) | |
download | cpython-5de39f4b412ed5b0f3ed0140c83b2c1f8c707603.zip cpython-5de39f4b412ed5b0f3ed0140c83b2c1f8c707603.tar.gz cpython-5de39f4b412ed5b0f3ed0140c83b2c1f8c707603.tar.bz2 |
bpo-45510: Check both types when specializing subtraction (GH-29995)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/specialize.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index cdc5353..5121845 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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)); |