diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 14:45:12 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 14:45:12 (GMT) |
commit | 5127ed727c014e320f3f449f47d31724679f9529 (patch) | |
tree | d0d1a8574691f746f2e5f1fc0a15156abc5cfd1d /Objects/setobject.c | |
parent | 1e95340bc378d883609d41da7176e24d1f3e9025 (diff) | |
download | cpython-5127ed727c014e320f3f449f47d31724679f9529.zip cpython-5127ed727c014e320f3f449f47d31724679f9529.tar.gz cpython-5127ed727c014e320f3f449f47d31724679f9529.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.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index b4b1178..8a58d65 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1548,9 +1548,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; @@ -1793,7 +1799,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_INCREF(Py_NotImplemented); @@ -1812,9 +1819,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: |