summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/setobject.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index b37db44..d97dc28 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -2127,17 +2127,7 @@ PySet_New(PyObject *iterable)
PyObject *
PyFrozenSet_New(PyObject *iterable)
{
- PyObject *args, *result;
-
- if (iterable == NULL)
- args = PyTuple_New(0);
- else
- args = PyTuple_Pack(1, iterable);
- if (args == NULL)
- return NULL;
- result = frozenset_new(&PyFrozenSet_Type, args, NULL);
- Py_DECREF(args);
- return result;
+ return make_new_set(&PyFrozenSet_Type, iterable);
}
Py_ssize_t
@@ -2153,7 +2143,7 @@ PySet_Size(PyObject *anyset)
int
PySet_Clear(PyObject *set)
{
- if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+ if (!PySet_Check(set)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2173,7 +2163,7 @@ PySet_Contains(PyObject *anyset, PyObject *key)
int
PySet_Discard(PyObject *set, PyObject *key)
{
- if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+ if (!PySet_Check(set)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2181,13 +2171,13 @@ PySet_Discard(PyObject *set, PyObject *key)
}
int
-PySet_Add(PyObject *set, PyObject *key)
+PySet_Add(PyObject *anyset, PyObject *key)
{
- if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+ if (!PyAnySet_Check(anyset)) {
PyErr_BadInternalCall();
return -1;
}
- return set_add_key((PySetObject *)set, key);
+ return set_add_key((PySetObject *)anyset, key);
}
int
@@ -2224,7 +2214,7 @@ _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash)
PyObject *
PySet_Pop(PyObject *set)
{
- if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+ if (!PySet_Check(set)) {
PyErr_BadInternalCall();
return NULL;
}
@@ -2234,7 +2224,7 @@ PySet_Pop(PyObject *set)
int
_PySet_Update(PyObject *set, PyObject *iterable)
{
- if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
+ if (!PySet_Check(set)) {
PyErr_BadInternalCall();
return -1;
}
@@ -2330,7 +2320,6 @@ test_c_api(PySetObject *so)
f = PyFrozenSet_New(dup);
assert(PySet_Size(f) == 3);
assert(PyFrozenSet_CheckExact(f));
- assertRaises(PySet_Add(f, elem) == -1, PyExc_SystemError);
assertRaises(PySet_Discard(f, elem) == -1, PyExc_SystemError);
assertRaises(PySet_Pop(f) == NULL, PyExc_SystemError);
Py_DECREF(f);