diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-10-07 20:40:09 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-10-07 20:40:09 (GMT) |
commit | 00c94edea0cdc8c490a91dd5455150be8b19d3e2 (patch) | |
tree | a3071f8bf0ca2401def09c64d0f5074ddb6c4c96 /Objects/setobject.c | |
parent | 001befaadcf562170039e085ebd4ae3318f322c2 (diff) | |
download | cpython-00c94edea0cdc8c490a91dd5455150be8b19d3e2.zip cpython-00c94edea0cdc8c490a91dd5455150be8b19d3e2.tar.gz cpython-00c94edea0cdc8c490a91dd5455150be8b19d3e2.tar.bz2 |
#4069: aSet.remove(otherSet) would always report the empty frozenset([]) as the missing key.
Now it correctly refers to the initial otherSet.
Backport of r66836.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r-- | Objects/setobject.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 075f8e7..ea3970e 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1874,7 +1874,7 @@ PyDoc_STRVAR(contains_doc, "x.__contains__(y) <==> y in x."); static PyObject * set_remove(PySetObject *so, PyObject *key) { - PyObject *tmpkey, *result; + PyObject *tmpkey; int rv; rv = set_discard_key(so, key); @@ -1886,11 +1886,14 @@ set_remove(PySetObject *so, PyObject *key) if (tmpkey == NULL) return NULL; set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); - result = set_remove(so, tmpkey); + rv = set_discard_key(so, tmpkey); set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key); Py_DECREF(tmpkey); - return result; - } else if (rv == DISCARD_NOTFOUND) { + if (rv == -1) + return NULL; + } + + if (rv == DISCARD_NOTFOUND) { set_key_error(key); return NULL; } |