summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-30 14:45:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-30 14:45:22 (GMT)
commitfa494fd88384acc52cf9292d0c89e2961c8f747f (patch)
treea30958b83189caf872f34e7b94a1aeeef28ed3a9 /Objects/setobject.c
parent50451eb91232b0e90c677419db19ed7b33a698a9 (diff)
downloadcpython-fa494fd88384acc52cf9292d0c89e2961c8f747f.zip
cpython-fa494fd88384acc52cf9292d0c89e2961c8f747f.tar.gz
cpython-fa494fd88384acc52cf9292d0c89e2961c8f747f.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/setobject.c')
-rw-r--r--Objects/setobject.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 34e43b9..304519c 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1569,9 +1569,15 @@ set_difference(PySetObject *so, PyObject *other)
if (PyDict_CheckExact(other)) {
while (set_next(so, &pos, &entry)) {
setentry entrycopy;
+ int rv;
entrycopy.hash = entry->hash;
entrycopy.key = entry->key;
- if (!_PyDict_Contains(other, entry->key, entry->hash)) {
+ rv = _PyDict_Contains(other, entry->key, entry->hash);
+ if (rv < 0) {
+ Py_DECREF(result);
+ return NULL;
+ }
+ if (!rv) {
if (set_add_entry((PySetObject *)result, &entrycopy) == -1) {
Py_DECREF(result);
return NULL;
@@ -1807,7 +1813,8 @@ PyDoc_STRVAR(issuperset_doc, "Report whether this set contains another set.");
static PyObject *
set_richcompare(PySetObject *v, PyObject *w, int op)
{
- PyObject *r1, *r2;
+ PyObject *r1;
+ int r2;
if(!PyAnySet_Check(w))
Py_RETURN_NOTIMPLEMENTED;
@@ -1825,9 +1832,11 @@ set_richcompare(PySetObject *v, PyObject *w, int op)
r1 = set_richcompare(v, w, Py_EQ);
if (r1 == NULL)
return NULL;
- r2 = PyBool_FromLong(PyObject_Not(r1));
+ r2 = PyObject_IsTrue(r1);
Py_DECREF(r1);
- return r2;
+ if (r2 < 0)
+ return NULL;
+ return PyBool_FromLong(!r2);
case Py_LE:
return set_issubset(v, w);
case Py_GE: