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

index 8a5f6602a809b8384e3049dc8f6ca5d7c0ca6b71..d53b916ecb8a926a7fa963943a9c56863f0d0194 100644 (file)
@@ -1,3 +1,4 @@
+
 import unittest
 from test import test_support
 import gc
@@ -48,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 af5d576b98d16c8c7d35a92c5ebcd6ffd8927eac..47362eb6adc82e7cd54e75480f5dddd999298074 100644 (file)
@@ -1987,6 +1987,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);