mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Ensure that PySet_Add() operates on a newly created frozenset, like PyTuple_SetItem does.
Add PyFrozenSet_Check(), which was not needed before; The list of Py*Set_Check* macros seems to be complete now. Add missing NEWS entries about all this.
This commit is contained in:
parent
e6a8074892
commit
cab3d98ca1
4 changed files with 24 additions and 2 deletions
|
|
@ -2188,7 +2188,8 @@ PySet_Discard(PyObject *set, PyObject *key)
|
|||
int
|
||||
PySet_Add(PyObject *anyset, PyObject *key)
|
||||
{
|
||||
if (!PyAnySet_Check(anyset)) {
|
||||
if (!PySet_Check(anyset) &&
|
||||
(!PyFrozenSet_Check(anyset) || Py_REFCNT(anyset) != 1)) {
|
||||
PyErr_BadInternalCall();
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2306,6 +2307,10 @@ test_c_api(PySetObject *so)
|
|||
f = PyFrozenSet_New(dup);
|
||||
assertRaises(PySet_Clear(f) == -1, PyExc_SystemError);
|
||||
assertRaises(_PySet_Update(f, dup) == -1, PyExc_SystemError);
|
||||
assert(PySet_Add(f, elem) == 0);
|
||||
Py_INCREF(f);
|
||||
assertRaises(PySet_Add(f, elem) == -1, PyExc_SystemError);
|
||||
Py_DECREF(f);
|
||||
Py_DECREF(f);
|
||||
|
||||
/* Exercise direct iteration */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue