]> granicus.if.org Git - python/commitdiff
Make PySet_Add() work with frozensets. Works like PyTuple_SetItem() to build-up...
authorRaymond Hettinger <python@rcn.com>
Sat, 26 Jan 2008 08:19:06 +0000 (08:19 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 26 Jan 2008 08:19:06 +0000 (08:19 +0000)
Doc/c-api/set.rst
Objects/setobject.c

index e677c05ea546ba941cf387bdc4d7831a996b90a2..24caa104a7ac9b1494d61c3f4c5ab09c0d47e012 100644 (file)
@@ -112,9 +112,6 @@ or :class:`frozenset` or instances of their subtypes.
    the *key* is unhashable. Raise :exc:`PyExc_SystemError` if *anyset* is not a
    :class:`set`, :class:`frozenset`, or an instance of a subtype.
 
-The following functions are available for instances of :class:`set` or its
-subtypes but not for instances of :class:`frozenset` or its subtypes.
-
 
 .. cfunction:: int PySet_Add(PyObject *set, PyObject *key)
 
@@ -124,6 +121,14 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
    Raise a :exc:`SystemError` if *set* is an not an instance of :class:`set` or its
    subtype.
 
+   .. versionchanged:: 2.6
+      Now works with instances of :class:`frozenset` or its subtypes.
+      Like :cfunc:`PyTuple_SetItem` in that it can be used to fill-in the
+      values of brand new frozensets before they are exposed to other code.
+
+The following functions are available for instances of :class:`set` or its
+subtypes but not for instances of :class:`frozenset` or its subtypes.
+
 
 .. cfunction:: int PySet_Discard(PyObject *set, PyObject *key)
 
index c8db7cef474acda0b04c8c80a09faf40ef6dd291..2556b74733a52549b0cb1ee60eba3b912aa94efb 100644 (file)
@@ -2198,10 +2198,6 @@ PySet_Discard(PyObject *set, PyObject *key)
 int
 PySet_Add(PyObject *set, PyObject *key)
 {
-       if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) {
-               PyErr_BadInternalCall();
-               return -1;
-       }
        return set_add_key((PySetObject *)set, key);
 }