]> granicus.if.org Git - python/commitdiff
Issue 8436: set.__init__ accepts keyword args
authorRaymond Hettinger <python@rcn.com>
Sun, 18 Apr 2010 23:03:16 +0000 (23:03 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 18 Apr 2010 23:03:16 +0000 (23:03 +0000)
Lib/test/test_set.py
Objects/setobject.c

index 2b43a1614bd6a8bbbda7d64fc74332072e51a8f2..3dde82fc920f0e77ac2ef9b3f17674c1c65db69f 100644 (file)
@@ -49,6 +49,7 @@ class TestJointOps(unittest.TestCase):
 
     def test_new_or_init(self):
         self.assertRaises(TypeError, self.thetype, [], 2)
+        self.assertRaises(TypeError, set().__init__, a=1)
 
     def test_uniquification(self):
         actual = sorted(self.s)
index d2a55fc313feb7dded5911e3fb142a15a6e08a72..36afeb37804f938683cf77828f38595338e8daba 100644 (file)
@@ -1978,6 +1978,8 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
 
        if (!PyAnySet_Check(self))
                return -1;
+       if (PySet_Check(self) && !_PyArg_NoKeywords("set()", kwds))
+               return -1;
        if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
                return -1;
        set_clear_internal(self);