mirror of
https://github.com/python/cpython.git
synced 2025-09-01 06:28:36 +00:00
Issue8757: Implicit set-to-frozenset conversion not thread-safe.
This commit is contained in:
parent
4f3086f264
commit
38bf2ccf4c
1 changed files with 3 additions and 9 deletions
|
@ -1846,12 +1846,10 @@ set_contains(PySetObject *so, PyObject *key)
|
||||||
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
|
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
|
||||||
return -1;
|
return -1;
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
|
tmpkey = make_new_set(&PyFrozenSet_Type, key);
|
||||||
if (tmpkey == NULL)
|
if (tmpkey == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
|
|
||||||
rv = set_contains(so, tmpkey);
|
rv = set_contains(so, tmpkey);
|
||||||
set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
|
|
||||||
Py_DECREF(tmpkey);
|
Py_DECREF(tmpkey);
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1881,12 +1879,10 @@ set_remove(PySetObject *so, PyObject *key)
|
||||||
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
|
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
|
||||||
return NULL;
|
return NULL;
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
|
tmpkey = make_new_set(&PyFrozenSet_Type, key);
|
||||||
if (tmpkey == NULL)
|
if (tmpkey == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
|
|
||||||
rv = set_discard_key(so, tmpkey);
|
rv = set_discard_key(so, tmpkey);
|
||||||
set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
|
|
||||||
Py_DECREF(tmpkey);
|
Py_DECREF(tmpkey);
|
||||||
if (rv == -1)
|
if (rv == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1915,12 +1911,10 @@ set_discard(PySetObject *so, PyObject *key)
|
||||||
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
|
if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
|
||||||
return NULL;
|
return NULL;
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
|
tmpkey = make_new_set(&PyFrozenSet_Type, key);
|
||||||
if (tmpkey == NULL)
|
if (tmpkey == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
|
|
||||||
result = set_discard(so, tmpkey);
|
result = set_discard(so, tmpkey);
|
||||||
set_swap_bodies((PySetObject *)tmpkey, (PySetObject *)key);
|
|
||||||
Py_DECREF(tmpkey);
|
Py_DECREF(tmpkey);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue