diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 14:48:19 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 14:48:19 (GMT) |
commit | ac5569b1fa483c50edca82bab1ab0a8a927ba86a (patch) | |
tree | 9eada65cbf98a2158fda4b3a668ad5ee5969f1c5 /Objects/bytearrayobject.c | |
parent | bf2b3b72d370f866aa5b8f9077ff37e7c53de894 (diff) | |
parent | fa494fd88384acc52cf9292d0c89e2961c8f747f (diff) | |
download | cpython-ac5569b1fa483c50edca82bab1ab0a8a927ba86a.zip cpython-ac5569b1fa483c50edca82bab1ab0a8a927ba86a.tar.gz cpython-ac5569b1fa483c50edca82bab1ab0a8a927ba86a.tar.bz2 |
Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains()
to check for and handle errors correctly.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r-- | Objects/bytearrayobject.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 28b1f68..49db367 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1011,13 +1011,17 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op) Py_buffer self_bytes, other_bytes; PyObject *res; Py_ssize_t minsize; - int cmp; + int cmp, rc; /* Bytes can be compared to anything that supports the (binary) buffer API. Except that a comparison with Unicode is always an error, even if the comparison is for equality. */ - if (PyObject_IsInstance(self, (PyObject*)&PyUnicode_Type) || - PyObject_IsInstance(other, (PyObject*)&PyUnicode_Type)) { + rc = PyObject_IsInstance(self, (PyObject*)&PyUnicode_Type); + if (!rc) + rc = PyObject_IsInstance(other, (PyObject*)&PyUnicode_Type); + if (rc < 0) + return NULL; + if (rc) { if (Py_BytesWarningFlag && (op == Py_EQ || op == Py_NE)) { if (PyErr_WarnEx(PyExc_BytesWarning, "Comparison between bytearray and string", 1)) |