diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-11 00:49:57 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-11 00:49:57 (GMT) |
commit | f10a79aad4e2fc62d2c3675e89f873b22b185e7b (patch) | |
tree | 06b042ca03a71663d26ad95949807d1bd2472bf4 /Objects/setobject.c | |
parent | 2d8dcdcb06005858e87eded012ceff10920445b7 (diff) | |
download | cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.zip cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.tar.gz cpython-f10a79aad4e2fc62d2c3675e89f873b22b185e7b.tar.bz2 |
merge from trunk
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r-- | Objects/setobject.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 1054166..d24e1af 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -746,7 +746,8 @@ set_pop(PySetObject *so) return key; } -PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element."); +PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.\n\ +Raises KeyError if the set is empty."); static int set_traverse(PySetObject *so, visitproc visit, void *arg) @@ -1861,7 +1862,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); @@ -1873,11 +1874,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; } |