mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
#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.
This commit is contained in:
parent
001befaadc
commit
00c94edea0
3 changed files with 23 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue