diff -r 177e0254fdee Objects/setobject.c --- a/Objects/setobject.c Tue Nov 19 11:06:44 2013 -0500 +++ b/Objects/setobject.c Tue Nov 19 10:14:31 2013 -0800 @@ -1749,11 +1749,25 @@ static PyObject * set_issubset(PySetObject *so, PyObject *other) { - setentry *entry; - Py_ssize_t pos = 0; + int rv; + PyObject *tmp, *result; - if (!PyAnySet_Check(other)) { - PyObject *tmp, *result; + if (PyAnySet_Check(other)) { + if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) + Py_RETURN_FALSE; + + setentry *entry; + Py_ssize_t pos = 0; + while (set_next(so, &pos, &entry)) { + rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) + return NULL; + if (!rv) + Py_RETURN_FALSE; + } + } + + else if (PyDict_CheckExact(other)) { tmp = make_new_set(&PySet_Type, other); if (tmp == NULL) return NULL; @@ -1761,16 +1775,52 @@ Py_DECREF(tmp); return result; } - if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) + + else { + PyObject *key, *it; + + tmp = make_new_set(&PySet_Type, NULL); + if (tmp == NULL) + return NULL; + + it = PyObject_GetIter(other); + if (it == NULL) { + Py_DECREF(tmp); + return NULL; + } + + int n = so->used; + while ((key = PyIter_Next(it)) != NULL) { + setentry entry; + Py_hash_t hash = PyObject_Hash(key); + if (hash == -1) { + Py_DECREF(it); + Py_DECREF(tmp); + Py_DECREF(key); + return NULL; + } + entry.hash = hash; + entry.key = key; + rv = set_add_entry((PySetObject *)tmp, &entry); + Py_DECREF(key); + if (rv == -1) { + continue; + } + if (set_contains_entry(so, &entry) == 1 && !(--n)) { + Py_DECREF(it); + Py_DECREF(tmp); + Py_RETURN_TRUE; + } + } + + Py_DECREF(it); + Py_DECREF(tmp); + if (PyErr_Occurred()) + return NULL; + Py_RETURN_FALSE; + } - while (set_next(so, &pos, &entry)) { - int rv = set_contains_entry((PySetObject *)other, entry); - if (rv == -1) - return NULL; - if (!rv) - Py_RETURN_FALSE; - } Py_RETURN_TRUE; }