return NULL;
while ((key = PyIter_Next(it)) != NULL) {
- Py_hash_t hash = PyObject_Hash(key);
-
- if (hash == -1) {
- Py_DECREF(key);
- Py_DECREF(it);
- return NULL;
- }
- rv = set_contains_entry(so, key, hash);
+ rv = set_contains_key(so, key);
Py_DECREF(key);
if (rv < 0) {
Py_DECREF(it);
static PyObject *
set_issuperset(PySetObject *so, PyObject *other)
{
- PyObject *tmp, *result;
+ if (PyAnySet_Check(other)) {
+ return set_issubset((PySetObject *)other, (PyObject *)so);
+ }
- if (!PyAnySet_Check(other)) {
- tmp = make_new_set(&PySet_Type, other);
- if (tmp == NULL)
+ PyObject *key, *it = PyObject_GetIter(other);
+ if (it == NULL) {
+ return NULL;
+ }
+ while ((key = PyIter_Next(it)) != NULL) {
+ int rv = set_contains_key(so, key);
+ Py_DECREF(key);
+ if (rv < 0) {
+ Py_DECREF(it);
return NULL;
- result = set_issuperset(so, tmp);
- Py_DECREF(tmp);
- return result;
+ }
+ if (!rv) {
+ Py_DECREF(it);
+ Py_RETURN_FALSE;
+ }
}
- return set_issubset((PySetObject *)other, (PyObject *)so);
+ Py_DECREF(it);
+ if (PyErr_Occurred()) {
+ return NULL;
+ }
+ Py_RETURN_TRUE;
}
PyDoc_STRVAR(issuperset_doc, "Report whether this set contains another set.");